From 9d34fb0cb7985b867116cb946f88d76c4fc481df Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Sat, 11 Mar 2023 13:11:15 +0100 Subject: [PATCH 01/80] Logic for the (Core) Fellowship (#13503) * More drafting * Paymaster pallet * Fix build * More tests * Rename * Rename * Renaming * Revert old changes * Multi-phase payouts to avoid bank-runs * Tests * Tests * Allow payment to be targeted elsewhere * Proper ssync payment failure handling * Test for repayment * Docs * Impl RankedMembers for RankedCollective * Implement Pay for Pot (i.e. basic account). * Benchmarks * Weights * Introduce Salary benchmark into node * Fix warning * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_salary * Update primitives/arithmetic/src/traits.rs Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> * Update frame/salary/src/lib.rs Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> * Update lib.rs * Update frame/salary/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Docs * Update frame/salary/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/salary/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Fix * Fixes * Fixes * Move some salary traits stuff to a shared location * Initial draft * Comment out bits * Fix * First couple of tests * One more test * Update frame/salary/src/lib.rs Co-authored-by: Oliver Tale-Yazdi * Update frame/salary/src/lib.rs Co-authored-by: Oliver Tale-Yazdi * Mul floor * Tests * Mul floor * Fix warnings * Fix test * Tests * Last tests * Docs * Fix warnings * Benchmarks * Weights * Integrate benchmark * Fixes * Fix * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_core_fellowship * Better process flow * Fix benchmarks & tests * Docs * Fixes * Fixes * docs * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_core_fellowship * Docs and allow custom evidence size * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_core_fellowship * Update frame/core-fellowship/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/core-fellowship/src/tests.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/core-fellowship/src/benchmarking.rs * Update frame/core-fellowship/src/benchmarking.rs * Apply suggestions from code review * Rename * Update primitives/arithmetic/src/traits.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Reduce magic numbers * Update frame/core-fellowship/src/lib.rs Co-authored-by: Oliver Tale-Yazdi * Update frame/core-fellowship/src/lib.rs Co-authored-by: Oliver Tale-Yazdi * Benchmark result * Remove dependency * set_params should pay * induct should pay * Remove some other free calls --------- Co-authored-by: command-bot <> Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: Oliver Tale-Yazdi Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- Cargo.lock | 20 + Cargo.toml | 1 + bin/node/runtime/Cargo.toml | 4 + bin/node/runtime/src/lib.rs | 14 + frame/core-fellowship/Cargo.toml | 55 ++ frame/core-fellowship/README.md | 3 + frame/core-fellowship/src/benchmarking.rs | 216 ++++++++ frame/core-fellowship/src/lib.rs | 594 ++++++++++++++++++++++ frame/core-fellowship/src/tests.rs | 362 +++++++++++++ frame/core-fellowship/src/weights.rs | 393 ++++++++++++++ frame/salary/src/lib.rs | 4 +- frame/system/src/lib.rs | 7 +- primitives/arithmetic/src/traits.rs | 32 ++ primitives/runtime/src/traits.rs | 18 + 14 files changed, 1716 insertions(+), 7 deletions(-) create mode 100644 frame/core-fellowship/Cargo.toml create mode 100644 frame/core-fellowship/README.md create mode 100644 frame/core-fellowship/src/benchmarking.rs create mode 100644 frame/core-fellowship/src/lib.rs create mode 100644 frame/core-fellowship/src/tests.rs create mode 100644 frame/core-fellowship/src/weights.rs diff --git a/Cargo.lock b/Cargo.lock index a970be356b2dc..9a63e25b4878c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3522,6 +3522,7 @@ dependencies = [ "pallet-contracts", "pallet-contracts-primitives", "pallet-conviction-voting", + "pallet-core-fellowship", "pallet-democracy", "pallet-election-provider-multi-phase", "pallet-election-provider-support-benchmarking", @@ -5777,6 +5778,25 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-core-fellowship" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-ranked-collective", + "pallet-salary", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-democracy" version = "4.0.0-dev" diff --git a/Cargo.toml b/Cargo.toml index 0b490bd17c82b..de562ad79e47e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,6 +94,7 @@ members = [ "frame/contracts/proc-macro", "frame/contracts/primitives", "frame/conviction-voting", + "frame/core-fellowship", "frame/democracy", "frame/fast-unstake", "frame/try-runtime", diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index a610bbe5d8113..16f1d0a4cb532 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -65,6 +65,7 @@ pallet-collective = { version = "4.0.0-dev", default-features = false, path = ". pallet-contracts = { version = "4.0.0-dev", default-features = false, path = "../../../frame/contracts" } pallet-contracts-primitives = { version = "7.0.0", default-features = false, path = "../../../frame/contracts/primitives/" } pallet-conviction-voting = { version = "4.0.0-dev", default-features = false, path = "../../../frame/conviction-voting" } +pallet-core-fellowship = { version = "4.0.0-dev", default-features = false, path = "../../../frame/core-fellowship" } pallet-democracy = { version = "4.0.0-dev", default-features = false, path = "../../../frame/democracy" } pallet-election-provider-multi-phase = { version = "4.0.0-dev", default-features = false, path = "../../../frame/election-provider-multi-phase" } pallet-election-provider-support-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/election-provider-support/benchmarking", optional = true } @@ -148,6 +149,7 @@ std = [ "pallet-contracts/std", "pallet-contracts-primitives/std", "pallet-conviction-voting/std", + "pallet-core-fellowship/std", "pallet-democracy/std", "pallet-elections-phragmen/std", "pallet-fast-unstake/std", @@ -235,6 +237,7 @@ runtime-benchmarks = [ "pallet-collective/runtime-benchmarks", "pallet-contracts/runtime-benchmarks", "pallet-conviction-voting/runtime-benchmarks", + "pallet-core-fellowship/runtime-benchmarks", "pallet-democracy/runtime-benchmarks", "pallet-election-provider-multi-phase/runtime-benchmarks", "pallet-election-provider-support-benchmarking/runtime-benchmarks", @@ -294,6 +297,7 @@ try-runtime = [ "pallet-collective/try-runtime", "pallet-contracts/try-runtime", "pallet-conviction-voting/try-runtime", + "pallet-core-fellowship/try-runtime", "pallet-democracy/try-runtime", "pallet-election-provider-multi-phase/try-runtime", "pallet-elections-phragmen/try-runtime", diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index c507c2d8d752f..614dbc4d958c8 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1574,6 +1574,18 @@ impl pallet_salary::Config for Runtime { type Budget = Budget; } +impl pallet_core_fellowship::Config for Runtime { + type WeightInfo = (); + type RuntimeEvent = RuntimeEvent; + type Members = RankedCollective; + type Balance = Balance; + type ParamsOrigin = frame_system::EnsureRoot; + type InductOrigin = pallet_core_fellowship::EnsureInducted; + type ApproveOrigin = frame_system::EnsureRootWithSuccess>; + type PromoteOrigin = frame_system::EnsureRootWithSuccess>; + type EvidenceSize = ConstU32<16_384>; +} + parameter_types! { pub Features: PalletFeatures = PalletFeatures::all_enabled(); pub const MaxAttributesPerCall: u32 = 10; @@ -1770,6 +1782,7 @@ construct_runtime!( Uniques: pallet_uniques, Nfts: pallet_nfts, Salary: pallet_salary, + CoreFellowship: pallet_core_fellowship, TransactionStorage: pallet_transaction_storage, VoterList: pallet_bags_list::, StateTrieMigration: pallet_state_trie_migration, @@ -1866,6 +1879,7 @@ mod benches { [pallet_collective, Council] [pallet_conviction_voting, ConvictionVoting] [pallet_contracts, Contracts] + [pallet_core_fellowship, CoreFellowship] [pallet_democracy, Democracy] [pallet_election_provider_multi_phase, ElectionProviderMultiPhase] [pallet_election_provider_support_benchmarking, EPSBench::] diff --git a/frame/core-fellowship/Cargo.toml b/frame/core-fellowship/Cargo.toml new file mode 100644 index 0000000000000..2785346c7341f --- /dev/null +++ b/frame/core-fellowship/Cargo.toml @@ -0,0 +1,55 @@ +[package] +name = "pallet-core-fellowship" +version = "4.0.0-dev" +authors = ["Parity Technologies "] +edition = "2021" +license = "Apache-2.0" +homepage = "https://substrate.io" +repository = "https://github.com/paritytech/substrate/" +description = "Logic as per the description of The Fellowship for core Polkadot technology" +readme = "README.md" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +log = { version = "0.4.16", default-features = false } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } +frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } +frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } +frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } +sp-arithmetic = { version = "6.0.0", default-features = false, path = "../../primitives/arithmetic" } +sp-core = { version = "7.0.0", default-features = false, path = "../../primitives/core" } +sp-io = { version = "7.0.0", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" } + +[dev-dependencies] +pallet-ranked-collective = { version = "4.0.0-dev", default-features = false, path = "../ranked-collective" } +pallet-salary = { version = "4.0.0-dev", default-features = false, path = "../salary" } + +[features] +default = ["std"] +std = [ + "codec/std", + "frame-benchmarking?/std", + "frame-support/std", + "frame-system/std", + "log/std", + "scale-info/std", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", +] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "pallet-ranked-collective/runtime-benchmarks", + "pallet-salary/runtime-benchmarks", +] +try-runtime = ["frame-support/try-runtime"] diff --git a/frame/core-fellowship/README.md b/frame/core-fellowship/README.md new file mode 100644 index 0000000000000..3c9b1f63e0896 --- /dev/null +++ b/frame/core-fellowship/README.md @@ -0,0 +1,3 @@ +# Core Fellowship + +Logic specific to the core Polkadot Fellowship. \ No newline at end of file diff --git a/frame/core-fellowship/src/benchmarking.rs b/frame/core-fellowship/src/benchmarking.rs new file mode 100644 index 0000000000000..551ec30c19f01 --- /dev/null +++ b/frame/core-fellowship/src/benchmarking.rs @@ -0,0 +1,216 @@ +// This file is part of Substrate. + +// Copyright (C) 2020-2022 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. + +//! Salary pallet benchmarking. + +#![cfg(feature = "runtime-benchmarks")] + +use super::*; +use crate::Pallet as CoreFellowship; + +use frame_benchmarking::v2::*; +use frame_system::RawOrigin; +use sp_arithmetic::traits::Bounded; + +const SEED: u32 = 0; + +type BenchResult = Result<(), BenchmarkError>; + +#[instance_benchmarks] +mod benchmarks { + use super::*; + + fn ensure_evidence, I: 'static>(who: &T::AccountId) -> BenchResult { + let evidence = BoundedVec::try_from(vec![0; Evidence::::bound()]).unwrap(); + let wish = Wish::Retention; + let origin = RawOrigin::Signed(who.clone()).into(); + CoreFellowship::::submit_evidence(origin, wish, evidence)?; + assert!(MemberEvidence::::contains_key(who)); + Ok(()) + } + + fn make_member, I: 'static>(rank: u16) -> Result { + let member = account("member", 0, SEED); + T::Members::induct(&member)?; + for _ in 0..rank { + T::Members::promote(&member)?; + } + CoreFellowship::::import(RawOrigin::Signed(member.clone()).into())?; + Ok(member) + } + + #[benchmark] + fn set_params() -> Result<(), BenchmarkError> { + let params = ParamsType { + active_salary: [100u32.into(); 9], + passive_salary: [10u32.into(); 9], + demotion_period: [100u32.into(); 9], + min_promotion_period: [100u32.into(); 9], + offboard_timeout: 1u32.into(), + }; + + #[extrinsic_call] + _(RawOrigin::Root, Box::new(params.clone())); + + assert_eq!(Params::::get(), params); + Ok(()) + } + + #[benchmark] + fn bump_offboard() -> Result<(), BenchmarkError> { + let member = make_member::(0)?; + + // Set it to the max value to ensure that any possible auto-demotion period has passed. + frame_system::Pallet::::set_block_number(T::BlockNumber::max_value()); + ensure_evidence::(&member)?; + assert!(Member::::contains_key(&member)); + + #[extrinsic_call] + CoreFellowship::::bump(RawOrigin::Signed(member.clone()), member.clone()); + + assert!(!Member::::contains_key(&member)); + assert!(!MemberEvidence::::contains_key(&member)); + Ok(()) + } + + #[benchmark] + fn bump_demote() -> Result<(), BenchmarkError> { + let member = make_member::(2)?; + + // Set it to the max value to ensure that any possible auto-demotion period has passed. + frame_system::Pallet::::set_block_number(T::BlockNumber::max_value()); + ensure_evidence::(&member)?; + assert!(Member::::contains_key(&member)); + assert_eq!(T::Members::rank_of(&member), Some(2)); + + #[extrinsic_call] + CoreFellowship::::bump(RawOrigin::Signed(member.clone()), member.clone()); + + assert!(Member::::contains_key(&member)); + assert_eq!(T::Members::rank_of(&member), Some(1)); + assert!(!MemberEvidence::::contains_key(&member)); + Ok(()) + } + + #[benchmark] + fn set_active() -> Result<(), BenchmarkError> { + let member = make_member::(1)?; + assert!(Member::::get(&member).unwrap().is_active); + + #[extrinsic_call] + _(RawOrigin::Signed(member.clone()), false); + + assert!(!Member::::get(&member).unwrap().is_active); + Ok(()) + } + + #[benchmark] + fn induct() -> Result<(), BenchmarkError> { + let candidate: T::AccountId = account("candidate", 0, SEED); + + #[extrinsic_call] + _(RawOrigin::Root, candidate.clone()); + + assert_eq!(T::Members::rank_of(&candidate), Some(0)); + assert!(Member::::contains_key(&candidate)); + Ok(()) + } + + #[benchmark] + fn promote() -> Result<(), BenchmarkError> { + let member = make_member::(1)?; + ensure_evidence::(&member)?; + + #[extrinsic_call] + _(RawOrigin::Root, member.clone(), 2u8.into()); + + assert_eq!(T::Members::rank_of(&member), Some(2)); + assert!(!MemberEvidence::::contains_key(&member)); + Ok(()) + } + + #[benchmark] + fn offboard() -> Result<(), BenchmarkError> { + let member = make_member::(0)?; + T::Members::demote(&member)?; + ensure_evidence::(&member)?; + + assert!(T::Members::rank_of(&member).is_none()); + assert!(Member::::contains_key(&member)); + assert!(MemberEvidence::::contains_key(&member)); + + #[extrinsic_call] + _(RawOrigin::Signed(member.clone()), member.clone()); + + assert!(!Member::::contains_key(&member)); + assert!(!MemberEvidence::::contains_key(&member)); + Ok(()) + } + + #[benchmark] + fn import() -> Result<(), BenchmarkError> { + let member = account("member", 0, SEED); + T::Members::induct(&member)?; + T::Members::promote(&member)?; + + assert!(!Member::::contains_key(&member)); + + #[extrinsic_call] + _(RawOrigin::Signed(member.clone())); + + assert!(Member::::contains_key(&member)); + Ok(()) + } + + #[benchmark] + fn approve() -> Result<(), BenchmarkError> { + let member = make_member::(1)?; + let then = frame_system::Pallet::::block_number(); + let now = then.saturating_plus_one(); + frame_system::Pallet::::set_block_number(now); + ensure_evidence::(&member)?; + + assert_eq!(Member::::get(&member).unwrap().last_proof, then); + + #[extrinsic_call] + _(RawOrigin::Root, member.clone(), 1u8.into()); + + assert_eq!(Member::::get(&member).unwrap().last_proof, now); + assert!(!MemberEvidence::::contains_key(&member)); + Ok(()) + } + + #[benchmark] + fn submit_evidence() -> Result<(), BenchmarkError> { + let member = make_member::(1)?; + let evidence = vec![0; Evidence::::bound()].try_into().unwrap(); + + assert!(!MemberEvidence::::contains_key(&member)); + + #[extrinsic_call] + _(RawOrigin::Signed(member.clone()), Wish::Retention, evidence); + + assert!(MemberEvidence::::contains_key(&member)); + Ok(()) + } + + impl_benchmark_test_suite! { + CoreFellowship, + crate::tests::new_test_ext(), + crate::tests::Test, + } +} diff --git a/frame/core-fellowship/src/lib.rs b/frame/core-fellowship/src/lib.rs new file mode 100644 index 0000000000000..6ba60dbaf2559 --- /dev/null +++ b/frame/core-fellowship/src/lib.rs @@ -0,0 +1,594 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2022 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. + +//! Additional logic for the Core Fellowship. This determines salary, registers activity/passivity +//! and handles promotion and demotion periods. +//! +//! This only handles members of non-zero rank. +//! +//! # Process Flow +//! - Begin with a call to `induct`, where some privileged origin (perhaps a pre-existing member of +//! `rank > 1`) is able to make a candidate from an account and introduce it to be tracked in this +//! pallet in order to allow evidence to be submitted and promotion voted on. +//! - The candidate then calls `submit_evidence` to apply for their promotion to rank 1. +//! - A `PromoteOrigin` of at least rank 1 calls `promote` on the candidate to elevate it to rank 1. +//! - Some time later but before rank 1's `demotion_period` elapses, candidate calls +//! `submit_evidence` with evidence of their efforts to apply for approval to stay at rank 1. +//! - An `ApproveOrigin` of at least rank 1 calls `approve` on the candidate to avoid imminent +//! demotion and keep it at rank 1. +//! - These last two steps continue until the candidate is ready to apply for a promotion, at which +//! point the previous two steps are repeated with a higher rank. +//! - If the member fails to get an approval within the `demotion_period` then anyone may call +//! `bump` to demote the candidate by one rank. +//! - If a candidate fails to be promoted to a member within the `offboard_timeout` period, then +//! anyone may call `bump` to remove the account's candidacy. +//! - Pre-existing members may call `import` to have their rank recognised and be inducted into this +//! pallet (to gain a salary and allow for eventual promotion). +//! - If, externally to this pallet, a member or candidate has their rank removed completely, then +//! `offboard` may be called to remove them entirely from this pallet. +//! +//! Note there is a difference between having a rank of 0 (whereby the account is a *candidate*) and +//! having no rank at all (whereby we consider it *unranked*). An account can be demoted from rank +//! 0 to become unranked. This process is called being offboarded and there is an extrinsic to do +//! this explicitly when external factors to this pallet have caused the tracked account to become +//! unranked. At rank 0, there is not a "demotion" period after which the account may be bumped to +//! become offboarded but rather an "offboard timeout". +//! +//! Candidates may be introduced (i.e. an account to go from unranked to rank of 0) by an origin +//! of a different privilege to that for promotion. This allows the possibility for even a single +//! existing member to introduce a new candidate without payment. +//! +//! Only tracked/ranked accounts may submit evidence for their proof and promotion. Candidates +//! cannot be approved - they must proceed only to promotion prior to the offboard timeout elapsing. + +#![cfg_attr(not(feature = "std"), no_std)] +#![recursion_limit = "128"] + +use codec::{Decode, Encode, MaxEncodedLen}; +use scale_info::TypeInfo; +use sp_arithmetic::traits::{Saturating, Zero}; +use sp_std::{marker::PhantomData, prelude::*}; + +use frame_support::{ + dispatch::DispatchResultWithPostInfo, + ensure, + traits::{tokens::Balance as BalanceTrait, EnsureOrigin, Get, RankedMembers}, + BoundedVec, RuntimeDebug, +}; + +#[cfg(test)] +mod tests; + +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; +pub mod weights; + +pub use pallet::*; +pub use weights::WeightInfo; + +/// The desired outcome for which evidence is presented. +#[derive(Encode, Decode, Eq, PartialEq, Copy, Clone, TypeInfo, MaxEncodedLen, RuntimeDebug)] +pub enum Wish { + /// Member wishes only to retain their current rank. + Retention, + /// Member wishes to be promoted. + Promotion, +} + +/// A piece of evidence to underpin a [Wish]. +/// +/// From the pallet's perspective, this is just a blob of data without meaning. The fellows can +/// decide how to concretely utilise it. This could be an IPFS hash, a URL or structured data. +pub type Evidence = BoundedVec>::EvidenceSize>; + +/// The status of the pallet instance. +#[derive(Encode, Decode, Eq, PartialEq, Clone, TypeInfo, MaxEncodedLen, RuntimeDebug)] +pub struct ParamsType { + /// The amounts to be paid when a member of a given rank (-1) is active. + active_salary: [Balance; RANKS], + /// The amounts to be paid when a member of a given rank (-1) is passive. + passive_salary: [Balance; RANKS], + /// The period between which unproven members become demoted. + demotion_period: [BlockNumber; RANKS], + /// The period between which members must wait before they may proceed to this rank. + min_promotion_period: [BlockNumber; RANKS], + /// Amount by which an account can remain at rank 0 (candidate before being offboard entirely). + offboard_timeout: BlockNumber, +} + +impl Default + for ParamsType +{ + fn default() -> Self { + Self { + active_salary: [Balance::default(); RANKS], + passive_salary: [Balance::default(); RANKS], + demotion_period: [BlockNumber::default(); RANKS], + min_promotion_period: [BlockNumber::default(); RANKS], + offboard_timeout: BlockNumber::default(), + } + } +} + +/// The status of a single member. +#[derive(Encode, Decode, Eq, PartialEq, Clone, TypeInfo, MaxEncodedLen, RuntimeDebug)] +pub struct MemberStatus { + /// Are they currently active? + is_active: bool, + /// The block number at which we last promoted them. + last_promotion: BlockNumber, + /// The last time a member was demoted, promoted or proved their rank. + last_proof: BlockNumber, +} + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::{ + dispatch::Pays, + pallet_prelude::*, + traits::{tokens::GetSalary, EnsureOrigin}, + }; + use frame_system::{ensure_root, pallet_prelude::*}; + + const RANK_COUNT: usize = 9; + + #[pallet::pallet] + #[pallet::generate_store(pub(super) trait Store)] + pub struct Pallet(PhantomData<(T, I)>); + + #[pallet::config] + pub trait Config: frame_system::Config { + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; + + /// The runtime event type. + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; + + /// The current membership of the fellowship. + type Members: RankedMembers< + AccountId = ::AccountId, + Rank = u16, + >; + + /// The type in which salaries/budgets are measured. + type Balance: BalanceTrait; + + /// The origin which has permission update the parameters. + type ParamsOrigin: EnsureOrigin; + + /// The origin which has permission to move a candidate into being tracked in this pallet. + /// Generally a very low-permission, such as a pre-existing member of rank 1 or above. + /// + /// This allows the candidate to deposit evidence for their request to be promoted to a + /// member. + type InductOrigin: EnsureOrigin; + + /// The origin which has permission to issue a proof that a member may retain their rank. + /// The `Success` value is the maximum rank of members it is able to prove. + type ApproveOrigin: EnsureOrigin>; + + /// The origin which has permission to promote a member. The `Success` value is the maximum + /// rank to which it can promote. + type PromoteOrigin: EnsureOrigin>; + + /// The maximum size in bytes submitted evidence is allowed to be. + #[pallet::constant] + type EvidenceSize: Get; + } + + pub type ParamsOf = + ParamsType<>::Balance, ::BlockNumber, RANK_COUNT>; + pub type MemberStatusOf = MemberStatus<::BlockNumber>; + pub type RankOf = <>::Members as RankedMembers>::Rank; + + /// The overall status of the system. + #[pallet::storage] + pub(super) type Params, I: 'static = ()> = + StorageValue<_, ParamsOf, ValueQuery>; + + /// The status of a claimant. + #[pallet::storage] + pub(super) type Member, I: 'static = ()> = + StorageMap<_, Twox64Concat, T::AccountId, MemberStatusOf, OptionQuery>; + + /// Some evidence together with the desired outcome for which it was presented. + #[pallet::storage] + pub(super) type MemberEvidence, I: 'static = ()> = + StorageMap<_, Twox64Concat, T::AccountId, (Wish, Evidence), OptionQuery>; + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event, I: 'static = ()> { + /// Parameters for the pallet have changed. + ParamsChanged { params: ParamsOf }, + /// Member activity flag has been set. + ActiveChanged { who: T::AccountId, is_active: bool }, + /// Member has begun being tracked in this pallet. + Inducted { who: T::AccountId }, + /// Member has been removed from being tracked in this pallet (i.e. because rank is now + /// zero). + Offboarded { who: T::AccountId }, + /// Member has been promoted to the given rank. + Promoted { who: T::AccountId, to_rank: RankOf }, + /// Member has been demoted to the given (non-zero) rank. + Demoted { who: T::AccountId, to_rank: RankOf }, + /// Member has been proven at their current rank, postponing auto-demotion. + Proven { who: T::AccountId, at_rank: RankOf }, + /// Member has stated evidence of their efforts their request for rank. + Requested { who: T::AccountId, wish: Wish }, + /// Some submitted evidence was judged and removed. There may or may not have been a change + /// to the rank, but in any case, `last_proof` is reset. + EvidenceJudged { + /// The member/candidate. + who: T::AccountId, + /// The desired outcome for which the evidence was presented. + wish: Wish, + /// The evidence of efforts. + evidence: Evidence, + /// The old rank, prior to this change. + old_rank: u16, + /// New rank. If `None` then candidate record was removed entirely. + new_rank: Option, + }, + /// Pre-ranked account has been inducted at their current rank. + Imported { who: T::AccountId, rank: RankOf }, + } + + #[pallet::error] + pub enum Error { + /// Member's rank is too low. + Unranked, + /// Member's rank is not zero. + Ranked, + /// Member's rank is not as expected - generally means that the rank provided to the call + /// does not agree with the state of the system. + UnexpectedRank, + /// The given rank is invalid - this generally means it's not between 1 and `RANK_COUNT`. + InvalidRank, + /// The origin does not have enough permission to do this operation. + NoPermission, + /// No work needs to be done at present for this member. + NothingDoing, + /// The candidate has already been inducted. This should never happen since it would + /// require a candidate (rank 0) to already be tracked in the pallet. + AlreadyInducted, + /// The candidate has not been inducted, so cannot be offboarded from this pallet. + NotTracked, + /// Operation cannot be done yet since not enough time has passed. + TooSoon, + } + + #[pallet::call] + impl, I: 'static> Pallet { + /// Bump the state of a member. + /// + /// This will demote a member whose `last_proof` is now beyond their rank's + /// `demotion_period`. + /// + /// - `origin`: A `Signed` origin of an account. + /// - `who`: A member account whose state is to be updated. + #[pallet::weight(T::WeightInfo::bump_offboard().max(T::WeightInfo::bump_demote()))] + #[pallet::call_index(0)] + pub fn bump(origin: OriginFor, who: T::AccountId) -> DispatchResultWithPostInfo { + let _ = ensure_signed(origin)?; + let mut member = Member::::get(&who).ok_or(Error::::NotTracked)?; + let rank = T::Members::rank_of(&who).ok_or(Error::::Unranked)?; + + let params = Params::::get(); + let demotion_period = if rank == 0 { + params.offboard_timeout + } else { + let rank_index = Self::rank_to_index(rank).ok_or(Error::::InvalidRank)?; + params.demotion_period[rank_index] + }; + let demotion_block = member.last_proof.saturating_add(demotion_period); + + // Ensure enough time has passed. + let now = frame_system::Pallet::::block_number(); + if now >= demotion_block { + T::Members::demote(&who)?; + let maybe_to_rank = T::Members::rank_of(&who); + Self::dispose_evidence(who.clone(), rank, maybe_to_rank); + let event = if let Some(to_rank) = maybe_to_rank { + member.last_proof = now; + Member::::insert(&who, &member); + Event::::Demoted { who, to_rank } + } else { + Member::::remove(&who); + Event::::Offboarded { who } + }; + Self::deposit_event(event); + return Ok(Pays::No.into()) + } + + Err(Error::::NothingDoing.into()) + } + + /// Set the parameters. + /// + /// - `origin`: A origin complying with `ParamsOrigin` or root. + /// - `params`: The new parameters for the pallet. + #[pallet::weight(T::WeightInfo::set_params())] + #[pallet::call_index(1)] + pub fn set_params(origin: OriginFor, params: Box>) -> DispatchResult { + T::ParamsOrigin::try_origin(origin).map(|_| ()).or_else(|o| ensure_root(o))?; + Params::::put(params.as_ref()); + Self::deposit_event(Event::::ParamsChanged { params: *params }); + Ok(()) + } + + /// Set whether a member is active or not. + /// + /// - `origin`: A `Signed` origin of a member's account. + /// - `is_active`: `true` iff the member is active. + #[pallet::weight(T::WeightInfo::set_active())] + #[pallet::call_index(2)] + pub fn set_active(origin: OriginFor, is_active: bool) -> DispatchResult { + let who = ensure_signed(origin)?; + ensure!( + T::Members::rank_of(&who).map_or(false, |r| !r.is_zero()), + Error::::Unranked + ); + let mut member = Member::::get(&who).ok_or(Error::::NotTracked)?; + member.is_active = is_active; + Member::::insert(&who, &member); + Self::deposit_event(Event::::ActiveChanged { who, is_active }); + Ok(()) + } + + /// Approve a member to continue at their rank. + /// + /// This resets `last_proof` to the current block, thereby delaying any automatic demotion. + /// + /// If `who` is not already tracked by this pallet, then it will become tracked. + /// `last_promotion` will be set to zero. + /// + /// - `origin`: An origin which satisfies `ApproveOrigin` or root. + /// - `who`: A member (i.e. of non-zero rank). + /// - `at_rank`: The rank of member. + #[pallet::weight(T::WeightInfo::approve())] + #[pallet::call_index(3)] + pub fn approve( + origin: OriginFor, + who: T::AccountId, + at_rank: RankOf, + ) -> DispatchResult { + match T::PromoteOrigin::try_origin(origin) { + Ok(allow_rank) => ensure!(allow_rank >= at_rank, Error::::NoPermission), + Err(origin) => ensure_root(origin)?, + } + ensure!(at_rank > 0, Error::::InvalidRank); + let rank = T::Members::rank_of(&who).ok_or(Error::::Unranked)?; + ensure!(rank == at_rank, Error::::UnexpectedRank); + let mut member = Member::::get(&who).ok_or(Error::::NotTracked)?; + + member.last_proof = frame_system::Pallet::::block_number(); + Member::::insert(&who, &member); + + Self::dispose_evidence(who.clone(), at_rank, Some(at_rank)); + Self::deposit_event(Event::::Proven { who, at_rank }); + + Ok(()) + } + + /// Introduce a new and unranked candidate (rank zero). + /// + /// - `origin`: An origin which satisfies `InductOrigin` or root. + /// - `who`: The account ID of the candidate to be inducted and become a member. + #[pallet::weight(T::WeightInfo::induct())] + #[pallet::call_index(4)] + pub fn induct(origin: OriginFor, who: T::AccountId) -> DispatchResult { + match T::InductOrigin::try_origin(origin) { + Ok(_) => {}, + Err(origin) => ensure_root(origin)?, + } + ensure!(!Member::::contains_key(&who), Error::::AlreadyInducted); + ensure!(T::Members::rank_of(&who).is_none(), Error::::Ranked); + + T::Members::induct(&who)?; + let now = frame_system::Pallet::::block_number(); + Member::::insert( + &who, + MemberStatus { is_active: true, last_promotion: now, last_proof: now }, + ); + Self::deposit_event(Event::::Inducted { who }); + Ok(()) + } + + /// Increment the rank of a ranked and tracked account. + /// + /// - `origin`: An origin which satisfies `PromoteOrigin` with a `Success` result of + /// `to_rank` or more or root. + /// - `who`: The account ID of the member to be promoted to `to_rank`. + /// - `to_rank`: One more than the current rank of `who`. + #[pallet::weight(T::WeightInfo::promote())] + #[pallet::call_index(5)] + pub fn promote( + origin: OriginFor, + who: T::AccountId, + to_rank: RankOf, + ) -> DispatchResult { + match T::PromoteOrigin::try_origin(origin) { + Ok(allow_rank) => ensure!(allow_rank >= to_rank, Error::::NoPermission), + Err(origin) => ensure_root(origin)?, + } + let rank = T::Members::rank_of(&who).ok_or(Error::::Unranked)?; + ensure!( + rank.checked_add(1).map_or(false, |i| i == to_rank), + Error::::UnexpectedRank + ); + + let mut member = Member::::get(&who).ok_or(Error::::NotTracked)?; + let now = frame_system::Pallet::::block_number(); + + let params = Params::::get(); + let rank_index = Self::rank_to_index(to_rank).ok_or(Error::::InvalidRank)?; + let min_period = params.min_promotion_period[rank_index]; + // Ensure enough time has passed. + ensure!( + member.last_promotion.saturating_add(min_period) <= now, + Error::::TooSoon, + ); + + T::Members::promote(&who)?; + member.last_promotion = now; + member.last_proof = now; + Member::::insert(&who, &member); + Self::dispose_evidence(who.clone(), rank, Some(to_rank)); + + Self::deposit_event(Event::::Promoted { who, to_rank }); + + Ok(()) + } + + /// Stop tracking a prior member who is now not a ranked member of the collective. + /// + /// - `origin`: A `Signed` origin of an account. + /// - `who`: The ID of an account which was tracked in this pallet but which is now not a + /// ranked member of the collective. + #[pallet::weight(T::WeightInfo::offboard())] + #[pallet::call_index(6)] + pub fn offboard(origin: OriginFor, who: T::AccountId) -> DispatchResultWithPostInfo { + let _ = ensure_signed(origin)?; + ensure!(T::Members::rank_of(&who).is_none(), Error::::Ranked); + ensure!(Member::::contains_key(&who), Error::::NotTracked); + Member::::remove(&who); + MemberEvidence::::remove(&who); + Self::deposit_event(Event::::Offboarded { who }); + Ok(Pays::No.into()) + } + + /// Provide evidence that a rank is deserved. + /// + /// This is free as long as no evidence for the forthcoming judgement is already submitted. + /// Evidence is cleared after an outcome (either demotion, promotion of approval). + /// + /// - `origin`: A `Signed` origin of an inducted and ranked account. + /// - `wish`: The stated desire of the member. + /// - `evidence`: A dump of evidence to be considered. This should generally be either a + /// Markdown-encoded document or a series of 32-byte hashes which can be found on a + /// decentralised content-based-indexing system such as IPFS. + #[pallet::weight(T::WeightInfo::submit_evidence())] + #[pallet::call_index(7)] + pub fn submit_evidence( + origin: OriginFor, + wish: Wish, + evidence: Evidence, + ) -> DispatchResultWithPostInfo { + let who = ensure_signed(origin)?; + ensure!(Member::::contains_key(&who), Error::::NotTracked); + let replaced = MemberEvidence::::contains_key(&who); + MemberEvidence::::insert(&who, (wish, evidence)); + Self::deposit_event(Event::::Requested { who, wish }); + Ok(if replaced { Pays::Yes } else { Pays::No }.into()) + } + + /// Introduce an already-ranked individual of the collective into this pallet. The rank may + /// still be zero. + /// + /// This resets `last_proof` to the current block and `last_promotion` will be set to zero, + /// thereby delaying any automatic demotion but allowing immediate promotion. + /// + /// - `origin`: A signed origin of a ranked, but not tracked, account. + #[pallet::weight(T::WeightInfo::import())] + #[pallet::call_index(8)] + pub fn import(origin: OriginFor) -> DispatchResultWithPostInfo { + let who = ensure_signed(origin)?; + ensure!(!Member::::contains_key(&who), Error::::AlreadyInducted); + let rank = T::Members::rank_of(&who).ok_or(Error::::Unranked)?; + + let now = frame_system::Pallet::::block_number(); + Member::::insert( + &who, + MemberStatus { is_active: true, last_promotion: 0u32.into(), last_proof: now }, + ); + Self::deposit_event(Event::::Imported { who, rank }); + + Ok(Pays::No.into()) + } + } + + impl, I: 'static> Pallet { + /// Convert a rank into a `0..RANK_COUNT` index suitable for the arrays in Params. + /// + /// Rank 1 becomes index 0, rank `RANK_COUNT` becomes index `RANK_COUNT - 1`. Any rank not + /// in the range `1..=RANK_COUNT` is `None`. + pub(crate) fn rank_to_index(rank: RankOf) -> Option { + match TryInto::::try_into(rank) { + Ok(r) if r <= RANK_COUNT && r > 0 => Some(r - 1), + _ => return None, + } + } + + fn dispose_evidence(who: T::AccountId, old_rank: u16, new_rank: Option) { + if let Some((wish, evidence)) = MemberEvidence::::take(&who) { + let e = Event::::EvidenceJudged { who, wish, evidence, old_rank, new_rank }; + Self::deposit_event(e); + } + } + } + + impl, I: 'static> GetSalary, T::AccountId, T::Balance> for Pallet { + fn get_salary(rank: RankOf, who: &T::AccountId) -> T::Balance { + let index = match Self::rank_to_index(rank) { + Some(i) => i, + None => return Zero::zero(), + }; + let member = match Member::::get(who) { + Some(m) => m, + None => return Zero::zero(), + }; + let params = Params::::get(); + let salary = + if member.is_active { params.active_salary } else { params.passive_salary }; + salary[index] + } + } +} + +/// Guard to ensure that the given origin is inducted into this pallet with a given minimum rank. +/// The account ID of the member is the `Success` value. +pub struct EnsureInducted(PhantomData<(T, I)>); +impl, I: 'static, const MIN_RANK: u16> EnsureOrigin + for EnsureInducted +{ + type Success = T::AccountId; + + fn try_origin(o: T::RuntimeOrigin) -> Result { + let who = frame_system::EnsureSigned::try_origin(o)?; + match T::Members::rank_of(&who) { + Some(rank) if rank >= MIN_RANK && Member::::contains_key(&who) => Ok(who), + _ => Err(frame_system::RawOrigin::Signed(who).into()), + } + } + + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin() -> Result { + let who = frame_benchmarking::account::("successful_origin", 0, 0); + if T::Members::rank_of(&who).is_none() { + T::Members::induct(&who).map_err(|_| ())?; + } + for _ in 0..MIN_RANK { + if T::Members::rank_of(&who).ok_or(())? < MIN_RANK { + T::Members::promote(&who).map_err(|_| ())?; + } + } + Ok(frame_system::RawOrigin::Signed(who).into()) + } +} diff --git a/frame/core-fellowship/src/tests.rs b/frame/core-fellowship/src/tests.rs new file mode 100644 index 0000000000000..87c0de112ac33 --- /dev/null +++ b/frame/core-fellowship/src/tests.rs @@ -0,0 +1,362 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2022 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. + +//! The crate's tests. + +use std::collections::BTreeMap; + +use frame_support::{ + assert_noop, assert_ok, ord_parameter_types, + pallet_prelude::Weight, + parameter_types, + traits::{tokens::GetSalary, ConstU32, ConstU64, Everything, IsInVec, TryMapSuccess}, +}; +use frame_system::EnsureSignedBy; +use sp_core::H256; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup, TryMorphInto}, + DispatchError, DispatchResult, +}; +use sp_std::cell::RefCell; + +use super::*; +use crate as pallet_core_fellowship; + +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Block = frame_system::mocking::MockBlock; + +frame_support::construct_runtime!( + pub enum Test where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + CoreFellowship: pallet_core_fellowship::{Pallet, Call, Storage, Event}, + } +); + +parameter_types! { + pub BlockWeights: frame_system::limits::BlockWeights = + frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1_000_000, u64::max_value())); +} +impl frame_system::Config for Test { + type BaseCallFilter = Everything; + type BlockWeights = (); + type BlockLength = (); + type DbWeight = (); + type RuntimeOrigin = RuntimeOrigin; + type Index = u64; + type BlockNumber = u64; + type RuntimeCall = RuntimeCall; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = u64; + type Lookup = IdentityLookup; + type Header = Header; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = ConstU64<250>; + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = ConstU32<16>; +} + +thread_local! { + pub static CLUB: RefCell> = RefCell::new(BTreeMap::new()); +} + +pub struct TestClub; +impl RankedMembers for TestClub { + type AccountId = u64; + type Rank = u16; + fn min_rank() -> Self::Rank { + 0 + } + fn rank_of(who: &Self::AccountId) -> Option { + CLUB.with(|club| club.borrow().get(who).cloned()) + } + fn induct(who: &Self::AccountId) -> DispatchResult { + CLUB.with(|club| club.borrow_mut().insert(*who, 0)); + Ok(()) + } + fn promote(who: &Self::AccountId) -> DispatchResult { + CLUB.with(|club| { + club.borrow_mut().entry(*who).and_modify(|r| *r += 1); + }); + Ok(()) + } + fn demote(who: &Self::AccountId) -> DispatchResult { + CLUB.with(|club| match Self::rank_of(who) { + None => Err(sp_runtime::DispatchError::Unavailable), + Some(0) => { + club.borrow_mut().remove(&who); + Ok(()) + }, + Some(_) => { + club.borrow_mut().entry(*who).and_modify(|x| *x -= 1); + Ok(()) + }, + }) + } +} + +fn set_rank(who: u64, rank: u16) { + CLUB.with(|club| club.borrow_mut().insert(who, rank)); +} + +fn unrank(who: u64) { + CLUB.with(|club| club.borrow_mut().remove(&who)); +} + +parameter_types! { + pub ZeroToNine: Vec = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +} +ord_parameter_types! { + pub const One: u64 = 1; +} + +impl Config for Test { + type WeightInfo = (); + type RuntimeEvent = RuntimeEvent; + type Members = TestClub; + type Balance = u64; + type ParamsOrigin = EnsureSignedBy; + type InductOrigin = EnsureInducted; + type ApproveOrigin = TryMapSuccess, u64>, TryMorphInto>; + type PromoteOrigin = TryMapSuccess, u64>, TryMorphInto>; + type EvidenceSize = ConstU32<1024>; +} + +pub fn new_test_ext() -> sp_io::TestExternalities { + let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut ext = sp_io::TestExternalities::new(t); + ext.execute_with(|| { + let params = ParamsType { + active_salary: [10, 20, 30, 40, 50, 60, 70, 80, 90], + passive_salary: [1, 2, 3, 4, 5, 6, 7, 8, 9], + demotion_period: [2, 4, 6, 8, 10, 12, 14, 16, 18], + min_promotion_period: [3, 6, 9, 12, 15, 18, 21, 24, 27], + offboard_timeout: 1, + }; + assert_ok!(CoreFellowship::set_params(signed(1), Box::new(params))); + System::set_block_number(1); + }); + ext +} + +fn next_block() { + System::set_block_number(System::block_number() + 1); +} + +fn run_to(n: u64) { + while System::block_number() < n { + next_block(); + } +} + +fn signed(who: u64) -> RuntimeOrigin { + RuntimeOrigin::signed(who) +} + +fn next_demotion(who: u64) -> u64 { + let member = Member::::get(who).unwrap(); + let demotion_period = Params::::get().demotion_period; + member.last_proof + demotion_period[TestClub::rank_of(&who).unwrap() as usize - 1] +} + +#[test] +fn basic_stuff() { + new_test_ext().execute_with(|| { + assert_eq!(CoreFellowship::rank_to_index(0), None); + assert_eq!(CoreFellowship::rank_to_index(1), Some(0)); + assert_eq!(CoreFellowship::rank_to_index(9), Some(8)); + assert_eq!(CoreFellowship::rank_to_index(10), None); + assert_eq!(CoreFellowship::get_salary(0, &1), 0); + }); +} + +#[test] +fn set_params_works() { + new_test_ext().execute_with(|| { + let params = ParamsType { + active_salary: [10, 20, 30, 40, 50, 60, 70, 80, 90], + passive_salary: [1, 2, 3, 4, 5, 6, 7, 8, 9], + demotion_period: [1, 2, 3, 4, 5, 6, 7, 8, 9], + min_promotion_period: [1, 2, 3, 4, 5, 10, 15, 20, 30], + offboard_timeout: 1, + }; + assert_noop!( + CoreFellowship::set_params(signed(2), Box::new(params.clone())), + DispatchError::BadOrigin + ); + assert_ok!(CoreFellowship::set_params(signed(1), Box::new(params))); + }); +} + +#[test] +fn induct_works() { + new_test_ext().execute_with(|| { + set_rank(0, 0); + assert_ok!(CoreFellowship::import(signed(0))); + set_rank(1, 1); + assert_ok!(CoreFellowship::import(signed(1))); + + assert_noop!(CoreFellowship::induct(signed(10), 10), DispatchError::BadOrigin); + assert_noop!(CoreFellowship::induct(signed(0), 10), DispatchError::BadOrigin); + assert_ok!(CoreFellowship::induct(signed(1), 10)); + assert_noop!(CoreFellowship::induct(signed(1), 10), Error::::AlreadyInducted); + }); +} + +#[test] +fn promote_works() { + new_test_ext().execute_with(|| { + set_rank(1, 1); + assert_ok!(CoreFellowship::import(signed(1))); + assert_noop!(CoreFellowship::promote(signed(1), 10, 1), Error::::Unranked); + + assert_ok!(CoreFellowship::induct(signed(1), 10)); + assert_noop!(CoreFellowship::promote(signed(10), 10, 1), DispatchError::BadOrigin); + assert_noop!(CoreFellowship::promote(signed(0), 10, 1), Error::::NoPermission); + assert_noop!(CoreFellowship::promote(signed(3), 10, 2), Error::::UnexpectedRank); + run_to(3); + assert_noop!(CoreFellowship::promote(signed(1), 10, 1), Error::::TooSoon); + run_to(4); + assert_ok!(CoreFellowship::promote(signed(1), 10, 1)); + set_rank(11, 0); + assert_noop!(CoreFellowship::promote(signed(1), 11, 1), Error::::NotTracked); + }); +} + +#[test] +fn sync_works() { + new_test_ext().execute_with(|| { + set_rank(10, 5); + assert_noop!(CoreFellowship::approve(signed(4), 10, 5), Error::::NoPermission); + assert_noop!(CoreFellowship::approve(signed(6), 10, 6), Error::::UnexpectedRank); + assert_ok!(CoreFellowship::import(signed(10))); + assert!(Member::::contains_key(10)); + assert_eq!(next_demotion(10), 11); + }); +} + +#[test] +fn auto_demote_works() { + new_test_ext().execute_with(|| { + set_rank(10, 5); + assert_ok!(CoreFellowship::import(signed(10))); + + run_to(10); + assert_noop!(CoreFellowship::bump(signed(0), 10), Error::::NothingDoing); + run_to(11); + assert_ok!(CoreFellowship::bump(signed(0), 10)); + assert_eq!(TestClub::rank_of(&10), Some(4)); + assert_noop!(CoreFellowship::bump(signed(0), 10), Error::::NothingDoing); + assert_eq!(next_demotion(10), 19); + }); +} + +#[test] +fn auto_demote_offboard_works() { + new_test_ext().execute_with(|| { + set_rank(10, 1); + assert_ok!(CoreFellowship::import(signed(10))); + + run_to(3); + assert_ok!(CoreFellowship::bump(signed(0), 10)); + assert_eq!(TestClub::rank_of(&10), Some(0)); + assert_noop!(CoreFellowship::bump(signed(0), 10), Error::::NothingDoing); + run_to(4); + assert_ok!(CoreFellowship::bump(signed(0), 10)); + assert_noop!(CoreFellowship::bump(signed(0), 10), Error::::NotTracked); + }); +} + +#[test] +fn offboard_works() { + new_test_ext().execute_with(|| { + assert_noop!(CoreFellowship::offboard(signed(0), 10), Error::::NotTracked); + set_rank(10, 0); + assert_noop!(CoreFellowship::offboard(signed(0), 10), Error::::Ranked); + + assert_ok!(CoreFellowship::import(signed(10))); + assert_noop!(CoreFellowship::offboard(signed(0), 10), Error::::Ranked); + + unrank(10); + assert_ok!(CoreFellowship::offboard(signed(0), 10)); + assert_noop!(CoreFellowship::offboard(signed(0), 10), Error::::NotTracked); + assert_noop!(CoreFellowship::bump(signed(0), 10), Error::::NotTracked); + }); +} + +#[test] +fn proof_postpones_auto_demote() { + new_test_ext().execute_with(|| { + set_rank(10, 5); + assert_ok!(CoreFellowship::import(signed(10))); + + run_to(11); + assert_ok!(CoreFellowship::approve(signed(5), 10, 5)); + assert_eq!(next_demotion(10), 21); + assert_noop!(CoreFellowship::bump(signed(0), 10), Error::::NothingDoing); + }); +} + +#[test] +fn promote_postpones_auto_demote() { + new_test_ext().execute_with(|| { + set_rank(10, 5); + assert_ok!(CoreFellowship::import(signed(10))); + + run_to(19); + assert_ok!(CoreFellowship::promote(signed(6), 10, 6)); + assert_eq!(next_demotion(10), 31); + assert_noop!(CoreFellowship::bump(signed(0), 10), Error::::NothingDoing); + }); +} + +#[test] +fn get_salary_works() { + new_test_ext().execute_with(|| { + for i in 1..=9u64 { + set_rank(10 + i, i as u16); + assert_ok!(CoreFellowship::import(signed(10 + i))); + assert_eq!(CoreFellowship::get_salary(i as u16, &(10 + i)), i * 10); + } + }); +} + +#[test] +fn active_changing_get_salary_works() { + new_test_ext().execute_with(|| { + for i in 1..=9u64 { + set_rank(10 + i, i as u16); + assert_ok!(CoreFellowship::import(signed(10 + i))); + assert_ok!(CoreFellowship::set_active(signed(10 + i), false)); + assert_eq!(CoreFellowship::get_salary(i as u16, &(10 + i)), i); + assert_ok!(CoreFellowship::set_active(signed(10 + i), true)); + assert_eq!(CoreFellowship::get_salary(i as u16, &(10 + i)), i * 10); + } + }); +} diff --git a/frame/core-fellowship/src/weights.rs b/frame/core-fellowship/src/weights.rs new file mode 100644 index 0000000000000..9f290635ec1cf --- /dev/null +++ b/frame/core-fellowship/src/weights.rs @@ -0,0 +1,393 @@ +// 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. + +//! Autogenerated weights for pallet_core_fellowship +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-03-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/substrate +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json +// --pallet=pallet_core_fellowship +// --chain=dev +// --header=./HEADER-APACHE2 +// --output=./frame/core-fellowship/src/weights.rs +// --template=./.maintain/frame-weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_core_fellowship. +pub trait WeightInfo { + fn set_params() -> Weight; + fn bump_offboard() -> Weight; + fn bump_demote() -> Weight; + fn set_active() -> Weight; + fn induct() -> Weight; + fn promote() -> Weight; + fn offboard() -> Weight; + fn import() -> Weight; + fn approve() -> Weight; + fn submit_evidence() -> Weight; +} + +/// Weights for pallet_core_fellowship using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: CoreFellowship Params (r:0 w:1) + /// Proof: CoreFellowship Params (max_values: Some(1), max_size: Some(364), added: 859, mode: MaxEncodedLen) + fn set_params() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 10_489_000 picoseconds. + Weight::from_parts(10_873_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: CoreFellowship Params (r:1 w:0) + /// Proof: CoreFellowship Params (max_values: Some(1), max_size: Some(364), added: 859, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:1 w:0) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: CoreFellowship MemberEvidence (r:1 w:1) + /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) + fn bump_offboard() -> Weight { + // Proof Size summary in bytes: + // Measured: `16886` + // Estimated: `35762` + // Minimum execution time: 61_794_000 picoseconds. + Weight::from_parts(62_455_000, 35762) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: CoreFellowship Params (r:1 w:0) + /// Proof: CoreFellowship Params (max_values: Some(1), max_size: Some(364), added: 859, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:1 w:0) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: CoreFellowship MemberEvidence (r:1 w:1) + /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) + fn bump_demote() -> Weight { + // Proof Size summary in bytes: + // Measured: `16996` + // Estimated: `35762` + // Minimum execution time: 63_921_000 picoseconds. + Weight::from_parts(64_871_000, 35762) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: RankedCollective Members (r:1 w:0) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + fn set_active() -> Weight { + // Proof Size summary in bytes: + // Measured: `355` + // Estimated: `7021` + // Minimum execution time: 19_023_000 picoseconds. + Weight::from_parts(19_270_000, 7021) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IndexToId (r:0 w:1) + /// Proof: RankedCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:0 w:1) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + fn induct() -> Weight { + // Proof Size summary in bytes: + // Measured: `113` + // Estimated: `10500` + // Minimum execution time: 29_089_000 picoseconds. + Weight::from_parts(29_718_000, 10500) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: CoreFellowship Params (r:1 w:0) + /// Proof: CoreFellowship Params (max_values: Some(1), max_size: Some(364), added: 859, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: CoreFellowship MemberEvidence (r:1 w:1) + /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) + /// Storage: RankedCollective IndexToId (r:0 w:1) + /// Proof: RankedCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:0 w:1) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + fn promote() -> Weight { + // Proof Size summary in bytes: + // Measured: `16864` + // Estimated: `32243` + // Minimum execution time: 59_529_000 picoseconds. + Weight::from_parts(60_057_000, 32243) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: RankedCollective Members (r:1 w:0) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + fn offboard() -> Weight { + // Proof Size summary in bytes: + // Measured: `292` + // Estimated: `7021` + // Minimum execution time: 17_221_000 picoseconds. + Weight::from_parts(17_585_000, 7021) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: RankedCollective Members (r:1 w:0) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + fn import() -> Weight { + // Proof Size summary in bytes: + // Measured: `280` + // Estimated: `7021` + // Minimum execution time: 18_602_000 picoseconds. + Weight::from_parts(18_813_000, 7021) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: RankedCollective Members (r:1 w:0) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: CoreFellowship MemberEvidence (r:1 w:1) + /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) + fn approve() -> Weight { + // Proof Size summary in bytes: + // Measured: `16842` + // Estimated: `26915` + // Minimum execution time: 43_525_000 picoseconds. + Weight::from_parts(43_994_000, 26915) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: CoreFellowship Member (r:1 w:0) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: CoreFellowship MemberEvidence (r:1 w:1) + /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) + fn submit_evidence() -> Weight { + // Proof Size summary in bytes: + // Measured: `79` + // Estimated: `23408` + // Minimum execution time: 27_960_000 picoseconds. + Weight::from_parts(28_331_000, 23408) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: CoreFellowship Params (r:0 w:1) + /// Proof: CoreFellowship Params (max_values: Some(1), max_size: Some(364), added: 859, mode: MaxEncodedLen) + fn set_params() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 10_489_000 picoseconds. + Weight::from_parts(10_873_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: CoreFellowship Params (r:1 w:0) + /// Proof: CoreFellowship Params (max_values: Some(1), max_size: Some(364), added: 859, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:1 w:0) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: CoreFellowship MemberEvidence (r:1 w:1) + /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) + fn bump_offboard() -> Weight { + // Proof Size summary in bytes: + // Measured: `16886` + // Estimated: `35762` + // Minimum execution time: 61_794_000 picoseconds. + Weight::from_parts(62_455_000, 35762) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: CoreFellowship Params (r:1 w:0) + /// Proof: CoreFellowship Params (max_values: Some(1), max_size: Some(364), added: 859, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:1 w:0) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: CoreFellowship MemberEvidence (r:1 w:1) + /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) + fn bump_demote() -> Weight { + // Proof Size summary in bytes: + // Measured: `16996` + // Estimated: `35762` + // Minimum execution time: 63_921_000 picoseconds. + Weight::from_parts(64_871_000, 35762) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: RankedCollective Members (r:1 w:0) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + fn set_active() -> Weight { + // Proof Size summary in bytes: + // Measured: `355` + // Estimated: `7021` + // Minimum execution time: 19_023_000 picoseconds. + Weight::from_parts(19_270_000, 7021) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IndexToId (r:0 w:1) + /// Proof: RankedCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:0 w:1) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + fn induct() -> Weight { + // Proof Size summary in bytes: + // Measured: `113` + // Estimated: `10500` + // Minimum execution time: 29_089_000 picoseconds. + Weight::from_parts(29_718_000, 10500) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: CoreFellowship Params (r:1 w:0) + /// Proof: CoreFellowship Params (max_values: Some(1), max_size: Some(364), added: 859, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: CoreFellowship MemberEvidence (r:1 w:1) + /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) + /// Storage: RankedCollective IndexToId (r:0 w:1) + /// Proof: RankedCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:0 w:1) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + fn promote() -> Weight { + // Proof Size summary in bytes: + // Measured: `16864` + // Estimated: `32243` + // Minimum execution time: 59_529_000 picoseconds. + Weight::from_parts(60_057_000, 32243) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: RankedCollective Members (r:1 w:0) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + fn offboard() -> Weight { + // Proof Size summary in bytes: + // Measured: `292` + // Estimated: `7021` + // Minimum execution time: 17_221_000 picoseconds. + Weight::from_parts(17_585_000, 7021) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: RankedCollective Members (r:1 w:0) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + fn import() -> Weight { + // Proof Size summary in bytes: + // Measured: `280` + // Estimated: `7021` + // Minimum execution time: 18_602_000 picoseconds. + Weight::from_parts(18_813_000, 7021) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: RankedCollective Members (r:1 w:0) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: CoreFellowship Member (r:1 w:1) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: CoreFellowship MemberEvidence (r:1 w:1) + /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) + fn approve() -> Weight { + // Proof Size summary in bytes: + // Measured: `16842` + // Estimated: `26915` + // Minimum execution time: 43_525_000 picoseconds. + Weight::from_parts(43_994_000, 26915) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: CoreFellowship Member (r:1 w:0) + /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: CoreFellowship MemberEvidence (r:1 w:1) + /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) + fn submit_evidence() -> Weight { + // Proof Size summary in bytes: + // Measured: `79` + // Estimated: `23408` + // Minimum execution time: 27_960_000 picoseconds. + Weight::from_parts(28_331_000, 23408) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} diff --git a/frame/salary/src/lib.rs b/frame/salary/src/lib.rs index 2169952f1a7f3..5a4ff8a66da50 100644 --- a/frame/salary/src/lib.rs +++ b/frame/salary/src/lib.rs @@ -82,8 +82,8 @@ pub trait Pay { /// after this call. Used in benchmarking code. #[cfg(feature = "runtime-benchmarks")] fn ensure_successful(who: &Self::AccountId, amount: Self::Balance); - /// Ensure that a call to check_payment with the given parameters will return either Success - /// or Failure. + /// Ensure that a call to `check_payment` with the given parameters will return either `Success` + /// or `Failure`. #[cfg(feature = "runtime-benchmarks")] fn ensure_concluded(id: Self::Id); } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 5e921ab854df1..0ec808d4c960f 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -878,12 +878,9 @@ impl< #[cfg(feature = "runtime-benchmarks")] fn try_successful_origin() -> Result { - let zero_account_id = - AccountId::decode(&mut TrailingZeroInput::zeroes()).map_err(|_| ())?; - let members = Who::sorted_members(); - let first_member = match members.get(0) { + let first_member = match Who::sorted_members().first() { Some(account) => account.clone(), - None => zero_account_id, + None => AccountId::decode(&mut TrailingZeroInput::zeroes()).map_err(|_| ())?, }; Ok(O::from(RawOrigin::Signed(first_member))) } diff --git a/primitives/arithmetic/src/traits.rs b/primitives/arithmetic/src/traits.rs index 84e3f60aa6a7d..33b4e376aaf9d 100644 --- a/primitives/arithmetic/src/traits.rs +++ b/primitives/arithmetic/src/traits.rs @@ -148,6 +148,20 @@ impl< { } +/// A meta trait for arithmetic. +/// +/// Arithmetic types do all the usual stuff you'd expect numbers to do. They are guaranteed to +/// be able to represent at least `u8` values without loss, hence the trait implies `From` +/// and smaller integers. All other conversions are fallible. +pub trait AtLeast8Bit: BaseArithmetic + From {} + +impl> AtLeast8Bit for T {} + +/// A meta trait for arithmetic. Same as [`AtLeast8Bit `], but also bounded to be unsigned. +pub trait AtLeast8BitUnsigned: AtLeast8Bit + Unsigned {} + +impl AtLeast8BitUnsigned for T {} + /// A meta trait for arithmetic. /// /// Arithmetic types do all the usual stuff you'd expect numbers to do. They are guaranteed to @@ -220,6 +234,24 @@ pub trait Saturating { /// instead of overflowing. fn saturating_pow(self, exp: usize) -> Self; + /// Decrement self by one, saturating at zero. + fn saturating_less_one(mut self) -> Self + where + Self: One, + { + self.saturating_dec(); + self + } + + /// Increment self by one, saturating at the numeric bounds instead of overflowing. + fn saturating_plus_one(mut self) -> Self + where + Self: One, + { + self.saturating_inc(); + self + } + /// Increment self by one, saturating. fn saturating_inc(&mut self) where diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index e853cad61d81e..4bba6f6bc1283 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -319,6 +319,24 @@ impl TryMorph for Identity { } } +/// Implementation of `Morph` which converts between types using `Into`. +pub struct MorphInto(sp_std::marker::PhantomData); +impl> Morph for MorphInto { + type Outcome = T; + fn morph(a: A) -> T { + a.into() + } +} + +/// Implementation of `TryMorph` which attmepts to convert between types using `TryInto`. +pub struct TryMorphInto(sp_std::marker::PhantomData); +impl> TryMorph for TryMorphInto { + type Outcome = T; + fn try_morph(a: A) -> Result { + a.try_into().map_err(|_| ()) + } +} + /// Create a `Morph` and/or `TryMorph` impls with a simple closure-like expression. /// /// # Examples From 3c3b223be82d91be85b3f3cc8305e444b2ca37fa Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Sat, 11 Mar 2023 17:04:54 +0100 Subject: [PATCH 02/80] Fix dependabot labels (#13578) * dependabot: fix label names * dependabot: apply E2-dependencies label for Cargo.lock changes --- .github/dependabot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cca9219e6c5e1..04cf0d1e1a5a4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,11 +2,11 @@ version: 2 updates: - package-ecosystem: "cargo" directory: "/" - labels: ["A2-insubstantial", "B0-silent", "C1-low 📌"] + labels: ["A2-insubstantial", "B0-silent", "C1-low", "E2-dependencies"] schedule: interval: "daily" - package-ecosystem: github-actions directory: '/' - labels: ["A2-insubstantial", "B0-silent", "C1-low 📌", "E3-dependencies"] + labels: ["A2-insubstantial", "B0-silent", "C1-low", "E2-dependencies"] schedule: interval: daily From 310fe4095bff177ddcfa660ac0ab06171a25a9c2 Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Sat, 11 Mar 2023 19:05:55 +0100 Subject: [PATCH 03/80] BEEFY: introduce offence report system (#13564) * Trivial adjustments to beefy and grandpa pallets * Introduce offence report system to beefy pallet * Minor adjustments * Fix beefy-mmr mock * Apply suggestions from code review Co-authored-by: Anton --------- Co-authored-by: Anton --- frame/babe/src/equivocation.rs | 14 +- frame/beefy-mmr/src/mock.rs | 14 +- frame/beefy/src/equivocation.rs | 412 ++++++++++--------------- frame/beefy/src/lib.rs | 130 ++------ frame/beefy/src/mock.rs | 12 +- frame/grandpa/src/equivocation.rs | 33 +- frame/grandpa/src/lib.rs | 3 +- frame/grandpa/src/mock.rs | 3 - frame/grandpa/src/tests.rs | 12 +- frame/offences/benchmarking/src/lib.rs | 4 +- 10 files changed, 233 insertions(+), 404 deletions(-) diff --git a/frame/babe/src/equivocation.rs b/frame/babe/src/equivocation.rs index ed98385a74474..3a14cacc905d2 100644 --- a/frame/babe/src/equivocation.rs +++ b/frame/babe/src/equivocation.rs @@ -95,14 +95,16 @@ impl Offence for EquivocationOffence { } } -/// Babe equivocation offence system. +/// BABE equivocation offence report system. /// -/// This type implements `OffenceReportSystem` +/// This type implements `OffenceReportSystem` such that: +/// - Equivocation reports are published on-chain as unsigned extrinsic via +/// `offchain::SendTransactioinsTypes`. +/// - On-chain validity checks and processing are mostly delegated to the user provided generic +/// types implementing `KeyOwnerProofSystem` and `ReportOffence` traits. +/// - Offence reporter for unsigned transactions is fetched via the the authorship pallet. pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, R, P, L)>); -// We use the authorship pallet to fetch the current block author and use -// `offchain::SendTransactionTypes` for unsigned extrinsic creation and -// submission. impl OffenceReportSystem, (EquivocationProof, T::KeyOwnerProof)> for EquivocationReportSystem @@ -131,7 +133,7 @@ where }; let res = SubmitTransaction::>::submit_unsigned_transaction(call.into()); match res { - Ok(()) => info!(target: LOG_TARGET, "Submitted equivocation report."), + Ok(_) => info!(target: LOG_TARGET, "Submitted equivocation report"), Err(e) => error!(target: LOG_TARGET, "Error submitting equivocation report: {:?}", e), } res diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index d31effc9ab577..8b3bedcb960b4 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -21,11 +21,11 @@ use codec::Encode; use frame_support::{ construct_runtime, parameter_types, sp_io::TestExternalities, - traits::{ConstU16, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem}, + traits::{ConstU16, ConstU32, ConstU64, GenesisBuild}, BasicExternalities, }; use sp_consensus_beefy::mmr::MmrLeafVersion; -use sp_core::{crypto::KeyTypeId, Hasher, H256}; +use sp_core::{Hasher, H256}; use sp_runtime::{ app_crypto::ecdsa::Public, impl_opaque_keys, @@ -124,18 +124,12 @@ impl pallet_mmr::Config for Test { impl pallet_beefy::Config for Test { type BeefyId = BeefyId; - type KeyOwnerProofSystem = (); - type KeyOwnerProof = - >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; - type HandleEquivocation = (); type MaxAuthorities = ConstU32<100>; type MaxSetIdSessionEntries = ConstU64<100>; type OnNewValidatorSet = BeefyMmr; type WeightInfo = (); + type KeyOwnerProof = sp_core::Void; + type EquivocationReportSystem = (); } parameter_types! { diff --git a/frame/beefy/src/equivocation.rs b/frame/beefy/src/equivocation.rs index cc04f316c3638..f83b037dcd26e 100644 --- a/frame/beefy/src/equivocation.rs +++ b/frame/beefy/src/equivocation.rs @@ -34,179 +34,205 @@ //! that the `ValidateUnsigned` for the BEEFY pallet is used in the runtime //! definition. -use sp_std::prelude::*; - use codec::{self as codec, Decode, Encode}; use frame_support::{ log, traits::{Get, KeyOwnerProofSystem}, }; -use frame_system::pallet_prelude::BlockNumberFor; -use sp_consensus_beefy::{EquivocationProof, ValidatorSetId}; +use log::{error, info}; +use sp_consensus_beefy::{EquivocationProof, ValidatorSetId, KEY_TYPE}; use sp_runtime::{ transaction_validity::{ InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity, TransactionValidityError, ValidTransaction, }, - DispatchResult, Perbill, RuntimeAppPublic, + DispatchError, KeyTypeId, Perbill, RuntimeAppPublic, }; +use sp_session::{GetSessionNumber, GetValidatorCount}; use sp_staking::{ - offence::{Kind, Offence, OffenceError, ReportOffence}, + offence::{Kind, Offence, OffenceReportSystem, ReportOffence}, SessionIndex, }; +use sp_std::prelude::*; -use super::{Call, Config, Pallet, LOG_TARGET}; - -/// A trait with utility methods for handling equivocation reports in BEEFY. -/// The offence type is generic, and the trait provides, reporting an offence -/// triggered by a valid equivocation report, and also for creating and -/// submitting equivocation report extrinsics (useful only in offchain context). -pub trait HandleEquivocation { - /// The offence type used for reporting offences on valid equivocation reports. - type Offence: BeefyOffence, T::KeyOwnerIdentification>; - - /// The longevity, in blocks, that the equivocation report is valid for. When using the staking - /// pallet this should be equal to the bonding duration (in blocks, not eras). - type ReportLongevity: Get; - - /// Report an offence proved by the given reporters. - fn report_offence( - reporters: Vec, - offence: Self::Offence, - ) -> Result<(), OffenceError>; - - /// Returns true if all of the offenders at the given time slot have already been reported. - fn is_known_offence( - offenders: &[T::KeyOwnerIdentification], - time_slot: &>::TimeSlot, - ) -> bool; - - /// Create and dispatch an equivocation report extrinsic. - fn submit_unsigned_equivocation_report( - equivocation_proof: EquivocationProof< - BlockNumberFor, - T::BeefyId, - ::Signature, - >, - key_owner_proof: T::KeyOwnerProof, - ) -> DispatchResult; - - /// Fetch the current block author id, if defined. - fn block_author() -> Option; +use super::{Call, Config, Error, Pallet, LOG_TARGET}; + +/// A round number and set id which point on the time of an offence. +#[derive(Copy, Clone, PartialOrd, Ord, Eq, PartialEq, Encode, Decode)] +pub struct TimeSlot { + // The order of these matters for `derive(Ord)`. + /// BEEFY Set ID. + pub set_id: ValidatorSetId, + /// Round number. + pub round: N, } -impl HandleEquivocation for () { - type Offence = BeefyEquivocationOffence, T::KeyOwnerIdentification>; - type ReportLongevity = (); +/// BEEFY equivocation offence report. +pub struct EquivocationOffence +where + N: Copy + Clone + PartialOrd + Ord + Eq + PartialEq + Encode + Decode, +{ + /// Time slot at which this incident happened. + pub time_slot: TimeSlot, + /// The session index in which the incident happened. + pub session_index: SessionIndex, + /// The size of the validator set at the time of the offence. + pub validator_set_count: u32, + /// The authority which produced this equivocation. + pub offender: Offender, +} - fn report_offence( - _reporters: Vec, - _offence: BeefyEquivocationOffence, T::KeyOwnerIdentification>, - ) -> Result<(), OffenceError> { - Ok(()) - } +impl Offence for EquivocationOffence +where + N: Copy + Clone + PartialOrd + Ord + Eq + PartialEq + Encode + Decode, +{ + const ID: Kind = *b"beefy:equivocati"; + type TimeSlot = TimeSlot; - fn is_known_offence( - _offenders: &[T::KeyOwnerIdentification], - _time_slot: &BeefyTimeSlot>, - ) -> bool { - true + fn offenders(&self) -> Vec { + vec![self.offender.clone()] } - fn submit_unsigned_equivocation_report( - _equivocation_proof: EquivocationProof< - BlockNumberFor, - T::BeefyId, - ::Signature, - >, - _key_owner_proof: T::KeyOwnerProof, - ) -> DispatchResult { - Ok(()) + fn session_index(&self) -> SessionIndex { + self.session_index } - fn block_author() -> Option { - None + fn validator_set_count(&self) -> u32 { + self.validator_set_count } -} -/// Generic equivocation handler. This type implements `HandleEquivocation` -/// using existing subsystems that are part of frame (type bounds described -/// below) and will dispatch to them directly, it's only purpose is to wire all -/// subsystems together. -pub struct EquivocationHandler> { - _phantom: sp_std::marker::PhantomData<(N, I, R, L, O)>, -} + fn time_slot(&self) -> Self::TimeSlot { + self.time_slot + } -impl Default for EquivocationHandler { - fn default() -> Self { - Self { _phantom: Default::default() } + // The formula is min((3k / n)^2, 1) + // where k = offenders_number and n = validators_number + fn slash_fraction(&self, offenders_count: u32) -> Perbill { + // Perbill type domain is [0, 1] by definition + Perbill::from_rational(3 * offenders_count, self.validator_set_count).square() } } -impl HandleEquivocation - for EquivocationHandler, T::KeyOwnerIdentification, R, L, O> +/// BEEFY equivocation offence report system. +/// +/// This type implements `OffenceReportSystem` such that: +/// - Equivocation reports are published on-chain as unsigned extrinsic via +/// `offchain::SendTransactioinsTypes`. +/// - On-chain validity checks and processing are mostly delegated to the user provided generic +/// types implementing `KeyOwnerProofSystem` and `ReportOffence` traits. +/// - Offence reporter for unsigned transactions is fetched via the the authorship pallet. +pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, R, P, L)>); + +/// Equivocation evidence convenience alias. +pub type EquivocationEvidenceFor = ( + EquivocationProof< + ::BlockNumber, + ::BeefyId, + <::BeefyId as RuntimeAppPublic>::Signature, + >, + ::KeyOwnerProof, +); + +impl OffenceReportSystem, EquivocationEvidenceFor> + for EquivocationReportSystem where - // We use the authorship pallet to fetch the current block author and use - // `offchain::SendTransactionTypes` for unsigned extrinsic creation and - // submission. T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes>, - // A system for reporting offences after valid equivocation reports are - // processed. - R: ReportOffence, - // The longevity (in blocks) that the equivocation report is valid for. When using the staking - // pallet this should be the bonding duration. + R: ReportOffence< + T::AccountId, + P::IdentificationTuple, + EquivocationOffence, + >, + P: KeyOwnerProofSystem<(KeyTypeId, T::BeefyId), Proof = T::KeyOwnerProof>, + P::IdentificationTuple: Clone, L: Get, - // The offence type that should be used when reporting. - O: BeefyOffence, T::KeyOwnerIdentification>, { - type Offence = O; - type ReportLongevity = L; + type Longevity = L; - fn report_offence(reporters: Vec, offence: O) -> Result<(), OffenceError> { - R::report_offence(reporters, offence) - } - - fn is_known_offence(offenders: &[T::KeyOwnerIdentification], time_slot: &O::TimeSlot) -> bool { - R::is_known_offence(offenders, time_slot) - } - - fn submit_unsigned_equivocation_report( - equivocation_proof: EquivocationProof< - BlockNumberFor, - T::BeefyId, - ::Signature, - >, - key_owner_proof: T::KeyOwnerProof, - ) -> DispatchResult { + fn publish_evidence(evidence: EquivocationEvidenceFor) -> Result<(), ()> { use frame_system::offchain::SubmitTransaction; + let (equivocation_proof, key_owner_proof) = evidence; let call = Call::report_equivocation_unsigned { equivocation_proof: Box::new(equivocation_proof), key_owner_proof, }; - match SubmitTransaction::>::submit_unsigned_transaction(call.into()) { - Ok(()) => log::info!(target: LOG_TARGET, "Submitted BEEFY equivocation report.",), - Err(e) => - log::error!(target: LOG_TARGET, "Error submitting equivocation report: {:?}", e,), + let res = SubmitTransaction::>::submit_unsigned_transaction(call.into()); + match res { + Ok(_) => info!(target: LOG_TARGET, "Submitted equivocation report."), + Err(e) => error!(target: LOG_TARGET, "Error submitting equivocation report: {:?}", e), } - - Ok(()) + res } - fn block_author() -> Option { - >::author() + fn check_evidence( + evidence: EquivocationEvidenceFor, + ) -> Result<(), TransactionValidityError> { + let (equivocation_proof, key_owner_proof) = evidence; + + // Check the membership proof to extract the offender's id + let key = (KEY_TYPE, equivocation_proof.offender_id().clone()); + let offender = P::check_proof(key, key_owner_proof).ok_or(InvalidTransaction::BadProof)?; + + // Check if the offence has already been reported, and if so then we can discard the report. + let time_slot = TimeSlot { + set_id: equivocation_proof.set_id(), + round: *equivocation_proof.round_number(), + }; + + if R::is_known_offence(&[offender], &time_slot) { + Err(InvalidTransaction::Stale.into()) + } else { + Ok(()) + } } -} -/// A round number and set id which point on the time of an offence. -#[derive(Copy, Clone, PartialOrd, Ord, Eq, PartialEq, Encode, Decode)] -pub struct BeefyTimeSlot { - // The order of these matters for `derive(Ord)`. - /// BEEFY Set ID. - pub set_id: ValidatorSetId, - /// Round number. - pub round: N, + fn process_evidence( + reporter: Option, + evidence: EquivocationEvidenceFor, + ) -> Result<(), DispatchError> { + let (equivocation_proof, key_owner_proof) = evidence; + let reporter = reporter.or_else(|| >::author()); + let offender = equivocation_proof.offender_id().clone(); + + // We check the equivocation within the context of its set id (and + // associated session) and round. We also need to know the validator + // set count at the time of the offence since it is required to calculate + // the slash amount. + let set_id = equivocation_proof.set_id(); + let round = *equivocation_proof.round_number(); + let session_index = key_owner_proof.session(); + let validator_set_count = key_owner_proof.validator_count(); + + // Validate the key ownership proof extracting the id of the offender. + let offender = P::check_proof((KEY_TYPE, offender), key_owner_proof) + .ok_or(Error::::InvalidKeyOwnershipProof)?; + + // Validate equivocation proof (check votes are different and signatures are valid). + if !sp_consensus_beefy::check_equivocation_proof(&equivocation_proof) { + return Err(Error::::InvalidEquivocationProof.into()) + } + + // Check that the session id for the membership proof is within the + // bounds of the set id reported in the equivocation. + let set_id_session_index = + crate::SetIdSession::::get(set_id).ok_or(Error::::InvalidEquivocationProof)?; + if session_index != set_id_session_index { + return Err(Error::::InvalidEquivocationProof.into()) + } + + let offence = EquivocationOffence { + time_slot: TimeSlot { set_id, round }, + session_index, + validator_set_count, + offender, + }; + + R::report_offence(reporter.into_iter().collect(), offence) + .map_err(|_| Error::::DuplicateOffenceReport)?; + + Ok(()) + } } /// Methods for the `ValidateUnsigned` implementation: @@ -228,11 +254,11 @@ impl Pallet { }, } - // check report staleness - is_known_offence::(equivocation_proof, key_owner_proof)?; + let evidence = (*equivocation_proof.clone(), key_owner_proof.clone()); + T::EquivocationReportSystem::check_evidence(evidence)?; let longevity = - >::ReportLongevity::get(); + >::Longevity::get(); ValidTransaction::with_tag_prefix("BeefyEquivocation") // We assign the maximum priority for any equivocation report. @@ -254,132 +280,10 @@ impl Pallet { pub fn pre_dispatch(call: &Call) -> Result<(), TransactionValidityError> { if let Call::report_equivocation_unsigned { equivocation_proof, key_owner_proof } = call { - is_known_offence::(equivocation_proof, key_owner_proof) + let evidence = (*equivocation_proof.clone(), key_owner_proof.clone()); + T::EquivocationReportSystem::check_evidence(evidence) } else { Err(InvalidTransaction::Call.into()) } } } - -fn is_known_offence( - equivocation_proof: &EquivocationProof< - BlockNumberFor, - T::BeefyId, - ::Signature, - >, - key_owner_proof: &T::KeyOwnerProof, -) -> Result<(), TransactionValidityError> { - // check the membership proof to extract the offender's id, - // equivocation validity will be fully checked during the call. - let key = (sp_consensus_beefy::KEY_TYPE, equivocation_proof.offender_id().clone()); - - let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof.clone()) - .ok_or(InvalidTransaction::BadProof)?; - - // check if the offence has already been reported, - // and if so then we can discard the report. - let time_slot = >::Offence::new_time_slot( - equivocation_proof.set_id(), - *equivocation_proof.round_number(), - ); - - let is_known_offence = T::HandleEquivocation::is_known_offence(&[offender], &time_slot); - - if is_known_offence { - Err(InvalidTransaction::Stale.into()) - } else { - Ok(()) - } -} - -/// A BEEFY equivocation offence report. -pub struct BeefyEquivocationOffence -where - N: Copy + Clone + PartialOrd + Ord + Eq + PartialEq + Encode + Decode, -{ - /// Time slot at which this incident happened. - pub time_slot: BeefyTimeSlot, - /// The session index in which the incident happened. - pub session_index: SessionIndex, - /// The size of the validator set at the time of the offence. - pub validator_set_count: u32, - /// The authority which produced this equivocation. - pub offender: FullIdentification, -} - -/// An interface for types that will be used as BEEFY offences and must also -/// implement the `Offence` trait. This trait provides a constructor that is -/// provided all available data during processing of BEEFY equivocations. -pub trait BeefyOffence: Offence -where - N: Copy + Clone + PartialOrd + Ord + Eq + PartialEq + Encode + Decode, -{ - /// Create a new BEEFY offence using the given equivocation details. - fn new( - session_index: SessionIndex, - validator_set_count: u32, - offender: FullIdentification, - set_id: ValidatorSetId, - round: N, - ) -> Self; - - /// Create a new BEEFY offence time slot. - fn new_time_slot(set_id: ValidatorSetId, round: N) -> Self::TimeSlot; -} - -impl BeefyOffence - for BeefyEquivocationOffence -where - N: Copy + Clone + PartialOrd + Ord + Eq + PartialEq + Encode + Decode, -{ - fn new( - session_index: SessionIndex, - validator_set_count: u32, - offender: FullIdentification, - set_id: ValidatorSetId, - round: N, - ) -> Self { - BeefyEquivocationOffence { - session_index, - validator_set_count, - offender, - time_slot: BeefyTimeSlot { set_id, round }, - } - } - - fn new_time_slot(set_id: ValidatorSetId, round: N) -> Self::TimeSlot { - BeefyTimeSlot { set_id, round } - } -} - -impl Offence - for BeefyEquivocationOffence -where - N: Copy + Clone + PartialOrd + Ord + Eq + PartialEq + Encode + Decode, -{ - const ID: Kind = *b"beefy:equivocati"; - type TimeSlot = BeefyTimeSlot; - - fn offenders(&self) -> Vec { - vec![self.offender.clone()] - } - - fn session_index(&self) -> SessionIndex { - self.session_index - } - - fn validator_set_count(&self) -> u32 { - self.validator_set_count - } - - fn time_slot(&self) -> Self::TimeSlot { - self.time_slot - } - - fn slash_fraction(&self, offenders_count: u32) -> Perbill { - // the formula is min((3k / n)^2, 1) - let x = Perbill::from_rational(3 * offenders_count, self.validator_set_count); - // _ ^ 2 - x.square() - } -} diff --git a/frame/beefy/src/lib.rs b/frame/beefy/src/lib.rs index 698e6e73312f1..945b32c12fe58 100644 --- a/frame/beefy/src/lib.rs +++ b/frame/beefy/src/lib.rs @@ -23,7 +23,7 @@ use frame_support::{ dispatch::{DispatchResultWithPostInfo, Pays}, log, pallet_prelude::*, - traits::{Get, KeyOwnerProofSystem, OneSessionHandler}, + traits::{Get, OneSessionHandler}, weights::Weight, BoundedSlice, BoundedVec, Parameter, }; @@ -34,10 +34,10 @@ use frame_system::{ use sp_runtime::{ generic::DigestItem, traits::{IsMember, Member}, - KeyTypeId, RuntimeAppPublic, + RuntimeAppPublic, }; use sp_session::{GetSessionNumber, GetValidatorCount}; -use sp_staking::SessionIndex; +use sp_staking::{offence::OffenceReportSystem, SessionIndex}; use sp_std::prelude::*; use sp_consensus_beefy::{ @@ -52,11 +52,11 @@ mod mock; #[cfg(test)] mod tests; -pub use crate::equivocation::{ - BeefyEquivocationOffence, BeefyOffence, BeefyTimeSlot, EquivocationHandler, HandleEquivocation, -}; +pub use crate::equivocation::{EquivocationOffence, EquivocationReportSystem, TimeSlot}; pub use pallet::*; +use crate::equivocation::EquivocationEvidenceFor; + const LOG_TARGET: &str = "runtime::beefy"; #[frame_support::pallet] @@ -74,30 +74,6 @@ pub mod pallet { + MaybeSerializeDeserialize + MaxEncodedLen; - /// A system for proving ownership of keys, i.e. that a given key was part - /// of a validator set, needed for validating equivocation reports. - type KeyOwnerProofSystem: KeyOwnerProofSystem< - (KeyTypeId, Self::BeefyId), - Proof = Self::KeyOwnerProof, - IdentificationTuple = Self::KeyOwnerIdentification, - >; - - /// The proof of key ownership, used for validating equivocation reports - /// The proof must include the session index and validator count of the - /// session at which the equivocation occurred. - type KeyOwnerProof: Parameter + GetSessionNumber + GetValidatorCount; - - /// The identification of a key owner, used when reporting equivocations. - type KeyOwnerIdentification: Parameter; - - /// The equivocation handling subsystem, defines methods to report an - /// offence (after the equivocation has been validated) and for submitting a - /// transaction to report an equivocation (from an offchain context). - /// NOTE: when enabling equivocation handling (i.e. this type isn't set to - /// `()`) you must use this pallet's `ValidateUnsigned` in the runtime - /// definition. - type HandleEquivocation: HandleEquivocation; - /// The maximum number of authorities that can be added. #[pallet::constant] type MaxAuthorities: Get; @@ -120,6 +96,19 @@ pub mod pallet { /// Weights for this pallet. type WeightInfo: WeightInfo; + + /// The proof of key ownership, used for validating equivocation reports + /// The proof must include the session index and validator count of the + /// session at which the equivocation occurred. + type KeyOwnerProof: Parameter + GetSessionNumber + GetValidatorCount; + + /// The equivocation handling subsystem. + /// + /// Defines methods to publish, check and process an equivocation offence. + type EquivocationReportSystem: OffenceReportSystem< + Option, + EquivocationEvidenceFor, + >; } #[pallet::pallet] @@ -229,7 +218,12 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { let reporter = ensure_signed(origin)?; - Self::do_report_equivocation(Some(reporter), *equivocation_proof, key_owner_proof) + T::EquivocationReportSystem::process_evidence( + Some(reporter), + (*equivocation_proof, key_owner_proof), + )?; + // Waive the fee since the report is valid and beneficial + Ok(Pays::No.into()) } /// Report voter equivocation/misbehavior. This method will verify the @@ -256,20 +250,22 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { ensure_none(origin)?; - Self::do_report_equivocation( - T::HandleEquivocation::block_author(), - *equivocation_proof, - key_owner_proof, - ) + T::EquivocationReportSystem::process_evidence( + None, + (*equivocation_proof, key_owner_proof), + )?; + Ok(Pays::No.into()) } } #[pallet::validate_unsigned] impl ValidateUnsigned for Pallet { type Call = Call; + fn pre_dispatch(call: &Self::Call) -> Result<(), TransactionValidityError> { Self::pre_dispatch(call) } + fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity { Self::validate_unsigned(source, call) } @@ -295,11 +291,7 @@ impl Pallet { >, key_owner_proof: T::KeyOwnerProof, ) -> Option<()> { - T::HandleEquivocation::submit_unsigned_equivocation_report( - equivocation_proof, - key_owner_proof, - ) - .ok() + T::EquivocationReportSystem::publish_evidence((equivocation_proof, key_owner_proof)).ok() } fn change_authorities( @@ -368,62 +360,6 @@ impl Pallet { Ok(()) } - - fn do_report_equivocation( - reporter: Option, - equivocation_proof: EquivocationProof< - BlockNumberFor, - T::BeefyId, - ::Signature, - >, - key_owner_proof: T::KeyOwnerProof, - ) -> DispatchResultWithPostInfo { - // We check the equivocation within the context of its set id (and - // associated session) and round. We also need to know the validator - // set count at the time of the offence since it is required to calculate - // the slash amount. - let set_id = equivocation_proof.set_id(); - let round = *equivocation_proof.round_number(); - let offender_id = equivocation_proof.offender_id().clone(); - let session_index = key_owner_proof.session(); - let validator_count = key_owner_proof.validator_count(); - - // validate the key ownership proof extracting the id of the offender. - let offender = T::KeyOwnerProofSystem::check_proof( - (sp_consensus_beefy::KEY_TYPE, offender_id), - key_owner_proof, - ) - .ok_or(Error::::InvalidKeyOwnershipProof)?; - - // validate equivocation proof (check votes are different and signatures are valid). - if !sp_consensus_beefy::check_equivocation_proof(&equivocation_proof) { - return Err(Error::::InvalidEquivocationProof.into()) - } - - // check that the session id for the membership proof is within the - // bounds of the set id reported in the equivocation. - let set_id_session_index = - Self::session_for_set(set_id).ok_or(Error::::InvalidEquivocationProof)?; - if session_index != set_id_session_index { - return Err(Error::::InvalidEquivocationProof.into()) - } - - // report to the offences module rewarding the sender. - T::HandleEquivocation::report_offence( - reporter.into_iter().collect(), - >::Offence::new( - session_index, - validator_count, - offender, - set_id, - round, - ), - ) - .map_err(|_| Error::::DuplicateOffenceReport)?; - - // waive the fee since the report is valid and beneficial - Ok(Pays::No.into()) - } } impl sp_runtime::BoundToRuntimeAppPublic for Pallet { diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 72e3f83dff91c..c92966235118e 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -116,19 +116,13 @@ parameter_types! { impl pallet_beefy::Config for Test { type BeefyId = BeefyId; - type KeyOwnerProofSystem = Historical; - type KeyOwnerProof = - >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; - type HandleEquivocation = - super::EquivocationHandler; type MaxAuthorities = ConstU32<100>; type MaxSetIdSessionEntries = MaxSetIdSessionEntries; type OnNewValidatorSet = (); type WeightInfo = (); + type KeyOwnerProof = >::Proof; + type EquivocationReportSystem = + super::EquivocationReportSystem; } parameter_types! { diff --git a/frame/grandpa/src/equivocation.rs b/frame/grandpa/src/equivocation.rs index 6fd12bbdfcdb9..44d0266375230 100644 --- a/frame/grandpa/src/equivocation.rs +++ b/frame/grandpa/src/equivocation.rs @@ -57,7 +57,7 @@ use super::{Call, Config, Error, Pallet, LOG_TARGET}; /// A round number and set id which point on the time of an offence. #[derive(Copy, Clone, PartialOrd, Ord, Eq, PartialEq, Encode, Decode)] -pub struct GrandpaTimeSlot { +pub struct TimeSlot { // The order of these matters for `derive(Ord)`. /// Grandpa Set ID. pub set_id: SetId, @@ -65,10 +65,10 @@ pub struct GrandpaTimeSlot { pub round: RoundNumber, } -/// A GRANDPA equivocation offence report. +/// GRANDPA equivocation offence report. pub struct EquivocationOffence { /// Time slot at which this incident happened. - pub time_slot: GrandpaTimeSlot, + pub time_slot: TimeSlot, /// The session index in which the incident happened. pub session_index: SessionIndex, /// The size of the validator set at the time of the offence. @@ -79,7 +79,7 @@ pub struct EquivocationOffence { impl Offence for EquivocationOffence { const ID: Kind = *b"grandpa:equivoca"; - type TimeSlot = GrandpaTimeSlot; + type TimeSlot = TimeSlot; fn offenders(&self) -> Vec { vec![self.offender.clone()] @@ -105,15 +105,16 @@ impl Offence for EquivocationOffence { } } -/// Generic equivocation handler. This type implements `HandleEquivocation` -/// using existing subsystems that are part of frame (type bounds described -/// below) and will dispatch to them directly, it's only purpose is to wire all -/// subsystems together. +/// GRANDPA equivocation offence report system. +/// +/// This type implements `OffenceReportSystem` such that: +/// - Equivocation reports are published on-chain as unsigned extrinsic via +/// `offchain::SendTransactioinsTypes`. +/// - On-chain validity checks and processing are mostly delegated to the user provided generic +/// types implementing `KeyOwnerProofSystem` and `ReportOffence` traits. +/// - Offence reporter for unsigned transactions is fetched via the the authorship pallet. pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, R, P, L)>); -// We use the authorship pallet to fetch the current block author and use -// `offchain::SendTransactionTypes` for unsigned extrinsic creation and -// submission. impl OffenceReportSystem< Option, @@ -144,7 +145,7 @@ where }; let res = SubmitTransaction::>::submit_unsigned_transaction(call.into()); match res { - Ok(()) => info!(target: LOG_TARGET, "Submitted equivocation report."), + Ok(_) => info!(target: LOG_TARGET, "Submitted equivocation report"), Err(e) => error!(target: LOG_TARGET, "Error submitting equivocation report: {:?}", e), } res @@ -160,10 +161,8 @@ where let offender = P::check_proof(key, key_owner_proof).ok_or(InvalidTransaction::BadProof)?; // Check if the offence has already been reported, and if so then we can discard the report. - let time_slot = GrandpaTimeSlot { - set_id: equivocation_proof.set_id(), - round: equivocation_proof.round(), - }; + let time_slot = + TimeSlot { set_id: equivocation_proof.set_id(), round: equivocation_proof.round() }; if R::is_known_offence(&[offender], &time_slot) { Err(InvalidTransaction::Stale.into()) } else { @@ -221,7 +220,7 @@ where } let offence = EquivocationOffence { - time_slot: GrandpaTimeSlot { set_id, round }, + time_slot: TimeSlot { set_id, round }, session_index, offender, validator_set_count, diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 2106860ea1441..538cd365b5a1a 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -63,7 +63,7 @@ mod mock; #[cfg(all(feature = "std", test))] mod tests; -pub use equivocation::{EquivocationOffence, EquivocationReportSystem, GrandpaTimeSlot}; +pub use equivocation::{EquivocationOffence, EquivocationReportSystem, TimeSlot}; pub use pallet::*; @@ -351,6 +351,7 @@ pub mod pallet { #[pallet::validate_unsigned] impl ValidateUnsigned for Pallet { type Call = Call; + fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity { Self::validate_unsigned(source, call) } diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 22ca9c624c626..4e4f2f79d040e 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -224,13 +224,10 @@ parameter_types! { impl Config for Test { type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); type MaxAuthorities = ConstU32<100>; type MaxSetIdSessionEntries = MaxSetIdSessionEntries; - type KeyOwnerProof = >::Proof; - type EquivocationReportSystem = super::EquivocationReportSystem; } diff --git a/frame/grandpa/src/tests.rs b/frame/grandpa/src/tests.rs index a956ca4bca6e9..16d89307bb71f 100644 --- a/frame/grandpa/src/tests.rs +++ b/frame/grandpa/src/tests.rs @@ -296,12 +296,12 @@ fn schedule_resume_only_when_paused() { #[test] fn time_slot_have_sane_ord() { // Ensure that `Ord` implementation is sane. - const FIXTURE: &[GrandpaTimeSlot] = &[ - GrandpaTimeSlot { set_id: 0, round: 0 }, - GrandpaTimeSlot { set_id: 0, round: 1 }, - GrandpaTimeSlot { set_id: 1, round: 0 }, - GrandpaTimeSlot { set_id: 1, round: 1 }, - GrandpaTimeSlot { set_id: 1, round: 2 }, + const FIXTURE: &[TimeSlot] = &[ + TimeSlot { set_id: 0, round: 0 }, + TimeSlot { set_id: 0, round: 1 }, + TimeSlot { set_id: 1, round: 0 }, + TimeSlot { set_id: 1, round: 1 }, + TimeSlot { set_id: 1, round: 2 }, ]; assert!(FIXTURE.windows(2).all(|f| f[0] < f[1])); } diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index 3db937bb378e5..0efbdcd48ecf3 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -38,7 +38,9 @@ use sp_staking::offence::{Offence, ReportOffence}; use pallet_babe::EquivocationOffence as BabeEquivocationOffence; use pallet_balances::Config as BalancesConfig; -use pallet_grandpa::{EquivocationOffence as GrandpaEquivocationOffence, GrandpaTimeSlot}; +use pallet_grandpa::{ + EquivocationOffence as GrandpaEquivocationOffence, TimeSlot as GrandpaTimeSlot, +}; use pallet_im_online::{Config as ImOnlineConfig, Pallet as ImOnline, UnresponsivenessOffence}; use pallet_offences::{Config as OffencesConfig, Pallet as Offences}; use pallet_session::{ From f5c2cecd7efe6dcbc828906794f3c4c41f23c791 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> Date: Mon, 13 Mar 2023 10:25:46 +0200 Subject: [PATCH 04/80] [NFTs] Rework permissions model (#13482) * Disallow admin to transfer or burn items he doesn't own * lock_collection should be accessible by collection's owner only * Allow admin to access lock_item_properties() * Fix do_lock_item_properties * Move update_mint_settings() to Issuer * Rename check_owner to check_origin * Typo * Make admin to be in charge of managing the metadata * Make admin the main attributes manager * offchain mint should be signed by Issuer * Remove the special case when the Issuer calls the mint() function * Rework burn and destroy methods * Return back item_metadatas * Don't repatriate the deposit on transfer * A bit more tests * One more test * Add migration * Chore * Clippy * Rename to owned_item * Address comments * Replace .filter_map with .find_map * Improve version validation in pre_upgrade() * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_nfts --------- Co-authored-by: parity-processbot <> --- frame/nfts/src/benchmarking.rs | 100 +- frame/nfts/src/features/approvals.rs | 12 +- frame/nfts/src/features/attributes.rs | 57 +- .../src/features/create_delete_collection.rs | 22 +- frame/nfts/src/features/create_delete_item.rs | 24 +- frame/nfts/src/features/lock.rs | 17 +- frame/nfts/src/features/metadata.rs | 66 +- frame/nfts/src/features/roles.rs | 15 + frame/nfts/src/features/settings.rs | 11 +- frame/nfts/src/features/transfer.rs | 10 - frame/nfts/src/lib.rs | 140 ++- frame/nfts/src/migration.rs | 117 ++ frame/nfts/src/tests.rs | 145 ++- frame/nfts/src/types.rs | 10 +- frame/nfts/src/weights.rs | 1028 ++++++++--------- 15 files changed, 970 insertions(+), 804 deletions(-) create mode 100644 frame/nfts/src/migration.rs diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index ae628fbefcce6..d4bbd809ce8be 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -72,6 +72,40 @@ fn add_collection_metadata, I: 'static>() -> (T::AccountId, Account fn mint_item, I: 'static>( index: u16, +) -> (T::ItemId, T::AccountId, AccountIdLookupOf) { + let item = T::Helper::item(index); + let collection = T::Helper::collection(0); + let caller = Collection::::get(collection).unwrap().owner; + if caller != whitelisted_caller() { + whitelist_account!(caller); + } + let caller_lookup = T::Lookup::unlookup(caller.clone()); + let item_exists = Item::::contains_key(&collection, &item); + let item_config = ItemConfigOf::::get(&collection, &item); + if item_exists { + return (item, caller, caller_lookup) + } else if let Some(item_config) = item_config { + assert_ok!(Nfts::::force_mint( + SystemOrigin::Signed(caller.clone()).into(), + collection, + item, + caller_lookup.clone(), + item_config, + )); + } else { + assert_ok!(Nfts::::mint( + SystemOrigin::Signed(caller.clone()).into(), + collection, + item, + caller_lookup.clone(), + None, + )); + } + (item, caller, caller_lookup) +} + +fn lock_item, I: 'static>( + index: u16, ) -> (T::ItemId, T::AccountId, AccountIdLookupOf) { let caller = Collection::::get(T::Helper::collection(0)).unwrap().owner; if caller != whitelisted_caller() { @@ -79,12 +113,27 @@ fn mint_item, I: 'static>( } let caller_lookup = T::Lookup::unlookup(caller.clone()); let item = T::Helper::item(index); - assert_ok!(Nfts::::mint( + assert_ok!(Nfts::::lock_item_transfer( + SystemOrigin::Signed(caller.clone()).into(), + T::Helper::collection(0), + item, + )); + (item, caller, caller_lookup) +} + +fn burn_item, I: 'static>( + index: u16, +) -> (T::ItemId, T::AccountId, AccountIdLookupOf) { + let caller = Collection::::get(T::Helper::collection(0)).unwrap().owner; + if caller != whitelisted_caller() { + whitelist_account!(caller); + } + let caller_lookup = T::Lookup::unlookup(caller.clone()); + let item = T::Helper::item(index); + assert_ok!(Nfts::::burn( SystemOrigin::Signed(caller.clone()).into(), T::Helper::collection(0), item, - caller_lookup.clone(), - None, )); (item, caller, caller_lookup) } @@ -126,6 +175,26 @@ fn add_item_attribute, I: 'static>( (key, caller, caller_lookup) } +fn add_collection_attribute, I: 'static>( + i: u16, +) -> (BoundedVec, T::AccountId, AccountIdLookupOf) { + let caller = Collection::::get(T::Helper::collection(0)).unwrap().owner; + if caller != whitelisted_caller() { + whitelist_account!(caller); + } + let caller_lookup = T::Lookup::unlookup(caller.clone()); + let key: BoundedVec<_, _> = make_filled_vec(i, T::KeyLimit::get() as usize).try_into().unwrap(); + assert_ok!(Nfts::::set_attribute( + SystemOrigin::Signed(caller.clone()).into(), + T::Helper::collection(0), + None, + AttributeNamespace::CollectionOwner, + key.clone(), + vec![0; T::ValueLimit::get() as usize].try_into().unwrap(), + )); + (key, caller, caller_lookup) +} + fn assert_last_event, I: 'static>(generic_event: >::RuntimeEvent) { let events = frame_system::Pallet::::events(); let system_event: ::RuntimeEvent = generic_event.into(); @@ -190,26 +259,25 @@ benchmarks_instance_pallet! { } destroy { - let n in 0 .. 1_000; let m in 0 .. 1_000; + let c in 0 .. 1_000; let a in 0 .. 1_000; let (collection, caller, _) = create_collection::(); add_collection_metadata::(); - for i in 0..n { - mint_item::(i as u16); - } for i in 0..m { - if !Item::::contains_key(collection, T::Helper::item(i as u16)) { - mint_item::(i as u16); - } + mint_item::(i as u16); add_item_metadata::(T::Helper::item(i as u16)); + lock_item::(i as u16); + burn_item::(i as u16); + } + for i in 0..c { + mint_item::(i as u16); + lock_item::(i as u16); + burn_item::(i as u16); } for i in 0..a { - if !Item::::contains_key(collection, T::Helper::item(i as u16)) { - mint_item::(i as u16); - } - add_item_attribute::(T::Helper::item(i as u16)); + add_collection_attribute::(i as u16); } let witness = Collection::::get(collection).unwrap().destroy_witness(); }: _(SystemOrigin::Signed(caller), collection, witness) @@ -234,9 +302,9 @@ benchmarks_instance_pallet! { } burn { - let (collection, caller, caller_lookup) = create_collection::(); + let (collection, caller, _) = create_collection::(); let (item, ..) = mint_item::(0); - }: _(SystemOrigin::Signed(caller.clone()), collection, item, Some(caller_lookup)) + }: _(SystemOrigin::Signed(caller.clone()), collection, item) verify { assert_last_event::(Event::Burned { collection, item, owner: caller }.into()); } diff --git a/frame/nfts/src/features/approvals.rs b/frame/nfts/src/features/approvals.rs index 408c441290fb4..634436a8562d8 100644 --- a/frame/nfts/src/features/approvals.rs +++ b/frame/nfts/src/features/approvals.rs @@ -40,9 +40,7 @@ impl, I: 'static> Pallet { ); if let Some(check_origin) = maybe_check_origin { - let is_admin = Self::has_role(&collection, &check_origin, CollectionRole::Admin); - let permitted = is_admin || check_origin == details.owner; - ensure!(permitted, Error::::NoPermission); + ensure!(check_origin == details.owner, Error::::NoPermission); } let now = frame_system::Pallet::::block_number(); @@ -85,9 +83,7 @@ impl, I: 'static> Pallet { if !is_past_deadline { if let Some(check_origin) = maybe_check_origin { - let is_admin = Self::has_role(&collection, &check_origin, CollectionRole::Admin); - let permitted = is_admin || check_origin == details.owner; - ensure!(permitted, Error::::NoPermission); + ensure!(check_origin == details.owner, Error::::NoPermission); } } @@ -113,9 +109,7 @@ impl, I: 'static> Pallet { Item::::get(&collection, &item).ok_or(Error::::UnknownCollection)?; if let Some(check_origin) = maybe_check_origin { - let is_admin = Self::has_role(&collection, &check_origin, CollectionRole::Admin); - let permitted = is_admin || check_origin == details.owner; - ensure!(permitted, Error::::NoPermission); + ensure!(check_origin == details.owner, Error::::NoPermission); } details.approvals.clear(); diff --git a/frame/nfts/src/features/attributes.rs b/frame/nfts/src/features/attributes.rs index fbd1c93247a52..9098679fa9145 100644 --- a/frame/nfts/src/features/attributes.rs +++ b/frame/nfts/src/features/attributes.rs @@ -33,17 +33,8 @@ impl, I: 'static> Pallet { Error::::MethodDisabled ); - let mut collection_details = - Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; - ensure!( - Self::is_valid_namespace( - &origin, - &namespace, - &collection, - &collection_details.owner, - &maybe_item, - )?, + Self::is_valid_namespace(&origin, &namespace, &collection, &maybe_item)?, Error::::NoPermission ); @@ -66,6 +57,9 @@ impl, I: 'static> Pallet { _ => (), } + let mut collection_details = + Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; + let attribute = Attribute::::get((collection, maybe_item, &namespace, &key)); let attribute_exists = attribute.is_some(); if !attribute_exists { @@ -219,7 +213,7 @@ impl, I: 'static> Pallet { } pub(crate) fn do_clear_attribute( - maybe_check_owner: Option, + maybe_check_origin: Option, collection: T::CollectionId, maybe_item: Option, namespace: AttributeNamespace, @@ -227,21 +221,13 @@ impl, I: 'static> Pallet { ) -> DispatchResult { let (_, deposit) = Attribute::::take((collection, maybe_item, &namespace, &key)) .ok_or(Error::::AttributeNotFound)?; - let mut collection_details = - Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; - if let Some(check_owner) = &maybe_check_owner { + if let Some(check_origin) = &maybe_check_origin { // validate the provided namespace when it's not a root call and the caller is not // the same as the `deposit.account` (e.g. the deposit was paid by different account) - if deposit.account != maybe_check_owner { + if deposit.account != maybe_check_origin { ensure!( - Self::is_valid_namespace( - &check_owner, - &namespace, - &collection, - &collection_details.owner, - &maybe_item, - )?, + Self::is_valid_namespace(&check_origin, &namespace, &collection, &maybe_item)?, Error::::NoPermission ); } @@ -264,17 +250,15 @@ impl, I: 'static> Pallet { .map_or(None, |c| { Some(c.has_disabled_setting(ItemSetting::UnlockedAttributes)) }); - match maybe_is_locked { - Some(is_locked) => { - // when item exists, then only the collection's owner can clear that - // attribute - ensure!( - check_owner == &collection_details.owner, - Error::::NoPermission - ); - ensure!(!is_locked, Error::::LockedItemAttributes); - }, - None => (), + if let Some(is_locked) = maybe_is_locked { + ensure!(!is_locked, Error::::LockedItemAttributes); + // Only the collection's admin can clear attributes in that namespace. + // e.g. in off-chain mints, the attribute's depositor will be the item's + // owner, that's why we need to do this extra check. + ensure!( + Self::has_role(&collection, &check_origin, CollectionRole::Admin), + Error::::NoPermission + ); } }, }, @@ -282,6 +266,9 @@ impl, I: 'static> Pallet { }; } + let mut collection_details = + Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; + collection_details.attributes.saturating_dec(); match deposit.account { @@ -372,12 +359,12 @@ impl, I: 'static> Pallet { origin: &T::AccountId, namespace: &AttributeNamespace, collection: &T::CollectionId, - collection_owner: &T::AccountId, maybe_item: &Option, ) -> Result { let mut result = false; match namespace { - AttributeNamespace::CollectionOwner => result = origin == collection_owner, + AttributeNamespace::CollectionOwner => + result = Self::has_role(&collection, &origin, CollectionRole::Admin), AttributeNamespace::ItemOwner => if let Some(item) = maybe_item { let item_details = diff --git a/frame/nfts/src/features/create_delete_collection.rs b/frame/nfts/src/features/create_delete_collection.rs index 8187fff7fca77..e9434760628ec 100644 --- a/frame/nfts/src/features/create_delete_collection.rs +++ b/frame/nfts/src/features/create_delete_collection.rs @@ -38,6 +38,7 @@ impl, I: 'static> Pallet { owner_deposit: deposit, items: 0, item_metadatas: 0, + item_configs: 0, attributes: 0, }, ); @@ -71,24 +72,23 @@ impl, I: 'static> Pallet { if let Some(check_owner) = maybe_check_owner { ensure!(collection_details.owner == check_owner, Error::::NoPermission); } - ensure!(collection_details.items == witness.items, Error::::BadWitness); + ensure!(collection_details.items == 0, Error::::CollectionNotEmpty); + ensure!(collection_details.attributes == witness.attributes, Error::::BadWitness); ensure!( collection_details.item_metadatas == witness.item_metadatas, Error::::BadWitness ); - ensure!(collection_details.attributes == witness.attributes, Error::::BadWitness); + ensure!( + collection_details.item_configs == witness.item_configs, + Error::::BadWitness + ); - for (item, details) in Item::::drain_prefix(&collection) { - Account::::remove((&details.owner, &collection, &item)); - T::Currency::unreserve(&details.deposit.account, details.deposit.amount); - } for (_, metadata) in ItemMetadataOf::::drain_prefix(&collection) { if let Some(depositor) = metadata.deposit.account { T::Currency::unreserve(&depositor, metadata.deposit.amount); } } - let _ = ItemPriceOf::::clear_prefix(&collection, witness.items, None); - let _ = PendingSwapOf::::clear_prefix(&collection, witness.items, None); + CollectionMetadataOf::::remove(&collection); Self::clear_roles(&collection)?; @@ -103,15 +103,13 @@ impl, I: 'static> Pallet { CollectionAccount::::remove(&collection_details.owner, &collection); T::Currency::unreserve(&collection_details.owner, collection_details.owner_deposit); CollectionConfigOf::::remove(&collection); - let _ = ItemConfigOf::::clear_prefix(&collection, witness.items, None); - let _ = - ItemAttributesApprovalsOf::::clear_prefix(&collection, witness.items, None); + let _ = ItemConfigOf::::clear_prefix(&collection, witness.item_configs, None); Self::deposit_event(Event::Destroyed { collection }); Ok(DestroyWitness { - items: collection_details.items, item_metadatas: collection_details.item_metadatas, + item_configs: collection_details.item_configs, attributes: collection_details.attributes, }) }) diff --git a/frame/nfts/src/features/create_delete_item.rs b/frame/nfts/src/features/create_delete_item.rs index 0319f2c8a0f18..cd96d28448055 100644 --- a/frame/nfts/src/features/create_delete_item.rs +++ b/frame/nfts/src/features/create_delete_item.rs @@ -66,6 +66,7 @@ impl, I: 'static> Pallet { ensure!(existing_config == item_config, Error::::InconsistentItemConfig); } else { ItemConfigOf::::insert(&collection, &item, item_config); + collection_details.item_configs.saturating_inc(); } T::Currency::reserve(&deposit_account, deposit_amount)?; @@ -107,7 +108,11 @@ impl, I: 'static> Pallet { let collection_details = Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; - ensure!(collection_details.owner == signer, Error::::NoPermission); + + ensure!( + Self::has_role(&collection, &signer, CollectionRole::Issuer), + Error::::NoPermission + ); let item_config = ItemConfig { settings: Self::get_default_item_settings(&collection)? }; Self::do_mint( @@ -118,9 +123,11 @@ impl, I: 'static> Pallet { item_config, |_, _| Ok(()), )?; + let origin = Self::find_account_by_role(&collection, CollectionRole::Admin) + .unwrap_or(collection_details.owner.clone()); for (key, value) in attributes { Self::do_set_attribute( - collection_details.owner.clone(), + origin.clone(), collection, Some(item), AttributeNamespace::CollectionOwner, @@ -131,7 +138,7 @@ impl, I: 'static> Pallet { } if !metadata.len().is_zero() { Self::do_set_item_metadata( - Some(collection_details.owner.clone()), + Some(origin.clone()), collection, item, metadata, @@ -148,6 +155,9 @@ impl, I: 'static> Pallet { ) -> DispatchResult { ensure!(!T::Locker::is_locked(collection, item), Error::::ItemLocked); let item_config = Self::get_item_config(&collection, &item)?; + // NOTE: if item's settings are not empty (e.g. item's metadata is locked) + // then we keep the config record and don't remove it + let remove_config = !item_config.has_disabled_settings(); let owner = Collection::::try_mutate( &collection, |maybe_collection_details| -> Result { @@ -161,6 +171,10 @@ impl, I: 'static> Pallet { T::Currency::unreserve(&details.deposit.account, details.deposit.amount); collection_details.items.saturating_dec(); + if remove_config { + collection_details.item_configs.saturating_dec(); + } + // Clear the metadata if it's not locked. if item_config.is_setting_enabled(ItemSetting::UnlockedMetadata) { if let Some(metadata) = ItemMetadataOf::::take(&collection, &item) { @@ -188,9 +202,7 @@ impl, I: 'static> Pallet { PendingSwapOf::::remove(&collection, &item); ItemAttributesApprovalsOf::::remove(&collection, &item); - // NOTE: if item's settings are not empty (e.g. item's metadata is locked) - // then we keep the record and don't remove it - if !item_config.has_disabled_settings() { + if remove_config { ItemConfigOf::::remove(&collection, &item); } diff --git a/frame/nfts/src/features/lock.rs b/frame/nfts/src/features/lock.rs index c28fdda983774..8b4914baeb450 100644 --- a/frame/nfts/src/features/lock.rs +++ b/frame/nfts/src/features/lock.rs @@ -24,10 +24,7 @@ impl, I: 'static> Pallet { collection: T::CollectionId, lock_settings: CollectionSettings, ) -> DispatchResult { - ensure!( - Self::has_role(&collection, &origin, CollectionRole::Freezer), - Error::::NoPermission - ); + ensure!(Self::collection_owner(collection) == Some(origin), Error::::NoPermission); ensure!( !lock_settings.is_disabled(CollectionSetting::DepositRequired), Error::::WrongSetting @@ -85,17 +82,17 @@ impl, I: 'static> Pallet { } pub(crate) fn do_lock_item_properties( - maybe_check_owner: Option, + maybe_check_origin: Option, collection: T::CollectionId, item: T::ItemId, lock_metadata: bool, lock_attributes: bool, ) -> DispatchResult { - let collection_details = - Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; - - if let Some(check_owner) = &maybe_check_owner { - ensure!(check_owner == &collection_details.owner, Error::::NoPermission); + if let Some(check_origin) = &maybe_check_origin { + ensure!( + Self::has_role(&collection, &check_origin, CollectionRole::Admin), + Error::::NoPermission + ); } ItemConfigOf::::try_mutate(collection, item, |maybe_config| { diff --git a/frame/nfts/src/features/metadata.rs b/frame/nfts/src/features/metadata.rs index 232262bdbb8fc..fde0296784d11 100644 --- a/frame/nfts/src/features/metadata.rs +++ b/frame/nfts/src/features/metadata.rs @@ -21,13 +21,20 @@ use frame_support::pallet_prelude::*; impl, I: 'static> Pallet { /// Note: if `maybe_depositor` is None, that means the depositor will be a collection's owner pub(crate) fn do_set_item_metadata( - maybe_check_owner: Option, + maybe_check_origin: Option, collection: T::CollectionId, item: T::ItemId, data: BoundedVec, maybe_depositor: Option, ) -> DispatchResult { - let is_root = maybe_check_owner.is_none(); + if let Some(check_origin) = &maybe_check_origin { + ensure!( + Self::has_role(&collection, &check_origin, CollectionRole::Admin), + Error::::NoPermission + ); + } + + let is_root = maybe_check_origin.is_none(); let mut collection_details = Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; @@ -37,10 +44,6 @@ impl, I: 'static> Pallet { Error::::LockedItemMetadata ); - if let Some(check_owner) = &maybe_check_owner { - ensure!(check_owner == &collection_details.owner, Error::::NoPermission); - } - let collection_config = Self::get_collection_config(&collection)?; ItemMetadataOf::::try_mutate_exists(collection, item, |metadata| { @@ -89,22 +92,26 @@ impl, I: 'static> Pallet { } pub(crate) fn do_clear_item_metadata( - maybe_check_owner: Option, + maybe_check_origin: Option, collection: T::CollectionId, item: T::ItemId, ) -> DispatchResult { - let is_root = maybe_check_owner.is_none(); + if let Some(check_origin) = &maybe_check_origin { + ensure!( + Self::has_role(&collection, &check_origin, CollectionRole::Admin), + Error::::NoPermission + ); + } + + let is_root = maybe_check_origin.is_none(); let metadata = ItemMetadataOf::::take(collection, item) .ok_or(Error::::MetadataNotFound)?; let mut collection_details = Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; + let depositor_account = metadata.deposit.account.unwrap_or(collection_details.owner.clone()); - if let Some(check_owner) = &maybe_check_owner { - ensure!(check_owner == &collection_details.owner, Error::::NoPermission); - } - // NOTE: if the item was previously burned, the ItemConfigOf record might not exist let is_locked = Self::get_item_config(&collection, &item) .map_or(false, |c| c.has_disabled_setting(ItemSetting::UnlockedMetadata)); @@ -125,29 +132,32 @@ impl, I: 'static> Pallet { } pub(crate) fn do_set_collection_metadata( - maybe_check_owner: Option, + maybe_check_origin: Option, collection: T::CollectionId, data: BoundedVec, ) -> DispatchResult { + if let Some(check_origin) = &maybe_check_origin { + ensure!( + Self::has_role(&collection, &check_origin, CollectionRole::Admin), + Error::::NoPermission + ); + } + + let is_root = maybe_check_origin.is_none(); let collection_config = Self::get_collection_config(&collection)?; ensure!( - maybe_check_owner.is_none() || - collection_config.is_setting_enabled(CollectionSetting::UnlockedMetadata), + is_root || collection_config.is_setting_enabled(CollectionSetting::UnlockedMetadata), Error::::LockedCollectionMetadata ); let mut details = Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; - if let Some(check_owner) = &maybe_check_owner { - ensure!(check_owner == &details.owner, Error::::NoPermission); - } CollectionMetadataOf::::try_mutate_exists(collection, |metadata| { let old_deposit = metadata.take().map_or(Zero::zero(), |m| m.deposit); details.owner_deposit.saturating_reduce(old_deposit); let mut deposit = Zero::zero(); - if maybe_check_owner.is_some() && - collection_config.is_setting_enabled(CollectionSetting::DepositRequired) + if !is_root && collection_config.is_setting_enabled(CollectionSetting::DepositRequired) { deposit = T::DepositPerByte::get() .saturating_mul(((data.len()) as u32).into()) @@ -170,18 +180,22 @@ impl, I: 'static> Pallet { } pub(crate) fn do_clear_collection_metadata( - maybe_check_owner: Option, + maybe_check_origin: Option, collection: T::CollectionId, ) -> DispatchResult { - let details = - Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; - if let Some(check_owner) = &maybe_check_owner { - ensure!(check_owner == &details.owner, Error::::NoPermission); + if let Some(check_origin) = &maybe_check_origin { + ensure!( + Self::has_role(&collection, &check_origin, CollectionRole::Admin), + Error::::NoPermission + ); } + let details = + Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; let collection_config = Self::get_collection_config(&collection)?; + ensure!( - maybe_check_owner.is_none() || + maybe_check_origin.is_none() || collection_config.is_setting_enabled(CollectionSetting::UnlockedMetadata), Error::::LockedCollectionMetadata ); diff --git a/frame/nfts/src/features/roles.rs b/frame/nfts/src/features/roles.rs index f3fa277b15617..f91f3ecb6f348 100644 --- a/frame/nfts/src/features/roles.rs +++ b/frame/nfts/src/features/roles.rs @@ -82,6 +82,21 @@ impl, I: 'static> Pallet { .map_or(false, |roles| roles.has_role(role)) } + /// Finds the account by a provided role within a collection. + /// + /// - `collection_id`: A collection to check the role in. + /// - `role`: A role to find the account for. + /// + /// Returns `Some(T::AccountId)` if the record was found, `None` otherwise. + pub(crate) fn find_account_by_role( + collection_id: &T::CollectionId, + role: CollectionRole, + ) -> Option { + CollectionRoleOf::::iter_prefix(&collection_id).into_iter().find_map( + |(account, roles)| if roles.has_role(role) { Some(account.clone()) } else { None }, + ) + } + /// Groups provided roles by account, given one account could have multiple roles. /// /// - `input`: A vector of (Account, Role) tuples. diff --git a/frame/nfts/src/features/settings.rs b/frame/nfts/src/features/settings.rs index 91bff9dc683f8..080d7b97f13b1 100644 --- a/frame/nfts/src/features/settings.rs +++ b/frame/nfts/src/features/settings.rs @@ -57,7 +57,7 @@ impl, I: 'static> Pallet { } pub(crate) fn do_update_mint_settings( - maybe_check_owner: Option, + maybe_check_origin: Option, collection: T::CollectionId, mint_settings: MintSettings< BalanceOf, @@ -65,10 +65,11 @@ impl, I: 'static> Pallet { T::CollectionId, >, ) -> DispatchResult { - let details = - Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; - if let Some(check_owner) = &maybe_check_owner { - ensure!(check_owner == &details.owner, Error::::NoPermission); + if let Some(check_origin) = &maybe_check_origin { + ensure!( + Self::has_role(&collection, &check_origin, CollectionRole::Issuer), + Error::::NoPermission + ); } CollectionConfigOf::::try_mutate(collection, |maybe_config| { diff --git a/frame/nfts/src/features/transfer.rs b/frame/nfts/src/features/transfer.rs index 998df81cd1fe1..00b5d4e76882a 100644 --- a/frame/nfts/src/features/transfer.rs +++ b/frame/nfts/src/features/transfer.rs @@ -48,16 +48,6 @@ impl, I: 'static> Pallet { Item::::get(&collection, &item).ok_or(Error::::UnknownItem)?; with_details(&collection_details, &mut details)?; - if details.deposit.account == details.owner { - // Move the deposit to the new owner. - T::Currency::repatriate_reserved( - &details.owner, - &dest, - details.deposit.amount, - Reserved, - )?; - } - Account::::remove((&details.owner, &collection, &item)); Account::::insert((&dest, &collection, &item), ()); let origin = details.owner; diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 2d19cf0455ad4..4d9547659a2a7 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -30,6 +30,7 @@ #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +pub mod migration; #[cfg(test)] pub mod mock; #[cfg(test)] @@ -58,6 +59,9 @@ pub use pallet::*; pub use types::*; pub use weights::WeightInfo; +/// The log target of this pallet. +pub const LOG_TARGET: &'static str = "runtime::nfts"; + type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; #[frame_support::pallet] @@ -67,9 +71,13 @@ pub mod pallet { use frame_system::pallet_prelude::*; use sp_runtime::traits::{IdentifyAccount, Verify}; + /// The current storage version. + const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] - pub struct Pallet(_); + #[pallet::storage_version(STORAGE_VERSION)] + pub struct Pallet(PhantomData<(T, I)>); #[cfg(feature = "runtime-benchmarks")] pub trait BenchmarkHelper { @@ -628,6 +636,8 @@ pub mod pallet { MaxAttributesLimitReached, /// The provided namespace isn't supported in this call. WrongNamespace, + /// Can't delete non-empty collections. + CollectionNotEmpty, } #[pallet::call] @@ -719,20 +729,22 @@ pub mod pallet { /// The origin must conform to `ForceOrigin` or must be `Signed` and the sender must be the /// owner of the `collection`. /// + /// NOTE: The collection must have 0 items to be destroyed. + /// /// - `collection`: The identifier of the collection to be destroyed. /// - `witness`: Information on the items minted in the collection. This must be /// correct. /// /// Emits `Destroyed` event when successful. /// - /// Weight: `O(n + m)` where: - /// - `n = witness.items` + /// Weight: `O(m + c + a)` where: /// - `m = witness.item_metadatas` + /// - `c = witness.item_configs` /// - `a = witness.attributes` #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::destroy( - witness.items, - witness.item_metadatas, + witness.item_metadatas, + witness.item_configs, witness.attributes, ))] pub fn destroy( @@ -746,8 +758,8 @@ pub mod pallet { let details = Self::do_destroy_collection(collection, witness, maybe_check_owner)?; Ok(Some(T::WeightInfo::destroy( - details.items, details.item_metadatas, + details.item_configs, details.attributes, )) .into()) @@ -755,7 +767,7 @@ pub mod pallet { /// Mint an item of a particular collection. /// - /// The origin must be Signed and the sender must be the Issuer of the `collection`. + /// The origin must be Signed and the sender must comply with the `mint_settings` rules. /// /// - `collection`: The collection of the item to be minted. /// - `item`: An identifier of the new item. @@ -789,11 +801,6 @@ pub mod pallet { mint_to.clone(), item_config, |collection_details, collection_config| { - // Issuer can mint regardless of mint settings - if Self::has_role(&collection, &caller, CollectionRole::Issuer) { - return Ok(()) - } - let mint_settings = collection_config.mint_settings; let now = frame_system::Pallet::::block_number(); @@ -805,7 +812,12 @@ pub mod pallet { } match mint_settings.mint_type { - MintType::Issuer => return Err(Error::::NoPermission.into()), + MintType::Issuer => { + ensure!( + Self::has_role(&collection, &caller, CollectionRole::Issuer), + Error::::NoPermission + ); + }, MintType::HolderOf(collection_id) => { let MintWitness { owned_item } = witness_data.ok_or(Error::::BadWitness)?; @@ -899,38 +911,30 @@ pub mod pallet { /// Destroy a single item. /// - /// Origin must be Signed and the signing account must be either: - /// - the Admin of the `collection`; - /// - the Owner of the `item`; + /// The origin must conform to `ForceOrigin` or must be Signed and the signing account must + /// be the owner of the `item`. /// /// - `collection`: The collection of the item to be burned. /// - `item`: The item to be burned. - /// - `check_owner`: If `Some` then the operation will fail with `WrongOwner` unless the - /// item is owned by this value. /// - /// Emits `Burned` with the actual amount burned. + /// Emits `Burned`. /// /// Weight: `O(1)` - /// Modes: `check_owner.is_some()`. #[pallet::call_index(5)] #[pallet::weight(T::WeightInfo::burn())] pub fn burn( origin: OriginFor, collection: T::CollectionId, item: T::ItemId, - check_owner: Option>, ) -> DispatchResult { - let origin = ensure_signed(origin)?; - let check_owner = check_owner.map(T::Lookup::lookup).transpose()?; + let maybe_check_origin = T::ForceOrigin::try_origin(origin) + .map(|_| None) + .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; Self::do_burn(collection, item, |details| { - let is_admin = Self::has_role(&collection, &origin, CollectionRole::Admin); - let is_permitted = is_admin || details.owner == origin; - ensure!(is_permitted, Error::::NoPermission); - ensure!( - check_owner.map_or(true, |o| o == details.owner), - Error::::WrongOwner - ); + if let Some(check_origin) = maybe_check_origin { + ensure!(details.owner == check_origin, Error::::NoPermission); + } Ok(()) }) } @@ -938,7 +942,6 @@ pub mod pallet { /// Move an item from the sender account to another. /// /// Origin must be Signed and the signing account must be either: - /// - the Admin of the `collection`; /// - the Owner of the `item`; /// - the approved delegate for the `item` (in this case, the approval is reset). /// @@ -962,8 +965,7 @@ pub mod pallet { let dest = T::Lookup::lookup(dest)?; Self::do_transfer(collection, item, dest, |_, details| { - let is_admin = Self::has_role(&collection, &origin, CollectionRole::Admin); - if details.owner != origin && !is_admin { + if details.owner != origin { let deadline = details.approvals.get(&origin).ok_or(Error::::NoPermission)?; if let Some(d) = deadline { @@ -1086,12 +1088,13 @@ pub mod pallet { /// Disallows specified settings for the whole collection. /// - /// Origin must be Signed and the sender should be the Freezer of the `collection`. + /// Origin must be Signed and the sender should be the Owner of the `collection`. /// /// - `collection`: The collection to be locked. /// - `lock_settings`: The settings to be locked. /// /// Note: it's possible to only lock(set) the setting, but not to unset it. + /// /// Emits `CollectionLocked`. /// /// Weight: `O(1)` @@ -1243,7 +1246,6 @@ pub mod pallet { /// /// Origin must be either: /// - the `Force` origin; - /// - `Signed` with the signer being the Admin of the `collection`; /// - `Signed` with the signer being the Owner of the `item`; /// /// Arguments: @@ -1273,7 +1275,6 @@ pub mod pallet { /// /// Origin must be either: /// - the `Force` origin; - /// - `Signed` with the signer being the Admin of the `collection`; /// - `Signed` with the signer being the Owner of the `item`; /// /// Arguments: @@ -1298,8 +1299,8 @@ pub mod pallet { /// Disallows changing the metadata or attributes of the item. /// - /// Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the - /// `collection`. + /// Origin must be either `ForceOrigin` or Signed and the sender should be the Admin + /// of the `collection`. /// /// - `collection`: The collection if the `item`. /// - `item`: An item to be locked. @@ -1307,8 +1308,8 @@ pub mod pallet { /// - `lock_attributes`: Specifies whether the attributes in the `CollectionOwner` namespace /// should be locked. /// - /// Note: `lock_attributes` affects the attributes in the `CollectionOwner` namespace - /// only. When the metadata or attributes are locked, it won't be possible the unlock them. + /// Note: `lock_attributes` affects the attributes in the `CollectionOwner` namespace only. + /// When the metadata or attributes are locked, it won't be possible the unlock them. /// /// Emits `ItemPropertiesLocked`. /// @@ -1322,11 +1323,11 @@ pub mod pallet { lock_metadata: bool, lock_attributes: bool, ) -> DispatchResult { - let maybe_check_owner = T::ForceOrigin::try_origin(origin) + let maybe_check_origin = T::ForceOrigin::try_origin(origin) .map(|_| None) .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; Self::do_lock_item_properties( - maybe_check_owner, + maybe_check_origin, collection, item, lock_metadata, @@ -1337,7 +1338,7 @@ pub mod pallet { /// Set an attribute for a collection or item. /// /// Origin must be Signed and must conform to the namespace ruleset: - /// - `CollectionOwner` namespace could be modified by the `collection` owner only; + /// - `CollectionOwner` namespace could be modified by the `collection` Admin only; /// - `ItemOwner` namespace could be modified by the `maybe_item` owner only. `maybe_item` /// should be set in that case; /// - `Account(AccountId)` namespace could be modified only when the `origin` was given a @@ -1367,15 +1368,12 @@ pub mod pallet { value: BoundedVec, ) -> DispatchResult { let origin = ensure_signed(origin)?; - Self::do_set_attribute( - origin.clone(), - collection, - maybe_item, - namespace, - key, - value, - origin, - ) + let depositor = match namespace { + AttributeNamespace::CollectionOwner => + Self::collection_owner(collection).ok_or(Error::::UnknownCollection)?, + _ => origin.clone(), + }; + Self::do_set_attribute(origin, collection, maybe_item, namespace, key, value, depositor) } /// Force-set an attribute for a collection or item. @@ -1490,7 +1488,7 @@ pub mod pallet { /// Set the metadata for an item. /// - /// Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the + /// Origin must be either `ForceOrigin` or Signed and the sender should be the Admin of the /// `collection`. /// /// If the origin is Signed, then funds of signer are reserved according to the formula: @@ -1512,15 +1510,15 @@ pub mod pallet { item: T::ItemId, data: BoundedVec, ) -> DispatchResult { - let maybe_check_owner = T::ForceOrigin::try_origin(origin) + let maybe_check_origin = T::ForceOrigin::try_origin(origin) .map(|_| None) .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; - Self::do_set_item_metadata(maybe_check_owner, collection, item, data, None) + Self::do_set_item_metadata(maybe_check_origin, collection, item, data, None) } /// Clear the metadata for an item. /// - /// Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the + /// Origin must be either `ForceOrigin` or Signed and the sender should be the Admin of the /// `collection`. /// /// Any deposit is freed for the collection's owner. @@ -1538,15 +1536,15 @@ pub mod pallet { collection: T::CollectionId, item: T::ItemId, ) -> DispatchResult { - let maybe_check_owner = T::ForceOrigin::try_origin(origin) + let maybe_check_origin = T::ForceOrigin::try_origin(origin) .map(|_| None) .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; - Self::do_clear_item_metadata(maybe_check_owner, collection, item) + Self::do_clear_item_metadata(maybe_check_origin, collection, item) } /// Set the metadata for a collection. /// - /// Origin must be either `ForceOrigin` or `Signed` and the sender should be the Owner of + /// Origin must be either `ForceOrigin` or `Signed` and the sender should be the Admin of /// the `collection`. /// /// If the origin is `Signed`, then funds of signer are reserved according to the formula: @@ -1566,15 +1564,15 @@ pub mod pallet { collection: T::CollectionId, data: BoundedVec, ) -> DispatchResult { - let maybe_check_owner = T::ForceOrigin::try_origin(origin) + let maybe_check_origin = T::ForceOrigin::try_origin(origin) .map(|_| None) .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; - Self::do_set_collection_metadata(maybe_check_owner, collection, data) + Self::do_set_collection_metadata(maybe_check_origin, collection, data) } /// Clear the metadata for a collection. /// - /// Origin must be either `ForceOrigin` or `Signed` and the sender should be the Owner of + /// Origin must be either `ForceOrigin` or `Signed` and the sender should be the Admin of /// the `collection`. /// /// Any deposit is freed for the collection's owner. @@ -1590,10 +1588,10 @@ pub mod pallet { origin: OriginFor, collection: T::CollectionId, ) -> DispatchResult { - let maybe_check_owner = T::ForceOrigin::try_origin(origin) + let maybe_check_origin = T::ForceOrigin::try_origin(origin) .map(|_| None) .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; - Self::do_clear_collection_metadata(maybe_check_owner, collection) + Self::do_clear_collection_metadata(maybe_check_origin, collection) } /// Set (or reset) the acceptance of ownership for a particular account. @@ -1640,8 +1638,8 @@ pub mod pallet { /// Update mint settings. /// - /// Origin must be either `ForceOrigin` or `Signed` and the sender should be the Owner of - /// the `collection`. + /// Origin must be either `ForceOrigin` or `Signed` and the sender should be the Issuer + /// of the `collection`. /// /// - `collection`: The identifier of the collection to change. /// - `mint_settings`: The new mint settings. @@ -1658,15 +1656,15 @@ pub mod pallet { T::CollectionId, >, ) -> DispatchResult { - let maybe_check_owner = T::ForceOrigin::try_origin(origin) + let maybe_check_origin = T::ForceOrigin::try_origin(origin) .map(|_| None) .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; - Self::do_update_mint_settings(maybe_check_owner, collection, mint_settings) + Self::do_update_mint_settings(maybe_check_origin, collection, mint_settings) } /// Set (or reset) the price for an item. /// - /// Origin must be Signed and must be the owner of the asset `item`. + /// Origin must be Signed and must be the owner of the `item`. /// /// - `collection`: The collection of the item. /// - `item`: The item to set the price for. @@ -1827,7 +1825,7 @@ pub mod pallet { /// its metadata, attributes, who can mint it (`None` for anyone) and until what block /// number. /// - `signature`: The signature of the `data` object. - /// - `signer`: The `data` object's signer. Should be an owner of the collection. + /// - `signer`: The `data` object's signer. Should be an Issuer of the collection. /// /// Emits `Issued` on success. /// Emits `AttributeSet` if the attributes were provided. @@ -1853,7 +1851,7 @@ pub mod pallet { /// - `data`: The pre-signed approval that consists of the information about the item, /// attributes to update and until what block number. /// - `signature`: The signature of the `data` object. - /// - `signer`: The `data` object's signer. Should be an owner of the collection for the + /// - `signer`: The `data` object's signer. Should be an Admin of the collection for the /// `CollectionOwner` namespace. /// /// Emits `AttributeSet` for each provided attribute. diff --git a/frame/nfts/src/migration.rs b/frame/nfts/src/migration.rs new file mode 100644 index 0000000000000..33ee87e4b9284 --- /dev/null +++ b/frame/nfts/src/migration.rs @@ -0,0 +1,117 @@ +// 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 super::*; +use frame_support::{log, traits::OnRuntimeUpgrade}; + +pub mod v1 { + use frame_support::{pallet_prelude::*, weights::Weight}; + + use super::*; + + #[derive(Decode)] + pub struct OldCollectionDetails { + pub owner: AccountId, + pub owner_deposit: DepositBalance, + pub items: u32, + pub item_metadatas: u32, + pub attributes: u32, + } + + impl OldCollectionDetails { + fn migrate_to_v1(self, item_configs: u32) -> CollectionDetails { + CollectionDetails { + owner: self.owner, + owner_deposit: self.owner_deposit, + items: self.items, + item_metadatas: self.item_metadatas, + item_configs, + attributes: self.attributes, + } + } + } + + pub struct MigrateToV1(sp_std::marker::PhantomData); + impl OnRuntimeUpgrade for MigrateToV1 { + fn on_runtime_upgrade() -> Weight { + let current_version = Pallet::::current_storage_version(); + let onchain_version = Pallet::::on_chain_storage_version(); + + log::info!( + target: LOG_TARGET, + "Running migration with current storage version {:?} / onchain {:?}", + current_version, + onchain_version + ); + + if onchain_version == 0 && current_version == 1 { + let mut translated = 0u64; + let mut configs_iterated = 0u64; + Collection::::translate::< + OldCollectionDetails>, + _, + >(|key, old_value| { + let item_configs = ItemConfigOf::::iter_prefix(&key).count() as u32; + configs_iterated += item_configs as u64; + translated.saturating_inc(); + Some(old_value.migrate_to_v1(item_configs)) + }); + + current_version.put::>(); + + log::info!( + target: LOG_TARGET, + "Upgraded {} records, storage to version {:?}", + translated, + current_version + ); + T::DbWeight::get().reads_writes(translated + configs_iterated + 1, translated + 1) + } else { + log::info!( + target: LOG_TARGET, + "Migration did not execute. This probably should be removed" + ); + T::DbWeight::get().reads(1) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + let current_version = Pallet::::current_storage_version(); + let onchain_version = Pallet::::on_chain_storage_version(); + ensure!(onchain_version == 0 && current_version == 1, "migration from version 0 to 1."); + let prev_count = Collection::::iter().count(); + Ok((prev_count as u32).encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(prev_count: Vec) -> Result<(), &'static str> { + let prev_count: u32 = Decode::decode(&mut prev_count.as_slice()).expect( + "the state parameter should be something that was generated by pre_upgrade", + ); + let post_count = Collection::::iter().count() as u32; + assert_eq!( + prev_count, post_count, + "the records count before and after the migration should be the same" + ); + + ensure!(Pallet::::on_chain_storage_version() == 1, "wrong storage version"); + + Ok(()) + } + } +} diff --git a/frame/nfts/src/tests.rs b/frame/nfts/src/tests.rs index e44e4151f84a0..694468aceebe5 100644 --- a/frame/nfts/src/tests.rs +++ b/frame/nfts/src/tests.rs @@ -215,21 +215,44 @@ fn lifecycle_should_work() { assert_eq!(items(), vec![(account(1), 0, 70), (account(10), 0, 42), (account(20), 0, 69)]); assert_eq!(Collection::::get(0).unwrap().items, 3); assert_eq!(Collection::::get(0).unwrap().item_metadatas, 0); + assert_eq!(Collection::::get(0).unwrap().item_configs, 3); - assert_eq!(Balances::reserved_balance(&account(2)), 0); + assert_eq!(Balances::reserved_balance(&account(1)), 8); assert_ok!(Nfts::transfer(RuntimeOrigin::signed(account(1)), 0, 70, account(2))); - assert_eq!(Balances::reserved_balance(&account(2)), 1); + assert_eq!(Balances::reserved_balance(&account(1)), 8); + assert_eq!(Balances::reserved_balance(&account(2)), 0); assert_ok!(Nfts::set_metadata(RuntimeOrigin::signed(account(1)), 0, 42, bvec![42, 42])); - assert_eq!(Balances::reserved_balance(&account(1)), 10); + assert_eq!(Balances::reserved_balance(&account(1)), 11); assert!(ItemMetadataOf::::contains_key(0, 42)); assert_ok!(Nfts::set_metadata(RuntimeOrigin::signed(account(1)), 0, 69, bvec![69, 69])); - assert_eq!(Balances::reserved_balance(&account(1)), 13); + assert_eq!(Balances::reserved_balance(&account(1)), 14); assert!(ItemMetadataOf::::contains_key(0, 69)); - + assert!(ItemConfigOf::::contains_key(0, 69)); let w = Nfts::get_destroy_witness(&0).unwrap(); - assert_eq!(w.items, 3); assert_eq!(w.item_metadatas, 2); + assert_eq!(w.item_configs, 3); + assert_noop!( + Nfts::destroy(RuntimeOrigin::signed(account(1)), 0, w), + Error::::CollectionNotEmpty + ); + + assert_ok!(Nfts::set_attribute( + RuntimeOrigin::signed(account(1)), + 0, + Some(69), + AttributeNamespace::CollectionOwner, + bvec![0], + bvec![0], + )); + assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(10)), 0, 42)); + assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(20)), 0, 69)); + assert_ok!(Nfts::burn(RuntimeOrigin::root(), 0, 70)); + + let w = Nfts::get_destroy_witness(&0).unwrap(); + assert_eq!(w.attributes, 1); + assert_eq!(w.item_metadatas, 0); + assert_eq!(w.item_configs, 0); assert_ok!(Nfts::destroy(RuntimeOrigin::signed(account(1)), 0, w)); assert_eq!(Balances::reserved_balance(&account(1)), 0); @@ -240,6 +263,8 @@ fn lifecycle_should_work() { assert!(!CollectionMetadataOf::::contains_key(0)); assert!(!ItemMetadataOf::::contains_key(0, 42)); assert!(!ItemMetadataOf::::contains_key(0, 69)); + assert!(!ItemConfigOf::::contains_key(0, 69)); + assert_eq!(attributes(0), vec![]); assert_eq!(collections(), vec![]); assert_eq!(items(), vec![]); }); @@ -256,14 +281,51 @@ fn destroy_with_bad_witness_should_not_work() { )); let w = Collection::::get(0).unwrap().destroy_witness(); - assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(1)), 0, 42, account(1), None)); assert_noop!( - Nfts::destroy(RuntimeOrigin::signed(account(1)), 0, w), + Nfts::destroy( + RuntimeOrigin::signed(account(1)), + 0, + DestroyWitness { item_configs: 1, ..w } + ), Error::::BadWitness ); }); } +#[test] +fn destroy_should_work() { + new_test_ext().execute_with(|| { + Balances::make_free_balance_be(&account(1), 100); + assert_ok!(Nfts::create( + RuntimeOrigin::signed(account(1)), + account(1), + collection_config_with_all_settings_enabled() + )); + + assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(1)), 0, 42, account(2), None)); + assert_noop!( + Nfts::destroy( + RuntimeOrigin::signed(account(1)), + 0, + Nfts::get_destroy_witness(&0).unwrap() + ), + Error::::CollectionNotEmpty + ); + assert_ok!(Nfts::lock_item_transfer(RuntimeOrigin::signed(account(1)), 0, 42)); + assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(2)), 0, 42)); + assert_eq!(Collection::::get(0).unwrap().item_configs, 1); + assert_eq!(ItemConfigOf::::iter_prefix(0).count() as u32, 1); + assert!(ItemConfigOf::::contains_key(0, 42)); + assert_ok!(Nfts::destroy( + RuntimeOrigin::signed(account(1)), + 0, + Nfts::get_destroy_witness(&0).unwrap() + )); + assert!(!ItemConfigOf::::contains_key(0, 42)); + assert_eq!(ItemConfigOf::::iter_prefix(0).count() as u32, 0); + }); +} + #[test] fn mint_should_work() { new_test_ext().execute_with(|| { @@ -491,8 +553,9 @@ fn origin_guards_should_work() { Nfts::mint(RuntimeOrigin::signed(account(2)), 0, 69, account(2), None), Error::::NoPermission ); + assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(1)), 0, 43, account(2), None)); assert_noop!( - Nfts::burn(RuntimeOrigin::signed(account(2)), 0, 42, None), + Nfts::burn(RuntimeOrigin::signed(account(1)), 0, 43), Error::::NoPermission ); let w = Nfts::get_destroy_witness(&0).unwrap(); @@ -536,13 +599,13 @@ fn transfer_owner_should_work() { // Mint and set metadata now and make sure that deposit gets transferred back. assert_ok!(Nfts::set_collection_metadata( - RuntimeOrigin::signed(account(2)), + RuntimeOrigin::signed(account(1)), 0, bvec![0u8; 20], )); assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(1)), 0, 42, account(1), None)); assert_eq!(Balances::reserved_balance(&account(1)), 1); - assert_ok!(Nfts::set_metadata(RuntimeOrigin::signed(account(2)), 0, 42, bvec![0u8; 20])); + assert_ok!(Nfts::set_metadata(RuntimeOrigin::signed(account(1)), 0, 42, bvec![0u8; 20])); assert_ok!(Nfts::set_accept_ownership(RuntimeOrigin::signed(account(3)), Some(0))); assert_ok!(Nfts::transfer_ownership(RuntimeOrigin::signed(account(2)), 0, account(3))); assert_eq!(collections(), vec![(account(3), 0)]); @@ -552,8 +615,9 @@ fn transfer_owner_should_work() { assert_eq!(Balances::reserved_balance(&account(3)), 44); assert_ok!(Nfts::transfer(RuntimeOrigin::signed(account(1)), 0, 42, account(2))); - assert_eq!(Balances::reserved_balance(&account(1)), 0); - assert_eq!(Balances::reserved_balance(&account(2)), 1); + // reserved_balance of accounts 1 & 2 should be unchanged: + assert_eq!(Balances::reserved_balance(&account(1)), 1); + assert_eq!(Balances::reserved_balance(&account(2)), 0); // 2's acceptance from before is reset when it became an owner, so it cannot be transferred // without a fresh acceptance. @@ -583,8 +647,14 @@ fn set_team_should_work() { assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(2)), 0, 42, account(2), None)); assert_ok!(Nfts::lock_item_transfer(RuntimeOrigin::signed(account(4)), 0, 42)); assert_ok!(Nfts::unlock_item_transfer(RuntimeOrigin::signed(account(4)), 0, 42)); - assert_ok!(Nfts::transfer(RuntimeOrigin::signed(account(3)), 0, 42, account(3))); - assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(3)), 0, 42, None)); + assert_noop!( + Nfts::transfer(RuntimeOrigin::signed(account(3)), 0, 42, account(3)), + Error::::NoPermission + ); + assert_noop!( + Nfts::burn(RuntimeOrigin::signed(account(3)), 0, 42), + Error::::NoPermission + ); }); } @@ -594,7 +664,7 @@ fn set_collection_metadata_should_work() { // Cannot add metadata to unknown item assert_noop!( Nfts::set_collection_metadata(RuntimeOrigin::signed(account(1)), 0, bvec![0u8; 20]), - Error::::NoConfig, + Error::::NoPermission, ); assert_ok!(Nfts::force_create( RuntimeOrigin::root(), @@ -668,7 +738,7 @@ fn set_collection_metadata_should_work() { ); assert_noop!( Nfts::clear_collection_metadata(RuntimeOrigin::signed(account(1)), 1), - Error::::UnknownCollection + Error::::NoPermission ); assert_noop!( Nfts::clear_collection_metadata(RuntimeOrigin::signed(account(1)), 0), @@ -743,7 +813,7 @@ fn set_item_metadata_should_work() { ); assert_noop!( Nfts::clear_metadata(RuntimeOrigin::signed(account(1)), 1, 42), - Error::::MetadataNotFound, + Error::::NoPermission, ); assert_ok!(Nfts::clear_metadata(RuntimeOrigin::root(), 0, 42)); assert!(!ItemMetadataOf::::contains_key(0, 42)); @@ -832,6 +902,7 @@ fn set_collection_owner_attributes_should_work() { ); assert_eq!(Balances::reserved_balance(account(1)), 16); + assert_ok!(Nfts::burn(RuntimeOrigin::root(), 0, 0)); let w = Nfts::get_destroy_witness(&0).unwrap(); assert_ok!(Nfts::destroy(RuntimeOrigin::signed(account(1)), 0, w)); assert_eq!(attributes(0), vec![]); @@ -997,7 +1068,7 @@ fn set_item_owner_attributes_should_work() { assert_eq!(Balances::reserved_balance(account(3)), 13); // validate attributes on item deletion - assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(3)), 0, 0, None)); + assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(3)), 0, 0)); assert_eq!( attributes(0), vec![ @@ -1317,7 +1388,7 @@ fn preserve_config_for_frozen_items() { assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(1)), 0, 1, account(1), None)); // if the item is not locked/frozen then the config gets deleted on item burn - assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(1)), 0, 1, Some(account(1)))); + assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(1)), 0, 1)); assert!(!ItemConfigOf::::contains_key(0, 1)); // lock the item and ensure the config stays unchanged @@ -1329,7 +1400,7 @@ fn preserve_config_for_frozen_items() { let config = ItemConfigOf::::get(0, 0).unwrap(); assert_eq!(config, expect_config); - assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(1)), 0, 0, Some(account(1)))); + assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(1)), 0, 0)); let config = ItemConfigOf::::get(0, 0).unwrap(); assert_eq!(config, expect_config); @@ -1405,6 +1476,7 @@ fn force_update_collection_should_work() { Balances::make_free_balance_be(&account(5), 100); assert_ok!(Nfts::force_collection_owner(RuntimeOrigin::root(), 0, account(5))); + assert_ok!(Nfts::set_team(RuntimeOrigin::root(), 0, account(2), account(5), account(4))); assert_eq!(collections(), vec![(account(5), 0)]); assert_eq!(Balances::reserved_balance(account(1)), 2); assert_eq!(Balances::reserved_balance(account(5)), 63); @@ -1475,7 +1547,7 @@ fn burn_works() { )); assert_noop!( - Nfts::burn(RuntimeOrigin::signed(account(5)), 0, 42, Some(account(5))), + Nfts::burn(RuntimeOrigin::signed(account(5)), 0, 42), Error::::UnknownItem ); @@ -1496,16 +1568,12 @@ fn burn_works() { assert_eq!(Balances::reserved_balance(account(1)), 2); assert_noop!( - Nfts::burn(RuntimeOrigin::signed(account(0)), 0, 42, None), + Nfts::burn(RuntimeOrigin::signed(account(0)), 0, 42), Error::::NoPermission ); - assert_noop!( - Nfts::burn(RuntimeOrigin::signed(account(5)), 0, 42, Some(account(6))), - Error::::WrongOwner - ); - assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(5)), 0, 42, Some(account(5)))); - assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(3)), 0, 69, Some(account(5)))); + assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(5)), 0, 42)); + assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(5)), 0, 69)); assert_eq!(Balances::reserved_balance(account(1)), 0); }); } @@ -1819,21 +1887,21 @@ fn cancel_approval_works_with_admin() { None )); assert_noop!( - Nfts::cancel_approval(RuntimeOrigin::signed(account(1)), 1, 42, account(1)), + Nfts::cancel_approval(RuntimeOrigin::signed(account(2)), 1, 42, account(1)), Error::::UnknownItem ); assert_noop!( - Nfts::cancel_approval(RuntimeOrigin::signed(account(1)), 0, 43, account(1)), + Nfts::cancel_approval(RuntimeOrigin::signed(account(2)), 0, 43, account(1)), Error::::UnknownItem ); assert_noop!( - Nfts::cancel_approval(RuntimeOrigin::signed(account(1)), 0, 42, account(4)), + Nfts::cancel_approval(RuntimeOrigin::signed(account(2)), 0, 42, account(4)), Error::::NotDelegate ); - assert_ok!(Nfts::cancel_approval(RuntimeOrigin::signed(account(1)), 0, 42, account(3))); + assert_ok!(Nfts::cancel_approval(RuntimeOrigin::signed(account(2)), 0, 42, account(3))); assert_noop!( - Nfts::cancel_approval(RuntimeOrigin::signed(account(1)), 0, 42, account(1)), + Nfts::cancel_approval(RuntimeOrigin::signed(account(2)), 0, 42, account(1)), Error::::NotDelegate ); }); @@ -3013,6 +3081,7 @@ fn add_remove_item_attributes_approval_should_work() { #[test] fn pre_signed_mints_should_work() { new_test_ext().execute_with(|| { + let user_0 = account(0); let user_1_pair = sp_core::sr25519::Pair::from_string("//Alice", None).unwrap(); let user_1_signer = MultiSigner::Sr25519(user_1_pair.public()); let user_1 = user_1_signer.clone().into_account(); @@ -3029,10 +3098,10 @@ fn pre_signed_mints_should_work() { let user_2 = account(2); let user_3 = account(3); - Balances::make_free_balance_be(&user_1, 100); + Balances::make_free_balance_be(&user_0, 100); Balances::make_free_balance_be(&user_2, 100); assert_ok!(Nfts::create( - RuntimeOrigin::signed(user_1.clone()), + RuntimeOrigin::signed(user_0.clone()), user_1.clone(), collection_config_with_all_settings_enabled(), )); @@ -3069,7 +3138,7 @@ fn pre_signed_mints_should_work() { assert_eq!(deposit.account, Some(user_2.clone())); assert_eq!(deposit.amount, 3); - assert_eq!(Balances::free_balance(&user_1), 100 - 2); // 2 - collection deposit + assert_eq!(Balances::free_balance(&user_0), 100 - 2); // 2 - collection deposit assert_eq!(Balances::free_balance(&user_2), 100 - 1 - 3 - 6); // 1 - item deposit, 3 - metadata, 6 - attributes assert_noop!( @@ -3082,7 +3151,7 @@ fn pre_signed_mints_should_work() { Error::::AlreadyExists ); - assert_ok!(Nfts::burn(RuntimeOrigin::signed(user_2.clone()), 0, 0, Some(user_2.clone()))); + assert_ok!(Nfts::burn(RuntimeOrigin::signed(user_2.clone()), 0, 0)); assert_eq!(Balances::free_balance(&user_2), 100 - 6); // validate the `only_account` field diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index f8ab2a355b48b..fe6d31c12acec 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -92,6 +92,8 @@ pub struct CollectionDetails { pub(super) items: u32, /// The total number of outstanding item metadata of this collection. pub(super) item_metadatas: u32, + /// The total number of outstanding item configs of this collection. + pub(super) item_configs: u32, /// The total number of attributes for this collection. pub(super) attributes: u32, } @@ -99,12 +101,12 @@ pub struct CollectionDetails { /// Witness data for the destroy transactions. #[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct DestroyWitness { - /// The total number of outstanding items of this collection. - #[codec(compact)] - pub items: u32, /// The total number of items in this collection that have outstanding item metadata. #[codec(compact)] pub item_metadatas: u32, + /// The total number of outstanding item configs of this collection. + #[codec(compact)] + pub item_configs: u32, /// The total number of attributes for this collection. #[codec(compact)] pub attributes: u32, @@ -113,8 +115,8 @@ pub struct DestroyWitness { impl CollectionDetails { pub fn destroy_witness(&self) -> DestroyWitness { DestroyWitness { - items: self.items, item_metadatas: self.item_metadatas, + item_configs: self.item_configs, attributes: self.attributes, } } diff --git a/frame/nfts/src/weights.rs b/frame/nfts/src/weights.rs index 858ae2fec9226..3d447c8d264d4 100644 --- a/frame/nfts/src/weights.rs +++ b/frame/nfts/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_nfts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-02-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-osnnfcqu-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -33,7 +33,7 @@ // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json // --pallet=pallet_nfts // --chain=dev // --header=./HEADER-APACHE2 @@ -51,7 +51,7 @@ use sp_std::marker::PhantomData; pub trait WeightInfo { fn create() -> Weight; fn force_create() -> Weight; - fn destroy(n: u32, m: u32, a: u32, ) -> Weight; + fn destroy(m: u32, c: u32, a: u32, ) -> Weight; fn mint() -> Weight; fn force_mint() -> Weight; fn burn() -> Weight; @@ -96,7 +96,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: Nfts NextCollectionId (r:1 w:1) /// Proof: Nfts NextCollectionId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionRoleOf (r:0 w:1) /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:0 w:1) @@ -106,17 +106,16 @@ impl WeightInfo for SubstrateWeight { fn create() -> Weight { // Proof Size summary in bytes: // Measured: `214` - // Estimated: `3054` - // Minimum execution time: 33_769 nanoseconds. - Weight::from_parts(36_031_000, 0) - .saturating_add(Weight::from_parts(0, 3054)) + // Estimated: `5038` + // Minimum execution time: 37_598_000 picoseconds. + Weight::from_parts(38_703_000, 5038) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Nfts NextCollectionId (r:1 w:1) /// Proof: Nfts NextCollectionId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionRoleOf (r:0 w:1) /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:0 w:1) @@ -126,54 +125,45 @@ impl WeightInfo for SubstrateWeight { fn force_create() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `3054` - // Minimum execution time: 21_767 nanoseconds. - Weight::from_parts(22_565_000, 0) - .saturating_add(Weight::from_parts(0, 3054)) + // Estimated: `5038` + // Minimum execution time: 25_899_000 picoseconds. + Weight::from_parts(26_385_000, 5038) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) - /// Storage: Nfts Item (r:1001 w:1000) - /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) - /// Storage: Nfts ItemMetadataOf (r:1001 w:1000) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:0) /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:1) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts Attribute (r:1001 w:1000) /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:0 w:1) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1000 w:1000) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) /// Storage: Nfts CollectionMetadataOf (r:0 w:1) /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:0 w:1) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) - /// Storage: Nfts ItemConfigOf (r:0 w:1000) - /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) - /// Storage: Nfts Account (r:0 w:1000) - /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) /// Storage: Nfts CollectionAccount (r:0 w:1) /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) - /// The range of component `n` is `[0, 1000]`. /// The range of component `m` is `[0, 1000]`. + /// The range of component `c` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. - fn destroy(_n: u32, m: u32, a: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `172781 + m * (127 ±0) + a * (402 ±0)` - // Estimated: `3347427 + m * (2615 ±0) + a * (2921 ±0)` - // Minimum execution time: 26_973_627 nanoseconds. - Weight::from_parts(19_692_361_714, 0) - .saturating_add(Weight::from_parts(0, 3347427)) - // Standard Error: 17_036 - .saturating_add(Weight::from_parts(7_797_219, 0).saturating_mul(m.into())) - // Standard Error: 17_036 - .saturating_add(Weight::from_parts(9_504_128, 0).saturating_mul(a.into())) + fn destroy(m: u32, _c: u32, a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `32218 + a * (364 ±0)` + // Estimated: `2538589 + a * (2921 ±0)` + // Minimum execution time: 1_129_980_000 picoseconds. + Weight::from_parts(1_096_213_543, 2538589) + // Standard Error: 5_210 + .saturating_add(Weight::from_parts(92, 0).saturating_mul(m.into())) + // Standard Error: 5_210 + .saturating_add(Weight::from_parts(5_480_550, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(1004_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) - .saturating_add(T::DbWeight::get().writes(3005_u64)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(m.into()))) + .saturating_add(T::DbWeight::get().writes(1005_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) - .saturating_add(Weight::from_parts(0, 2615).saturating_mul(m.into())) .saturating_add(Weight::from_parts(0, 2921).saturating_mul(a.into())) } /// Storage: Nfts CollectionConfigOf (r:1 w:0) @@ -181,7 +171,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionRoleOf (r:1 w:0) /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:1) @@ -190,11 +180,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `448` - // Estimated: `13506` - // Minimum execution time: 44_837 nanoseconds. - Weight::from_parts(46_794_000, 0) - .saturating_add(Weight::from_parts(0, 13506)) + // Measured: `453` + // Estimated: `18460` + // Minimum execution time: 49_434_000 picoseconds. + Weight::from_parts(50_248_000, 18460) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -203,7 +192,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:1) @@ -212,22 +201,19 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn force_mint() -> Weight { // Proof Size summary in bytes: - // Measured: `448` - // Estimated: `13506` - // Minimum execution time: 43_976 nanoseconds. - Weight::from_parts(44_831_000, 0) - .saturating_add(Weight::from_parts(0, 13506)) + // Measured: `453` + // Estimated: `18460` + // Minimum execution time: 47_393_000 picoseconds. + Weight::from_parts(47_906_000, 18460) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: Nfts ItemConfigOf (r:1 w:1) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:1 w:0) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts ItemMetadataOf (r:1 w:0) /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) /// Storage: Nfts Account (r:0 w:1) @@ -240,26 +226,21 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn burn() -> Weight { // Proof Size summary in bytes: - // Measured: `647` - // Estimated: `13573` - // Minimum execution time: 48_233 nanoseconds. - Weight::from_parts(50_113_000, 0) - .saturating_add(Weight::from_parts(0, 13573)) - .saturating_add(T::DbWeight::get().reads(5_u64)) + // Measured: `594` + // Estimated: `14993` + // Minimum execution time: 47_188_000 picoseconds. + Weight::from_parts(47_746_000, 14993) + .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:0) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:1 w:0) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Nfts Account (r:0 w:2) /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) /// Storage: Nfts ItemPriceOf (r:0 w:1) @@ -268,16 +249,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `882` - // Estimated: `16109` - // Minimum execution time: 55_452 nanoseconds. - Weight::from_parts(57_642_000, 0) - .saturating_add(Weight::from_parts(0, 16109)) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(6_u64)) + // Measured: `623` + // Estimated: `14926` + // Minimum execution time: 37_984_000 picoseconds. + Weight::from_parts(38_446_000, 14926) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts Item (r:5000 w:5000) @@ -285,13 +265,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `756 + i * (140 ±0)` - // Estimated: `5103 + i * (3336 ±0)` - // Minimum execution time: 15_598 nanoseconds. - Weight::from_parts(15_926_000, 0) - .saturating_add(Weight::from_parts(0, 5103)) - // Standard Error: 13_692 - .saturating_add(Weight::from_parts(14_040_741, 0).saturating_mul(i.into())) + // Measured: `761 + i * (140 ±0)` + // Estimated: `8077 + i * (3336 ±0)` + // Minimum execution time: 17_297_000 picoseconds. + Weight::from_parts(17_634_000, 8077) + // Standard Error: 17_773 + .saturating_add(Weight::from_parts(14_395_819, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -304,10 +283,9 @@ impl WeightInfo for SubstrateWeight { fn lock_item_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `401` - // Estimated: `5067` - // Minimum execution time: 19_686 nanoseconds. - Weight::from_parts(20_404_000, 0) - .saturating_add(Weight::from_parts(0, 5067)) + // Estimated: `7047` + // Minimum execution time: 21_827_000 picoseconds. + Weight::from_parts(22_134_000, 7047) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -318,101 +296,96 @@ impl WeightInfo for SubstrateWeight { fn unlock_item_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `401` - // Estimated: `5067` - // Minimum execution time: 19_172 nanoseconds. - Weight::from_parts(20_151_000, 0) - .saturating_add(Weight::from_parts(0, 5067)) + // Estimated: `7047` + // Minimum execution time: 21_549_000 picoseconds. + Weight::from_parts(21_987_000, 7047) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: Nfts CollectionRoleOf (r:1 w:0) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:1) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn lock_collection() -> Weight { // Proof Size summary in bytes: - // Measured: `289` - // Estimated: `5092` - // Minimum execution time: 17_063 nanoseconds. - Weight::from_parts(17_482_000, 0) - .saturating_add(Weight::from_parts(0, 5092)) + // Measured: `338` + // Estimated: `7087` + // Minimum execution time: 18_930_000 picoseconds. + Weight::from_parts(19_200_000, 7087) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Nfts OwnershipAcceptance (r:1 w:1) /// Proof: Nfts OwnershipAcceptance (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionAccount (r:0 w:2) /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `5082` - // Minimum execution time: 21_974 nanoseconds. - Weight::from_parts(22_770_000, 0) - .saturating_add(Weight::from_parts(0, 5082)) + // Measured: `386` + // Estimated: `7066` + // Minimum execution time: 24_929_000 picoseconds. + Weight::from_parts(25_786_000, 7066) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:0 w:4) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:4) /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn set_team() -> Weight { // Proof Size summary in bytes: - // Measured: `362` - // Estimated: `2555` - // Minimum execution time: 24_341 nanoseconds. - Weight::from_parts(25_059_000, 0) - .saturating_add(Weight::from_parts(0, 2555)) - .saturating_add(T::DbWeight::get().reads(1_u64)) + // Measured: `367` + // Estimated: `7083` + // Minimum execution time: 28_245_000 picoseconds. + Weight::from_parts(28_490_000, 7083) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionAccount (r:0 w:2) /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_collection_owner() -> Weight { // Proof Size summary in bytes: - // Measured: `304` - // Estimated: `2555` - // Minimum execution time: 16_897 nanoseconds. - Weight::from_parts(17_560_000, 0) - .saturating_add(Weight::from_parts(0, 2555)) + // Measured: `309` + // Estimated: `3549` + // Minimum execution time: 19_971_000 picoseconds. + Weight::from_parts(20_276_000, 3549) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:0 w:1) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn force_collection_config() -> Weight { // Proof Size summary in bytes: // Measured: `242` - // Estimated: `2555` - // Minimum execution time: 13_239 nanoseconds. - Weight::from_parts(13_963_000, 0) - .saturating_add(Weight::from_parts(0, 2555)) + // Estimated: `3549` + // Minimum execution time: 15_924_000 picoseconds. + Weight::from_parts(16_258_000, 3549) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:1) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn lock_item_properties() -> Weight { // Proof Size summary in bytes: - // Measured: `445` - // Estimated: `5078` - // Minimum execution time: 17_187 nanoseconds. - Weight::from_parts(17_942_000, 0) - .saturating_add(Weight::from_parts(0, 5078)) + // Measured: `401` + // Estimated: `7047` + // Minimum execution time: 20_780_000 picoseconds. + Weight::from_parts(21_109_000, 7047) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:0) @@ -421,42 +394,41 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) fn set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `474` - // Estimated: `10547` - // Minimum execution time: 40_925 nanoseconds. - Weight::from_parts(42_733_000, 0) - .saturating_add(Weight::from_parts(0, 10547)) - .saturating_add(T::DbWeight::get().reads(4_u64)) + // Measured: `537` + // Estimated: `18045` + // Minimum execution time: 50_817_000 picoseconds. + Weight::from_parts(51_585_000, 18045) + .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts Attribute (r:1 w:1) /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) fn force_set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `337` - // Estimated: `5476` - // Minimum execution time: 24_486 nanoseconds. - Weight::from_parts(25_409_000, 0) - .saturating_add(Weight::from_parts(0, 5476)) + // Measured: `342` + // Estimated: `7460` + // Minimum execution time: 28_821_000 picoseconds. + Weight::from_parts(29_417_000, 7460) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: Nfts Attribute (r:1 w:1) /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) - /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:0) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) fn clear_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `916` - // Estimated: `7999` - // Minimum execution time: 36_643 nanoseconds. - Weight::from_parts(37_805_000, 0) - .saturating_add(Weight::from_parts(0, 7999)) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Measured: `979` + // Estimated: `14507` + // Minimum execution time: 47_021_000 picoseconds. + Weight::from_parts(47_509_000, 14507) + .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: Nfts Item (r:1 w:0) @@ -466,10 +438,9 @@ impl WeightInfo for SubstrateWeight { fn approve_item_attributes() -> Weight { // Proof Size summary in bytes: // Measured: `379` - // Estimated: `6492` - // Minimum execution time: 16_798 nanoseconds. - Weight::from_parts(17_326_000, 0) - .saturating_add(Weight::from_parts(0, 6492)) + // Estimated: `8472` + // Minimum execution time: 19_457_000 picoseconds. + Weight::from_parts(19_738_000, 8472) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -485,20 +456,21 @@ impl WeightInfo for SubstrateWeight { fn cancel_item_attributes_approval(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `899 + n * (396 ±0)` - // Estimated: `12016 + n * (2921 ±0)` - // Minimum execution time: 25_524 nanoseconds. - Weight::from_parts(26_107_000, 0) - .saturating_add(Weight::from_parts(0, 12016)) - // Standard Error: 5_460 - .saturating_add(Weight::from_parts(9_030_830, 0).saturating_mul(n.into())) + // Estimated: `15976 + n * (2921 ±0)` + // Minimum execution time: 29_027_000 picoseconds. + Weight::from_parts(29_376_000, 15976) + // Standard Error: 3_500 + .saturating_add(Weight::from_parts(5_568_116, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_parts(0, 2921).saturating_mul(n.into())) } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:0) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) @@ -507,104 +479,97 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn set_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `474` - // Estimated: `10241` - // Minimum execution time: 34_400 nanoseconds. - Weight::from_parts(35_469_000, 0) - .saturating_add(Weight::from_parts(0, 10241)) - .saturating_add(T::DbWeight::get().reads(4_u64)) + // Measured: `537` + // Estimated: `17739` + // Minimum execution time: 41_658_000 picoseconds. + Weight::from_parts(42_241_000, 17739) + .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts ItemMetadataOf (r:1 w:1) /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:0) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `609` - // Estimated: `7693` - // Minimum execution time: 31_560 nanoseconds. - Weight::from_parts(33_081_000, 0) - .saturating_add(Weight::from_parts(0, 7693)) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Measured: `672` + // Estimated: `14201` + // Minimum execution time: 39_838_000 picoseconds. + Weight::from_parts(40_757_000, 14201) + .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionMetadataOf (r:1 w:1) /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `333` - // Estimated: `7665` - // Minimum execution time: 28_821 nanoseconds. - Weight::from_parts(30_010_000, 0) - .saturating_add(Weight::from_parts(0, 7665)) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Measured: `396` + // Estimated: `14173` + // Minimum execution time: 37_327_000 picoseconds. + Weight::from_parts(37_874_000, 14173) + .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts CollectionMetadataOf (r:1 w:1) /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `476` - // Estimated: `7665` - // Minimum execution time: 27_608 nanoseconds. - Weight::from_parts(28_766_000, 0) - .saturating_add(Weight::from_parts(0, 7665)) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Measured: `539` + // Estimated: `14173` + // Minimum execution time: 35_305_000 picoseconds. + Weight::from_parts(36_213_000, 14173) + .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:1 w:0) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn approve_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `466` - // Estimated: `8428` - // Minimum execution time: 23_987 nanoseconds. - Weight::from_parts(24_819_000, 0) - .saturating_add(Weight::from_parts(0, 8428)) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Measured: `408` + // Estimated: `7864` + // Minimum execution time: 22_680_000 picoseconds. + Weight::from_parts(23_126_000, 7864) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:1 w:0) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn cancel_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `474` - // Estimated: `5880` - // Minimum execution time: 21_254 nanoseconds. - Weight::from_parts(21_826_000, 0) - .saturating_add(Weight::from_parts(0, 5880)) - .saturating_add(T::DbWeight::get().reads(2_u64)) + // Measured: `416` + // Estimated: `4326` + // Minimum execution time: 19_837_000 picoseconds. + Weight::from_parts(20_352_000, 4326) + .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:1 w:0) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn clear_all_transfer_approvals() -> Weight { // Proof Size summary in bytes: - // Measured: `474` - // Estimated: `5880` - // Minimum execution time: 20_272 nanoseconds. - Weight::from_parts(20_922_000, 0) - .saturating_add(Weight::from_parts(0, 5880)) - .saturating_add(T::DbWeight::get().reads(2_u64)) + // Measured: `416` + // Estimated: `4326` + // Minimum execution time: 18_911_000 picoseconds. + Weight::from_parts(19_233_000, 4326) + .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Nfts OwnershipAcceptance (r:1 w:1) @@ -612,38 +577,35 @@ impl WeightInfo for SubstrateWeight { fn set_accept_ownership() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `2527` - // Minimum execution time: 14_287 nanoseconds. - Weight::from_parts(14_960_000, 0) - .saturating_add(Weight::from_parts(0, 2527)) + // Estimated: `3517` + // Minimum execution time: 17_292_000 picoseconds. + Weight::from_parts(17_568_000, 3517) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Nfts CollectionConfigOf (r:1 w:1) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: - // Measured: `333` - // Estimated: `5103` - // Minimum execution time: 17_948 nanoseconds. - Weight::from_parts(18_780_000, 0) - .saturating_add(Weight::from_parts(0, 5103)) + // Measured: `338` + // Estimated: `7087` + // Minimum execution time: 20_323_000 picoseconds. + Weight::from_parts(20_692_000, 7087) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:1) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn update_mint_settings() -> Weight { // Proof Size summary in bytes: - // Measured: `333` - // Estimated: `5103` - // Minimum execution time: 16_616 nanoseconds. - Weight::from_parts(17_155_000, 0) - .saturating_add(Weight::from_parts(0, 5103)) + // Measured: `289` + // Estimated: `7072` + // Minimum execution time: 19_971_000 picoseconds. + Weight::from_parts(20_159_000, 7072) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -658,10 +620,9 @@ impl WeightInfo for SubstrateWeight { fn set_price() -> Weight { // Proof Size summary in bytes: // Measured: `516` - // Estimated: `8407` - // Minimum execution time: 22_777 nanoseconds. - Weight::from_parts(23_955_000, 0) - .saturating_add(Weight::from_parts(0, 8407)) + // Estimated: `11377` + // Minimum execution time: 26_202_000 picoseconds. + Weight::from_parts(26_499_000, 11377) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -670,37 +631,33 @@ impl WeightInfo for SubstrateWeight { /// Storage: Nfts ItemPriceOf (r:1 w:1) /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:0) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Nfts Account (r:0 w:2) /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) /// Storage: Nfts PendingSwapOf (r:0 w:1) /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn buy_item() -> Weight { // Proof Size summary in bytes: - // Measured: `934` - // Estimated: `16129` - // Minimum execution time: 61_131 nanoseconds. - Weight::from_parts(62_791_000, 0) - .saturating_add(Weight::from_parts(0, 16129)) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(6_u64)) + // Measured: `767` + // Estimated: `18480` + // Minimum execution time: 50_601_000 picoseconds. + Weight::from_parts(51_283_000, 18480) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } /// The range of component `n` is `[0, 10]`. fn pay_tips(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_952 nanoseconds. - Weight::from_parts(3_975_700, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 11_254 - .saturating_add(Weight::from_parts(3_501_698, 0).saturating_mul(n.into())) + // Minimum execution time: 2_733_000 picoseconds. + Weight::from_parts(5_568_590, 0) + // Standard Error: 14_136 + .saturating_add(Weight::from_parts(3_763_928, 0).saturating_mul(n.into())) } /// Storage: Nfts Item (r:2 w:0) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) @@ -709,10 +666,9 @@ impl WeightInfo for SubstrateWeight { fn create_swap() -> Weight { // Proof Size summary in bytes: // Measured: `524` - // Estimated: `6672` - // Minimum execution time: 20_327 nanoseconds. - Weight::from_parts(21_714_000, 0) - .saturating_add(Weight::from_parts(0, 6672)) + // Estimated: `7662` + // Minimum execution time: 22_901_000 picoseconds. + Weight::from_parts(23_673_000, 7662) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -723,10 +679,9 @@ impl WeightInfo for SubstrateWeight { fn cancel_swap() -> Weight { // Proof Size summary in bytes: // Measured: `511` - // Estimated: `5882` - // Minimum execution time: 20_668 nanoseconds. - Weight::from_parts(21_416_000, 0) - .saturating_add(Weight::from_parts(0, 5882)) + // Estimated: `7862` + // Minimum execution time: 22_532_000 picoseconds. + Weight::from_parts(22_831_000, 7862) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -735,29 +690,28 @@ impl WeightInfo for SubstrateWeight { /// Storage: Nfts PendingSwapOf (r:1 w:2) /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:2 w:0) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Nfts Account (r:0 w:4) /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) /// Storage: Nfts ItemPriceOf (r:0 w:2) /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn claim_swap() -> Weight { // Proof Size summary in bytes: - // Measured: `1097` - // Estimated: `21970` - // Minimum execution time: 88_006 nanoseconds. - Weight::from_parts(90_390_000, 0) - .saturating_add(Weight::from_parts(0, 21970)) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(11_u64)) + // Measured: `896` + // Estimated: `24321` + // Minimum execution time: 77_668_000 picoseconds. + Weight::from_parts(78_407_000, 24321) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(10_u64)) } /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:2 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts Item (r:1 w:1) @@ -775,14 +729,13 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 10]`. fn mint_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `596` - // Estimated: `16180 + n * (2921 ±0)` - // Minimum execution time: 124_967 nanoseconds. - Weight::from_parts(131_602_642, 0) - .saturating_add(Weight::from_parts(0, 16180)) - // Standard Error: 36_480 - .saturating_add(Weight::from_parts(25_811_394, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(6_u64)) + // Measured: `659` + // Estimated: `29192 + n * (2921 ±0)` + // Minimum execution time: 133_147_000 picoseconds. + Weight::from_parts(138_031_439, 29192) + // Standard Error: 28_665 + .saturating_add(Weight::from_parts(28_206_062, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) @@ -792,10 +745,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) /// Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(681), added: 3156, mode: MaxEncodedLen) - /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts Attribute (r:10 w:10) /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) @@ -803,13 +756,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 10]`. fn set_attributes_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `716` - // Estimated: `14198 + n * (2921 ±0)` - // Minimum execution time: 84_153 nanoseconds. - Weight::from_parts(96_401_623, 0) - .saturating_add(Weight::from_parts(0, 14198)) - // Standard Error: 70_244 - .saturating_add(Weight::from_parts(26_866_222, 0).saturating_mul(n.into())) + // Measured: `721` + // Estimated: `20142 + n * (2921 ±0)` + // Minimum execution time: 78_243_000 picoseconds. + Weight::from_parts(90_947_408, 20142) + // Standard Error: 75_516 + .saturating_add(Weight::from_parts(28_059_623, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -823,7 +775,7 @@ impl WeightInfo for () { /// Storage: Nfts NextCollectionId (r:1 w:1) /// Proof: Nfts NextCollectionId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionRoleOf (r:0 w:1) /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:0 w:1) @@ -833,17 +785,16 @@ impl WeightInfo for () { fn create() -> Weight { // Proof Size summary in bytes: // Measured: `214` - // Estimated: `3054` - // Minimum execution time: 33_769 nanoseconds. - Weight::from_parts(36_031_000, 0) - .saturating_add(Weight::from_parts(0, 3054)) + // Estimated: `5038` + // Minimum execution time: 37_598_000 picoseconds. + Weight::from_parts(38_703_000, 5038) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Nfts NextCollectionId (r:1 w:1) /// Proof: Nfts NextCollectionId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionRoleOf (r:0 w:1) /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:0 w:1) @@ -853,54 +804,45 @@ impl WeightInfo for () { fn force_create() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `3054` - // Minimum execution time: 21_767 nanoseconds. - Weight::from_parts(22_565_000, 0) - .saturating_add(Weight::from_parts(0, 3054)) + // Estimated: `5038` + // Minimum execution time: 25_899_000 picoseconds. + Weight::from_parts(26_385_000, 5038) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) - /// Storage: Nfts Item (r:1001 w:1000) - /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) - /// Storage: Nfts ItemMetadataOf (r:1001 w:1000) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:0) /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:1) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts Attribute (r:1001 w:1000) /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:0 w:1) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1000 w:1000) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) /// Storage: Nfts CollectionMetadataOf (r:0 w:1) /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:0 w:1) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) - /// Storage: Nfts ItemConfigOf (r:0 w:1000) - /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) - /// Storage: Nfts Account (r:0 w:1000) - /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) /// Storage: Nfts CollectionAccount (r:0 w:1) /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) - /// The range of component `n` is `[0, 1000]`. /// The range of component `m` is `[0, 1000]`. + /// The range of component `c` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. - fn destroy(_n: u32, m: u32, a: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `172781 + m * (127 ±0) + a * (402 ±0)` - // Estimated: `3347427 + m * (2615 ±0) + a * (2921 ±0)` - // Minimum execution time: 26_973_627 nanoseconds. - Weight::from_parts(19_692_361_714, 0) - .saturating_add(Weight::from_parts(0, 3347427)) - // Standard Error: 17_036 - .saturating_add(Weight::from_parts(7_797_219, 0).saturating_mul(m.into())) - // Standard Error: 17_036 - .saturating_add(Weight::from_parts(9_504_128, 0).saturating_mul(a.into())) + fn destroy(m: u32, _c: u32, a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `32218 + a * (364 ±0)` + // Estimated: `2538589 + a * (2921 ±0)` + // Minimum execution time: 1_129_980_000 picoseconds. + Weight::from_parts(1_096_213_543, 2538589) + // Standard Error: 5_210 + .saturating_add(Weight::from_parts(92, 0).saturating_mul(m.into())) + // Standard Error: 5_210 + .saturating_add(Weight::from_parts(5_480_550, 0).saturating_mul(a.into())) .saturating_add(RocksDbWeight::get().reads(1004_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) - .saturating_add(RocksDbWeight::get().writes(3005_u64)) - .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(m.into()))) + .saturating_add(RocksDbWeight::get().writes(1005_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) - .saturating_add(Weight::from_parts(0, 2615).saturating_mul(m.into())) .saturating_add(Weight::from_parts(0, 2921).saturating_mul(a.into())) } /// Storage: Nfts CollectionConfigOf (r:1 w:0) @@ -908,7 +850,7 @@ impl WeightInfo for () { /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionRoleOf (r:1 w:0) /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:1) @@ -917,11 +859,10 @@ impl WeightInfo for () { /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `448` - // Estimated: `13506` - // Minimum execution time: 44_837 nanoseconds. - Weight::from_parts(46_794_000, 0) - .saturating_add(Weight::from_parts(0, 13506)) + // Measured: `453` + // Estimated: `18460` + // Minimum execution time: 49_434_000 picoseconds. + Weight::from_parts(50_248_000, 18460) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -930,7 +871,7 @@ impl WeightInfo for () { /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:1) @@ -939,22 +880,19 @@ impl WeightInfo for () { /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn force_mint() -> Weight { // Proof Size summary in bytes: - // Measured: `448` - // Estimated: `13506` - // Minimum execution time: 43_976 nanoseconds. - Weight::from_parts(44_831_000, 0) - .saturating_add(Weight::from_parts(0, 13506)) + // Measured: `453` + // Estimated: `18460` + // Minimum execution time: 47_393_000 picoseconds. + Weight::from_parts(47_906_000, 18460) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } /// Storage: Nfts ItemConfigOf (r:1 w:1) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:1 w:0) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts ItemMetadataOf (r:1 w:0) /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) /// Storage: Nfts Account (r:0 w:1) @@ -967,26 +905,21 @@ impl WeightInfo for () { /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn burn() -> Weight { // Proof Size summary in bytes: - // Measured: `647` - // Estimated: `13573` - // Minimum execution time: 48_233 nanoseconds. - Weight::from_parts(50_113_000, 0) - .saturating_add(Weight::from_parts(0, 13573)) - .saturating_add(RocksDbWeight::get().reads(5_u64)) + // Measured: `594` + // Estimated: `14993` + // Minimum execution time: 47_188_000 picoseconds. + Weight::from_parts(47_746_000, 14993) + .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:0) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:1 w:0) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Nfts Account (r:0 w:2) /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) /// Storage: Nfts ItemPriceOf (r:0 w:1) @@ -995,16 +928,15 @@ impl WeightInfo for () { /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `882` - // Estimated: `16109` - // Minimum execution time: 55_452 nanoseconds. - Weight::from_parts(57_642_000, 0) - .saturating_add(Weight::from_parts(0, 16109)) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(6_u64)) + // Measured: `623` + // Estimated: `14926` + // Minimum execution time: 37_984_000 picoseconds. + Weight::from_parts(38_446_000, 14926) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts Item (r:5000 w:5000) @@ -1012,13 +944,12 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `756 + i * (140 ±0)` - // Estimated: `5103 + i * (3336 ±0)` - // Minimum execution time: 15_598 nanoseconds. - Weight::from_parts(15_926_000, 0) - .saturating_add(Weight::from_parts(0, 5103)) - // Standard Error: 13_692 - .saturating_add(Weight::from_parts(14_040_741, 0).saturating_mul(i.into())) + // Measured: `761 + i * (140 ±0)` + // Estimated: `8077 + i * (3336 ±0)` + // Minimum execution time: 17_297_000 picoseconds. + Weight::from_parts(17_634_000, 8077) + // Standard Error: 17_773 + .saturating_add(Weight::from_parts(14_395_819, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -1031,10 +962,9 @@ impl WeightInfo for () { fn lock_item_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `401` - // Estimated: `5067` - // Minimum execution time: 19_686 nanoseconds. - Weight::from_parts(20_404_000, 0) - .saturating_add(Weight::from_parts(0, 5067)) + // Estimated: `7047` + // Minimum execution time: 21_827_000 picoseconds. + Weight::from_parts(22_134_000, 7047) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1045,101 +975,96 @@ impl WeightInfo for () { fn unlock_item_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `401` - // Estimated: `5067` - // Minimum execution time: 19_172 nanoseconds. - Weight::from_parts(20_151_000, 0) - .saturating_add(Weight::from_parts(0, 5067)) + // Estimated: `7047` + // Minimum execution time: 21_549_000 picoseconds. + Weight::from_parts(21_987_000, 7047) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Nfts CollectionRoleOf (r:1 w:0) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:1) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn lock_collection() -> Weight { // Proof Size summary in bytes: - // Measured: `289` - // Estimated: `5092` - // Minimum execution time: 17_063 nanoseconds. - Weight::from_parts(17_482_000, 0) - .saturating_add(Weight::from_parts(0, 5092)) + // Measured: `338` + // Estimated: `7087` + // Minimum execution time: 18_930_000 picoseconds. + Weight::from_parts(19_200_000, 7087) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Nfts OwnershipAcceptance (r:1 w:1) /// Proof: Nfts OwnershipAcceptance (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionAccount (r:0 w:2) /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `5082` - // Minimum execution time: 21_974 nanoseconds. - Weight::from_parts(22_770_000, 0) - .saturating_add(Weight::from_parts(0, 5082)) + // Measured: `386` + // Estimated: `7066` + // Minimum execution time: 24_929_000 picoseconds. + Weight::from_parts(25_786_000, 7066) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:0 w:4) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:4) /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn set_team() -> Weight { // Proof Size summary in bytes: - // Measured: `362` - // Estimated: `2555` - // Minimum execution time: 24_341 nanoseconds. - Weight::from_parts(25_059_000, 0) - .saturating_add(Weight::from_parts(0, 2555)) - .saturating_add(RocksDbWeight::get().reads(1_u64)) + // Measured: `367` + // Estimated: `7083` + // Minimum execution time: 28_245_000 picoseconds. + Weight::from_parts(28_490_000, 7083) + .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionAccount (r:0 w:2) /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_collection_owner() -> Weight { // Proof Size summary in bytes: - // Measured: `304` - // Estimated: `2555` - // Minimum execution time: 16_897 nanoseconds. - Weight::from_parts(17_560_000, 0) - .saturating_add(Weight::from_parts(0, 2555)) + // Measured: `309` + // Estimated: `3549` + // Minimum execution time: 19_971_000 picoseconds. + Weight::from_parts(20_276_000, 3549) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:0 w:1) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn force_collection_config() -> Weight { // Proof Size summary in bytes: // Measured: `242` - // Estimated: `2555` - // Minimum execution time: 13_239 nanoseconds. - Weight::from_parts(13_963_000, 0) - .saturating_add(Weight::from_parts(0, 2555)) + // Estimated: `3549` + // Minimum execution time: 15_924_000 picoseconds. + Weight::from_parts(16_258_000, 3549) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:1) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn lock_item_properties() -> Weight { // Proof Size summary in bytes: - // Measured: `445` - // Estimated: `5078` - // Minimum execution time: 17_187 nanoseconds. - Weight::from_parts(17_942_000, 0) - .saturating_add(Weight::from_parts(0, 5078)) + // Measured: `401` + // Estimated: `7047` + // Minimum execution time: 20_780_000 picoseconds. + Weight::from_parts(21_109_000, 7047) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:0) @@ -1148,42 +1073,41 @@ impl WeightInfo for () { /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) fn set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `474` - // Estimated: `10547` - // Minimum execution time: 40_925 nanoseconds. - Weight::from_parts(42_733_000, 0) - .saturating_add(Weight::from_parts(0, 10547)) - .saturating_add(RocksDbWeight::get().reads(4_u64)) + // Measured: `537` + // Estimated: `18045` + // Minimum execution time: 50_817_000 picoseconds. + Weight::from_parts(51_585_000, 18045) + .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts Attribute (r:1 w:1) /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) fn force_set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `337` - // Estimated: `5476` - // Minimum execution time: 24_486 nanoseconds. - Weight::from_parts(25_409_000, 0) - .saturating_add(Weight::from_parts(0, 5476)) + // Measured: `342` + // Estimated: `7460` + // Minimum execution time: 28_821_000 picoseconds. + Weight::from_parts(29_417_000, 7460) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: Nfts Attribute (r:1 w:1) /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) - /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:0) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) fn clear_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `916` - // Estimated: `7999` - // Minimum execution time: 36_643 nanoseconds. - Weight::from_parts(37_805_000, 0) - .saturating_add(Weight::from_parts(0, 7999)) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Measured: `979` + // Estimated: `14507` + // Minimum execution time: 47_021_000 picoseconds. + Weight::from_parts(47_509_000, 14507) + .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: Nfts Item (r:1 w:0) @@ -1193,10 +1117,9 @@ impl WeightInfo for () { fn approve_item_attributes() -> Weight { // Proof Size summary in bytes: // Measured: `379` - // Estimated: `6492` - // Minimum execution time: 16_798 nanoseconds. - Weight::from_parts(17_326_000, 0) - .saturating_add(Weight::from_parts(0, 6492)) + // Estimated: `8472` + // Minimum execution time: 19_457_000 picoseconds. + Weight::from_parts(19_738_000, 8472) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1212,20 +1135,21 @@ impl WeightInfo for () { fn cancel_item_attributes_approval(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `899 + n * (396 ±0)` - // Estimated: `12016 + n * (2921 ±0)` - // Minimum execution time: 25_524 nanoseconds. - Weight::from_parts(26_107_000, 0) - .saturating_add(Weight::from_parts(0, 12016)) - // Standard Error: 5_460 - .saturating_add(Weight::from_parts(9_030_830, 0).saturating_mul(n.into())) + // Estimated: `15976 + n * (2921 ±0)` + // Minimum execution time: 29_027_000 picoseconds. + Weight::from_parts(29_376_000, 15976) + // Standard Error: 3_500 + .saturating_add(Weight::from_parts(5_568_116, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_parts(0, 2921).saturating_mul(n.into())) } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:0) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) @@ -1234,104 +1158,97 @@ impl WeightInfo for () { /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn set_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `474` - // Estimated: `10241` - // Minimum execution time: 34_400 nanoseconds. - Weight::from_parts(35_469_000, 0) - .saturating_add(Weight::from_parts(0, 10241)) - .saturating_add(RocksDbWeight::get().reads(4_u64)) + // Measured: `537` + // Estimated: `17739` + // Minimum execution time: 41_658_000 picoseconds. + Weight::from_parts(42_241_000, 17739) + .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts ItemMetadataOf (r:1 w:1) /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:0) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `609` - // Estimated: `7693` - // Minimum execution time: 31_560 nanoseconds. - Weight::from_parts(33_081_000, 0) - .saturating_add(Weight::from_parts(0, 7693)) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Measured: `672` + // Estimated: `14201` + // Minimum execution time: 39_838_000 picoseconds. + Weight::from_parts(40_757_000, 14201) + .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionMetadataOf (r:1 w:1) /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `333` - // Estimated: `7665` - // Minimum execution time: 28_821 nanoseconds. - Weight::from_parts(30_010_000, 0) - .saturating_add(Weight::from_parts(0, 7665)) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Measured: `396` + // Estimated: `14173` + // Minimum execution time: 37_327_000 picoseconds. + Weight::from_parts(37_874_000, 14173) + .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts CollectionMetadataOf (r:1 w:1) /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `476` - // Estimated: `7665` - // Minimum execution time: 27_608 nanoseconds. - Weight::from_parts(28_766_000, 0) - .saturating_add(Weight::from_parts(0, 7665)) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Measured: `539` + // Estimated: `14173` + // Minimum execution time: 35_305_000 picoseconds. + Weight::from_parts(36_213_000, 14173) + .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:1 w:0) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn approve_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `466` - // Estimated: `8428` - // Minimum execution time: 23_987 nanoseconds. - Weight::from_parts(24_819_000, 0) - .saturating_add(Weight::from_parts(0, 8428)) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Measured: `408` + // Estimated: `7864` + // Minimum execution time: 22_680_000 picoseconds. + Weight::from_parts(23_126_000, 7864) + .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:1 w:0) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn cancel_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `474` - // Estimated: `5880` - // Minimum execution time: 21_254 nanoseconds. - Weight::from_parts(21_826_000, 0) - .saturating_add(Weight::from_parts(0, 5880)) - .saturating_add(RocksDbWeight::get().reads(2_u64)) + // Measured: `416` + // Estimated: `4326` + // Minimum execution time: 19_837_000 picoseconds. + Weight::from_parts(20_352_000, 4326) + .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:1 w:0) - /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn clear_all_transfer_approvals() -> Weight { // Proof Size summary in bytes: - // Measured: `474` - // Estimated: `5880` - // Minimum execution time: 20_272 nanoseconds. - Weight::from_parts(20_922_000, 0) - .saturating_add(Weight::from_parts(0, 5880)) - .saturating_add(RocksDbWeight::get().reads(2_u64)) + // Measured: `416` + // Estimated: `4326` + // Minimum execution time: 18_911_000 picoseconds. + Weight::from_parts(19_233_000, 4326) + .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Nfts OwnershipAcceptance (r:1 w:1) @@ -1339,38 +1256,35 @@ impl WeightInfo for () { fn set_accept_ownership() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `2527` - // Minimum execution time: 14_287 nanoseconds. - Weight::from_parts(14_960_000, 0) - .saturating_add(Weight::from_parts(0, 2527)) + // Estimated: `3517` + // Minimum execution time: 17_292_000 picoseconds. + Weight::from_parts(17_568_000, 3517) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Nfts CollectionConfigOf (r:1 w:1) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: - // Measured: `333` - // Estimated: `5103` - // Minimum execution time: 17_948 nanoseconds. - Weight::from_parts(18_780_000, 0) - .saturating_add(Weight::from_parts(0, 5103)) + // Measured: `338` + // Estimated: `7087` + // Minimum execution time: 20_323_000 picoseconds. + Weight::from_parts(20_692_000, 7087) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:1) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn update_mint_settings() -> Weight { // Proof Size summary in bytes: - // Measured: `333` - // Estimated: `5103` - // Minimum execution time: 16_616 nanoseconds. - Weight::from_parts(17_155_000, 0) - .saturating_add(Weight::from_parts(0, 5103)) + // Measured: `289` + // Estimated: `7072` + // Minimum execution time: 19_971_000 picoseconds. + Weight::from_parts(20_159_000, 7072) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1385,10 +1299,9 @@ impl WeightInfo for () { fn set_price() -> Weight { // Proof Size summary in bytes: // Measured: `516` - // Estimated: `8407` - // Minimum execution time: 22_777 nanoseconds. - Weight::from_parts(23_955_000, 0) - .saturating_add(Weight::from_parts(0, 8407)) + // Estimated: `11377` + // Minimum execution time: 26_202_000 picoseconds. + Weight::from_parts(26_499_000, 11377) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1397,37 +1310,33 @@ impl WeightInfo for () { /// Storage: Nfts ItemPriceOf (r:1 w:1) /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:0) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Nfts Account (r:0 w:2) /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) /// Storage: Nfts PendingSwapOf (r:0 w:1) /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn buy_item() -> Weight { // Proof Size summary in bytes: - // Measured: `934` - // Estimated: `16129` - // Minimum execution time: 61_131 nanoseconds. - Weight::from_parts(62_791_000, 0) - .saturating_add(Weight::from_parts(0, 16129)) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(6_u64)) + // Measured: `767` + // Estimated: `18480` + // Minimum execution time: 50_601_000 picoseconds. + Weight::from_parts(51_283_000, 18480) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// The range of component `n` is `[0, 10]`. fn pay_tips(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_952 nanoseconds. - Weight::from_parts(3_975_700, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 11_254 - .saturating_add(Weight::from_parts(3_501_698, 0).saturating_mul(n.into())) + // Minimum execution time: 2_733_000 picoseconds. + Weight::from_parts(5_568_590, 0) + // Standard Error: 14_136 + .saturating_add(Weight::from_parts(3_763_928, 0).saturating_mul(n.into())) } /// Storage: Nfts Item (r:2 w:0) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) @@ -1436,10 +1345,9 @@ impl WeightInfo for () { fn create_swap() -> Weight { // Proof Size summary in bytes: // Measured: `524` - // Estimated: `6672` - // Minimum execution time: 20_327 nanoseconds. - Weight::from_parts(21_714_000, 0) - .saturating_add(Weight::from_parts(0, 6672)) + // Estimated: `7662` + // Minimum execution time: 22_901_000 picoseconds. + Weight::from_parts(23_673_000, 7662) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1450,10 +1358,9 @@ impl WeightInfo for () { fn cancel_swap() -> Weight { // Proof Size summary in bytes: // Measured: `511` - // Estimated: `5882` - // Minimum execution time: 20_668 nanoseconds. - Weight::from_parts(21_416_000, 0) - .saturating_add(Weight::from_parts(0, 5882)) + // Estimated: `7862` + // Minimum execution time: 22_532_000 picoseconds. + Weight::from_parts(22_831_000, 7862) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1462,29 +1369,28 @@ impl WeightInfo for () { /// Storage: Nfts PendingSwapOf (r:1 w:2) /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) /// Storage: Nfts Collection (r:1 w:0) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:2 w:0) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Nfts Account (r:0 w:4) /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) /// Storage: Nfts ItemPriceOf (r:0 w:2) /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn claim_swap() -> Weight { // Proof Size summary in bytes: - // Measured: `1097` - // Estimated: `21970` - // Minimum execution time: 88_006 nanoseconds. - Weight::from_parts(90_390_000, 0) - .saturating_add(Weight::from_parts(0, 21970)) - .saturating_add(RocksDbWeight::get().reads(8_u64)) - .saturating_add(RocksDbWeight::get().writes(11_u64)) + // Measured: `896` + // Estimated: `24321` + // Minimum execution time: 77_668_000 picoseconds. + Weight::from_parts(78_407_000, 24321) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(10_u64)) } /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:2 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts Item (r:1 w:1) @@ -1502,14 +1408,13 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 10]`. fn mint_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `596` - // Estimated: `16180 + n * (2921 ±0)` - // Minimum execution time: 124_967 nanoseconds. - Weight::from_parts(131_602_642, 0) - .saturating_add(Weight::from_parts(0, 16180)) - // Standard Error: 36_480 - .saturating_add(Weight::from_parts(25_811_394, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(6_u64)) + // Measured: `659` + // Estimated: `29192 + n * (2921 ±0)` + // Minimum execution time: 133_147_000 picoseconds. + Weight::from_parts(138_031_439, 29192) + // Standard Error: 28_665 + .saturating_add(Weight::from_parts(28_206_062, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) @@ -1519,10 +1424,10 @@ impl WeightInfo for () { /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) /// Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(681), added: 3156, mode: MaxEncodedLen) - /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts Attribute (r:10 w:10) /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) @@ -1530,13 +1435,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 10]`. fn set_attributes_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `716` - // Estimated: `14198 + n * (2921 ±0)` - // Minimum execution time: 84_153 nanoseconds. - Weight::from_parts(96_401_623, 0) - .saturating_add(Weight::from_parts(0, 14198)) - // Standard Error: 70_244 - .saturating_add(Weight::from_parts(26_866_222, 0).saturating_mul(n.into())) + // Measured: `721` + // Estimated: `20142 + n * (2921 ±0)` + // Minimum execution time: 78_243_000 picoseconds. + Weight::from_parts(90_947_408, 20142) + // Standard Error: 75_516 + .saturating_add(Weight::from_parts(28_059_623, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) From 1bbde5d7c50e55458ff3925ed0ee911d035719d5 Mon Sep 17 00:00:00 2001 From: Vivek Pandya Date: Mon, 13 Mar 2023 21:00:05 +0530 Subject: [PATCH 05/80] Remove use of trait Store from all pallets and deprecate it. (#13535) * Remove use of trait Store from staking pallet * Remove use of trait Store from bounties pallet * Remove use of trait Store from collective pallet * Remove use of trait Store from babe pallet * Remove use of trait Store from assets pallet * Remove use of trait Store from grandpa pallet * Remove use of trait Store from balances pallet * Remove use of trait Store from authorship pallet * Remove use of trait Store from authority-discovery pallet * Remove use of trait Store from atomic-swap pallet * Remove use of trait Store from sudo pallet * Remove use of trait Store from scheduler pallet * Remove use of trait Store from scored-pool pallet * Remove use of trait Store from society pallet * Remove use of trait Store from lottery pallet * Remove use of trait Store from executive pallet * Remove use of trait Store from democracy pallet * Remove use of trait Store from elections-phragmen pallet * Remove use of trait Store from indices pallet * Remove use of trait Store from identity pallet * Remove use of trait Store from multisig pallet * Remove use of trait Store from merkle-mountain-range pallet * Remove use of trait Store from im-online pallet * Remove use of trait Store from membership pallet * Remove use of trait Store from nicks pallet * Remove use of trait Store from session pallet * Remove use of trait Store from transaction-payment pallet * Remove use of trait Store from utility pallet * Remove use of trait Store from child-bounties pallet * Remove use of trait Store from nis pallet * Remove use of trait Store from nfts pallet * Remove use of trait Store from conviction-voting pallet * Remove use of trait Store from treasury pallet * Remove use of trait Store from vesting pallet * Remove use of trait Store from preimage pallet * Remove use of trait Store from uniques pallet * Remove use of trait Store from ranked-collective pallet * Remove use of trait Store from beefy-mmr pallet * Remove use of trait Store from referenda pallet * Remove use of trait Store from whitelist pallet * Remove use of trait Store from alliance pallet * Remove use of trait Store from nomination-pools pallet * Remove use of trait Store from state-trie-migration pallet * Remove use of trait Store from message-queue pallet * Remove use of trait Store from root-offences pallet * Remove use of trait Store from root-testing pallet * Remove use of trait Store from timestamps pallet * Remove use of trait Store from system pallet * Remove use of trait Store from offences pallet * Remove use of trait Store from recovery pallet * Remove use of trait Store from node-authorization pallet * Remove use of trait Store from proxy pallet * Remove use of trait Store from benchmarking pallet * Remove use of trait Store from bags-list pallet * Add deprecated warning in store_trait * Change warning message * Run cargo fmt * Fix warning and update tests * Remove unnecessary allow deprecated * Remove use of trait Store * Fix mismatch in expected output * Minor update to warning message for deprecation of generate_store with Store trait attribute * Fixes as per review comments * Fixes as per review suggestions * Remove use of Store trait from core-fellowship pallet * Fix type in store_trait.rs * Fixes as pre review comment --- bin/node-template/pallets/template/src/lib.rs | 1 - frame/alliance/src/lib.rs | 1 - frame/assets/src/lib.rs | 1 - frame/atomic-swap/src/lib.rs | 1 - frame/authority-discovery/src/lib.rs | 1 - frame/authorship/src/lib.rs | 1 - frame/babe/src/lib.rs | 1 - frame/bags-list/src/lib.rs | 1 - frame/balances/src/lib.rs | 1 - frame/beefy-mmr/src/lib.rs | 1 - frame/benchmarking/pov/src/lib.rs | 1 - frame/benchmarking/src/tests.rs | 1 - frame/benchmarking/src/tests_instance.rs | 1 - frame/bounties/src/lib.rs | 1 - frame/child-bounties/src/lib.rs | 1 - frame/collective/src/lib.rs | 1 - frame/collective/src/tests.rs | 1 - frame/conviction-voting/src/lib.rs | 1 - frame/core-fellowship/src/lib.rs | 1 - frame/democracy/src/lib.rs | 1 - frame/elections-phragmen/src/lib.rs | 1 - frame/examples/basic/src/lib.rs | 1 - frame/examples/offchain-worker/src/lib.rs | 1 - frame/executive/src/lib.rs | 1 - frame/grandpa/src/lib.rs | 1 - frame/identity/src/lib.rs | 1 - frame/im-online/src/lib.rs | 1 - frame/indices/src/lib.rs | 1 - .../src/lib.rs | 4 +- frame/lottery/src/lib.rs | 1 - frame/membership/src/lib.rs | 1 - frame/merkle-mountain-range/src/lib.rs | 1 - frame/message-queue/src/lib.rs | 3 +- frame/multisig/src/lib.rs | 1 - frame/nfts/src/lib.rs | 1 - frame/nicks/src/lib.rs | 1 - frame/nis/src/lib.rs | 1 - frame/node-authorization/src/lib.rs | 1 - frame/nomination-pools/src/lib.rs | 1 - frame/offences/src/lib.rs | 1 - frame/preimage/src/lib.rs | 1 - frame/proxy/src/lib.rs | 1 - frame/ranked-collective/src/lib.rs | 1 - frame/recovery/src/lib.rs | 1 - frame/referenda/src/lib.rs | 1 - frame/root-offences/src/lib.rs | 1 - frame/root-testing/src/lib.rs | 1 - frame/salary/src/lib.rs | 1 - frame/scheduler/src/lib.rs | 1 - frame/scheduler/src/mock.rs | 1 - frame/scored-pool/src/lib.rs | 1 - frame/session/src/historical/mod.rs | 5 +-- frame/session/src/lib.rs | 1 - frame/society/src/lib.rs | 1 - frame/staking/src/migrations.rs | 2 +- frame/staking/src/pallet/impls.rs | 4 +- frame/staking/src/pallet/mod.rs | 5 +-- frame/staking/src/slashing.rs | 41 +++++++++-------- frame/staking/src/tests.rs | 44 +++++++++---------- frame/state-trie-migration/src/lib.rs | 1 - frame/sudo/src/lib.rs | 1 - frame/sudo/src/mock.rs | 1 - .../src/pallet/expand/store_trait.rs | 13 +++++- .../src/pallet/parse/pallet_struct.rs | 10 ++--- frame/support/test/tests/pallet.rs | 11 ----- frame/support/test/tests/pallet_instance.rs | 2 - .../tests/pallet_ui/deprecated_store_attr.rs | 11 +++++ .../pallet_ui/deprecated_store_attr.stderr | 9 ++++ .../tests/pallet_ui/duplicate_call_attr.rs | 1 - .../pallet_ui/duplicate_call_attr.stderr | 4 +- .../pallet_ui/duplicate_storage_prefix.rs | 1 - .../pallet_ui/duplicate_storage_prefix.stderr | 32 +++++++------- .../pallet_ui/duplicate_store_attr.stderr | 4 +- .../pallet_ui/store_trait_leak_private.stderr | 12 ++++- frame/system/benches/bench.rs | 1 - frame/system/src/lib.rs | 1 - frame/timestamp/src/lib.rs | 1 - frame/tips/src/lib.rs | 1 - .../asset-tx-payment/src/lib.rs | 1 - frame/transaction-payment/src/lib.rs | 1 - frame/transaction-storage/src/lib.rs | 1 - frame/treasury/src/lib.rs | 1 - frame/uniques/src/lib.rs | 1 - frame/utility/src/lib.rs | 1 - frame/utility/src/tests.rs | 1 - frame/vesting/src/lib.rs | 1 - frame/whitelist/src/lib.rs | 1 - test-utils/runtime/src/system.rs | 1 - utils/frame/rpc/support/src/lib.rs | 1 - 89 files changed, 119 insertions(+), 168 deletions(-) create mode 100644 frame/support/test/tests/pallet_ui/deprecated_store_attr.rs create mode 100644 frame/support/test/tests/pallet_ui/deprecated_store_attr.stderr diff --git a/bin/node-template/pallets/template/src/lib.rs b/bin/node-template/pallets/template/src/lib.rs index 4630e344add31..9f17623db328f 100644 --- a/bin/node-template/pallets/template/src/lib.rs +++ b/bin/node-template/pallets/template/src/lib.rs @@ -20,7 +20,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); /// Configure the pallet by specifying the parameters and types on which it depends. diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index c9232a1f2fb8e..6cc162f7d2f3d 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -222,7 +222,6 @@ pub mod pallet { use super::*; #[pallet::pallet] - #[pallet::generate_store(pub (super) trait Store)] #[pallet::storage_version(migration::STORAGE_VERSION)] pub struct Pallet(PhantomData<(T, I)>); diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index 662c20e00fb1a..bb0e8ce8b3704 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -197,7 +197,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs index 68d2544204b83..ed89a88698a3c 100644 --- a/frame/atomic-swap/src/lib.rs +++ b/frame/atomic-swap/src/lib.rs @@ -184,7 +184,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData); #[pallet::storage] diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index e93deabeb5318..341646b674e48 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -38,7 +38,6 @@ pub mod pallet { use frame_support::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index cb1d777fa56c3..4bb8ba587ac8b 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -49,7 +49,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::hooks] diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 903f6249e3310..61284267b07e7 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -114,7 +114,6 @@ pub mod pallet { /// The BABE Pallet #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/bags-list/src/lib.rs b/frame/bags-list/src/lib.rs index b65b65c39223d..87eb2d1b341aa 100644 --- a/frame/bags-list/src/lib.rs +++ b/frame/bags-list/src/lib.rs @@ -99,7 +99,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(crate) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index f02c7f9c0c579..ecd7e171e39ec 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -253,7 +253,6 @@ pub mod pallet { frame_support::traits::StorageVersion::new(1); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(PhantomData<(T, I)>); diff --git a/frame/beefy-mmr/src/lib.rs b/frame/beefy-mmr/src/lib.rs index ba52be4f883f0..b9d4bdfd8eb59 100644 --- a/frame/beefy-mmr/src/lib.rs +++ b/frame/beefy-mmr/src/lib.rs @@ -95,7 +95,6 @@ pub mod pallet { /// BEEFY-MMR pallet. #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); /// The module's configuration trait. diff --git a/frame/benchmarking/pov/src/lib.rs b/frame/benchmarking/pov/src/lib.rs index b66b5e417817a..dccfe72d3f243 100644 --- a/frame/benchmarking/pov/src/lib.rs +++ b/frame/benchmarking/pov/src/lib.rs @@ -32,7 +32,6 @@ pub mod pallet { use sp_std::prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData); #[pallet::config] diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index a3e19cde3642e..453e8e125cbb3 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -35,7 +35,6 @@ mod pallet_test { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData); #[pallet::config] diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 49f9786d77ea1..d49d7cc817c6b 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -34,7 +34,6 @@ mod pallet_test { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData<(T, I)>); pub trait OtherConfig { diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs index 325347502a918..e7a3e2053c065 100644 --- a/frame/bounties/src/lib.rs +++ b/frame/bounties/src/lib.rs @@ -188,7 +188,6 @@ pub mod pallet { use super::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/child-bounties/src/lib.rs b/frame/child-bounties/src/lib.rs index 3046d97007cae..094b41822c433 100644 --- a/frame/child-bounties/src/lib.rs +++ b/frame/child-bounties/src/lib.rs @@ -130,7 +130,6 @@ pub mod pallet { use super::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index ae5b22559d7c8..c58965d2c9199 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -175,7 +175,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] #[pallet::without_storage_info] pub struct Pallet(PhantomData<(T, I)>); diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 2d9b31a539d59..79f6cc27fadbd 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -57,7 +57,6 @@ mod mock_democracy { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index 6c15c6cf25b13..f28953c4a35b9 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -92,7 +92,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/core-fellowship/src/lib.rs b/frame/core-fellowship/src/lib.rs index 6ba60dbaf2559..93d2302448989 100644 --- a/frame/core-fellowship/src/lib.rs +++ b/frame/core-fellowship/src/lib.rs @@ -148,7 +148,6 @@ pub mod pallet { const RANK_COUNT: usize = 9; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData<(T, I)>); #[pallet::config] diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index e1e111e96313f..a3d7f103a98f3 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -217,7 +217,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index fa63762c5e09a..e3eed6ec4bcc4 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -187,7 +187,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] #[pallet::without_storage_info] pub struct Pallet(PhantomData); diff --git a/frame/examples/basic/src/lib.rs b/frame/examples/basic/src/lib.rs index a75a0e17cceba..6665c3b78b024 100644 --- a/frame/examples/basic/src/lib.rs +++ b/frame/examples/basic/src/lib.rs @@ -379,7 +379,6 @@ pub mod pallet { // Simple declaration of the `Pallet` type. It is placeholder we use to implement traits and // method. #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); // Pallet implements [`Hooks`] trait to define some logic to execute in some context. diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index c9c72f8e82514..418ad5d139ef3 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -158,7 +158,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::hooks] diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index b3a04c4fe0596..7a8de43140c35 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -706,7 +706,6 @@ mod tests { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 538cd365b5a1a..f01c25e49edd4 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -77,7 +77,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index d1b764591dc79..f192ee2b461b3 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -152,7 +152,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); /// Information that is pertinent to identify the entity behind an account. diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 39762945ca70e..bc1e541cef125 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -313,7 +313,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/indices/src/lib.rs b/frame/indices/src/lib.rs index 82dc48f7bce5b..74f86abb51914 100644 --- a/frame/indices/src/lib.rs +++ b/frame/indices/src/lib.rs @@ -75,7 +75,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData); #[pallet::call] diff --git a/frame/insecure-randomness-collective-flip/src/lib.rs b/frame/insecure-randomness-collective-flip/src/lib.rs index c73419efe87fe..ad39c4c4fd885 100644 --- a/frame/insecure-randomness-collective-flip/src/lib.rs +++ b/frame/insecure-randomness-collective-flip/src/lib.rs @@ -17,7 +17,7 @@ //! # DO NOT USE IN PRODUCTION //! -//! The produced values do not fulfill the cryptographic requirements for random numbers. +//! The produced values do not fulfill the cryptographic requirements for random numbers. //! Should not be used for high-stake production use-cases. //! //! # Randomness Pallet @@ -51,7 +51,6 @@ //! use frame_system::pallet_prelude::*; //! //! #[pallet::pallet] -//! #[pallet::generate_store(pub(super) trait Store)] //! pub struct Pallet(_); //! //! #[pallet::config] @@ -94,7 +93,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index bd7ca40fb4556..178f221a8946f 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -123,7 +123,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); /// The pallet's config trait. diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 04263b93e1a89..0be33a95613fe 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -50,7 +50,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(PhantomData<(T, I)>); diff --git a/frame/merkle-mountain-range/src/lib.rs b/frame/merkle-mountain-range/src/lib.rs index 0b4c2f8d97a8b..4ef833e6c5fca 100644 --- a/frame/merkle-mountain-range/src/lib.rs +++ b/frame/merkle-mountain-range/src/lib.rs @@ -121,7 +121,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData<(T, I)>); /// This pallet's configuration trait diff --git a/frame/message-queue/src/lib.rs b/frame/message-queue/src/lib.rs index bed131e5f0669..c8e1976103ebf 100644 --- a/frame/message-queue/src/lib.rs +++ b/frame/message-queue/src/lib.rs @@ -39,7 +39,7 @@ //! which queue it will be stored. Messages are stored by being appended to the last [`Page`] of a //! book. Each book keeps track of its pages by indexing `Pages`. The `ReadyRing` contains all //! queues which hold at least one unprocessed message and are thereby *ready* to be serviced. The -//! `ServiceHead` indicates which *ready* queue is the next to be serviced. +//! `ServiceHead` indicates which *ready* queue is the next to be serviced. //! The pallet implements [`frame_support::traits::EnqueueMessage`], //! [`frame_support::traits::ServiceQueues`] and has [`frame_support::traits::ProcessMessage`] and //! [`OnQueueChanged`] hooks to communicate with the outside world. @@ -438,7 +438,6 @@ pub mod pallet { use super::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); /// The module configuration trait. diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index fb10838cedc44..64058be9c8fbf 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -172,7 +172,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 4d9547659a2a7..254fa75964ab8 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -75,7 +75,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(PhantomData<(T, I)>); diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index b457cc2996dbf..b74d2e6ee40b2 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -114,7 +114,6 @@ pub mod pallet { StorageMap<_, Twox64Concat, T::AccountId, (BoundedVec, BalanceOf)>; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::call] diff --git a/frame/nis/src/lib.rs b/frame/nis/src/lib.rs index 9cae5e2aae5c1..6fd9c60a89836 100644 --- a/frame/nis/src/lib.rs +++ b/frame/nis/src/lib.rs @@ -310,7 +310,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); /// A single bid, an item of a *queue* in `Queues`. diff --git a/frame/node-authorization/src/lib.rs b/frame/node-authorization/src/lib.rs index d91a769b36ba0..eaeda3cade9e9 100644 --- a/frame/node-authorization/src/lib.rs +++ b/frame/node-authorization/src/lib.rs @@ -59,7 +59,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::without_storage_info] pub struct Pallet(_); diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index b296eb048562a..c1dda69ab5d67 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -1214,7 +1214,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(3); #[pallet::pallet] - #[pallet::generate_store(pub(crate) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); diff --git a/frame/offences/src/lib.rs b/frame/offences/src/lib.rs index 8ac1ca0bd734c..c89d93c12bd95 100644 --- a/frame/offences/src/lib.rs +++ b/frame/offences/src/lib.rs @@ -49,7 +49,6 @@ pub mod pallet { use frame_support::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::without_storage_info] pub struct Pallet(_); diff --git a/frame/preimage/src/lib.rs b/frame/preimage/src/lib.rs index 74a3176b1144a..60208424db953 100644 --- a/frame/preimage/src/lib.rs +++ b/frame/preimage/src/lib.rs @@ -107,7 +107,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(PhantomData); diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index c26a53d1a0c40..023d0253519f7 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -102,7 +102,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); /// Configuration trait. diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index 8ed1bbd2e01d6..288fd78d6e718 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -321,7 +321,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData<(T, I)>); #[pallet::config] diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index b32d19d5dda1d..d66b5725fd4f7 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -218,7 +218,6 @@ pub mod pallet { use sp_runtime::ArithmeticError; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); /// Configuration trait. diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index dccc40112867d..f699850062267 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -145,7 +145,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); diff --git a/frame/root-offences/src/lib.rs b/frame/root-offences/src/lib.rs index 92f3e17b5e17e..a93e7ff848718 100644 --- a/frame/root-offences/src/lib.rs +++ b/frame/root-offences/src/lib.rs @@ -57,7 +57,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::event] diff --git a/frame/root-testing/src/lib.rs b/frame/root-testing/src/lib.rs index ad0e4cfea7373..e04c7bfa13d26 100644 --- a/frame/root-testing/src/lib.rs +++ b/frame/root-testing/src/lib.rs @@ -39,7 +39,6 @@ pub mod pallet { pub trait Config: frame_system::Config {} #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::call] diff --git a/frame/salary/src/lib.rs b/frame/salary/src/lib.rs index 5a4ff8a66da50..6f9e63271cc2f 100644 --- a/frame/salary/src/lib.rs +++ b/frame/salary/src/lib.rs @@ -155,7 +155,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData<(T, I)>); #[pallet::config] diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index 95bfe8411f381..09bb3561188f8 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -172,7 +172,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 914a97ab9d5d7..adb54fd78b181 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -50,7 +50,6 @@ pub mod logger { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData); #[pallet::hooks] diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index 16d59b6609000..336a69a798477 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -135,7 +135,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/session/src/historical/mod.rs b/frame/session/src/historical/mod.rs index d9827679400b8..f00a1c95e763e 100644 --- a/frame/session/src/historical/mod.rs +++ b/frame/session/src/historical/mod.rs @@ -62,7 +62,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); @@ -97,7 +96,7 @@ impl Pallet { /// Prune historical stored session roots up to (but not including) /// `up_to`. pub fn prune_up_to(up_to: SessionIndex) { - ::StoredRange::mutate(|range| { + StoredRange::::mutate(|range| { let (start, end) = match *range { Some(range) => range, None => return, // nothing to prune. @@ -109,7 +108,7 @@ impl Pallet { return // out of bounds. harmless. } - (start..up_to).for_each(::HistoricalSessions::remove); + (start..up_to).for_each(HistoricalSessions::::remove); let new_start = up_to; *range = if new_start == end { diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 7d5dd632493f3..ed5f80e6099c1 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -371,7 +371,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(0); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] #[pallet::without_storage_info] pub struct Pallet(_); diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index f3207dabdaf8f..899b6005af024 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -371,7 +371,6 @@ pub mod pallet { use super::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::without_storage_info] pub struct Pallet(_); diff --git a/frame/staking/src/migrations.rs b/frame/staking/src/migrations.rs index 3c33ae2a35d62..23bcfa4398627 100644 --- a/frame/staking/src/migrations.rs +++ b/frame/staking/src/migrations.rs @@ -265,7 +265,7 @@ pub mod v10 { impl OnRuntimeUpgrade for MigrateToV10 { fn on_runtime_upgrade() -> frame_support::weights::Weight { if StorageVersion::::get() == ObsoleteReleases::V9_0_0 { - let pending_slashes = as Store>::UnappliedSlashes::iter().take(512); + let pending_slashes = UnappliedSlashes::::iter().take(512); for (era, slashes) in pending_slashes { for slash in slashes { // in the old slashing scheme, the slash era was the key at which we read diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 78c9a51bc829c..760345e8ddb28 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -682,7 +682,7 @@ impl Pallet { /// Apply previously-unapplied slashes on the beginning of a new era, after a delay. fn apply_unapplied_slashes(active_era: EraIndex) { - let era_slashes = ::UnappliedSlashes::take(&active_era); + let era_slashes = UnappliedSlashes::::take(&active_era); log!( debug, "found {} slashes scheduled to be executed in era {:?}", @@ -1369,7 +1369,7 @@ where active_era, slash_era + slash_defer_duration + 1, ); - ::UnappliedSlashes::mutate( + UnappliedSlashes::::mutate( slash_era.saturating_add(slash_defer_duration).saturating_add(One::one()), move |for_later| for_later.push(unapplied), ); diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index a030538878241..d8f1855da4bc0 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -68,7 +68,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(13); #[pallet::pallet] - #[pallet::generate_store(pub(crate) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); @@ -1452,7 +1451,7 @@ pub mod pallet { ensure!(!slash_indices.is_empty(), Error::::EmptyTargets); ensure!(is_sorted_and_unique(&slash_indices), Error::::NotSortedAndUnique); - let mut unapplied = ::UnappliedSlashes::get(&era); + let mut unapplied = UnappliedSlashes::::get(&era); let last_item = slash_indices[slash_indices.len() - 1]; ensure!((last_item as usize) < unapplied.len(), Error::::InvalidSlashIndex); @@ -1461,7 +1460,7 @@ pub mod pallet { unapplied.remove(index); } - ::UnappliedSlashes::insert(&era, &unapplied); + UnappliedSlashes::::insert(&era, &unapplied); Ok(()) } diff --git a/frame/staking/src/slashing.rs b/frame/staking/src/slashing.rs index f73e3a6f818a2..bb02da73f6e5d 100644 --- a/frame/staking/src/slashing.rs +++ b/frame/staking/src/slashing.rs @@ -50,8 +50,9 @@ //! Based on research at use crate::{ - BalanceOf, Config, Error, Exposure, NegativeImbalanceOf, Pallet, Perbill, SessionInterface, - Store, UnappliedSlash, + BalanceOf, Config, Error, Exposure, NegativeImbalanceOf, NominatorSlashInEra, + OffendingValidators, Pallet, Perbill, SessionInterface, SpanSlash, UnappliedSlash, + ValidatorSlashInEra, }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ @@ -239,14 +240,13 @@ pub(crate) fn compute_slash( return None } - let prior_slash_p = - as Store>::ValidatorSlashInEra::get(¶ms.slash_era, params.stash) - .map_or(Zero::zero(), |(prior_slash_proportion, _)| prior_slash_proportion); + let prior_slash_p = ValidatorSlashInEra::::get(¶ms.slash_era, params.stash) + .map_or(Zero::zero(), |(prior_slash_proportion, _)| prior_slash_proportion); // compare slash proportions rather than slash values to avoid issues due to rounding // error. if params.slash.deconstruct() > prior_slash_p.deconstruct() { - as Store>::ValidatorSlashInEra::insert( + ValidatorSlashInEra::::insert( ¶ms.slash_era, params.stash, &(params.slash, own_slash), @@ -327,7 +327,7 @@ fn kick_out_if_recent(params: SlashParams) { /// If after adding the validator `OffendingValidatorsThreshold` is reached /// a new era will be forced. fn add_offending_validator(stash: &T::AccountId, disable: bool) { - as Store>::OffendingValidators::mutate(|offending| { + OffendingValidators::::mutate(|offending| { let validators = T::SessionInterface::validators(); let validator_index = match validators.iter().position(|i| i == stash) { Some(index) => index, @@ -388,10 +388,9 @@ fn slash_nominators( let own_slash_difference = own_slash_by_validator.saturating_sub(own_slash_prior); let mut era_slash = - as Store>::NominatorSlashInEra::get(¶ms.slash_era, stash) - .unwrap_or_else(Zero::zero); + NominatorSlashInEra::::get(¶ms.slash_era, stash).unwrap_or_else(Zero::zero); era_slash += own_slash_difference; - as Store>::NominatorSlashInEra::insert(¶ms.slash_era, stash, &era_slash); + NominatorSlashInEra::::insert(¶ms.slash_era, stash, &era_slash); era_slash }; @@ -445,9 +444,9 @@ fn fetch_spans<'a, T: Config + 'a>( slash_of: &'a mut BalanceOf, reward_proportion: Perbill, ) -> InspectingSpans<'a, T> { - let spans = as Store>::SlashingSpans::get(stash).unwrap_or_else(|| { + let spans = crate::SlashingSpans::::get(stash).unwrap_or_else(|| { let spans = SlashingSpans::new(window_start); - as Store>::SlashingSpans::insert(stash, &spans); + crate::SlashingSpans::::insert(stash, &spans); spans }); @@ -496,7 +495,7 @@ impl<'a, T: 'a + Config> InspectingSpans<'a, T> { ) -> Option { let target_span = self.era_span(slash_era)?; let span_slash_key = (self.stash.clone(), target_span.index); - let mut span_record = as Store>::SpanSlash::get(&span_slash_key); + let mut span_record = SpanSlash::::get(&span_slash_key); let mut changed = false; let reward = if span_record.slashed < slash { @@ -527,7 +526,7 @@ impl<'a, T: 'a + Config> InspectingSpans<'a, T> { if changed { self.dirty = true; - as Store>::SpanSlash::insert(&span_slash_key, &span_record); + SpanSlash::::insert(&span_slash_key, &span_record); } Some(target_span.index) @@ -543,20 +542,20 @@ impl<'a, T: 'a + Config> Drop for InspectingSpans<'a, T> { if let Some((start, end)) = self.spans.prune(self.window_start) { for span_index in start..end { - as Store>::SpanSlash::remove(&(self.stash.clone(), span_index)); + SpanSlash::::remove(&(self.stash.clone(), span_index)); } } - as Store>::SlashingSpans::insert(self.stash, &self.spans); + crate::SlashingSpans::::insert(self.stash, &self.spans); } } /// Clear slashing metadata for an obsolete era. pub(crate) fn clear_era_metadata(obsolete_era: EraIndex) { #[allow(deprecated)] - as Store>::ValidatorSlashInEra::remove_prefix(&obsolete_era, None); + ValidatorSlashInEra::::remove_prefix(&obsolete_era, None); #[allow(deprecated)] - as Store>::NominatorSlashInEra::remove_prefix(&obsolete_era, None); + NominatorSlashInEra::::remove_prefix(&obsolete_era, None); } /// Clear slashing metadata for a dead account. @@ -564,7 +563,7 @@ pub(crate) fn clear_stash_metadata( stash: &T::AccountId, num_slashing_spans: u32, ) -> DispatchResult { - let spans = match as Store>::SlashingSpans::get(stash) { + let spans = match crate::SlashingSpans::::get(stash) { None => return Ok(()), Some(s) => s, }; @@ -574,7 +573,7 @@ pub(crate) fn clear_stash_metadata( Error::::IncorrectSlashingSpans ); - as Store>::SlashingSpans::remove(stash); + crate::SlashingSpans::::remove(stash); // kill slashing-span metadata for account. // @@ -582,7 +581,7 @@ pub(crate) fn clear_stash_metadata( // in that case, they may re-bond, but it would count again as span 0. Further ancient // slashes would slash into this new bond, since metadata has now been cleared. for span in spans.iter() { - as Store>::SpanSlash::remove(&(stash.clone(), span.index)); + SpanSlash::::remove(&(stash.clone(), span.index)); } Ok(()) diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 16bafae01e3c3..966eae8c1da9a 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -512,10 +512,10 @@ fn no_candidate_emergency_condition() { // initial validators assert_eq_uvec!(validator_controllers(), vec![10, 20, 30, 40]); let prefs = ValidatorPrefs { commission: Perbill::one(), ..Default::default() }; - ::Validators::insert(11, prefs.clone()); + Validators::::insert(11, prefs.clone()); // set the minimum validator count. - ::MinimumValidatorCount::put(10); + MinimumValidatorCount::::put(10); // try to chill let res = Staking::chill(RuntimeOrigin::signed(10)); @@ -536,7 +536,7 @@ fn no_candidate_emergency_condition() { // changed) assert_eq_uvec!(validator_controllers(), vec![10, 20, 30, 40]); // The chill is still pending. - assert!(!::Validators::contains_key(11)); + assert!(!Validators::::contains_key(11)); // No new era is created. assert_eq!(current_era, CurrentEra::::get()); }); @@ -2432,7 +2432,7 @@ fn slash_in_old_span_does_not_deselect() { ); // the validator doesn't get chilled again - assert!(::Validators::iter().any(|(stash, _)| stash == 11)); + assert!(Validators::::iter().any(|(stash, _)| stash == 11)); // but we are still forcing a new era assert_eq!(Staking::force_era(), Forcing::ForceNew); @@ -2449,7 +2449,7 @@ fn slash_in_old_span_does_not_deselect() { ); // the validator doesn't get chilled again - assert!(::Validators::iter().any(|(stash, _)| stash == 11)); + assert!(Validators::::iter().any(|(stash, _)| stash == 11)); // but it's disabled assert!(is_disabled(10)); @@ -2648,8 +2648,8 @@ fn garbage_collection_after_slashing() { ); assert_eq!(Balances::free_balance(11), 2000 - 200); - assert!(::SlashingSpans::get(&11).is_some()); - assert_eq!(::SpanSlash::get(&(11, 0)).amount(), &200); + assert!(SlashingSpans::::get(&11).is_some()); + assert_eq!(SpanSlash::::get(&(11, 0)).amount(), &200); on_offence_now( &[OffenceDetails { @@ -2665,7 +2665,7 @@ fn garbage_collection_after_slashing() { assert_eq!(Balances::free_balance(11), 2); assert_eq!(Balances::total_balance(&11), 2); - let slashing_spans = ::SlashingSpans::get(&11).unwrap(); + let slashing_spans = SlashingSpans::::get(&11).unwrap(); assert_eq!(slashing_spans.iter().count(), 2); // reap_stash respects num_slashing_spans so that weight is accurate @@ -2675,8 +2675,8 @@ fn garbage_collection_after_slashing() { ); assert_ok!(Staking::reap_stash(RuntimeOrigin::signed(20), 11, 2)); - assert!(::SlashingSpans::get(&11).is_none()); - assert_eq!(::SpanSlash::get(&(11, 0)).amount(), &0); + assert!(SlashingSpans::::get(&11).is_none()); + assert_eq!(SpanSlash::::get(&(11, 0)).amount(), &0); }) } @@ -2702,19 +2702,19 @@ fn garbage_collection_on_window_pruning() { assert_eq!(Balances::free_balance(11), 900); assert_eq!(Balances::free_balance(101), 2000 - (nominated_value / 10)); - assert!(::ValidatorSlashInEra::get(&now, &11).is_some()); - assert!(::NominatorSlashInEra::get(&now, &101).is_some()); + assert!(ValidatorSlashInEra::::get(&now, &11).is_some()); + assert!(NominatorSlashInEra::::get(&now, &101).is_some()); // + 1 because we have to exit the bonding window. for era in (0..(BondingDuration::get() + 1)).map(|offset| offset + now + 1) { - assert!(::ValidatorSlashInEra::get(&now, &11).is_some()); - assert!(::NominatorSlashInEra::get(&now, &101).is_some()); + assert!(ValidatorSlashInEra::::get(&now, &11).is_some()); + assert!(NominatorSlashInEra::::get(&now, &101).is_some()); mock::start_active_era(era); } - assert!(::ValidatorSlashInEra::get(&now, &11).is_none()); - assert!(::NominatorSlashInEra::get(&now, &101).is_none()); + assert!(ValidatorSlashInEra::::get(&now, &11).is_none()); + assert!(NominatorSlashInEra::::get(&now, &101).is_none()); }) } @@ -2755,7 +2755,7 @@ fn slashing_nominators_by_span_max() { slashing::SlashingSpan { index: 0, start: 0, length: Some(4) }, ]; - let get_span = |account| ::SlashingSpans::get(&account).unwrap(); + let get_span = |account| SlashingSpans::::get(&account).unwrap(); assert_eq!(get_span(11).iter().collect::>(), expected_spans); @@ -2817,7 +2817,7 @@ fn slashes_are_summed_across_spans() { assert_eq!(Balances::free_balance(21), 2000); assert_eq!(Staking::slashable_balance_of(&21), 1000); - let get_span = |account| ::SlashingSpans::get(&account).unwrap(); + let get_span = |account| SlashingSpans::::get(&account).unwrap(); on_offence_now( &[OffenceDetails { @@ -3192,7 +3192,7 @@ fn remove_multi_deferred() { &[Perbill::from_percent(25)], ); - assert_eq!(::UnappliedSlashes::get(&4).len(), 5); + assert_eq!(UnappliedSlashes::::get(&4).len(), 5); // fails if list is not sorted assert_noop!( @@ -3212,7 +3212,7 @@ fn remove_multi_deferred() { assert_ok!(Staking::cancel_deferred_slash(RuntimeOrigin::root(), 4, vec![0, 2, 4])); - let slashes = ::UnappliedSlashes::get(&4); + let slashes = UnappliedSlashes::::get(&4); assert_eq!(slashes.len(), 2); assert_eq!(slashes[0].validator, 21); assert_eq!(slashes[1].validator, 42); @@ -3267,7 +3267,7 @@ fn slash_kicks_validators_not_nominators_and_disables_nominator_for_kicked_valid assert_eq!(Balances::free_balance(101), 2000 - nominator_slash_amount_11); // check that validator was chilled. - assert!(::Validators::iter().all(|(stash, _)| stash != 11)); + assert!(Validators::::iter().all(|(stash, _)| stash != 11)); // actually re-bond the slashed validator assert_ok!(Staking::validate(RuntimeOrigin::signed(10), Default::default())); @@ -3612,7 +3612,7 @@ fn zero_slash_keeps_nominators() { assert_eq!(Balances::free_balance(101), 2000); // 11 is still removed.. - assert!(::Validators::iter().all(|(stash, _)| stash != 11)); + assert!(Validators::::iter().all(|(stash, _)| stash != 11)); // but their nominations are kept. assert_eq!(Staking::nominators(101).unwrap().targets, vec![11, 21]); }); diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 547dfa5cda9c8..5385c6b5f4f46 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -439,7 +439,6 @@ pub mod pallet { /// The outer Pallet struct. #[pallet::pallet] - #[pallet::generate_store(pub(crate) trait Store)] pub struct Pallet(_); /// Configurations of this pallet. diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index 4d5149926ac29..47309833a0681 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -133,7 +133,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData); #[pallet::call] diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 59a5cb6cc1a15..6d6043cfd1821 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -39,7 +39,6 @@ pub mod logger { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData); #[pallet::call] diff --git a/frame/support/procedural/src/pallet/expand/store_trait.rs b/frame/support/procedural/src/pallet/expand/store_trait.rs index 15a6a223e9708..251c88f08e7a0 100644 --- a/frame/support/procedural/src/pallet/expand/store_trait.rs +++ b/frame/support/procedural/src/pallet/expand/store_trait.rs @@ -22,7 +22,7 @@ use syn::spanned::Spanned; /// * generate Store trait with all storages, /// * implement Store trait for Pallet. pub fn expand_store_trait(def: &mut Def) -> proc_macro2::TokenStream { - let (trait_vis, trait_store) = + let (trait_vis, trait_store, attribute_span) = if let Some(store) = &def.pallet_struct.store { store } else { return Default::default() }; let type_impl_gen = &def.type_impl_generics(trait_store.span()); @@ -36,8 +36,19 @@ pub fn expand_store_trait(def: &mut Def) -> proc_macro2::TokenStream { let storage_names = &def.storages.iter().map(|storage| &storage.ident).collect::>(); let storage_cfg_attrs = &def.storages.iter().map(|storage| &storage.cfg_attrs).collect::>(); + let warnig_struct_name = syn::Ident::new("Store", *attribute_span); + let warning: syn::ItemStruct = syn::parse_quote!( + #[deprecated(note = r" + Use of `#[pallet::generate_store(pub(super) trait Store)]` will be removed soon. + Check https://github.com/paritytech/substrate/pull/13535 for more details.")] + struct #warnig_struct_name; + ); quote::quote_spanned!(trait_store.span() => + const _:() = { + #warning + const _: Option<#warnig_struct_name> = None; + }; #trait_vis trait #trait_store { #( #(#storage_cfg_attrs)* diff --git a/frame/support/procedural/src/pallet/parse/pallet_struct.rs b/frame/support/procedural/src/pallet/parse/pallet_struct.rs index 571298d5a12ec..98312d0652d8e 100644 --- a/frame/support/procedural/src/pallet/parse/pallet_struct.rs +++ b/frame/support/procedural/src/pallet/parse/pallet_struct.rs @@ -38,7 +38,7 @@ pub struct PalletStructDef { /// The keyword Pallet used (contains span). pub pallet: keyword::Pallet, /// Whether the trait `Store` must be generated. - pub store: Option<(syn::Visibility, keyword::Store)>, + pub store: Option<(syn::Visibility, keyword::Store, proc_macro2::Span)>, /// The span of the pallet::pallet attribute. pub attr_span: proc_macro2::Span, /// Whether to specify the storages max encoded len when implementing `StorageInfoTrait`. @@ -78,13 +78,13 @@ impl syn::parse::Parse for PalletStructAttr { let lookahead = content.lookahead1(); if lookahead.peek(keyword::generate_store) { - let span = content.parse::()?.span(); - + content.parse::()?; let generate_content; syn::parenthesized!(generate_content in content); let vis = generate_content.parse::()?; generate_content.parse::()?; let keyword = generate_content.parse::()?; + let span = content.span(); Ok(Self::GenerateStore { vis, keyword, span }) } else if lookahead.peek(keyword::without_storage_info) { let span = content.parse::()?.span(); @@ -123,8 +123,8 @@ impl PalletStructDef { let struct_attrs: Vec = helper::take_item_pallet_attrs(&mut item.attrs)?; for attr in struct_attrs { match attr { - PalletStructAttr::GenerateStore { vis, keyword, .. } if store.is_none() => { - store = Some((vis, keyword)); + PalletStructAttr::GenerateStore { vis, keyword, span } if store.is_none() => { + store = Some((vis, keyword, span)); }, PalletStructAttr::WithoutStorageInfoTrait(span) if without_storage_info.is_none() => diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index c33d2c8c9cf25..8e77cd0251184 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -158,7 +158,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(crate) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); @@ -496,7 +495,6 @@ pub mod pallet2 { } #[pallet::pallet] - #[pallet::generate_store(pub(crate) trait Store)] #[pallet::without_storage_info] pub struct Pallet(_); @@ -946,15 +944,6 @@ fn validate_unsigned_expand() { assert_eq!(validity, ValidTransaction::default()); } -#[test] -fn trait_store_expand() { - TestExternalities::default().execute_with(|| { - as pallet::Store>::Value::get(); - as pallet::Store>::Map::get(1); - as pallet::Store>::DoubleMap::get(1, 2); - }) -} - #[test] fn pallet_expand_deposit_event() { TestExternalities::default().execute_with(|| { diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 5beb1480a4e82..517f920c5ce07 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -46,7 +46,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(crate) trait Store)] pub struct Pallet(PhantomData<(T, I)>); #[pallet::hooks] @@ -260,7 +259,6 @@ pub mod pallet2 { } #[pallet::pallet] - #[pallet::generate_store(pub(crate) trait Store)] pub struct Pallet(PhantomData<(T, I)>); #[pallet::event] diff --git a/frame/support/test/tests/pallet_ui/deprecated_store_attr.rs b/frame/support/test/tests/pallet_ui/deprecated_store_attr.rs new file mode 100644 index 0000000000000..0799a3fce8d58 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/deprecated_store_attr.rs @@ -0,0 +1,11 @@ +#[frame_support::pallet] +mod pallet { + #[pallet::config] + pub trait Config: frame_system::Config {} + + #[pallet::pallet] + #[pallet::generate_store(trait Store)] + pub struct Pallet(core::marker::PhantomData); +} + +fn main() {} diff --git a/frame/support/test/tests/pallet_ui/deprecated_store_attr.stderr b/frame/support/test/tests/pallet_ui/deprecated_store_attr.stderr new file mode 100644 index 0000000000000..bbc4743fc1003 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/deprecated_store_attr.stderr @@ -0,0 +1,9 @@ +error: use of deprecated struct `pallet::_::Store`: + Use of `#[pallet::generate_store(pub(super) trait Store)]` will be removed soon. + Check https://github.com/paritytech/substrate/pull/13535 for more details. + --> tests/pallet_ui/deprecated_store_attr.rs:7:3 + | +7 | #[pallet::generate_store(trait Store)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D deprecated` implied by `-D warnings` diff --git a/frame/support/test/tests/pallet_ui/duplicate_call_attr.rs b/frame/support/test/tests/pallet_ui/duplicate_call_attr.rs index b8a32a0bd9f69..6d781a19e6742 100644 --- a/frame/support/test/tests/pallet_ui/duplicate_call_attr.rs +++ b/frame/support/test/tests/pallet_ui/duplicate_call_attr.rs @@ -8,7 +8,6 @@ mod pallet { pub trait Config: frame_system::Config {} #[pallet::pallet] - #[pallet::generate_store(trait Store)] pub struct Pallet(core::marker::PhantomData); #[pallet::hooks] diff --git a/frame/support/test/tests/pallet_ui/duplicate_call_attr.stderr b/frame/support/test/tests/pallet_ui/duplicate_call_attr.stderr index c2956717bb2bb..2b03f41024351 100644 --- a/frame/support/test/tests/pallet_ui/duplicate_call_attr.stderr +++ b/frame/support/test/tests/pallet_ui/duplicate_call_attr.stderr @@ -1,5 +1,5 @@ error: Invalid duplicated attribute - --> $DIR/duplicate_call_attr.rs:23:12 + --> $DIR/duplicate_call_attr.rs:22:12 | -23 | #[pallet::call] +22 | #[pallet::call] | ^^^^ diff --git a/frame/support/test/tests/pallet_ui/duplicate_storage_prefix.rs b/frame/support/test/tests/pallet_ui/duplicate_storage_prefix.rs index 5e99c84050c95..543c15bd06905 100644 --- a/frame/support/test/tests/pallet_ui/duplicate_storage_prefix.rs +++ b/frame/support/test/tests/pallet_ui/duplicate_storage_prefix.rs @@ -6,7 +6,6 @@ mod pallet { pub trait Config: frame_system::Config {} #[pallet::pallet] - #[pallet::generate_store(trait Store)] pub struct Pallet(core::marker::PhantomData); #[pallet::storage] diff --git a/frame/support/test/tests/pallet_ui/duplicate_storage_prefix.stderr b/frame/support/test/tests/pallet_ui/duplicate_storage_prefix.stderr index 716888c9d8b65..75297dc5a7f79 100644 --- a/frame/support/test/tests/pallet_ui/duplicate_storage_prefix.stderr +++ b/frame/support/test/tests/pallet_ui/duplicate_storage_prefix.stderr @@ -1,47 +1,47 @@ error: Duplicate storage prefixes found for `Foo` - --> $DIR/duplicate_storage_prefix.rs:16:29 + --> $DIR/duplicate_storage_prefix.rs:15:29 | -16 | #[pallet::storage_prefix = "Foo"] +15 | #[pallet::storage_prefix = "Foo"] | ^^^^^ error: Duplicate storage prefixes found for `Foo` - --> $DIR/duplicate_storage_prefix.rs:13:7 + --> $DIR/duplicate_storage_prefix.rs:12:7 | -13 | type Foo = StorageValue<_, u8>; +12 | type Foo = StorageValue<_, u8>; | ^^^ error: Duplicate storage prefixes found for `CounterForBar`, used for counter associated to counted storage map - --> $DIR/duplicate_storage_prefix.rs:23:7 + --> $DIR/duplicate_storage_prefix.rs:22:7 | -23 | type Bar = CountedStorageMap<_, Twox64Concat, u16, u16>; +22 | type Bar = CountedStorageMap<_, Twox64Concat, u16, u16>; | ^^^ error: Duplicate storage prefixes found for `CounterForBar` - --> $DIR/duplicate_storage_prefix.rs:20:7 + --> $DIR/duplicate_storage_prefix.rs:19:7 | -20 | type CounterForBar = StorageValue<_, u16>; +19 | type CounterForBar = StorageValue<_, u16>; | ^^^^^^^^^^^^^ error[E0412]: cannot find type `_GeneratedPrefixForStorageFoo` in this scope - --> $DIR/duplicate_storage_prefix.rs:13:7 + --> $DIR/duplicate_storage_prefix.rs:12:7 | -13 | type Foo = StorageValue<_, u8>; +12 | type Foo = StorageValue<_, u8>; | ^^^ not found in this scope error[E0412]: cannot find type `_GeneratedPrefixForStorageNotFoo` in this scope - --> $DIR/duplicate_storage_prefix.rs:17:7 + --> $DIR/duplicate_storage_prefix.rs:16:7 | -17 | type NotFoo = StorageValue<_, u16>; +16 | type NotFoo = StorageValue<_, u16>; | ^^^^^^ not found in this scope error[E0412]: cannot find type `_GeneratedPrefixForStorageCounterForBar` in this scope - --> $DIR/duplicate_storage_prefix.rs:20:7 + --> $DIR/duplicate_storage_prefix.rs:19:7 | -20 | type CounterForBar = StorageValue<_, u16>; +19 | type CounterForBar = StorageValue<_, u16>; | ^^^^^^^^^^^^^ not found in this scope error[E0412]: cannot find type `_GeneratedPrefixForStorageBar` in this scope - --> $DIR/duplicate_storage_prefix.rs:23:7 + --> $DIR/duplicate_storage_prefix.rs:22:7 | -23 | type Bar = CountedStorageMap<_, Twox64Concat, u16, u16>; +22 | type Bar = CountedStorageMap<_, Twox64Concat, u16, u16>; | ^^^ not found in this scope diff --git a/frame/support/test/tests/pallet_ui/duplicate_store_attr.stderr b/frame/support/test/tests/pallet_ui/duplicate_store_attr.stderr index 232144b8deaca..1c13ee17eb751 100644 --- a/frame/support/test/tests/pallet_ui/duplicate_store_attr.stderr +++ b/frame/support/test/tests/pallet_ui/duplicate_store_attr.stderr @@ -1,5 +1,5 @@ error: Unexpected duplicated attribute - --> $DIR/duplicate_store_attr.rs:12:12 + --> tests/pallet_ui/duplicate_store_attr.rs:12:3 | 12 | #[pallet::generate_store(trait Store)] - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/frame/support/test/tests/pallet_ui/store_trait_leak_private.stderr b/frame/support/test/tests/pallet_ui/store_trait_leak_private.stderr index d8c62faa303ee..24fda4ff1abbf 100644 --- a/frame/support/test/tests/pallet_ui/store_trait_leak_private.stderr +++ b/frame/support/test/tests/pallet_ui/store_trait_leak_private.stderr @@ -1,5 +1,15 @@ +error: use of deprecated struct `pallet::_::Store`: + Use of `#[pallet::generate_store(pub(super) trait Store)]` will be removed soon. + Check https://github.com/paritytech/substrate/pull/13535 for more details. + --> tests/pallet_ui/store_trait_leak_private.rs:11:3 + | +11 | #[pallet::generate_store(pub trait Store)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D deprecated` implied by `-D warnings` + error[E0446]: private type `_GeneratedPrefixForStorageFoo` in public interface - --> $DIR/store_trait_leak_private.rs:11:37 + --> tests/pallet_ui/store_trait_leak_private.rs:11:37 | 11 | #[pallet::generate_store(pub trait Store)] | ^^^^^ can't leak private type diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index d2b579814f8a9..e2fed3e51855d 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -29,7 +29,6 @@ mod module { use frame_support::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 0ec808d4c960f..faa1ee5d6cf4f 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -357,7 +357,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub (super) trait Store)] pub struct Pallet(_); #[pallet::hooks] diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index 93af4447d9612..192c81502bf6e 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -151,7 +151,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData); /// Current time for the current block. diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index d82906563fb8e..970e2ac152c4b 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -121,7 +121,6 @@ pub mod pallet { const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] #[pallet::without_storage_info] pub struct Pallet(_); diff --git a/frame/transaction-payment/asset-tx-payment/src/lib.rs b/frame/transaction-payment/asset-tx-payment/src/lib.rs index ec0bfcd4f4028..b9cd6ef995578 100644 --- a/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -124,7 +124,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::event] diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 42798c62f4012..83ff69428d144 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -295,7 +295,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index c4b1a622fc5f3..59662ee860541 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -141,7 +141,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::hooks] diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 04e989373c8cd..450aee51f2ce8 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -140,7 +140,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(PhantomData<(T, I)>); #[pallet::config] diff --git a/frame/uniques/src/lib.rs b/frame/uniques/src/lib.rs index 587f1ae4b7d84..fd94bd3a9a7e4 100644 --- a/frame/uniques/src/lib.rs +++ b/frame/uniques/src/lib.rs @@ -71,7 +71,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[cfg(feature = "runtime-benchmarks")] diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 6cfa8b7e36e9a..af212a31eb971 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -76,7 +76,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); /// Configuration trait. diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index 413315a25eb44..d9ac2ebbc15a9 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -96,7 +96,6 @@ mod mock_democracy { use frame_system::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::config] diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index dbc018796a3c6..af3654924914c 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -211,7 +211,6 @@ pub mod pallet { pub(crate) type StorageVersion = StorageValue<_, Releases, ValueQuery>; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::genesis_config] diff --git a/frame/whitelist/src/lib.rs b/frame/whitelist/src/lib.rs index bfbadd073a8f8..decf010b06757 100644 --- a/frame/whitelist/src/lib.rs +++ b/frame/whitelist/src/lib.rs @@ -88,7 +88,6 @@ pub mod pallet { } #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); #[pallet::event] diff --git a/test-utils/runtime/src/system.rs b/test-utils/runtime/src/system.rs index 657e3c90fa6d3..12ebf486bb1b9 100644 --- a/test-utils/runtime/src/system.rs +++ b/test-utils/runtime/src/system.rs @@ -47,7 +47,6 @@ mod pallet { use frame_support::pallet_prelude::*; #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] #[pallet::without_storage_info] pub struct Pallet(PhantomData); diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index c0ec8befc4bee..eecc80c408efd 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -94,7 +94,6 @@ use sp_storage::{StorageData, StorageKey}; /// use frame_support::pallet_prelude::*; /// /// #[pallet::pallet] -/// #[pallet::generate_store(pub(super) trait Store)] /// pub struct Pallet(PhantomData); /// /// #[pallet::config] From 30aa444d2e398c5ca798e306c9c9b04c0e1b5ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Pa=C4=8Dandi?= <3002868+Dinonard@users.noreply.github.com> Date: Mon, 13 Mar 2023 16:44:47 +0100 Subject: [PATCH 06/80] Pallet assets improvements (#13543) --- frame/assets/src/functions.rs | 4 +-- frame/assets/src/lib.rs | 13 +++++++--- frame/assets/src/mock.rs | 40 +++++++++++++++++++++++++++--- frame/assets/src/tests.rs | 46 +++++++++++++++++++++++++++++------ 4 files changed, 85 insertions(+), 18 deletions(-) diff --git a/frame/assets/src/functions.rs b/frame/assets/src/functions.rs index f6e027472f159..47657ff267494 100644 --- a/frame/assets/src/functions.rs +++ b/frame/assets/src/functions.rs @@ -661,8 +661,8 @@ impl, I: 'static> Pallet { status: AssetStatus::Live, }, ); + ensure!(T::CallbackHandle::created(&id, &owner).is_ok(), Error::::CallbackFailed); Self::deposit_event(Event::ForceCreated { asset_id: id, owner: owner.clone() }); - T::CallbackHandle::created(&id, &owner); Ok(()) } @@ -752,7 +752,6 @@ impl, I: 'static> Pallet { approvals_destroyed: removed_approvals as u32, approvals_remaining: details.approvals as u32, }); - T::CallbackHandle::destroyed(&id); Ok(()) })?; Ok(removed_approvals) @@ -767,6 +766,7 @@ impl, I: 'static> Pallet { ensure!(details.status == AssetStatus::Destroying, Error::::IncorrectStatus); ensure!(details.accounts == 0, Error::::InUse); ensure!(details.approvals == 0, Error::::InUse); + ensure!(T::CallbackHandle::destroyed(&id).is_ok(), Error::::CallbackFailed); let metadata = Metadata::::take(&id); T::Currency::unreserve( diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index bb0e8ce8b3704..b36a5cabd377a 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -178,10 +178,14 @@ const LOG_TARGET: &str = "runtime::assets"; /// Trait with callbacks that are executed after successfull asset creation or destruction. pub trait AssetsCallback { /// Indicates that asset with `id` was successfully created by the `owner` - fn created(_id: &AssetId, _owner: &AccountId) {} + fn created(_id: &AssetId, _owner: &AccountId) -> Result<(), ()> { + Ok(()) + } /// Indicates that asset with `id` has just been destroyed - fn destroyed(_id: &AssetId) {} + fn destroyed(_id: &AssetId) -> Result<(), ()> { + Ok(()) + } } /// Empty implementation in case no callbacks are required. @@ -560,6 +564,8 @@ pub mod pallet { IncorrectStatus, /// The asset should be frozen before the given operation. NotFrozen, + /// Callback action resulted in error + CallbackFailed, } #[pallet::call] @@ -618,13 +624,12 @@ pub mod pallet { status: AssetStatus::Live, }, ); - + ensure!(T::CallbackHandle::created(&id, &owner).is_ok(), Error::::CallbackFailed); Self::deposit_event(Event::Created { asset_id: id, creator: owner.clone(), owner: admin, }); - T::CallbackHandle::created(&id, &owner); Ok(()) } diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 14795b10a7e15..3f456a7de3eda 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -91,12 +91,44 @@ impl pallet_balances::Config for Test { pub struct AssetsCallbackHandle; impl AssetsCallback for AssetsCallbackHandle { - fn created(_id: &AssetId, _owner: &AccountId) { - storage::set(b"asset_created", &().encode()); + fn created(_id: &AssetId, _owner: &AccountId) -> Result<(), ()> { + if Self::should_err() { + Err(()) + } else { + storage::set(Self::CREATED.as_bytes(), &().encode()); + Ok(()) + } } - fn destroyed(_id: &AssetId) { - storage::set(b"asset_destroyed", &().encode()); + fn destroyed(_id: &AssetId) -> Result<(), ()> { + if Self::should_err() { + Err(()) + } else { + storage::set(Self::DESTROYED.as_bytes(), &().encode()); + Ok(()) + } + } +} + +impl AssetsCallbackHandle { + pub const CREATED: &'static str = "asset_created"; + pub const DESTROYED: &'static str = "asset_destroyed"; + + const RETURN_ERROR: &'static str = "return_error"; + + // Configures `Self` to return `Ok` when callbacks are invoked + pub fn set_return_ok() { + storage::clear(Self::RETURN_ERROR.as_bytes()); + } + + // Configures `Self` to return `Err` when callbacks are invoked + pub fn set_return_error() { + storage::set(Self::RETURN_ERROR.as_bytes(), &().encode()); + } + + // If `true`, callback should return `Err`, `Ok` otherwise. + fn should_err() -> bool { + storage::exists(Self::RETURN_ERROR.as_bytes()) } } diff --git a/frame/assets/src/tests.rs b/frame/assets/src/tests.rs index a2788f7f4a9aa..bc61810a76ac4 100644 --- a/frame/assets/src/tests.rs +++ b/frame/assets/src/tests.rs @@ -1261,28 +1261,58 @@ fn querying_roles_should_work() { #[test] fn normal_asset_create_and_destroy_callbacks_should_work() { new_test_ext().execute_with(|| { - assert!(storage::get(b"asset_created").is_none()); - assert!(storage::get(b"asset_destroyed").is_none()); + assert!(storage::get(AssetsCallbackHandle::CREATED.as_bytes()).is_none()); + assert!(storage::get(AssetsCallbackHandle::DESTROYED.as_bytes()).is_none()); Balances::make_free_balance_be(&1, 100); assert_ok!(Assets::create(RuntimeOrigin::signed(1), 0, 1, 1)); - assert!(storage::get(b"asset_created").is_some()); - assert!(storage::get(b"asset_destroyed").is_none()); + assert!(storage::get(AssetsCallbackHandle::CREATED.as_bytes()).is_some()); + assert!(storage::get(AssetsCallbackHandle::DESTROYED.as_bytes()).is_none()); assert_ok!(Assets::start_destroy(RuntimeOrigin::signed(1), 0)); assert_ok!(Assets::destroy_accounts(RuntimeOrigin::signed(1), 0)); assert_ok!(Assets::destroy_approvals(RuntimeOrigin::signed(1), 0)); + // Callback still hasn't been invoked + assert!(storage::get(AssetsCallbackHandle::DESTROYED.as_bytes()).is_none()); + assert_ok!(Assets::finish_destroy(RuntimeOrigin::signed(1), 0)); - assert!(storage::get(b"asset_destroyed").is_some()); + assert!(storage::get(AssetsCallbackHandle::DESTROYED.as_bytes()).is_some()); }); } #[test] fn root_asset_create_should_work() { new_test_ext().execute_with(|| { - assert!(storage::get(b"asset_created").is_none()); + assert!(storage::get(AssetsCallbackHandle::CREATED.as_bytes()).is_none()); assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, 1, true, 1)); - assert!(storage::get(b"asset_created").is_some()); - assert!(storage::get(b"asset_destroyed").is_none()); + assert!(storage::get(AssetsCallbackHandle::CREATED.as_bytes()).is_some()); + assert!(storage::get(AssetsCallbackHandle::DESTROYED.as_bytes()).is_none()); + }); +} + +#[test] +fn asset_create_and_destroy_is_reverted_if_callback_fails() { + new_test_ext().execute_with(|| { + // Asset creation fails due to callback failure + AssetsCallbackHandle::set_return_error(); + Balances::make_free_balance_be(&1, 100); + assert_noop!( + Assets::create(RuntimeOrigin::signed(1), 0, 1, 1), + Error::::CallbackFailed + ); + + // Callback succeeds, so asset creation succeeds + AssetsCallbackHandle::set_return_ok(); + assert_ok!(Assets::create(RuntimeOrigin::signed(1), 0, 1, 1)); + + // Asset destroy should fail due to callback failure + AssetsCallbackHandle::set_return_error(); + assert_ok!(Assets::start_destroy(RuntimeOrigin::signed(1), 0)); + assert_ok!(Assets::destroy_accounts(RuntimeOrigin::signed(1), 0)); + assert_ok!(Assets::destroy_approvals(RuntimeOrigin::signed(1), 0)); + assert_noop!( + Assets::finish_destroy(RuntimeOrigin::signed(1), 0), + Error::::CallbackFailed + ); }); } From 959c5b636f2536b883f64e13591aa61825a558f5 Mon Sep 17 00:00:00 2001 From: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Date: Mon, 13 Mar 2023 21:02:53 +0200 Subject: [PATCH 07/80] Metadata V15: Expose pallet documentation (#13452) * frame/proc: Helpers to parse pallet documentation attributes Signed-off-by: Alexandru Vasile * frame/proc: Expand pallet with runtime metadata documentation Signed-off-by: Alexandru Vasile * frame/dispatch: Implement doc function getter for dispatch Signed-off-by: Alexandru Vasile * frame/tests: Check exposed runtime metadata documentation Signed-off-by: Alexandru Vasile * frame/tests: Add UI tests for `pallet_doc` attribute Signed-off-by: Alexandru Vasile * frame/proc: Document pallet_doc attribute Signed-off-by: Alexandru Vasile * frame/support: Use `derive_syn_parse` Signed-off-by: Alexandru Vasile * Update frame/support/procedural/src/lib.rs Co-authored-by: Niklas Adolfsson * frame/support: Improve documentation Signed-off-by: Alexandru Vasile --------- Signed-off-by: Alexandru Vasile Co-authored-by: parity-processbot <> Co-authored-by: Niklas Adolfsson --- frame/support/procedural/src/lib.rs | 51 ++++ .../src/pallet/expand/documentation.rs | 221 ++++++++++++++++++ .../procedural/src/pallet/expand/mod.rs | 4 + frame/support/src/dispatch.rs | 24 ++ frame/support/test/tests/pallet.rs | 12 + .../pallet_ui/pallet_doc_arg_non_path.rs | 16 ++ .../pallet_ui/pallet_doc_arg_non_path.stderr | 5 + .../test/tests/pallet_ui/pallet_doc_empty.rs | 16 ++ .../tests/pallet_ui/pallet_doc_empty.stderr | 5 + .../tests/pallet_ui/pallet_doc_invalid_arg.rs | 16 ++ .../pallet_ui/pallet_doc_invalid_arg.stderr | 5 + .../pallet_ui/pallet_doc_multiple_args.rs | 16 ++ .../pallet_ui/pallet_doc_multiple_args.stderr | 5 + 13 files changed, 396 insertions(+) create mode 100644 frame/support/procedural/src/pallet/expand/documentation.rs create mode 100644 frame/support/test/tests/pallet_ui/pallet_doc_arg_non_path.rs create mode 100644 frame/support/test/tests/pallet_ui/pallet_doc_arg_non_path.stderr create mode 100644 frame/support/test/tests/pallet_ui/pallet_doc_empty.rs create mode 100644 frame/support/test/tests/pallet_ui/pallet_doc_empty.stderr create mode 100644 frame/support/test/tests/pallet_ui/pallet_doc_invalid_arg.rs create mode 100644 frame/support/test/tests/pallet_ui/pallet_doc_invalid_arg.stderr create mode 100644 frame/support/test/tests/pallet_ui/pallet_doc_multiple_args.rs create mode 100644 frame/support/test/tests/pallet_ui/pallet_doc_multiple_args.stderr diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index fec824107f123..1d5dde20e2034 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -481,6 +481,57 @@ pub fn construct_runtime(input: TokenStream) -> TokenStream { /// /// /// See `frame_support::pallet` docs for more info. +/// +/// ## Runtime Metadata Documentation +/// +/// The documentation added to this pallet is included in the runtime metadata. +/// +/// The documentation can be defined in the following ways: +/// +/// ```ignore +/// #[pallet::pallet] +/// /// Documentation for pallet 1 +/// #[doc = "Documentation for pallet 2"] +/// #[doc = include_str!("../README.md")] +/// #[pallet_doc("../doc1.md")] +/// #[pallet_doc("../doc2.md")] +/// pub struct Pallet(_); +/// ``` +/// +/// The runtime metadata for this pallet contains the following +/// - " Documentation for pallet 1" (captured from `///`) +/// - "Documentation for pallet 2" (captured from `#[doc]`) +/// - content of ../README.md (captured from `#[doc]` with `include_str!`) +/// - content of "../doc1.md" (captured from `pallet_doc`) +/// - content of "../doc2.md" (captured from `pallet_doc`) +/// +/// ### `doc` attribute +/// +/// The value of the `doc` attribute is included in the runtime metadata, as well as +/// expanded on the pallet module. The previous example is expanded to: +/// +/// ```ignore +/// /// Documentation for pallet 1 +/// /// Documentation for pallet 2 +/// /// Content of README.md +/// pub struct Pallet(_); +/// ``` +/// +/// If you want to specify the file from which the documentation is loaded, you can use the +/// `include_str` macro. However, if you only want the documentation to be included in the +/// runtime metadata, use the `pallet_doc` attribute. +/// +/// ### `pallet_doc` attribute +/// +/// Unlike the `doc` attribute, the documentation provided to the `pallet_doc` attribute is +/// not inserted on the module. +/// +/// The `pallet_doc` attribute can only be provided with one argument, +/// which is the file path that holds the documentation to be added to the metadata. +/// +/// This approach is beneficial when you use the `include_str` macro at the beginning of the file +/// and want that documentation to extend to the runtime metadata, without reiterating the +/// documentation on the module itself. #[proc_macro_attribute] pub fn pallet(attr: TokenStream, item: TokenStream) -> TokenStream { pallet::pallet(attr, item) diff --git a/frame/support/procedural/src/pallet/expand/documentation.rs b/frame/support/procedural/src/pallet/expand/documentation.rs new file mode 100644 index 0000000000000..e158448a89711 --- /dev/null +++ b/frame/support/procedural/src/pallet/expand/documentation.rs @@ -0,0 +1,221 @@ +// 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 crate::pallet::Def; +use derive_syn_parse::Parse; +use proc_macro2::TokenStream; +use quote::ToTokens; +use syn::{ + parse::{self, Parse, ParseStream}, + spanned::Spanned, + Attribute, Lit, +}; + +const DOC: &'static str = "doc"; +const PALLET_DOC: &'static str = "pallet_doc"; + +mod keywords { + syn::custom_keyword!(include_str); +} + +/// Get the documentation file path from the `pallet_doc` attribute. +/// +/// Supported format: +/// `#[pallet_doc(PATH)]`: The path of the file from which the documentation is loaded +fn parse_pallet_doc_value(attr: &Attribute) -> syn::Result { + let span = attr.span(); + + let meta = attr.parse_meta()?; + let syn::Meta::List(metalist) = meta else { + let msg = "The `pallet_doc` attribute must receive arguments as a list. Supported format: `pallet_doc(PATH)`"; + return Err(syn::Error::new(span, msg)) + }; + + let paths: Vec<_> = metalist + .nested + .into_iter() + .map(|nested| { + let syn::NestedMeta::Lit(lit) = nested else { + let msg = "The `pallet_doc` received an unsupported argument. Supported format: `pallet_doc(PATH)`"; + return Err(syn::Error::new(span, msg)) + }; + + Ok(lit) + }) + .collect::>()?; + + if paths.len() != 1 { + let msg = "The `pallet_doc` attribute must receive only one argument. Supported format: `pallet_doc(PATH)`"; + return Err(syn::Error::new(span, msg)) + } + + Ok(DocMetaValue::Path(paths[0].clone())) +} + +/// Get the value from the `doc` comment attribute: +/// +/// Supported formats: +/// - `#[doc = "A doc string"]`: Documentation as a string literal +/// - `#[doc = include_str!(PATH)]`: Documentation obtained from a path +fn parse_doc_value(attr: &Attribute) -> Option { + let Some(ident) = attr.path.get_ident() else { + return None + }; + if ident != DOC { + return None + } + + let parser = |input: ParseStream| DocParser::parse(input); + let result = parse::Parser::parse2(parser, attr.tokens.clone()).ok()?; + + if let Some(lit) = result.lit { + Some(DocMetaValue::Lit(lit)) + } else if let Some(include_doc) = result.include_doc { + Some(DocMetaValue::Path(include_doc.lit)) + } else { + None + } +} + +/// Parse the include_str attribute. +#[derive(Debug, Parse)] +struct IncludeDocParser { + _include_str: keywords::include_str, + _eq_token: syn::token::Bang, + #[paren] + _paren: syn::token::Paren, + #[inside(_paren)] + lit: Lit, +} + +/// Parse the doc literal. +#[derive(Debug, Parse)] +struct DocParser { + _eq_token: syn::token::Eq, + #[peek(Lit)] + lit: Option, + #[parse_if(lit.is_none())] + include_doc: Option, +} + +/// Supported documentation tokens. +#[derive(Debug)] +enum DocMetaValue { + /// Documentation with string literals. + /// + /// `#[doc = "Lit"]` + Lit(Lit), + /// Documentation with `include_str!` macro. + /// + /// The string literal represents the file `PATH`. + /// + /// `#[doc = include_str!(PATH)]` + Path(Lit), +} + +impl ToTokens for DocMetaValue { + fn to_tokens(&self, tokens: &mut TokenStream) { + match self { + DocMetaValue::Lit(lit) => lit.to_tokens(tokens), + DocMetaValue::Path(path_lit) => { + let decl = quote::quote!(include_str!(#path_lit)); + tokens.extend(decl) + }, + } + } +} + +/// Extract the documentation from the given pallet definition +/// to include in the runtime metadata. +/// +/// Implement a `pallet_documentation_metadata` function to fetch the +/// documentation that is included in the metadata. +/// +/// The documentation is placed at the top of the module similar to: +/// +/// ```ignore +/// #[pallet] +/// /// Documentation for pallet +/// #[doc = "Documentation for pallet"] +/// #[doc = include_str!("../README.md")] +/// #[pallet_doc("../documentation1.md")] +/// #[pallet_doc("../documentation2.md")] +/// pub mod pallet {} +/// ``` +/// +/// # pallet_doc +/// +/// The `pallet_doc` attribute can only be provided with one argument, +/// which is the file path that holds the documentation to be added to the metadata. +/// +/// Unlike the `doc` attribute, the documentation provided to the `proc_macro` attribute is +/// not inserted at the beginning of the module. +pub fn expand_documentation(def: &mut Def) -> proc_macro2::TokenStream { + let frame_support = &def.frame_support; + let type_impl_gen = &def.type_impl_generics(proc_macro2::Span::call_site()); + let type_use_gen = &def.type_use_generics(proc_macro2::Span::call_site()); + let pallet_ident = &def.pallet_struct.pallet; + let where_clauses = &def.config.where_clause; + + // TODO: Use [drain_filter](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.drain_filter) when it is stable. + + // The `pallet_doc` attributes are excluded from the generation of the pallet, + // but they are included in the runtime metadata. + let mut pallet_docs = Vec::with_capacity(def.item.attrs.len()); + let mut index = 0; + while index < def.item.attrs.len() { + let attr = &def.item.attrs[index]; + if let Some(ident) = attr.path.get_ident() { + if ident == PALLET_DOC { + let elem = def.item.attrs.remove(index); + pallet_docs.push(elem); + // Do not increment the index, we have just removed the + // element from the attributes. + continue + } + } + + index += 1; + } + + // Capture the `#[doc = include_str!("../README.md")]` and `#[doc = "Documentation"]`. + let mut docs: Vec<_> = def.item.attrs.iter().filter_map(parse_doc_value).collect(); + + // Capture the `#[pallet_doc("../README.md")]`. + let pallet_docs: Vec<_> = match pallet_docs + .into_iter() + .map(|attr| parse_pallet_doc_value(&attr)) + .collect::>() + { + Ok(docs) => docs, + Err(err) => return err.into_compile_error(), + }; + + docs.extend(pallet_docs); + + quote::quote!( + impl<#type_impl_gen> #pallet_ident<#type_use_gen> #where_clauses{ + + #[doc(hidden)] + pub fn pallet_documentation_metadata() + -> #frame_support::sp_std::vec::Vec<&'static str> + { + #frame_support::sp_std::vec![ #( #docs ),* ] + } + } + ) +} diff --git a/frame/support/procedural/src/pallet/expand/mod.rs b/frame/support/procedural/src/pallet/expand/mod.rs index 3ccbf91b4f130..09a25a7101ee7 100644 --- a/frame/support/procedural/src/pallet/expand/mod.rs +++ b/frame/support/procedural/src/pallet/expand/mod.rs @@ -18,6 +18,7 @@ mod call; mod config; mod constants; +mod documentation; mod error; mod event; mod genesis_build; @@ -52,6 +53,8 @@ pub fn merge_where_clauses(clauses: &[&Option]) -> Option proc_macro2::TokenStream { + // Remove the `pallet_doc` attribute first. + let metadata_docs = documentation::expand_documentation(&mut def); let constants = constants::expand_constants(&mut def); let pallet_struct = pallet_struct::expand_pallet_struct(&mut def); let config = config::expand_config(&mut def); @@ -82,6 +85,7 @@ pub fn expand(mut def: Def) -> proc_macro2::TokenStream { } let new_items = quote::quote!( + #metadata_docs #constants #pallet_struct #config diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index e2798763df437..c5f4cc60c1f1b 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -2948,6 +2948,10 @@ macro_rules! decl_module { { $( $other_where_bounds )* } $( $error_type )* } + $crate::__impl_docs_metadata! { + $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?> + { $( $other_where_bounds )* } + } $crate::__impl_module_constants_metadata ! { $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?> { $( $other_where_bounds )* } @@ -3018,6 +3022,26 @@ macro_rules! __impl_error_metadata { }; } +/// Implement metadata for pallet documentation. +#[macro_export] +#[doc(hidden)] +macro_rules! __impl_docs_metadata { + ( + $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?> + { $( $other_where_bounds:tt )* } + ) => { + impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $mod_type<$trait_instance $(, $instance)?> + where $( $other_where_bounds )* + { + #[doc(hidden)] + #[allow(dead_code)] + pub fn pallet_documentation_metadata() -> $crate::sp_std::vec::Vec<&'static str> { + $crate::sp_std::vec![] + } + } + }; +} + /// Implement metadata for module constants. #[macro_export] #[doc(hidden)] diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 8e77cd0251184..fbebbef455f7b 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -101,6 +101,10 @@ impl SomeAssociation2 for u64 { } #[frame_support::pallet] +/// Pallet documentation +// Comments should not be included in the pallet documentation +#[pallet_doc("../../README.md")] +#[doc = include_str!("../../README.md")] pub mod pallet { use super::*; use frame_support::pallet_prelude::*; @@ -1589,6 +1593,14 @@ fn metadata() { pretty_assertions::assert_eq!(actual_metadata.pallets, expected_metadata.pallets); } +#[test] +fn test_pallet_runtime_docs() { + let docs = crate::pallet::Pallet::::pallet_documentation_metadata(); + let readme = "Support code for the runtime.\n\nLicense: Apache-2.0"; + let expected = vec![" Pallet documentation", readme, readme]; + assert_eq!(docs, expected); +} + #[test] fn test_pallet_info_access() { assert_eq!(::name(), "System"); diff --git a/frame/support/test/tests/pallet_ui/pallet_doc_arg_non_path.rs b/frame/support/test/tests/pallet_ui/pallet_doc_arg_non_path.rs new file mode 100644 index 0000000000000..ef3097d23007d --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pallet_doc_arg_non_path.rs @@ -0,0 +1,16 @@ +#[frame_support::pallet] +// Must receive a string literal pointing to a path +#[pallet_doc(X)] +mod pallet { + #[pallet::config] + pub trait Config: frame_system::Config + where + ::Index: From, + { + } + + #[pallet::pallet] + pub struct Pallet(core::marker::PhantomData); +} + +fn main() {} diff --git a/frame/support/test/tests/pallet_ui/pallet_doc_arg_non_path.stderr b/frame/support/test/tests/pallet_ui/pallet_doc_arg_non_path.stderr new file mode 100644 index 0000000000000..ba60479c07202 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pallet_doc_arg_non_path.stderr @@ -0,0 +1,5 @@ +error: The `pallet_doc` received an unsupported argument. Supported format: `pallet_doc(PATH)` + --> tests/pallet_ui/pallet_doc_arg_non_path.rs:3:1 + | +3 | #[pallet_doc(X)] + | ^ diff --git a/frame/support/test/tests/pallet_ui/pallet_doc_empty.rs b/frame/support/test/tests/pallet_ui/pallet_doc_empty.rs new file mode 100644 index 0000000000000..fe40806d2fa75 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pallet_doc_empty.rs @@ -0,0 +1,16 @@ +#[frame_support::pallet] +// Expected one argument for the doc path. +#[pallet_doc] +mod pallet { + #[pallet::config] + pub trait Config: frame_system::Config + where + ::Index: From, + { + } + + #[pallet::pallet] + pub struct Pallet(core::marker::PhantomData); +} + +fn main() {} diff --git a/frame/support/test/tests/pallet_ui/pallet_doc_empty.stderr b/frame/support/test/tests/pallet_ui/pallet_doc_empty.stderr new file mode 100644 index 0000000000000..d6a189d7918f5 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pallet_doc_empty.stderr @@ -0,0 +1,5 @@ +error: The `pallet_doc` attribute must receive arguments as a list. Supported format: `pallet_doc(PATH)` + --> tests/pallet_ui/pallet_doc_empty.rs:3:1 + | +3 | #[pallet_doc] + | ^ diff --git a/frame/support/test/tests/pallet_ui/pallet_doc_invalid_arg.rs b/frame/support/test/tests/pallet_ui/pallet_doc_invalid_arg.rs new file mode 100644 index 0000000000000..8f0ccb3777a49 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pallet_doc_invalid_arg.rs @@ -0,0 +1,16 @@ +#[frame_support::pallet] +// Argument expected as list, not named value. +#[pallet_doc = "invalid"] +mod pallet { + #[pallet::config] + pub trait Config: frame_system::Config + where + ::Index: From, + { + } + + #[pallet::pallet] + pub struct Pallet(core::marker::PhantomData); +} + +fn main() {} diff --git a/frame/support/test/tests/pallet_ui/pallet_doc_invalid_arg.stderr b/frame/support/test/tests/pallet_ui/pallet_doc_invalid_arg.stderr new file mode 100644 index 0000000000000..9dd03978934a4 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pallet_doc_invalid_arg.stderr @@ -0,0 +1,5 @@ +error: The `pallet_doc` attribute must receive arguments as a list. Supported format: `pallet_doc(PATH)` + --> tests/pallet_ui/pallet_doc_invalid_arg.rs:3:1 + | +3 | #[pallet_doc = "invalid"] + | ^ diff --git a/frame/support/test/tests/pallet_ui/pallet_doc_multiple_args.rs b/frame/support/test/tests/pallet_ui/pallet_doc_multiple_args.rs new file mode 100644 index 0000000000000..ffbed9d950799 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pallet_doc_multiple_args.rs @@ -0,0 +1,16 @@ +#[frame_support::pallet] +// Supports only one argument. +#[pallet_doc("A", "B")] +mod pallet { + #[pallet::config] + pub trait Config: frame_system::Config + where + ::Index: From, + { + } + + #[pallet::pallet] + pub struct Pallet(core::marker::PhantomData); +} + +fn main() {} diff --git a/frame/support/test/tests/pallet_ui/pallet_doc_multiple_args.stderr b/frame/support/test/tests/pallet_ui/pallet_doc_multiple_args.stderr new file mode 100644 index 0000000000000..58ad75a0a2aec --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pallet_doc_multiple_args.stderr @@ -0,0 +1,5 @@ +error: The `pallet_doc` attribute must receive only one argument. Supported format: `pallet_doc(PATH)` + --> tests/pallet_ui/pallet_doc_multiple_args.rs:3:1 + | +3 | #[pallet_doc("A", "B")] + | ^ From 3a94009daac8919db46e3014964fe23866edb996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 13 Mar 2023 22:46:53 +0100 Subject: [PATCH 08/80] sc-slots: Cleanup (#13590) Calculate remaining proposal duration once and also use proposal time as timeout for creating the inherent data. --- client/consensus/slots/src/lib.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index c18284de6a088..f1d817ab7d8cf 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -190,7 +190,7 @@ pub trait SimpleSlotWorker { proposer: Self::Proposer, claim: &Self::Claim, slot_info: SlotInfo, - proposing_remaining: Delay, + end_proposing_at: Instant, ) -> Option< Proposal< B, @@ -202,9 +202,11 @@ pub trait SimpleSlotWorker { let telemetry = self.telemetry(); let log_target = self.logging_target(); - let inherent_data = Self::create_inherent_data(&slot_info, &log_target).await?; + let inherent_data = + Self::create_inherent_data(&slot_info, &log_target, end_proposing_at).await?; - let proposing_remaining_duration = self.proposing_remaining_duration(&slot_info); + let proposing_remaining_duration = + end_proposing_at.saturating_duration_since(Instant::now()); let logs = self.pre_digest_data(slot, claim); // deadline our production to 98% of the total time left for proposing. As we deadline @@ -219,7 +221,12 @@ pub trait SimpleSlotWorker { ) .map_err(|e| sp_consensus::Error::ClientImport(e.to_string())); - let proposal = match futures::future::select(proposing, proposing_remaining).await { + let proposal = match futures::future::select( + proposing, + Delay::new(proposing_remaining_duration), + ) + .await + { Either::Left((Ok(p), _)) => p, Either::Left((Err(err), _)) => { warn!(target: log_target, "Proposing failed: {}", err); @@ -255,8 +262,9 @@ pub trait SimpleSlotWorker { async fn create_inherent_data( slot_info: &SlotInfo, logging_target: &str, + end_proposing_at: Instant, ) -> Option { - let remaining_duration = slot_info.ends_at.saturating_duration_since(Instant::now()); + let remaining_duration = end_proposing_at.saturating_duration_since(Instant::now()); let delay = Delay::new(remaining_duration); let cid = slot_info.create_inherent_data.create_inherent_data(); let inherent_data = match futures::future::select(delay, cid).await { @@ -300,7 +308,7 @@ pub trait SimpleSlotWorker { let proposing_remaining_duration = self.proposing_remaining_duration(&slot_info); - let proposing_remaining = if proposing_remaining_duration == Duration::default() { + let end_proposing_at = if proposing_remaining_duration == Duration::default() { debug!( target: logging_target, "Skipping proposal slot {} since there's no time left to propose", slot, @@ -308,7 +316,7 @@ pub trait SimpleSlotWorker { return None } else { - Delay::new(proposing_remaining_duration) + Instant::now() + proposing_remaining_duration }; let aux_data = match self.aux_data(&slot_info.chain_head, slot) { @@ -379,7 +387,7 @@ pub trait SimpleSlotWorker { }, }; - let proposal = self.propose(proposer, &claim, slot_info, proposing_remaining).await?; + let proposal = self.propose(proposer, &claim, slot_info, end_proposing_at).await?; let (block, storage_proof) = (proposal.block, proposal.proof); let (header, body) = block.deconstruct(); From 4f28d2923a825dafc8431825270e78c5ab218ce0 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> Date: Tue, 14 Mar 2023 09:55:18 +0200 Subject: [PATCH 09/80] [NFTs] Allow to set the role to None (#13591) * Allow to unset the role * Chore * Array instead of vec --------- Co-authored-by: parity-processbot <> --- frame/nfts/src/benchmarking.rs | 12 +-- frame/nfts/src/features/create_delete_item.rs | 46 +++++----- frame/nfts/src/features/roles.rs | 38 ++++++-- frame/nfts/src/lib.rs | 21 +++-- frame/nfts/src/tests.rs | 88 +++++++++++++++---- 5 files changed, 143 insertions(+), 62 deletions(-) diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index d4bbd809ce8be..68252ebfc9cac 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -383,16 +383,16 @@ benchmarks_instance_pallet! { set_team { let (collection, caller, _) = create_collection::(); - 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)); + let target0 = Some(T::Lookup::unlookup(account("target", 0, SEED))); + let target1 = Some(T::Lookup::unlookup(account("target", 1, SEED))); + let target2 = Some(T::Lookup::unlookup(account("target", 2, SEED))); }: _(SystemOrigin::Signed(caller), collection, target0, target1, target2) verify { assert_last_event::(Event::TeamChanged{ collection, - issuer: account("target", 0, SEED), - admin: account("target", 1, SEED), - freezer: account("target", 2, SEED), + issuer: Some(account("target", 0, SEED)), + admin: Some(account("target", 1, SEED)), + freezer: Some(account("target", 2, SEED)), }.into()); } diff --git a/frame/nfts/src/features/create_delete_item.rs b/frame/nfts/src/features/create_delete_item.rs index cd96d28448055..2aa27dc066619 100644 --- a/frame/nfts/src/features/create_delete_item.rs +++ b/frame/nfts/src/features/create_delete_item.rs @@ -106,9 +106,6 @@ impl, I: 'static> Pallet { let now = frame_system::Pallet::::block_number(); ensure!(deadline >= now, Error::::DeadlineExpired); - let collection_details = - Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; - ensure!( Self::has_role(&collection, &signer, CollectionRole::Issuer), Error::::NoPermission @@ -123,27 +120,28 @@ impl, I: 'static> Pallet { item_config, |_, _| Ok(()), )?; - let origin = Self::find_account_by_role(&collection, CollectionRole::Admin) - .unwrap_or(collection_details.owner.clone()); - for (key, value) in attributes { - Self::do_set_attribute( - origin.clone(), - collection, - Some(item), - AttributeNamespace::CollectionOwner, - Self::construct_attribute_key(key)?, - Self::construct_attribute_value(value)?, - mint_to.clone(), - )?; - } - if !metadata.len().is_zero() { - Self::do_set_item_metadata( - Some(origin.clone()), - collection, - item, - metadata, - Some(mint_to.clone()), - )?; + let admin_account = Self::find_account_by_role(&collection, CollectionRole::Admin); + if let Some(admin_account) = admin_account { + for (key, value) in attributes { + Self::do_set_attribute( + admin_account.clone(), + collection, + Some(item), + AttributeNamespace::CollectionOwner, + Self::construct_attribute_key(key)?, + Self::construct_attribute_value(value)?, + mint_to.clone(), + )?; + } + if !metadata.len().is_zero() { + Self::do_set_item_metadata( + Some(admin_account.clone()), + collection, + item, + metadata, + Some(mint_to.clone()), + )?; + } } Ok(()) } diff --git a/frame/nfts/src/features/roles.rs b/frame/nfts/src/features/roles.rs index f91f3ecb6f348..3bac002069cf3 100644 --- a/frame/nfts/src/features/roles.rs +++ b/frame/nfts/src/features/roles.rs @@ -23,24 +23,46 @@ impl, I: 'static> Pallet { pub(crate) fn do_set_team( maybe_check_owner: Option, collection: T::CollectionId, - issuer: T::AccountId, - admin: T::AccountId, - freezer: T::AccountId, + issuer: Option, + admin: Option, + freezer: Option, ) -> DispatchResult { Collection::::try_mutate(collection, |maybe_details| { let details = maybe_details.as_mut().ok_or(Error::::UnknownCollection)?; + let is_root = maybe_check_owner.is_none(); if let Some(check_origin) = maybe_check_owner { ensure!(check_origin == details.owner, Error::::NoPermission); } - // delete previous values - Self::clear_roles(&collection)?; - - let account_to_role = Self::group_roles_by_account(vec![ + let roles_map = [ (issuer.clone(), CollectionRole::Issuer), (admin.clone(), CollectionRole::Admin), (freezer.clone(), CollectionRole::Freezer), - ]); + ]; + + // only root can change the role from `None` to `Some(account)` + if !is_root { + for (account, role) in roles_map.iter() { + if account.is_some() { + ensure!( + Self::find_account_by_role(&collection, *role).is_some(), + Error::::NoPermission + ); + } + } + } + + let roles = roles_map + .into_iter() + .filter_map(|(account, role)| account.map(|account| (account, role))) + .collect(); + + let account_to_role = Self::group_roles_by_account(roles); + + // delete the previous records + Self::clear_roles(&collection)?; + + // insert new records for (account, roles) in account_to_role { CollectionRoleOf::::insert(&collection, &account, roles); } diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 254fa75964ab8..f4d0e41593476 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -403,9 +403,9 @@ pub mod pallet { /// The management team changed. TeamChanged { collection: T::CollectionId, - issuer: T::AccountId, - admin: T::AccountId, - freezer: T::AccountId, + issuer: Option, + admin: Option, + freezer: Option, }, /// An `item` of a `collection` has been approved by the `owner` for transfer by /// a `delegate`. @@ -1136,6 +1136,9 @@ pub mod pallet { /// Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the /// `collection`. /// + /// Note: by setting the role to `None` only the `ForceOrigin` will be able to change it + /// after to `Some(account)`. + /// /// - `collection`: The collection whose team should be changed. /// - `issuer`: The new Issuer of this collection. /// - `admin`: The new Admin of this collection. @@ -1149,16 +1152,16 @@ pub mod pallet { pub fn set_team( origin: OriginFor, collection: T::CollectionId, - issuer: AccountIdLookupOf, - admin: AccountIdLookupOf, - freezer: AccountIdLookupOf, + issuer: Option>, + admin: Option>, + freezer: Option>, ) -> DispatchResult { let maybe_check_owner = T::ForceOrigin::try_origin(origin) .map(|_| None) .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; - let issuer = T::Lookup::lookup(issuer)?; - let admin = T::Lookup::lookup(admin)?; - let freezer = T::Lookup::lookup(freezer)?; + let issuer = issuer.map(T::Lookup::lookup).transpose()?; + let admin = admin.map(T::Lookup::lookup).transpose()?; + let freezer = freezer.map(T::Lookup::lookup).transpose()?; Self::do_set_team(maybe_check_owner, collection, issuer, admin, freezer) } diff --git a/frame/nfts/src/tests.rs b/frame/nfts/src/tests.rs index 694468aceebe5..0fc6fcd15c45f 100644 --- a/frame/nfts/src/tests.rs +++ b/frame/nfts/src/tests.rs @@ -535,9 +535,9 @@ fn origin_guards_should_work() { Nfts::set_team( RuntimeOrigin::signed(account(2)), 0, - account(2), - account(2), - account(2), + Some(account(2)), + Some(account(2)), + Some(account(2)), ), Error::::NoPermission ); @@ -639,14 +639,14 @@ fn set_team_should_work() { assert_ok!(Nfts::set_team( RuntimeOrigin::signed(account(1)), 0, - account(2), - account(3), - account(4), + Some(account(2)), + Some(account(3)), + Some(account(4)), )); assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(2)), 0, 42, account(2), None)); - assert_ok!(Nfts::lock_item_transfer(RuntimeOrigin::signed(account(4)), 0, 42)); - assert_ok!(Nfts::unlock_item_transfer(RuntimeOrigin::signed(account(4)), 0, 42)); + + // admin can't transfer/burn items he doesn't own assert_noop!( Nfts::transfer(RuntimeOrigin::signed(account(3)), 0, 42, account(3)), Error::::NoPermission @@ -655,6 +655,46 @@ fn set_team_should_work() { Nfts::burn(RuntimeOrigin::signed(account(3)), 0, 42), Error::::NoPermission ); + + assert_ok!(Nfts::lock_item_transfer(RuntimeOrigin::signed(account(4)), 0, 42)); + assert_ok!(Nfts::unlock_item_transfer(RuntimeOrigin::signed(account(4)), 0, 42)); + + // validate we can set any role to None + assert_ok!(Nfts::set_team( + RuntimeOrigin::signed(account(1)), + 0, + Some(account(2)), + Some(account(3)), + None, + )); + assert_noop!( + Nfts::lock_item_transfer(RuntimeOrigin::signed(account(4)), 0, 42), + Error::::NoPermission + ); + + // set all the roles to None + assert_ok!(Nfts::set_team(RuntimeOrigin::signed(account(1)), 0, None, None, None,)); + + // validate we can't set the roles back + assert_noop!( + Nfts::set_team( + RuntimeOrigin::signed(account(1)), + 0, + Some(account(2)), + Some(account(3)), + None, + ), + Error::::NoPermission + ); + + // only the root account can change the roles from None to Some() + assert_ok!(Nfts::set_team( + RuntimeOrigin::root(), + 0, + Some(account(2)), + Some(account(3)), + None, + )); }); } @@ -1476,7 +1516,13 @@ fn force_update_collection_should_work() { Balances::make_free_balance_be(&account(5), 100); assert_ok!(Nfts::force_collection_owner(RuntimeOrigin::root(), 0, account(5))); - assert_ok!(Nfts::set_team(RuntimeOrigin::root(), 0, account(2), account(5), account(4))); + assert_ok!(Nfts::set_team( + RuntimeOrigin::root(), + 0, + Some(account(2)), + Some(account(5)), + Some(account(4)), + )); assert_eq!(collections(), vec![(account(5), 0)]); assert_eq!(Balances::reserved_balance(account(1)), 2); assert_eq!(Balances::reserved_balance(account(5)), 63); @@ -1502,7 +1548,13 @@ fn force_update_collection_should_work() { assert_eq!(Balances::reserved_balance(account(5)), 0); // validate new roles - assert_ok!(Nfts::set_team(RuntimeOrigin::root(), 0, account(2), account(3), account(4))); + assert_ok!(Nfts::set_team( + RuntimeOrigin::root(), + 0, + Some(account(2)), + Some(account(3)), + Some(account(4)), + )); assert_eq!( CollectionRoleOf::::get(0, account(2)).unwrap(), CollectionRoles(CollectionRole::Issuer.into()) @@ -1516,7 +1568,13 @@ fn force_update_collection_should_work() { CollectionRoles(CollectionRole::Freezer.into()) ); - assert_ok!(Nfts::set_team(RuntimeOrigin::root(), 0, account(3), account(2), account(3))); + assert_ok!(Nfts::set_team( + RuntimeOrigin::root(), + 0, + Some(account(3)), + Some(account(2)), + Some(account(3)), + )); assert_eq!( CollectionRoleOf::::get(0, account(2)).unwrap(), @@ -1541,9 +1599,9 @@ fn burn_works() { assert_ok!(Nfts::set_team( RuntimeOrigin::signed(account(1)), 0, - account(2), - account(3), - account(4), + Some(account(2)), + Some(account(3)), + Some(account(4)), )); assert_noop!( @@ -3220,7 +3278,7 @@ fn pre_signed_mints_should_work() { signature, user_1.clone(), ), - Error::::UnknownCollection + Error::::NoPermission ); // validate max attributes limit From 897b95d98424a44eb493eb982e5ac88d37f60cb5 Mon Sep 17 00:00:00 2001 From: Aaro Altonen <48052676+altonen@users.noreply.github.com> Date: Tue, 14 Mar 2023 14:06:40 +0200 Subject: [PATCH 10/80] Move code from `sc-network-common` back to `sc-network` (#13592) * Move service tests to `client/network/tests` These tests depend on `sc-network` and `sc-network-sync` so they should live outside the crate. * Move some configs from `sc-network-common` to `sc-network` * Move `NetworkService` traits to `sc-network` * Move request-responses to `sc-network` * Remove more stuff * Remove rest of configs from `sc-network-common` to `sc-network` * Remove more stuff * Fix warnings * Update client/network/src/request_responses.rs Co-authored-by: Dmitry Markin * Fix cargo doc --------- Co-authored-by: Dmitry Markin --- Cargo.lock | 12 +- bin/node/cli/src/service.rs | 6 +- client/authority-discovery/Cargo.toml | 1 + client/authority-discovery/src/lib.rs | 2 +- client/authority-discovery/src/worker.rs | 5 +- .../authority-discovery/src/worker/tests.rs | 9 +- client/chain-spec/Cargo.toml | 2 +- client/chain-spec/src/chain_spec.rs | 2 +- client/chain-spec/src/lib.rs | 2 +- client/cli/src/arg_enums.rs | 20 +- client/cli/src/params/network_params.rs | 8 +- client/cli/src/params/node_key_params.rs | 14 +- .../consensus/beefy/src/communication/mod.rs | 5 +- .../incoming_requests_handler.rs | 6 +- .../outgoing_requests_engine.rs | 5 +- client/consensus/beefy/src/lib.rs | 3 +- .../grandpa/src/communication/gossip.rs | 7 +- .../grandpa/src/communication/mod.rs | 9 +- .../grandpa/src/communication/tests.rs | 16 +- client/consensus/grandpa/src/lib.rs | 10 +- client/informant/Cargo.toml | 1 + client/informant/src/display.rs | 10 +- client/informant/src/lib.rs | 3 +- client/network-gossip/Cargo.toml | 1 + client/network-gossip/src/bridge.rs | 18 +- client/network-gossip/src/lib.rs | 7 +- client/network-gossip/src/state_machine.rs | 14 +- client/network-gossip/src/validator.rs | 2 +- client/network/Cargo.toml | 1 + client/network/bitswap/Cargo.toml | 1 + client/network/bitswap/src/lib.rs | 9 +- client/network/common/Cargo.toml | 1 - client/network/common/src/config.rs | 702 ----------------- client/network/common/src/lib.rs | 7 +- .../network/common/src/request_responses.rs | 155 ---- .../network/common/src/{protocol => }/role.rs | 0 client/network/common/src/sync.rs | 2 +- client/network/common/src/sync/message.rs | 2 +- client/network/light/Cargo.toml | 1 + .../light/src/light_client_requests.rs | 8 +- .../src/light_client_requests/handler.rs | 2 +- client/network/src/behaviour.rs | 13 +- client/network/src/config.rs | 708 +++++++++++++++++- client/network/src/discovery.rs | 5 +- client/network/{common => }/src/error.rs | 3 +- .../{common/src/protocol => src}/event.rs | 6 +- client/network/src/lib.rs | 32 +- client/network/src/peer_info.rs | 4 +- client/network/src/protocol.rs | 26 +- client/network/src/protocol/message.rs | 2 +- .../src/protocol/notifications/behaviour.rs | 8 +- .../src/protocol/notifications/handler.rs | 15 +- .../protocol/notifications/upgrade/collec.rs | 2 +- .../notifications/upgrade/notifications.rs | 8 +- client/network/src/request_responses.rs | 160 +++- client/network/src/service.rs | 54 +- client/network/src/service/out_events.rs | 3 +- .../{common => }/src/service/signature.rs | 4 +- client/network/src/service/tests/mod.rs | 240 ------ .../src/service.rs => src/service/traits.rs} | 11 +- .../{common/src/protocol.rs => src/types.rs} | 9 +- client/network/{common => }/src/utils.rs | 3 + client/network/sync/Cargo.toml | 1 + .../network/sync/src/block_request_handler.rs | 7 +- client/network/sync/src/engine.rs | 14 +- client/network/sync/src/lib.rs | 44 +- client/network/sync/src/service/chain_sync.rs | 6 +- client/network/sync/src/service/mock.rs | 14 +- client/network/sync/src/service/network.rs | 8 +- .../network/sync/src/state_request_handler.rs | 5 +- .../network/sync/src/warp_request_handler.rs | 6 +- client/network/test/src/lib.rs | 16 +- .../service/tests => test/src}/service.rs | 245 +++++- client/network/transactions/Cargo.toml | 1 + client/network/transactions/src/lib.rs | 15 +- client/offchain/Cargo.toml | 1 + client/offchain/src/api.rs | 6 +- client/offchain/src/lib.rs | 4 +- client/rpc/src/system/tests.rs | 2 +- client/service/src/builder.rs | 11 +- client/service/src/config.rs | 10 +- client/service/src/error.rs | 2 +- client/service/src/lib.rs | 6 +- client/service/src/metrics.rs | 7 +- client/service/test/src/lib.rs | 7 +- 85 files changed, 1411 insertions(+), 1434 deletions(-) delete mode 100644 client/network/common/src/config.rs delete mode 100644 client/network/common/src/request_responses.rs rename client/network/common/src/{protocol => }/role.rs (100%) rename client/network/{common => }/src/error.rs (97%) rename client/network/{common/src/protocol => src}/event.rs (97%) rename client/network/{common => }/src/service/signature.rs (96%) delete mode 100644 client/network/src/service/tests/mod.rs rename client/network/{common/src/service.rs => src/service/traits.rs} (99%) rename client/network/{common/src/protocol.rs => src/types.rs} (99%) rename client/network/{common => }/src/utils.rs (98%) rename client/network/{src/service/tests => test/src}/service.rs (72%) diff --git a/Cargo.lock b/Cargo.lock index 9a63e25b4878c..4aac7f3c7ed99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8101,6 +8101,7 @@ dependencies = [ "quickcheck", "rand 0.8.5", "sc-client-api", + "sc-network", "sc-network-common", "sp-api", "sp-authority-discovery", @@ -8163,7 +8164,7 @@ dependencies = [ "sc-chain-spec-derive", "sc-client-api", "sc-executor", - "sc-network-common", + "sc-network", "sc-telemetry", "serde", "serde_json", @@ -8751,6 +8752,7 @@ dependencies = [ "futures-timer", "log", "sc-client-api", + "sc-network", "sc-network-common", "sp-blockchain", "sp-runtime", @@ -8787,6 +8789,7 @@ dependencies = [ "futures-timer", "ip_network", "libp2p", + "linked_hash_set", "log", "lru", "mockall", @@ -8838,6 +8841,7 @@ dependencies = [ "sc-block-builder", "sc-client-api", "sc-consensus", + "sc-network", "sc-network-common", "sp-blockchain", "sp-consensus", @@ -8861,7 +8865,6 @@ dependencies = [ "futures", "futures-timer", "libp2p", - "linked_hash_set", "parity-scale-codec", "prost-build", "sc-consensus", @@ -8890,6 +8893,7 @@ dependencies = [ "log", "lru", "quickcheck", + "sc-network", "sc-network-common", "sc-peerset", "sp-runtime", @@ -8911,6 +8915,7 @@ dependencies = [ "prost", "prost-build", "sc-client-api", + "sc-network", "sc-network-common", "sc-peerset", "sp-blockchain", @@ -8939,6 +8944,7 @@ dependencies = [ "sc-block-builder", "sc-client-api", "sc-consensus", + "sc-network", "sc-network-common", "sc-peerset", "sc-utils", @@ -8997,6 +9003,7 @@ dependencies = [ "log", "parity-scale-codec", "pin-project", + "sc-network", "sc-network-common", "sc-peerset", "sc-utils", @@ -9026,6 +9033,7 @@ dependencies = [ "sc-block-builder", "sc-client-api", "sc-client-db", + "sc-network", "sc-network-common", "sc-peerset", "sc-transaction-pool", diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index e9a34b2a5c728..3c9716c08d1c0 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -31,10 +31,8 @@ use node_primitives::Block; use sc_client_api::BlockBackend; use sc_consensus_babe::{self, SlotProportion}; use sc_executor::NativeElseWasmExecutor; -use sc_network::NetworkService; -use sc_network_common::{ - protocol::event::Event, service::NetworkEventStream, sync::warp::WarpSyncParams, -}; +use sc_network::{event::Event, NetworkEventStream, NetworkService}; +use sc_network_common::sync::warp::WarpSyncParams; use sc_network_sync::SyncingService; use sc_service::{config::Configuration, error::Error as ServiceError, RpcHandlers, TaskManager}; use sc_telemetry::{Telemetry, TelemetryWorker}; diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index b37507662bfeb..900d9c59dfdae 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -28,6 +28,7 @@ rand = "0.8.5" thiserror = "1.0" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" } sc-client-api = { version = "4.0.0-dev", path = "../api" } +sc-network = { version = "0.10.0-dev", path = "../network/" } sc-network-common = { version = "0.10.0-dev", path = "../network/common" } sp-api = { version = "4.0.0-dev", path = "../../primitives/api" } sp-authority-discovery = { version = "4.0.0-dev", path = "../../primitives/authority-discovery" } diff --git a/client/authority-discovery/src/lib.rs b/client/authority-discovery/src/lib.rs index 579b9d8b15051..a3c6699091297 100644 --- a/client/authority-discovery/src/lib.rs +++ b/client/authority-discovery/src/lib.rs @@ -40,7 +40,7 @@ use futures::{ }; use libp2p::{Multiaddr, PeerId}; -use sc_network_common::protocol::event::DhtEvent; +use sc_network::event::DhtEvent; use sp_authority_discovery::AuthorityId; use sp_blockchain::HeaderBackend; use sp_runtime::traits::Block as BlockT; diff --git a/client/authority-discovery/src/worker.rs b/client/authority-discovery/src/worker.rs index bc5fe2848d5a1..034d72902e65d 100644 --- a/client/authority-discovery/src/worker.rs +++ b/client/authority-discovery/src/worker.rs @@ -43,9 +43,8 @@ use log::{debug, error, log_enabled}; use prometheus_endpoint::{register, Counter, CounterVec, Gauge, Opts, U64}; use prost::Message; use rand::{seq::SliceRandom, thread_rng}; -use sc_network_common::{ - protocol::event::DhtEvent, - service::{KademliaKey, NetworkDHTProvider, NetworkSigner, NetworkStateInfo, Signature}, +use sc_network::{ + event::DhtEvent, KademliaKey, NetworkDHTProvider, NetworkSigner, NetworkStateInfo, Signature, }; use sp_api::{ApiError, ProvideRuntimeApi}; use sp_authority_discovery::{ diff --git a/client/authority-discovery/src/worker/tests.rs b/client/authority-discovery/src/worker/tests.rs index 22f984d9718ee..febe40657e06a 100644 --- a/client/authority-discovery/src/worker/tests.rs +++ b/client/authority-discovery/src/worker/tests.rs @@ -29,11 +29,16 @@ use futures::{ sink::SinkExt, task::LocalSpawn, }; -use libp2p::{core::multiaddr, identity::Keypair, PeerId}; +use libp2p::{ + core::multiaddr, + identity::{error::SigningError, Keypair}, + kad::record::Key as KademliaKey, + PeerId, +}; use prometheus_endpoint::prometheus::default_registry; use sc_client_api::HeaderBackend; -use sc_network_common::service::{KademliaKey, Signature, SigningError}; +use sc_network::Signature; use sp_api::{ApiRef, ProvideRuntimeApi}; use sp_keystore::{testing::KeyStore, CryptoStore}; use sp_runtime::traits::{Block as BlockT, NumberFor, Zero}; diff --git a/client/chain-spec/Cargo.toml b/client/chain-spec/Cargo.toml index 6168a897c962c..b1188b3bd4625 100644 --- a/client/chain-spec/Cargo.toml +++ b/client/chain-spec/Cargo.toml @@ -19,7 +19,7 @@ serde_json = "1.0.85" sc-client-api = { version = "4.0.0-dev", path = "../api" } sc-chain-spec-derive = { version = "4.0.0-dev", path = "./derive" } sc-executor = { version = "0.10.0-dev", path = "../executor" } -sc-network-common = { version = "0.10.0-dev", path = "../network/common" } +sc-network = { version = "0.10.0-dev", path = "../network" } sc-telemetry = { version = "4.0.0-dev", path = "../telemetry" } sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" } sp-core = { version = "7.0.0", path = "../../primitives/core" } diff --git a/client/chain-spec/src/chain_spec.rs b/client/chain-spec/src/chain_spec.rs index 9eed5bbbc4e69..96e36d8399ed5 100644 --- a/client/chain-spec/src/chain_spec.rs +++ b/client/chain-spec/src/chain_spec.rs @@ -20,7 +20,7 @@ #![warn(missing_docs)] use crate::{extension::GetExtension, ChainType, Properties, RuntimeGenesis}; -use sc_network_common::config::MultiaddrWithPeerId; +use sc_network::config::MultiaddrWithPeerId; use sc_telemetry::TelemetryEndpoints; use serde::{Deserialize, Serialize}; use serde_json as json; diff --git a/client/chain-spec/src/lib.rs b/client/chain-spec/src/lib.rs index e43a247961f02..6239eb7326b78 100644 --- a/client/chain-spec/src/lib.rs +++ b/client/chain-spec/src/lib.rs @@ -189,7 +189,7 @@ pub use self::{ }; pub use sc_chain_spec_derive::{ChainSpecExtension, ChainSpecGroup}; -use sc_network_common::config::MultiaddrWithPeerId; +use sc_network::config::MultiaddrWithPeerId; use sc_telemetry::TelemetryEndpoints; use serde::{de::DeserializeOwned, Serialize}; use sp_core::storage::Storage; diff --git a/client/cli/src/arg_enums.rs b/client/cli/src/arg_enums.rs index 472c1722f9ed8..c3399a89680d1 100644 --- a/client/cli/src/arg_enums.rs +++ b/client/cli/src/arg_enums.rs @@ -251,19 +251,15 @@ pub enum SyncMode { Warp, } -impl Into for SyncMode { - fn into(self) -> sc_network_common::config::SyncMode { +impl Into for SyncMode { + fn into(self) -> sc_network::config::SyncMode { match self { - SyncMode::Full => sc_network_common::config::SyncMode::Full, - SyncMode::Fast => sc_network_common::config::SyncMode::Fast { - skip_proofs: false, - storage_chain_mode: false, - }, - SyncMode::FastUnsafe => sc_network_common::config::SyncMode::Fast { - skip_proofs: true, - storage_chain_mode: false, - }, - SyncMode::Warp => sc_network_common::config::SyncMode::Warp, + SyncMode::Full => sc_network::config::SyncMode::Full, + SyncMode::Fast => + sc_network::config::SyncMode::Fast { skip_proofs: false, storage_chain_mode: false }, + SyncMode::FastUnsafe => + sc_network::config::SyncMode::Fast { skip_proofs: true, storage_chain_mode: false }, + SyncMode::Warp => sc_network::config::SyncMode::Warp, } } } diff --git a/client/cli/src/params/network_params.rs b/client/cli/src/params/network_params.rs index 31b761938df84..106fba75aa727 100644 --- a/client/cli/src/params/network_params.rs +++ b/client/cli/src/params/network_params.rs @@ -18,8 +18,12 @@ use crate::{arg_enums::SyncMode, params::node_key_params::NodeKeyParams}; use clap::Args; -use sc_network::{config::NetworkConfiguration, multiaddr::Protocol}; -use sc_network_common::config::{NodeKeyConfig, NonReservedPeerMode, SetConfig, TransportConfig}; +use sc_network::{ + config::{ + NetworkConfiguration, NodeKeyConfig, NonReservedPeerMode, SetConfig, TransportConfig, + }, + multiaddr::Protocol, +}; use sc_service::{ config::{Multiaddr, MultiaddrWithPeerId}, ChainSpec, ChainType, diff --git a/client/cli/src/params/node_key_params.rs b/client/cli/src/params/node_key_params.rs index d470ef1fad12a..074b95bea0f3a 100644 --- a/client/cli/src/params/node_key_params.rs +++ b/client/cli/src/params/node_key_params.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . use clap::Args; -use sc_network_common::config::{identity::ed25519, NodeKeyConfig}; +use sc_network::config::{identity::ed25519, NodeKeyConfig}; use sp_core::H256; use std::{path::PathBuf, str::FromStr}; @@ -92,7 +92,7 @@ impl NodeKeyParams { let secret = if let Some(node_key) = self.node_key.as_ref() { parse_ed25519_secret(node_key)? } else { - sc_network_common::config::Secret::File( + sc_network::config::Secret::File( self.node_key_file .clone() .unwrap_or_else(|| net_config_dir.join(NODE_KEY_ED25519_FILE)), @@ -111,10 +111,10 @@ fn invalid_node_key(e: impl std::fmt::Display) -> error::Error { } /// Parse a Ed25519 secret key from a hex string into a `sc_network::Secret`. -fn parse_ed25519_secret(hex: &str) -> error::Result { +fn parse_ed25519_secret(hex: &str) -> error::Result { H256::from_str(hex).map_err(invalid_node_key).and_then(|bytes| { ed25519::SecretKey::from_bytes(bytes) - .map(sc_network_common::config::Secret::Input) + .map(sc_network::config::Secret::Input) .map_err(invalid_node_key) }) } @@ -123,7 +123,7 @@ fn parse_ed25519_secret(hex: &str) -> error::Result Ok(()), _ => Err(error::Error::Input("Unexpected node key config".into())), @@ -200,7 +200,7 @@ mod tests { let dir = PathBuf::from(net_config_dir.clone()); let typ = params.node_key_type; params.node_key(net_config_dir).and_then(move |c| match c { - NodeKeyConfig::Ed25519(sc_network_common::config::Secret::File(ref f)) + NodeKeyConfig::Ed25519(sc_network::config::Secret::File(ref f)) if typ == NodeKeyType::Ed25519 && f == &dir.join(NODE_KEY_ED25519_FILE) => Ok(()), _ => Err(error::Error::Input("Unexpected node key config".into())), diff --git a/client/consensus/beefy/src/communication/mod.rs b/client/consensus/beefy/src/communication/mod.rs index f91b08bbc97ec..295d549bb1ba8 100644 --- a/client/consensus/beefy/src/communication/mod.rs +++ b/client/consensus/beefy/src/communication/mod.rs @@ -67,9 +67,8 @@ pub(crate) mod beefy_protocol_name { /// For standard protocol name see [`beefy_protocol_name::gossip_protocol_name`]. pub fn beefy_peers_set_config( gossip_protocol_name: sc_network::ProtocolName, -) -> sc_network_common::config::NonDefaultSetConfig { - let mut cfg = - sc_network_common::config::NonDefaultSetConfig::new(gossip_protocol_name, 1024 * 1024); +) -> sc_network::config::NonDefaultSetConfig { + let mut cfg = sc_network::config::NonDefaultSetConfig::new(gossip_protocol_name, 1024 * 1024); cfg.allow_non_reserved(25, 25); cfg } diff --git a/client/consensus/beefy/src/communication/request_response/incoming_requests_handler.rs b/client/consensus/beefy/src/communication/request_response/incoming_requests_handler.rs index ab6c21a187c95..1670e99828831 100644 --- a/client/consensus/beefy/src/communication/request_response/incoming_requests_handler.rs +++ b/client/consensus/beefy/src/communication/request_response/incoming_requests_handler.rs @@ -23,8 +23,10 @@ use futures::{ }; use log::{debug, trace}; use sc_client_api::BlockBackend; -use sc_network::{config as netconfig, config::RequestResponseConfig, PeerId, ReputationChange}; -use sc_network_common::protocol::ProtocolName; +use sc_network::{ + config as netconfig, config::RequestResponseConfig, types::ProtocolName, PeerId, + ReputationChange, +}; use sp_consensus_beefy::BEEFY_ENGINE_ID; use sp_runtime::traits::Block; use std::{marker::PhantomData, sync::Arc}; diff --git a/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs b/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs index 7450d4b3239f1..c642e3dfe581c 100644 --- a/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs +++ b/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs @@ -22,10 +22,9 @@ use codec::Encode; use futures::channel::{oneshot, oneshot::Canceled}; use log::{debug, warn}; use parking_lot::Mutex; -use sc_network::{PeerId, ProtocolName}; -use sc_network_common::{ +use sc_network::{ request_responses::{IfDisconnected, RequestFailure}, - service::NetworkRequest, + NetworkRequest, PeerId, ProtocolName, }; use sp_consensus_beefy::{crypto::AuthorityId, ValidatorSet}; use sp_runtime::traits::{Block, NumberFor}; diff --git a/client/consensus/beefy/src/lib.rs b/client/consensus/beefy/src/lib.rs index 67758a4979b19..eb56a97de1dd9 100644 --- a/client/consensus/beefy/src/lib.rs +++ b/client/consensus/beefy/src/lib.rs @@ -38,8 +38,7 @@ use parking_lot::Mutex; use prometheus::Registry; use sc_client_api::{Backend, BlockBackend, BlockchainEvents, FinalityNotifications, Finalizer}; use sc_consensus::BlockImport; -use sc_network::ProtocolName; -use sc_network_common::service::NetworkRequest; +use sc_network::{NetworkRequest, ProtocolName}; use sc_network_gossip::{GossipEngine, Network as GossipNetwork, Syncing as GossipSyncing}; use sp_api::{HeaderT, NumberFor, ProvideRuntimeApi}; use sp_blockchain::{ diff --git a/client/consensus/grandpa/src/communication/gossip.rs b/client/consensus/grandpa/src/communication/gossip.rs index 0a3029e25477a..2c0fe3d8571e5 100644 --- a/client/consensus/grandpa/src/communication/gossip.rs +++ b/client/consensus/grandpa/src/communication/gossip.rs @@ -91,7 +91,7 @@ use parity_scale_codec::{Decode, Encode}; use prometheus_endpoint::{register, CounterVec, Opts, PrometheusError, Registry, U64}; use rand::seq::SliceRandom; use sc_network::{PeerId, ReputationChange}; -use sc_network_common::protocol::role::ObservedRole; +use sc_network_common::role::ObservedRole; use sc_network_gossip::{MessageIntent, ValidatorContext}; use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG}; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender}; @@ -820,7 +820,7 @@ impl Inner { fn note_set(&mut self, set_id: SetId, authorities: Vec) -> MaybeMessage { let local_view = match self.local_view { ref mut x @ None => x.get_or_insert(LocalView::new(set_id, Round(1))), - Some(ref mut v) => + Some(ref mut v) => { if v.set_id == set_id { let diff_authorities = self.authorities.iter().collect::>() != authorities.iter().collect::>(); @@ -841,7 +841,8 @@ impl Inner { return None } else { v - }, + } + }, }; local_view.update_set(set_id); diff --git a/client/consensus/grandpa/src/communication/mod.rs b/client/consensus/grandpa/src/communication/mod.rs index 6c7e3ea46511e..3896bc36031ba 100644 --- a/client/consensus/grandpa/src/communication/mod.rs +++ b/client/consensus/grandpa/src/communication/mod.rs @@ -46,7 +46,7 @@ use finality_grandpa::{ Message::{Precommit, Prevote, PrimaryPropose}, }; use parity_scale_codec::{Decode, Encode}; -use sc_network::ReputationChange; +use sc_network::{NetworkBlock, NetworkSyncForkRequest, ReputationChange}; use sc_network_gossip::{GossipEngine, Network as GossipNetwork}; use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_INFO}; use sp_keystore::SyncCryptoStorePtr; @@ -59,10 +59,7 @@ use crate::{ use gossip::{ FullCatchUpMessage, FullCommitMessage, GossipMessage, GossipValidator, PeerReport, VoteMessage, }; -use sc_network_common::{ - service::{NetworkBlock, NetworkSyncForkRequest}, - sync::SyncEventStream, -}; +use sc_network_common::sync::SyncEventStream; use sc_utils::mpsc::TracingUnboundedReceiver; use sp_consensus_grandpa::{AuthorityId, AuthoritySignature, RoundNumber, SetId as SetIdNumber}; @@ -77,7 +74,7 @@ pub(crate) const NEIGHBOR_REBROADCAST_PERIOD: Duration = Duration::from_secs(2 * pub mod grandpa_protocol_name { use sc_chain_spec::ChainSpec; - use sc_network_common::protocol::ProtocolName; + use sc_network::types::ProtocolName; pub(crate) const NAME: &str = "/grandpa/1"; /// Old names for the notifications protocol, used for backward compatibility. diff --git a/client/consensus/grandpa/src/communication/tests.rs b/client/consensus/grandpa/src/communication/tests.rs index 843e5467910e8..f97b1f1e88181 100644 --- a/client/consensus/grandpa/src/communication/tests.rs +++ b/client/consensus/grandpa/src/communication/tests.rs @@ -25,14 +25,16 @@ use super::{ use crate::{communication::grandpa_protocol_name, environment::SharedVoterSetState}; use futures::prelude::*; use parity_scale_codec::Encode; -use sc_network::{config::Role, Multiaddr, PeerId, ReputationChange}; +use sc_network::{ + config::{MultiaddrWithPeerId, Role}, + event::Event as NetworkEvent, + types::ProtocolName, + Multiaddr, NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers, + NetworkSyncForkRequest, NotificationSenderError, NotificationSenderT as NotificationSender, + PeerId, ReputationChange, +}; use sc_network_common::{ - config::MultiaddrWithPeerId, - protocol::{event::Event as NetworkEvent, role::ObservedRole, ProtocolName}, - service::{ - NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers, - NetworkSyncForkRequest, NotificationSender, NotificationSenderError, - }, + role::ObservedRole, sync::{SyncEvent as SyncStreamEvent, SyncEventStream}, }; use sc_network_gossip::Validator; diff --git a/client/consensus/grandpa/src/lib.rs b/client/consensus/grandpa/src/lib.rs index 7bf48a498fabb..2baa135081c55 100644 --- a/client/consensus/grandpa/src/lib.rs +++ b/client/consensus/grandpa/src/lib.rs @@ -68,7 +68,7 @@ use sc_client_api::{ StorageProvider, TransactionFor, }; use sc_consensus::BlockImport; -use sc_network_common::protocol::ProtocolName; +use sc_network::types::ProtocolName; use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_INFO}; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver}; use sp_api::ProvideRuntimeApi; @@ -695,19 +695,19 @@ pub struct GrandpaParams { /// For standard protocol name see [`crate::protocol_standard_name`]. pub fn grandpa_peers_set_config( protocol_name: ProtocolName, -) -> sc_network_common::config::NonDefaultSetConfig { +) -> sc_network::config::NonDefaultSetConfig { use communication::grandpa_protocol_name; - sc_network_common::config::NonDefaultSetConfig { + sc_network::config::NonDefaultSetConfig { notifications_protocol: protocol_name, fallback_names: grandpa_protocol_name::LEGACY_NAMES.iter().map(|&n| n.into()).collect(), // Notifications reach ~256kiB in size at the time of writing on Kusama and Polkadot. max_notification_size: 1024 * 1024, handshake: None, - set_config: sc_network_common::config::SetConfig { + set_config: sc_network::config::SetConfig { in_peers: 0, out_peers: 0, reserved_nodes: Vec::new(), - non_reserved_mode: sc_network_common::config::NonReservedPeerMode::Deny, + non_reserved_mode: sc_network::config::NonReservedPeerMode::Deny, }, } } diff --git a/client/informant/Cargo.toml b/client/informant/Cargo.toml index ca0ae03af3265..cd84dcb5a0dfe 100644 --- a/client/informant/Cargo.toml +++ b/client/informant/Cargo.toml @@ -19,5 +19,6 @@ futures-timer = "3.0.1" log = "0.4.17" sc-client-api = { version = "4.0.0-dev", path = "../api" } sc-network-common = { version = "0.10.0-dev", path = "../network/common" } +sc-network = { version = "0.10.0-dev", path = "../network" } sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" } sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" } diff --git a/client/informant/src/display.rs b/client/informant/src/display.rs index fc68e5603c134..46e7229273d79 100644 --- a/client/informant/src/display.rs +++ b/client/informant/src/display.rs @@ -20,12 +20,10 @@ use crate::OutputFormat; use ansi_term::Colour; use log::info; use sc_client_api::ClientInfo; -use sc_network_common::{ - service::NetworkStatus, - sync::{ - warp::{WarpSyncPhase, WarpSyncProgress}, - SyncState, SyncStatus, - }, +use sc_network::NetworkStatus; +use sc_network_common::sync::{ + warp::{WarpSyncPhase, WarpSyncProgress}, + SyncState, SyncStatus, }; use sp_runtime::traits::{Block as BlockT, CheckedDiv, NumberFor, Saturating, Zero}; use std::{fmt, time::Instant}; diff --git a/client/informant/src/lib.rs b/client/informant/src/lib.rs index dc6aebc2ed658..03f9075055e2f 100644 --- a/client/informant/src/lib.rs +++ b/client/informant/src/lib.rs @@ -23,7 +23,8 @@ use futures::prelude::*; use futures_timer::Delay; use log::{debug, info, trace}; use sc_client_api::{BlockchainEvents, UsageProvider}; -use sc_network_common::{service::NetworkStatusProvider, sync::SyncStatusProvider}; +use sc_network::NetworkStatusProvider; +use sc_network_common::sync::SyncStatusProvider; use sp_blockchain::HeaderMetadata; use sp_runtime::traits::{Block as BlockT, Header}; use std::{collections::VecDeque, fmt::Display, sync::Arc, time::Duration}; diff --git a/client/network-gossip/Cargo.toml b/client/network-gossip/Cargo.toml index 7811e86c095ba..5c1bc91f105c8 100644 --- a/client/network-gossip/Cargo.toml +++ b/client/network-gossip/Cargo.toml @@ -22,6 +22,7 @@ log = "0.4.17" lru = "0.8.1" tracing = "0.1.29" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" } +sc-network = { version = "0.10.0-dev", path = "../network/" } sc-network-common = { version = "0.10.0-dev", path = "../network/common" } sc-peerset = { version = "4.0.0-dev", path = "../peerset" } sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" } diff --git a/client/network-gossip/src/bridge.rs b/client/network-gossip/src/bridge.rs index 7368cc770306e..4793d7822ddbe 100644 --- a/client/network-gossip/src/bridge.rs +++ b/client/network-gossip/src/bridge.rs @@ -21,10 +21,8 @@ use crate::{ Network, Syncing, Validator, }; -use sc_network_common::{ - protocol::{event::Event, ProtocolName}, - sync::SyncEvent, -}; +use sc_network::{event::Event, types::ProtocolName}; +use sc_network_common::sync::SyncEvent; use sc_peerset::ReputationChange; use futures::{ @@ -340,15 +338,11 @@ mod tests { future::poll_fn, }; use quickcheck::{Arbitrary, Gen, QuickCheck}; - use sc_network_common::{ - config::MultiaddrWithPeerId, - protocol::role::ObservedRole, - service::{ - NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers, - NotificationSender, NotificationSenderError, - }, - sync::SyncEventStream, + use sc_network::{ + config::MultiaddrWithPeerId, NetworkBlock, NetworkEventStream, NetworkNotification, + NetworkPeers, NotificationSenderError, NotificationSenderT as NotificationSender, }; + use sc_network_common::{role::ObservedRole, sync::SyncEventStream}; use sp_runtime::{ testing::H256, traits::{Block as BlockT, NumberFor}, diff --git a/client/network-gossip/src/lib.rs b/client/network-gossip/src/lib.rs index e3448ba01c373..ef87dd599e010 100644 --- a/client/network-gossip/src/lib.rs +++ b/client/network-gossip/src/lib.rs @@ -68,11 +68,10 @@ pub use self::{ }; use libp2p::{multiaddr, PeerId}; -use sc_network_common::{ - protocol::ProtocolName, - service::{NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers}, - sync::SyncEventStream, +use sc_network::{ + types::ProtocolName, NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers, }; +use sc_network_common::sync::SyncEventStream; use sp_runtime::traits::{Block as BlockT, NumberFor}; use std::iter; diff --git a/client/network-gossip/src/state_machine.rs b/client/network-gossip/src/state_machine.rs index 3a0d5fc0de173..e6d2b0e2ae4c8 100644 --- a/client/network-gossip/src/state_machine.rs +++ b/client/network-gossip/src/state_machine.rs @@ -22,7 +22,8 @@ use ahash::AHashSet; use libp2p::PeerId; use lru::LruCache; use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64}; -use sc_network_common::protocol::{role::ObservedRole, ProtocolName}; +use sc_network::types::ProtocolName; +use sc_network_common::role::ObservedRole; use sp_runtime::traits::{Block as BlockT, Hash, HashFor}; use std::{collections::HashMap, iter, num::NonZeroUsize, sync::Arc, time, time::Instant}; @@ -525,13 +526,10 @@ mod tests { use super::*; use crate::multiaddr::Multiaddr; use futures::prelude::*; - use sc_network_common::{ - config::MultiaddrWithPeerId, - protocol::event::Event, - service::{ - NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers, - NotificationSender, NotificationSenderError, - }, + use sc_network::{ + config::MultiaddrWithPeerId, event::Event, NetworkBlock, NetworkEventStream, + NetworkNotification, NetworkPeers, NotificationSenderError, + NotificationSenderT as NotificationSender, }; use sc_peerset::ReputationChange; use sp_runtime::{ diff --git a/client/network-gossip/src/validator.rs b/client/network-gossip/src/validator.rs index 26835a5ae6687..2272efba50652 100644 --- a/client/network-gossip/src/validator.rs +++ b/client/network-gossip/src/validator.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . use libp2p::PeerId; -use sc_network_common::protocol::role::ObservedRole; +use sc_network_common::role::ObservedRole; use sp_runtime::traits::Block as BlockT; /// Validates consensus messages. diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 5a918bebd626e..90b5ce871ef1a 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -26,6 +26,7 @@ futures = "0.3.21" futures-timer = "3.0.2" ip_network = "0.4.1" libp2p = { version = "0.50.0", features = ["dns", "identify", "kad", "macros", "mdns", "mplex", "noise", "ping", "tcp", "tokio", "yamux", "websocket"] } +linked_hash_set = "0.1.3" log = "0.4.17" lru = "0.8.1" mockall = "0.11.3" diff --git a/client/network/bitswap/Cargo.toml b/client/network/bitswap/Cargo.toml index 0bbb5ff09e4b9..ee2e0cfc79ff7 100644 --- a/client/network/bitswap/Cargo.toml +++ b/client/network/bitswap/Cargo.toml @@ -24,6 +24,7 @@ prost = "0.11" thiserror = "1.0" unsigned-varint = { version = "0.7.1", features = ["futures", "asynchronous_codec"] } sc-client-api = { version = "4.0.0-dev", path = "../../api" } +sc-network = { version = "0.10.0-dev", path = "../" } sc-network-common = { version = "0.10.0-dev", path = "../common" } sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } diff --git a/client/network/bitswap/src/lib.rs b/client/network/bitswap/src/lib.rs index dd5fc46f6ca71..5a7a7b51355c6 100644 --- a/client/network/bitswap/src/lib.rs +++ b/client/network/bitswap/src/lib.rs @@ -26,9 +26,9 @@ use libp2p::core::PeerId; use log::{debug, error, trace}; use prost::Message; use sc_client_api::BlockBackend; -use sc_network_common::{ - protocol::ProtocolName, +use sc_network::{ request_responses::{IncomingRequest, OutgoingResponse, ProtocolConfig}, + types::ProtocolName, }; use schema::bitswap::{ message::{wantlist::WantType, Block as MessageBlock, BlockPresence, BlockPresenceType}, @@ -127,8 +127,9 @@ impl BitswapRequestHandler { }; match pending_response.send(response) { - Ok(()) => - trace!(target: LOG_TARGET, "Handled bitswap request from {peer}.",), + Ok(()) => { + trace!(target: LOG_TARGET, "Handled bitswap request from {peer}.",) + }, Err(_) => debug!( target: LOG_TARGET, "Failed to handle light client request from {peer}: {}", diff --git a/client/network/common/Cargo.toml b/client/network/common/Cargo.toml index c5f9d6d4cb027..983342b014b82 100644 --- a/client/network/common/Cargo.toml +++ b/client/network/common/Cargo.toml @@ -26,7 +26,6 @@ codec = { package = "parity-scale-codec", version = "3.2.2", features = [ futures = "0.3.21" futures-timer = "3.0.2" libp2p = { version = "0.50.0", features = ["request-response", "kad"] } -linked_hash_set = "0.1.3" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } smallvec = "1.8.0" sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" } diff --git a/client/network/common/src/config.rs b/client/network/common/src/config.rs deleted file mode 100644 index 6a02129fcfe06..0000000000000 --- a/client/network/common/src/config.rs +++ /dev/null @@ -1,702 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -//! Configuration of the networking layer. - -pub use crate::{ - protocol::{self, role::Role}, - request_responses::{ - IncomingRequest, OutgoingResponse, ProtocolConfig as RequestResponseConfig, - }, - sync::warp::WarpSyncProvider, - ExHashT, -}; -pub use libp2p::{build_multiaddr, core::PublicKey, identity}; - -use codec::Encode; -use libp2p::{ - identity::{ed25519, Keypair}, - multiaddr, Multiaddr, PeerId, -}; -use zeroize::Zeroize; - -use std::{ - error::Error, - fmt, fs, - io::{self, Write}, - iter, - net::Ipv4Addr, - path::{Path, PathBuf}, - str, - str::FromStr, -}; - -/// Protocol name prefix, transmitted on the wire for legacy protocol names. -/// I.e., `dot` in `/dot/sync/2`. Should be unique for each chain. Always UTF-8. -/// Deprecated in favour of genesis hash & fork ID based protocol names. -#[derive(Clone, PartialEq, Eq, Hash)] -pub struct ProtocolId(smallvec::SmallVec<[u8; 6]>); - -impl<'a> From<&'a str> for ProtocolId { - fn from(bytes: &'a str) -> ProtocolId { - Self(bytes.as_bytes().into()) - } -} - -impl AsRef for ProtocolId { - fn as_ref(&self) -> &str { - str::from_utf8(&self.0[..]) - .expect("the only way to build a ProtocolId is through a UTF-8 String; qed") - } -} - -impl fmt::Debug for ProtocolId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(self.as_ref(), f) - } -} - -/// Parses a string address and splits it into Multiaddress and PeerId, if -/// valid. -/// -/// # Example -/// -/// ``` -/// # use libp2p::{Multiaddr, PeerId}; -/// # use sc_network_common::config::parse_str_addr; -/// let (peer_id, addr) = parse_str_addr( -/// "/ip4/198.51.100.19/tcp/30333/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV" -/// ).unwrap(); -/// assert_eq!(peer_id, "QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV".parse::().unwrap()); -/// assert_eq!(addr, "/ip4/198.51.100.19/tcp/30333".parse::().unwrap()); -/// ``` -pub fn parse_str_addr(addr_str: &str) -> Result<(PeerId, Multiaddr), ParseErr> { - let addr: Multiaddr = addr_str.parse()?; - parse_addr(addr) -} - -/// Splits a Multiaddress into a Multiaddress and PeerId. -pub fn parse_addr(mut addr: Multiaddr) -> Result<(PeerId, Multiaddr), ParseErr> { - let who = match addr.pop() { - Some(multiaddr::Protocol::P2p(key)) => - PeerId::from_multihash(key).map_err(|_| ParseErr::InvalidPeerId)?, - _ => return Err(ParseErr::PeerIdMissing), - }; - - Ok((who, addr)) -} - -/// Address of a node, including its identity. -/// -/// This struct represents a decoded version of a multiaddress that ends with `/p2p/`. -/// -/// # Example -/// -/// ``` -/// # use libp2p::{Multiaddr, PeerId}; -/// # use sc_network_common::config::MultiaddrWithPeerId; -/// let addr: MultiaddrWithPeerId = -/// "/ip4/198.51.100.19/tcp/30333/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV".parse().unwrap(); -/// assert_eq!(addr.peer_id.to_base58(), "QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV"); -/// assert_eq!(addr.multiaddr.to_string(), "/ip4/198.51.100.19/tcp/30333"); -/// ``` -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq)] -#[serde(try_from = "String", into = "String")] -pub struct MultiaddrWithPeerId { - /// Address of the node. - pub multiaddr: Multiaddr, - /// Its identity. - pub peer_id: PeerId, -} - -impl MultiaddrWithPeerId { - /// Concatenates the multiaddress and peer ID into one multiaddress containing both. - pub fn concat(&self) -> Multiaddr { - let proto = multiaddr::Protocol::P2p(From::from(self.peer_id)); - self.multiaddr.clone().with(proto) - } -} - -impl fmt::Display for MultiaddrWithPeerId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Display::fmt(&self.concat(), f) - } -} - -impl FromStr for MultiaddrWithPeerId { - type Err = ParseErr; - - fn from_str(s: &str) -> Result { - let (peer_id, multiaddr) = parse_str_addr(s)?; - Ok(Self { peer_id, multiaddr }) - } -} - -impl From for String { - fn from(ma: MultiaddrWithPeerId) -> String { - format!("{}", ma) - } -} - -impl TryFrom for MultiaddrWithPeerId { - type Error = ParseErr; - fn try_from(string: String) -> Result { - string.parse() - } -} - -/// Error that can be generated by `parse_str_addr`. -#[derive(Debug)] -pub enum ParseErr { - /// Error while parsing the multiaddress. - MultiaddrParse(multiaddr::Error), - /// Multihash of the peer ID is invalid. - InvalidPeerId, - /// The peer ID is missing from the address. - PeerIdMissing, -} - -impl fmt::Display for ParseErr { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::MultiaddrParse(err) => write!(f, "{}", err), - Self::InvalidPeerId => write!(f, "Peer id at the end of the address is invalid"), - Self::PeerIdMissing => write!(f, "Peer id is missing from the address"), - } - } -} - -impl std::error::Error for ParseErr { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - match self { - Self::MultiaddrParse(err) => Some(err), - Self::InvalidPeerId => None, - Self::PeerIdMissing => None, - } - } -} - -impl From for ParseErr { - fn from(err: multiaddr::Error) -> ParseErr { - Self::MultiaddrParse(err) - } -} - -/// Configuration for a set of nodes. -#[derive(Clone, Debug)] -pub struct SetConfig { - /// Maximum allowed number of incoming substreams related to this set. - pub in_peers: u32, - /// Number of outgoing substreams related to this set that we're trying to maintain. - pub out_peers: u32, - /// List of reserved node addresses. - pub reserved_nodes: Vec, - /// Whether nodes that aren't in [`SetConfig::reserved_nodes`] are accepted or automatically - /// refused. - pub non_reserved_mode: NonReservedPeerMode, -} - -impl Default for SetConfig { - fn default() -> Self { - Self { - in_peers: 25, - out_peers: 75, - reserved_nodes: Vec::new(), - non_reserved_mode: NonReservedPeerMode::Accept, - } - } -} - -/// Custom handshake for the notification protocol -#[derive(Debug, Clone)] -pub struct NotificationHandshake(Vec); - -impl NotificationHandshake { - /// Create new `NotificationHandshake` from an object that implements `Encode` - pub fn new(handshake: H) -> Self { - Self(handshake.encode()) - } - - /// Create new `NotificationHandshake` from raw bytes - pub fn from_bytes(bytes: Vec) -> Self { - Self(bytes) - } -} - -impl std::ops::Deref for NotificationHandshake { - type Target = Vec; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -/// Extension to [`SetConfig`] for sets that aren't the default set. -/// -/// > **Note**: As new fields might be added in the future, please consider using the `new` method -/// > and modifiers instead of creating this struct manually. -#[derive(Clone, Debug)] -pub struct NonDefaultSetConfig { - /// Name of the notifications protocols of this set. A substream on this set will be - /// considered established once this protocol is open. - /// - /// > **Note**: This field isn't present for the default set, as this is handled internally - /// > by the networking code. - pub notifications_protocol: protocol::ProtocolName, - /// If the remote reports that it doesn't support the protocol indicated in the - /// `notifications_protocol` field, then each of these fallback names will be tried one by - /// one. - /// - /// If a fallback is used, it will be reported in - /// `sc_network::protocol::event::Event::NotificationStreamOpened::negotiated_fallback` - pub fallback_names: Vec, - /// Handshake of the protocol - /// - /// NOTE: Currently custom handshakes are not fully supported. See issue #5685 for more - /// details. This field is temporarily used to allow moving the hardcoded block announcement - /// protocol out of `protocol.rs`. - pub handshake: Option, - /// Maximum allowed size of single notifications. - pub max_notification_size: u64, - /// Base configuration. - pub set_config: SetConfig, -} - -impl NonDefaultSetConfig { - /// Creates a new [`NonDefaultSetConfig`]. Zero slots and accepts only reserved nodes. - pub fn new(notifications_protocol: protocol::ProtocolName, max_notification_size: u64) -> Self { - Self { - notifications_protocol, - max_notification_size, - fallback_names: Vec::new(), - handshake: None, - set_config: SetConfig { - in_peers: 0, - out_peers: 0, - reserved_nodes: Vec::new(), - non_reserved_mode: NonReservedPeerMode::Deny, - }, - } - } - - /// Modifies the configuration to allow non-reserved nodes. - pub fn allow_non_reserved(&mut self, in_peers: u32, out_peers: u32) { - self.set_config.in_peers = in_peers; - self.set_config.out_peers = out_peers; - self.set_config.non_reserved_mode = NonReservedPeerMode::Accept; - } - - /// Add a node to the list of reserved nodes. - pub fn add_reserved(&mut self, peer: MultiaddrWithPeerId) { - self.set_config.reserved_nodes.push(peer); - } - - /// Add a list of protocol names used for backward compatibility. - /// - /// See the explanations in [`NonDefaultSetConfig::fallback_names`]. - pub fn add_fallback_names(&mut self, fallback_names: Vec) { - self.fallback_names.extend(fallback_names); - } -} - -/// Configuration for the transport layer. -#[derive(Clone, Debug)] -pub enum TransportConfig { - /// Normal transport mode. - Normal { - /// If true, the network will use mDNS to discover other libp2p nodes on the local network - /// and connect to them if they support the same chain. - enable_mdns: bool, - - /// If true, allow connecting to private IPv4/IPv6 addresses (as defined in - /// [RFC1918](https://tools.ietf.org/html/rfc1918)). Irrelevant for addresses that have - /// been passed in `::sc_network::config::NetworkConfiguration::boot_nodes`. - allow_private_ip: bool, - }, - - /// Only allow connections within the same process. - /// Only addresses of the form `/memory/...` will be supported. - MemoryOnly, -} - -/// The policy for connections to non-reserved peers. -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum NonReservedPeerMode { - /// Accept them. This is the default. - Accept, - /// Deny them. - Deny, -} - -impl NonReservedPeerMode { - /// Attempt to parse the peer mode from a string. - pub fn parse(s: &str) -> Option { - match s { - "accept" => Some(Self::Accept), - "deny" => Some(Self::Deny), - _ => None, - } - } -} - -/// Sync operation mode. -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub enum SyncMode { - /// Full block download and verification. - Full, - /// Download blocks and the latest state. - Fast { - /// Skip state proof download and verification. - skip_proofs: bool, - /// Download indexed transactions for recent blocks. - storage_chain_mode: bool, - }, - /// Warp sync - verify authority set transitions and the latest state. - Warp, -} - -impl SyncMode { - /// Returns if `self` is [`Self::Warp`]. - pub fn is_warp(&self) -> bool { - matches!(self, Self::Warp) - } - - /// Returns if `self` is [`Self::Fast`]. - pub fn is_fast(&self) -> bool { - matches!(self, Self::Fast { .. }) - } -} - -impl Default for SyncMode { - fn default() -> Self { - Self::Full - } -} - -/// Network service configuration. -#[derive(Clone, Debug)] -pub struct NetworkConfiguration { - /// Directory path to store network-specific configuration. None means nothing will be saved. - pub net_config_path: Option, - /// Multiaddresses to listen for incoming connections. - pub listen_addresses: Vec, - /// Multiaddresses to advertise. Detected automatically if empty. - pub public_addresses: Vec, - /// List of initial node addresses - pub boot_nodes: Vec, - /// The node key configuration, which determines the node's network identity keypair. - pub node_key: NodeKeyConfig, - /// List of request-response protocols that the node supports. - pub request_response_protocols: Vec, - /// Configuration for the default set of nodes used for block syncing and transactions. - pub default_peers_set: SetConfig, - /// Number of substreams to reserve for full nodes for block syncing and transactions. - /// Any other slot will be dedicated to light nodes. - /// - /// This value is implicitly capped to `default_set.out_peers + default_set.in_peers`. - pub default_peers_set_num_full: u32, - /// Configuration for extra sets of nodes. - pub extra_sets: Vec, - /// Client identifier. Sent over the wire for debugging purposes. - pub client_version: String, - /// Name of the node. Sent over the wire for debugging purposes. - pub node_name: String, - /// Configuration for the transport layer. - pub transport: TransportConfig, - /// Maximum number of peers to ask the same blocks in parallel. - pub max_parallel_downloads: u32, - /// Initial syncing mode. - pub sync_mode: SyncMode, - - /// True if Kademlia random discovery should be enabled. - /// - /// If true, the node will automatically randomly walk the DHT in order to find new peers. - pub enable_dht_random_walk: bool, - - /// Should we insert non-global addresses into the DHT? - pub allow_non_globals_in_dht: bool, - - /// Require iterative Kademlia DHT queries to use disjoint paths for increased resiliency in - /// the presence of potentially adversarial nodes. - pub kademlia_disjoint_query_paths: bool, - /// Enable serving block data over IPFS bitswap. - pub ipfs_server: bool, - - /// Size of Yamux receive window of all substreams. `None` for the default (256kiB). - /// Any value less than 256kiB is invalid. - /// - /// # Context - /// - /// By design, notifications substreams on top of Yamux connections only allow up to `N` bytes - /// to be transferred at a time, where `N` is the Yamux receive window size configurable here. - /// This means, in practice, that every `N` bytes must be acknowledged by the receiver before - /// the sender can send more data. The maximum bandwidth of each notifications substream is - /// therefore `N / round_trip_time`. - /// - /// It is recommended to leave this to `None`, and use a request-response protocol instead if - /// a large amount of data must be transferred. The reason why the value is configurable is - /// that some Substrate users mis-use notification protocols to send large amounts of data. - /// As such, this option isn't designed to stay and will likely get removed in the future. - /// - /// Note that configuring a value here isn't a modification of the Yamux protocol, but rather - /// a modification of the way the implementation works. Different nodes with different - /// configured values remain compatible with each other. - pub yamux_window_size: Option, -} - -impl NetworkConfiguration { - /// Create new default configuration - pub fn new, SV: Into>( - node_name: SN, - client_version: SV, - node_key: NodeKeyConfig, - net_config_path: Option, - ) -> Self { - let default_peers_set = SetConfig::default(); - Self { - net_config_path, - listen_addresses: Vec::new(), - public_addresses: Vec::new(), - boot_nodes: Vec::new(), - node_key, - request_response_protocols: Vec::new(), - default_peers_set_num_full: default_peers_set.in_peers + default_peers_set.out_peers, - default_peers_set, - extra_sets: Vec::new(), - client_version: client_version.into(), - node_name: node_name.into(), - transport: TransportConfig::Normal { enable_mdns: false, allow_private_ip: true }, - max_parallel_downloads: 5, - sync_mode: SyncMode::Full, - enable_dht_random_walk: true, - allow_non_globals_in_dht: false, - kademlia_disjoint_query_paths: false, - yamux_window_size: None, - ipfs_server: false, - } - } - - /// Create new default configuration for localhost-only connection with random port (useful for - /// testing) - pub fn new_local() -> NetworkConfiguration { - let mut config = - NetworkConfiguration::new("test-node", "test-client", Default::default(), None); - - config.listen_addresses = - vec![iter::once(multiaddr::Protocol::Ip4(Ipv4Addr::new(127, 0, 0, 1))) - .chain(iter::once(multiaddr::Protocol::Tcp(0))) - .collect()]; - - config.allow_non_globals_in_dht = true; - config - } - - /// Create new default configuration for localhost-only connection with random port (useful for - /// testing) - pub fn new_memory() -> NetworkConfiguration { - let mut config = - NetworkConfiguration::new("test-node", "test-client", Default::default(), None); - - config.listen_addresses = - vec![iter::once(multiaddr::Protocol::Ip4(Ipv4Addr::new(127, 0, 0, 1))) - .chain(iter::once(multiaddr::Protocol::Tcp(0))) - .collect()]; - - config.allow_non_globals_in_dht = true; - config - } -} - -/// The configuration of a node's secret key, describing the type of key -/// and how it is obtained. A node's identity keypair is the result of -/// the evaluation of the node key configuration. -#[derive(Clone, Debug)] -pub enum NodeKeyConfig { - /// A Ed25519 secret key configuration. - Ed25519(Secret), -} - -impl Default for NodeKeyConfig { - fn default() -> NodeKeyConfig { - Self::Ed25519(Secret::New) - } -} - -/// The options for obtaining a Ed25519 secret key. -pub type Ed25519Secret = Secret; - -/// The configuration options for obtaining a secret key `K`. -#[derive(Clone)] -pub enum Secret { - /// Use the given secret key `K`. - Input(K), - /// Read the secret key from a file. If the file does not exist, - /// it is created with a newly generated secret key `K`. The format - /// of the file is determined by `K`: - /// - /// * `ed25519::SecretKey`: An unencoded 32 bytes Ed25519 secret key. - File(PathBuf), - /// Always generate a new secret key `K`. - New, -} - -impl fmt::Debug for Secret { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match self { - Self::Input(_) => f.debug_tuple("Secret::Input").finish(), - Self::File(path) => f.debug_tuple("Secret::File").field(path).finish(), - Self::New => f.debug_tuple("Secret::New").finish(), - } - } -} - -impl NodeKeyConfig { - /// Evaluate a `NodeKeyConfig` to obtain an identity `Keypair`: - /// - /// * If the secret is configured as input, the corresponding keypair is returned. - /// - /// * If the secret is configured as a file, it is read from that file, if it exists. Otherwise - /// a new secret is generated and stored. In either case, the keypair obtained from the - /// secret is returned. - /// - /// * If the secret is configured to be new, it is generated and the corresponding keypair is - /// returned. - pub fn into_keypair(self) -> io::Result { - use NodeKeyConfig::*; - match self { - Ed25519(Secret::New) => Ok(Keypair::generate_ed25519()), - - Ed25519(Secret::Input(k)) => Ok(Keypair::Ed25519(k.into())), - - Ed25519(Secret::File(f)) => get_secret( - f, - |mut b| match String::from_utf8(b.to_vec()).ok().and_then(|s| { - if s.len() == 64 { - array_bytes::hex2bytes(&s).ok() - } else { - None - } - }) { - Some(s) => ed25519::SecretKey::from_bytes(s), - _ => ed25519::SecretKey::from_bytes(&mut b), - }, - ed25519::SecretKey::generate, - |b| b.as_ref().to_vec(), - ) - .map(ed25519::Keypair::from) - .map(Keypair::Ed25519), - } - } -} - -/// Load a secret key from a file, if it exists, or generate a -/// new secret key and write it to that file. In either case, -/// the secret key is returned. -fn get_secret(file: P, parse: F, generate: G, serialize: W) -> io::Result -where - P: AsRef, - F: for<'r> FnOnce(&'r mut [u8]) -> Result, - G: FnOnce() -> K, - E: Error + Send + Sync + 'static, - W: Fn(&K) -> Vec, -{ - std::fs::read(&file) - .and_then(|mut sk_bytes| { - parse(&mut sk_bytes).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)) - }) - .or_else(|e| { - if e.kind() == io::ErrorKind::NotFound { - file.as_ref().parent().map_or(Ok(()), fs::create_dir_all)?; - let sk = generate(); - let mut sk_vec = serialize(&sk); - write_secret_file(file, &sk_vec)?; - sk_vec.zeroize(); - Ok(sk) - } else { - Err(e) - } - }) -} - -/// Write secret bytes to a file. -fn write_secret_file

(path: P, sk_bytes: &[u8]) -> io::Result<()> -where - P: AsRef, -{ - let mut file = open_secret_file(&path)?; - file.write_all(sk_bytes) -} - -/// Opens a file containing a secret key in write mode. -#[cfg(unix)] -fn open_secret_file

(path: P) -> io::Result -where - P: AsRef, -{ - use std::os::unix::fs::OpenOptionsExt; - fs::OpenOptions::new().write(true).create_new(true).mode(0o600).open(path) -} - -/// Opens a file containing a secret key in write mode. -#[cfg(not(unix))] -fn open_secret_file

(path: P) -> Result -where - P: AsRef, -{ - fs::OpenOptions::new().write(true).create_new(true).open(path) -} - -#[cfg(test)] -mod tests { - use super::*; - use tempfile::TempDir; - - fn tempdir_with_prefix(prefix: &str) -> TempDir { - tempfile::Builder::new().prefix(prefix).tempdir().unwrap() - } - - fn secret_bytes(kp: &Keypair) -> Vec { - let Keypair::Ed25519(p) = kp; - p.secret().as_ref().iter().cloned().collect() - } - - #[test] - fn test_secret_file() { - let tmp = tempdir_with_prefix("x"); - std::fs::remove_dir(tmp.path()).unwrap(); // should be recreated - let file = tmp.path().join("x").to_path_buf(); - let kp1 = NodeKeyConfig::Ed25519(Secret::File(file.clone())).into_keypair().unwrap(); - let kp2 = NodeKeyConfig::Ed25519(Secret::File(file.clone())).into_keypair().unwrap(); - assert!(file.is_file() && secret_bytes(&kp1) == secret_bytes(&kp2)) - } - - #[test] - fn test_secret_input() { - let sk = ed25519::SecretKey::generate(); - let kp1 = NodeKeyConfig::Ed25519(Secret::Input(sk.clone())).into_keypair().unwrap(); - let kp2 = NodeKeyConfig::Ed25519(Secret::Input(sk)).into_keypair().unwrap(); - assert!(secret_bytes(&kp1) == secret_bytes(&kp2)); - } - - #[test] - fn test_secret_new() { - let kp1 = NodeKeyConfig::Ed25519(Secret::New).into_keypair().unwrap(); - let kp2 = NodeKeyConfig::Ed25519(Secret::New).into_keypair().unwrap(); - assert!(secret_bytes(&kp1) != secret_bytes(&kp2)); - } -} diff --git a/client/network/common/src/lib.rs b/client/network/common/src/lib.rs index 10d2449388bb9..f53590efd4c84 100644 --- a/client/network/common/src/lib.rs +++ b/client/network/common/src/lib.rs @@ -18,14 +18,9 @@ //! Common data structures of the networking layer. -pub mod config; -pub mod error; pub mod message; -pub mod protocol; -pub mod request_responses; -pub mod service; +pub mod role; pub mod sync; -pub mod utils; /// Minimum Requirements for a Hash within Networking pub trait ExHashT: std::hash::Hash + Eq + std::fmt::Debug + Clone + Send + Sync + 'static {} diff --git a/client/network/common/src/request_responses.rs b/client/network/common/src/request_responses.rs deleted file mode 100644 index 4fa53a736ac33..0000000000000 --- a/client/network/common/src/request_responses.rs +++ /dev/null @@ -1,155 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -//! Collection of generic data structures for request-response protocols. - -use crate::protocol::ProtocolName; -use futures::channel::{mpsc, oneshot}; -use libp2p::{request_response::OutboundFailure, PeerId}; -use sc_peerset::ReputationChange; -use std::time::Duration; - -/// Configuration for a single request-response protocol. -#[derive(Debug, Clone)] -pub struct ProtocolConfig { - /// Name of the protocol on the wire. Should be something like `/foo/bar`. - pub name: ProtocolName, - - /// Fallback on the wire protocol names to support. - pub fallback_names: Vec, - - /// Maximum allowed size, in bytes, of a request. - /// - /// Any request larger than this value will be declined as a way to avoid allocating too - /// much memory for it. - pub max_request_size: u64, - - /// Maximum allowed size, in bytes, of a response. - /// - /// Any response larger than this value will be declined as a way to avoid allocating too - /// much memory for it. - pub max_response_size: u64, - - /// Duration after which emitted requests are considered timed out. - /// - /// If you expect the response to come back quickly, you should set this to a smaller duration. - pub request_timeout: Duration, - - /// Channel on which the networking service will send incoming requests. - /// - /// Every time a peer sends a request to the local node using this protocol, the networking - /// service will push an element on this channel. The receiving side of this channel then has - /// to pull this element, process the request, and send back the response to send back to the - /// peer. - /// - /// The size of the channel has to be carefully chosen. If the channel is full, the networking - /// service will discard the incoming request send back an error to the peer. Consequently, - /// the channel being full is an indicator that the node is overloaded. - /// - /// You can typically set the size of the channel to `T / d`, where `T` is the - /// `request_timeout` and `d` is the expected average duration of CPU and I/O it takes to - /// build a response. - /// - /// Can be `None` if the local node does not support answering incoming requests. - /// If this is `None`, then the local node will not advertise support for this protocol towards - /// other peers. If this is `Some` but the channel is closed, then the local node will - /// advertise support for this protocol, but any incoming request will lead to an error being - /// sent back. - pub inbound_queue: Option>, -} - -/// A single request received by a peer on a request-response protocol. -#[derive(Debug)] -pub struct IncomingRequest { - /// Who sent the request. - pub peer: PeerId, - - /// Request sent by the remote. Will always be smaller than - /// [`ProtocolConfig::max_request_size`]. - pub payload: Vec, - - /// Channel to send back the response. - /// - /// There are two ways to indicate that handling the request failed: - /// - /// 1. Drop `pending_response` and thus not changing the reputation of the peer. - /// - /// 2. Sending an `Err(())` via `pending_response`, optionally including reputation changes for - /// the given peer. - pub pending_response: oneshot::Sender, -} - -/// Response for an incoming request to be send by a request protocol handler. -#[derive(Debug)] -pub struct OutgoingResponse { - /// The payload of the response. - /// - /// `Err(())` if none is available e.g. due an error while handling the request. - pub result: Result, ()>, - - /// Reputation changes accrued while handling the request. To be applied to the reputation of - /// the peer sending the request. - pub reputation_changes: Vec, - - /// If provided, the `oneshot::Sender` will be notified when the request has been sent to the - /// peer. - /// - /// > **Note**: Operating systems typically maintain a buffer of a few dozen kilobytes of - /// > outgoing data for each TCP socket, and it is not possible for a user - /// > application to inspect this buffer. This channel here is not actually notified - /// > when the response has been fully sent out, but rather when it has fully been - /// > written to the buffer managed by the operating system. - pub sent_feedback: Option>, -} - -/// When sending a request, what to do on a disconnected recipient. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum IfDisconnected { - /// Try to connect to the peer. - TryConnect, - /// Just fail if the destination is not yet connected. - ImmediateError, -} - -/// Convenience functions for `IfDisconnected`. -impl IfDisconnected { - /// Shall we connect to a disconnected peer? - pub fn should_connect(self) -> bool { - match self { - Self::TryConnect => true, - Self::ImmediateError => false, - } - } -} - -/// Error in a request. -#[derive(Debug, thiserror::Error)] -#[allow(missing_docs)] -pub enum RequestFailure { - #[error("We are not currently connected to the requested peer.")] - NotConnected, - #[error("Given protocol hasn't been registered.")] - UnknownProtocol, - #[error("Remote has closed the substream before answering, thereby signaling that it considers the request as valid, but refused to answer it.")] - Refused, - #[error("The remote replied, but the local node is no longer interested in the response.")] - Obsolete, - /// Problem on the network. - #[error("Problem on the network: {0}")] - Network(OutboundFailure), -} diff --git a/client/network/common/src/protocol/role.rs b/client/network/common/src/role.rs similarity index 100% rename from client/network/common/src/protocol/role.rs rename to client/network/common/src/role.rs diff --git a/client/network/common/src/sync.rs b/client/network/common/src/sync.rs index 262da6c202aa3..130f354b70050 100644 --- a/client/network/common/src/sync.rs +++ b/client/network/common/src/sync.rs @@ -22,7 +22,7 @@ pub mod message; pub mod metrics; pub mod warp; -use crate::protocol::role::Roles; +use crate::role::Roles; use futures::Stream; use libp2p::PeerId; diff --git a/client/network/common/src/sync/message.rs b/client/network/common/src/sync/message.rs index 7b8be18bda5cc..c651660c89c8d 100644 --- a/client/network/common/src/sync/message.rs +++ b/client/network/common/src/sync/message.rs @@ -19,7 +19,7 @@ //! Network packet message types. These get serialized and put into the lower level protocol //! payload. -use crate::protocol::role::Roles; +use crate::role::Roles; use bitflags::bitflags; use codec::{Decode, Encode, Error, Input, Output}; diff --git a/client/network/light/Cargo.toml b/client/network/light/Cargo.toml index f3e94790df61e..ed2a5d6cb4ec6 100644 --- a/client/network/light/Cargo.toml +++ b/client/network/light/Cargo.toml @@ -26,6 +26,7 @@ log = "0.4.16" prost = "0.11" sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } sc-client-api = { version = "4.0.0-dev", path = "../../api" } +sc-network = { version = "0.10.0-dev", path = "../" } sc-network-common = { version = "0.10.0-dev", path = "../common" } sc-peerset = { version = "4.0.0-dev", path = "../../peerset" } sp-core = { version = "7.0.0", path = "../../../primitives/core" } diff --git a/client/network/light/src/light_client_requests.rs b/client/network/light/src/light_client_requests.rs index 5b6daf174cce6..4d2a301c00e6b 100644 --- a/client/network/light/src/light_client_requests.rs +++ b/client/network/light/src/light_client_requests.rs @@ -18,13 +18,13 @@ //! Helpers for outgoing and incoming light client requests. -/// For incoming light client requests. -pub mod handler; - -use sc_network_common::{config::ProtocolId, request_responses::ProtocolConfig}; +use sc_network::{config::ProtocolId, request_responses::ProtocolConfig}; use std::time::Duration; +/// For incoming light client requests. +pub mod handler; + /// Generate the light client protocol name from the genesis hash and fork id. fn generate_protocol_name>(genesis_hash: Hash, fork_id: Option<&str>) -> String { let genesis_hash = genesis_hash.as_ref(); diff --git a/client/network/light/src/light_client_requests/handler.rs b/client/network/light/src/light_client_requests/handler.rs index 0a1215a1dc6a9..db2630b79f498 100644 --- a/client/network/light/src/light_client_requests/handler.rs +++ b/client/network/light/src/light_client_requests/handler.rs @@ -29,7 +29,7 @@ use libp2p::PeerId; use log::{debug, trace}; use prost::Message; use sc_client_api::{BlockBackend, ProofProvider}; -use sc_network_common::{ +use sc_network::{ config::ProtocolId, request_responses::{IncomingRequest, OutgoingResponse, ProtocolConfig}, }; diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index 5591290200361..f068099928efc 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -18,9 +18,11 @@ use crate::{ discovery::{DiscoveryBehaviour, DiscoveryConfig, DiscoveryOut}, + event::DhtEvent, peer_info, protocol::{CustomMessageOutcome, NotificationsSink, Protocol}, - request_responses, + request_responses::{self, IfDisconnected, ProtocolConfig, RequestFailure}, + types::ProtocolName, }; use bytes::Bytes; @@ -32,14 +34,7 @@ use libp2p::{ swarm::NetworkBehaviour, }; -use sc_network_common::{ - protocol::{ - event::DhtEvent, - role::{ObservedRole, Roles}, - ProtocolName, - }, - request_responses::{IfDisconnected, ProtocolConfig, RequestFailure}, -}; +use sc_network_common::role::{ObservedRole, Roles}; use sc_peerset::{PeersetHandle, ReputationChange}; use sp_runtime::traits::Block as BlockT; use std::{collections::HashSet, time::Duration}; diff --git a/client/network/src/config.rs b/client/network/src/config.rs index 90d02af848bf4..925a7795d290f 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -21,21 +21,671 @@ //! The [`Params`] struct is the struct that must be passed in order to initialize the networking. //! See the documentation of [`Params`]. -pub use sc_network_common::{ - config::{NetworkConfiguration, ProtocolId}, - protocol::role::Role, +pub use crate::{ request_responses::{ IncomingRequest, OutgoingResponse, ProtocolConfig as RequestResponseConfig, }, - sync::warp::WarpSyncProvider, - ExHashT, + types::ProtocolName, }; -pub use libp2p::{build_multiaddr, core::PublicKey, identity}; - +use codec::Encode; +use libp2p::{identity::Keypair, multiaddr, Multiaddr, PeerId}; use prometheus_endpoint::Registry; -use sc_network_common::config::NonDefaultSetConfig; -use std::{future::Future, pin::Pin, sync::Arc}; +pub use sc_network_common::{role::Role, sync::warp::WarpSyncProvider, ExHashT}; +use zeroize::Zeroize; + +use std::{ + error::Error, + fmt, fs, + future::Future, + io::{self, Write}, + iter, + net::Ipv4Addr, + path::{Path, PathBuf}, + pin::Pin, + str::{self, FromStr}, + sync::Arc, +}; + +pub use libp2p::{ + build_multiaddr, + identity::{self, ed25519}, +}; + +/// Protocol name prefix, transmitted on the wire for legacy protocol names. +/// I.e., `dot` in `/dot/sync/2`. Should be unique for each chain. Always UTF-8. +/// Deprecated in favour of genesis hash & fork ID based protocol names. +#[derive(Clone, PartialEq, Eq, Hash)] +pub struct ProtocolId(smallvec::SmallVec<[u8; 6]>); + +impl<'a> From<&'a str> for ProtocolId { + fn from(bytes: &'a str) -> ProtocolId { + Self(bytes.as_bytes().into()) + } +} + +impl AsRef for ProtocolId { + fn as_ref(&self) -> &str { + str::from_utf8(&self.0[..]) + .expect("the only way to build a ProtocolId is through a UTF-8 String; qed") + } +} + +impl fmt::Debug for ProtocolId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(self.as_ref(), f) + } +} + +/// Parses a string address and splits it into Multiaddress and PeerId, if +/// valid. +/// +/// # Example +/// +/// ``` +/// # use libp2p::{Multiaddr, PeerId}; +/// use sc_network::config::parse_str_addr; +/// let (peer_id, addr) = parse_str_addr( +/// "/ip4/198.51.100.19/tcp/30333/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV" +/// ).unwrap(); +/// assert_eq!(peer_id, "QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV".parse::().unwrap()); +/// assert_eq!(addr, "/ip4/198.51.100.19/tcp/30333".parse::().unwrap()); +/// ``` +pub fn parse_str_addr(addr_str: &str) -> Result<(PeerId, Multiaddr), ParseErr> { + let addr: Multiaddr = addr_str.parse()?; + parse_addr(addr) +} + +/// Splits a Multiaddress into a Multiaddress and PeerId. +pub fn parse_addr(mut addr: Multiaddr) -> Result<(PeerId, Multiaddr), ParseErr> { + let who = match addr.pop() { + Some(multiaddr::Protocol::P2p(key)) => + PeerId::from_multihash(key).map_err(|_| ParseErr::InvalidPeerId)?, + _ => return Err(ParseErr::PeerIdMissing), + }; + + Ok((who, addr)) +} + +/// Address of a node, including its identity. +/// +/// This struct represents a decoded version of a multiaddress that ends with `/p2p/`. +/// +/// # Example +/// +/// ``` +/// # use libp2p::{Multiaddr, PeerId}; +/// use sc_network::config::MultiaddrWithPeerId; +/// let addr: MultiaddrWithPeerId = +/// "/ip4/198.51.100.19/tcp/30333/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV".parse().unwrap(); +/// assert_eq!(addr.peer_id.to_base58(), "QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV"); +/// assert_eq!(addr.multiaddr.to_string(), "/ip4/198.51.100.19/tcp/30333"); +/// ``` +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq)] +#[serde(try_from = "String", into = "String")] +pub struct MultiaddrWithPeerId { + /// Address of the node. + pub multiaddr: Multiaddr, + /// Its identity. + pub peer_id: PeerId, +} + +impl MultiaddrWithPeerId { + /// Concatenates the multiaddress and peer ID into one multiaddress containing both. + pub fn concat(&self) -> Multiaddr { + let proto = multiaddr::Protocol::P2p(From::from(self.peer_id)); + self.multiaddr.clone().with(proto) + } +} + +impl fmt::Display for MultiaddrWithPeerId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.concat(), f) + } +} + +impl FromStr for MultiaddrWithPeerId { + type Err = ParseErr; + + fn from_str(s: &str) -> Result { + let (peer_id, multiaddr) = parse_str_addr(s)?; + Ok(Self { peer_id, multiaddr }) + } +} + +impl From for String { + fn from(ma: MultiaddrWithPeerId) -> String { + format!("{}", ma) + } +} + +impl TryFrom for MultiaddrWithPeerId { + type Error = ParseErr; + fn try_from(string: String) -> Result { + string.parse() + } +} + +/// Error that can be generated by `parse_str_addr`. +#[derive(Debug)] +pub enum ParseErr { + /// Error while parsing the multiaddress. + MultiaddrParse(multiaddr::Error), + /// Multihash of the peer ID is invalid. + InvalidPeerId, + /// The peer ID is missing from the address. + PeerIdMissing, +} + +impl fmt::Display for ParseErr { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::MultiaddrParse(err) => write!(f, "{}", err), + Self::InvalidPeerId => write!(f, "Peer id at the end of the address is invalid"), + Self::PeerIdMissing => write!(f, "Peer id is missing from the address"), + } + } +} + +impl std::error::Error for ParseErr { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Self::MultiaddrParse(err) => Some(err), + Self::InvalidPeerId => None, + Self::PeerIdMissing => None, + } + } +} + +impl From for ParseErr { + fn from(err: multiaddr::Error) -> ParseErr { + Self::MultiaddrParse(err) + } +} + +/// Custom handshake for the notification protocol +#[derive(Debug, Clone)] +pub struct NotificationHandshake(Vec); + +impl NotificationHandshake { + /// Create new `NotificationHandshake` from an object that implements `Encode` + pub fn new(handshake: H) -> Self { + Self(handshake.encode()) + } + + /// Create new `NotificationHandshake` from raw bytes + pub fn from_bytes(bytes: Vec) -> Self { + Self(bytes) + } +} + +impl std::ops::Deref for NotificationHandshake { + type Target = Vec; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +/// Configuration for the transport layer. +#[derive(Clone, Debug)] +pub enum TransportConfig { + /// Normal transport mode. + Normal { + /// If true, the network will use mDNS to discover other libp2p nodes on the local network + /// and connect to them if they support the same chain. + enable_mdns: bool, + + /// If true, allow connecting to private IPv4/IPv6 addresses (as defined in + /// [RFC1918](https://tools.ietf.org/html/rfc1918)). Irrelevant for addresses that have + /// been passed in `::sc_network::config::NetworkConfiguration::boot_nodes`. + allow_private_ip: bool, + }, + + /// Only allow connections within the same process. + /// Only addresses of the form `/memory/...` will be supported. + MemoryOnly, +} + +/// The policy for connections to non-reserved peers. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum NonReservedPeerMode { + /// Accept them. This is the default. + Accept, + /// Deny them. + Deny, +} + +impl NonReservedPeerMode { + /// Attempt to parse the peer mode from a string. + pub fn parse(s: &str) -> Option { + match s { + "accept" => Some(Self::Accept), + "deny" => Some(Self::Deny), + _ => None, + } + } +} + +/// Sync operation mode. +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum SyncMode { + /// Full block download and verification. + Full, + /// Download blocks and the latest state. + Fast { + /// Skip state proof download and verification. + skip_proofs: bool, + /// Download indexed transactions for recent blocks. + storage_chain_mode: bool, + }, + /// Warp sync - verify authority set transitions and the latest state. + Warp, +} + +impl SyncMode { + /// Returns if `self` is [`Self::Warp`]. + pub fn is_warp(&self) -> bool { + matches!(self, Self::Warp) + } + + /// Returns if `self` is [`Self::Fast`]. + pub fn is_fast(&self) -> bool { + matches!(self, Self::Fast { .. }) + } +} + +impl Default for SyncMode { + fn default() -> Self { + Self::Full + } +} + +/// The configuration of a node's secret key, describing the type of key +/// and how it is obtained. A node's identity keypair is the result of +/// the evaluation of the node key configuration. +#[derive(Clone, Debug)] +pub enum NodeKeyConfig { + /// A Ed25519 secret key configuration. + Ed25519(Secret), +} + +impl Default for NodeKeyConfig { + fn default() -> NodeKeyConfig { + Self::Ed25519(Secret::New) + } +} + +/// The options for obtaining a Ed25519 secret key. +pub type Ed25519Secret = Secret; + +/// The configuration options for obtaining a secret key `K`. +#[derive(Clone)] +pub enum Secret { + /// Use the given secret key `K`. + Input(K), + /// Read the secret key from a file. If the file does not exist, + /// it is created with a newly generated secret key `K`. The format + /// of the file is determined by `K`: + /// + /// * `ed25519::SecretKey`: An unencoded 32 bytes Ed25519 secret key. + File(PathBuf), + /// Always generate a new secret key `K`. + New, +} + +impl fmt::Debug for Secret { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Self::Input(_) => f.debug_tuple("Secret::Input").finish(), + Self::File(path) => f.debug_tuple("Secret::File").field(path).finish(), + Self::New => f.debug_tuple("Secret::New").finish(), + } + } +} + +impl NodeKeyConfig { + /// Evaluate a `NodeKeyConfig` to obtain an identity `Keypair`: + /// + /// * If the secret is configured as input, the corresponding keypair is returned. + /// + /// * If the secret is configured as a file, it is read from that file, if it exists. Otherwise + /// a new secret is generated and stored. In either case, the keypair obtained from the + /// secret is returned. + /// + /// * If the secret is configured to be new, it is generated and the corresponding keypair is + /// returned. + pub fn into_keypair(self) -> io::Result { + use NodeKeyConfig::*; + match self { + Ed25519(Secret::New) => Ok(Keypair::generate_ed25519()), + + Ed25519(Secret::Input(k)) => Ok(Keypair::Ed25519(k.into())), + + Ed25519(Secret::File(f)) => get_secret( + f, + |mut b| match String::from_utf8(b.to_vec()).ok().and_then(|s| { + if s.len() == 64 { + array_bytes::hex2bytes(&s).ok() + } else { + None + } + }) { + Some(s) => ed25519::SecretKey::from_bytes(s), + _ => ed25519::SecretKey::from_bytes(&mut b), + }, + ed25519::SecretKey::generate, + |b| b.as_ref().to_vec(), + ) + .map(ed25519::Keypair::from) + .map(Keypair::Ed25519), + } + } +} + +/// Load a secret key from a file, if it exists, or generate a +/// new secret key and write it to that file. In either case, +/// the secret key is returned. +fn get_secret(file: P, parse: F, generate: G, serialize: W) -> io::Result +where + P: AsRef, + F: for<'r> FnOnce(&'r mut [u8]) -> Result, + G: FnOnce() -> K, + E: Error + Send + Sync + 'static, + W: Fn(&K) -> Vec, +{ + std::fs::read(&file) + .and_then(|mut sk_bytes| { + parse(&mut sk_bytes).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)) + }) + .or_else(|e| { + if e.kind() == io::ErrorKind::NotFound { + file.as_ref().parent().map_or(Ok(()), fs::create_dir_all)?; + let sk = generate(); + let mut sk_vec = serialize(&sk); + write_secret_file(file, &sk_vec)?; + sk_vec.zeroize(); + Ok(sk) + } else { + Err(e) + } + }) +} + +/// Write secret bytes to a file. +fn write_secret_file

(path: P, sk_bytes: &[u8]) -> io::Result<()> +where + P: AsRef, +{ + let mut file = open_secret_file(&path)?; + file.write_all(sk_bytes) +} + +/// Opens a file containing a secret key in write mode. +#[cfg(unix)] +fn open_secret_file

(path: P) -> io::Result +where + P: AsRef, +{ + use std::os::unix::fs::OpenOptionsExt; + fs::OpenOptions::new().write(true).create_new(true).mode(0o600).open(path) +} + +/// Opens a file containing a secret key in write mode. +#[cfg(not(unix))] +fn open_secret_file

(path: P) -> Result +where + P: AsRef, +{ + fs::OpenOptions::new().write(true).create_new(true).open(path) +} + +/// Configuration for a set of nodes. +#[derive(Clone, Debug)] +pub struct SetConfig { + /// Maximum allowed number of incoming substreams related to this set. + pub in_peers: u32, + + /// Number of outgoing substreams related to this set that we're trying to maintain. + pub out_peers: u32, + + /// List of reserved node addresses. + pub reserved_nodes: Vec, + + /// Whether nodes that aren't in [`SetConfig::reserved_nodes`] are accepted or automatically + /// refused. + pub non_reserved_mode: NonReservedPeerMode, +} + +impl Default for SetConfig { + fn default() -> Self { + Self { + in_peers: 25, + out_peers: 75, + reserved_nodes: Vec::new(), + non_reserved_mode: NonReservedPeerMode::Accept, + } + } +} + +/// Extension to [`SetConfig`] for sets that aren't the default set. +/// +/// > **Note**: As new fields might be added in the future, please consider using the `new` method +/// > and modifiers instead of creating this struct manually. +#[derive(Clone, Debug)] +pub struct NonDefaultSetConfig { + /// Name of the notifications protocols of this set. A substream on this set will be + /// considered established once this protocol is open. + /// + /// > **Note**: This field isn't present for the default set, as this is handled internally + /// > by the networking code. + pub notifications_protocol: ProtocolName, + + /// If the remote reports that it doesn't support the protocol indicated in the + /// `notifications_protocol` field, then each of these fallback names will be tried one by + /// one. + /// + /// If a fallback is used, it will be reported in + /// `sc_network::protocol::event::Event::NotificationStreamOpened::negotiated_fallback` + pub fallback_names: Vec, + + /// Handshake of the protocol + /// + /// NOTE: Currently custom handshakes are not fully supported. See issue #5685 for more + /// details. This field is temporarily used to allow moving the hardcoded block announcement + /// protocol out of `protocol.rs`. + pub handshake: Option, + + /// Maximum allowed size of single notifications. + pub max_notification_size: u64, + + /// Base configuration. + pub set_config: SetConfig, +} + +impl NonDefaultSetConfig { + /// Creates a new [`NonDefaultSetConfig`]. Zero slots and accepts only reserved nodes. + pub fn new(notifications_protocol: ProtocolName, max_notification_size: u64) -> Self { + Self { + notifications_protocol, + max_notification_size, + fallback_names: Vec::new(), + handshake: None, + set_config: SetConfig { + in_peers: 0, + out_peers: 0, + reserved_nodes: Vec::new(), + non_reserved_mode: NonReservedPeerMode::Deny, + }, + } + } + + /// Modifies the configuration to allow non-reserved nodes. + pub fn allow_non_reserved(&mut self, in_peers: u32, out_peers: u32) { + self.set_config.in_peers = in_peers; + self.set_config.out_peers = out_peers; + self.set_config.non_reserved_mode = NonReservedPeerMode::Accept; + } + + /// Add a node to the list of reserved nodes. + pub fn add_reserved(&mut self, peer: MultiaddrWithPeerId) { + self.set_config.reserved_nodes.push(peer); + } + + /// Add a list of protocol names used for backward compatibility. + /// + /// See the explanations in [`NonDefaultSetConfig::fallback_names`]. + pub fn add_fallback_names(&mut self, fallback_names: Vec) { + self.fallback_names.extend(fallback_names); + } +} + +/// Network service configuration. +#[derive(Clone, Debug)] +pub struct NetworkConfiguration { + /// Directory path to store network-specific configuration. None means nothing will be saved. + pub net_config_path: Option, + + /// Multiaddresses to listen for incoming connections. + pub listen_addresses: Vec, + + /// Multiaddresses to advertise. Detected automatically if empty. + pub public_addresses: Vec, + + /// List of initial node addresses + pub boot_nodes: Vec, + + /// The node key configuration, which determines the node's network identity keypair. + pub node_key: NodeKeyConfig, + + /// List of request-response protocols that the node supports. + pub request_response_protocols: Vec, + /// Configuration for the default set of nodes used for block syncing and transactions. + pub default_peers_set: SetConfig, + + /// Number of substreams to reserve for full nodes for block syncing and transactions. + /// Any other slot will be dedicated to light nodes. + /// + /// This value is implicitly capped to `default_set.out_peers + default_set.in_peers`. + pub default_peers_set_num_full: u32, + + /// Configuration for extra sets of nodes. + pub extra_sets: Vec, + + /// Client identifier. Sent over the wire for debugging purposes. + pub client_version: String, + + /// Name of the node. Sent over the wire for debugging purposes. + pub node_name: String, + + /// Configuration for the transport layer. + pub transport: TransportConfig, + + /// Maximum number of peers to ask the same blocks in parallel. + pub max_parallel_downloads: u32, + + /// Initial syncing mode. + pub sync_mode: SyncMode, + + /// True if Kademlia random discovery should be enabled. + /// + /// If true, the node will automatically randomly walk the DHT in order to find new peers. + pub enable_dht_random_walk: bool, + + /// Should we insert non-global addresses into the DHT? + pub allow_non_globals_in_dht: bool, + + /// Require iterative Kademlia DHT queries to use disjoint paths for increased resiliency in + /// the presence of potentially adversarial nodes. + pub kademlia_disjoint_query_paths: bool, + + /// Enable serving block data over IPFS bitswap. + pub ipfs_server: bool, + + /// Size of Yamux receive window of all substreams. `None` for the default (256kiB). + /// Any value less than 256kiB is invalid. + /// + /// # Context + /// + /// By design, notifications substreams on top of Yamux connections only allow up to `N` bytes + /// to be transferred at a time, where `N` is the Yamux receive window size configurable here. + /// This means, in practice, that every `N` bytes must be acknowledged by the receiver before + /// the sender can send more data. The maximum bandwidth of each notifications substream is + /// therefore `N / round_trip_time`. + /// + /// It is recommended to leave this to `None`, and use a request-response protocol instead if + /// a large amount of data must be transferred. The reason why the value is configurable is + /// that some Substrate users mis-use notification protocols to send large amounts of data. + /// As such, this option isn't designed to stay and will likely get removed in the future. + /// + /// Note that configuring a value here isn't a modification of the Yamux protocol, but rather + /// a modification of the way the implementation works. Different nodes with different + /// configured values remain compatible with each other. + pub yamux_window_size: Option, +} + +impl NetworkConfiguration { + /// Create new default configuration + pub fn new, SV: Into>( + node_name: SN, + client_version: SV, + node_key: NodeKeyConfig, + net_config_path: Option, + ) -> Self { + let default_peers_set = SetConfig::default(); + Self { + net_config_path, + listen_addresses: Vec::new(), + public_addresses: Vec::new(), + boot_nodes: Vec::new(), + node_key, + request_response_protocols: Vec::new(), + default_peers_set_num_full: default_peers_set.in_peers + default_peers_set.out_peers, + default_peers_set, + extra_sets: Vec::new(), + client_version: client_version.into(), + node_name: node_name.into(), + transport: TransportConfig::Normal { enable_mdns: false, allow_private_ip: true }, + max_parallel_downloads: 5, + sync_mode: SyncMode::Full, + enable_dht_random_walk: true, + allow_non_globals_in_dht: false, + kademlia_disjoint_query_paths: false, + yamux_window_size: None, + ipfs_server: false, + } + } + + /// Create new default configuration for localhost-only connection with random port (useful for + /// testing) + pub fn new_local() -> NetworkConfiguration { + let mut config = + NetworkConfiguration::new("test-node", "test-client", Default::default(), None); + + config.listen_addresses = + vec![iter::once(multiaddr::Protocol::Ip4(Ipv4Addr::new(127, 0, 0, 1))) + .chain(iter::once(multiaddr::Protocol::Tcp(0))) + .collect()]; + + config.allow_non_globals_in_dht = true; + config + } + + /// Create new default configuration for localhost-only connection with random port (useful for + /// testing) + pub fn new_memory() -> NetworkConfiguration { + let mut config = + NetworkConfiguration::new("test-node", "test-client", Default::default(), None); + + config.listen_addresses = + vec![iter::once(multiaddr::Protocol::Ip4(Ipv4Addr::new(127, 0, 0, 1))) + .chain(iter::once(multiaddr::Protocol::Tcp(0))) + .collect()]; + + config.allow_non_globals_in_dht = true; + config + } +} /// Network initialization parameters. pub struct Params { @@ -67,3 +717,43 @@ pub struct Params { /// Request response protocol configurations pub request_response_protocol_configs: Vec, } + +#[cfg(test)] +mod tests { + use super::*; + use tempfile::TempDir; + + fn tempdir_with_prefix(prefix: &str) -> TempDir { + tempfile::Builder::new().prefix(prefix).tempdir().unwrap() + } + + fn secret_bytes(kp: &Keypair) -> Vec { + let Keypair::Ed25519(p) = kp; + p.secret().as_ref().iter().cloned().collect() + } + + #[test] + fn test_secret_file() { + let tmp = tempdir_with_prefix("x"); + std::fs::remove_dir(tmp.path()).unwrap(); // should be recreated + let file = tmp.path().join("x").to_path_buf(); + let kp1 = NodeKeyConfig::Ed25519(Secret::File(file.clone())).into_keypair().unwrap(); + let kp2 = NodeKeyConfig::Ed25519(Secret::File(file.clone())).into_keypair().unwrap(); + assert!(file.is_file() && secret_bytes(&kp1) == secret_bytes(&kp2)) + } + + #[test] + fn test_secret_input() { + let sk = ed25519::SecretKey::generate(); + let kp1 = NodeKeyConfig::Ed25519(Secret::Input(sk.clone())).into_keypair().unwrap(); + let kp2 = NodeKeyConfig::Ed25519(Secret::Input(sk)).into_keypair().unwrap(); + assert!(secret_bytes(&kp1) == secret_bytes(&kp2)); + } + + #[test] + fn test_secret_new() { + let kp1 = NodeKeyConfig::Ed25519(Secret::New).into_keypair().unwrap(); + let kp2 = NodeKeyConfig::Ed25519(Secret::New).into_keypair().unwrap(); + assert!(secret_bytes(&kp1) != secret_bytes(&kp2)); + } +} diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 6a8c777cac9c6..7100c0c70d525 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -46,6 +46,8 @@ //! active mechanism that asks nodes for the addresses they are listening on. Whenever we learn //! of a node's address, you must call `add_self_reported_address`. +use crate::{config::ProtocolId, utils::LruHashSet}; + use array_bytes::bytes2hex; use futures::prelude::*; use futures_timer::Delay; @@ -73,7 +75,6 @@ use libp2p::{ }, }; use log::{debug, info, trace, warn}; -use sc_network_common::{config::ProtocolId, utils::LruHashSet}; use sp_core::hexdisplay::HexDisplay; use std::{ cmp, @@ -904,6 +905,7 @@ mod tests { use super::{ kademlia_protocol_name, legacy_kademlia_protocol_name, DiscoveryConfig, DiscoveryOut, }; + use crate::config::ProtocolId; use futures::prelude::*; use libp2p::{ core::{ @@ -915,7 +917,6 @@ mod tests { swarm::{Executor, Swarm, SwarmEvent}, yamux, Multiaddr, }; - use sc_network_common::config::ProtocolId; use sp_core::hash::H256; use std::{collections::HashSet, pin::Pin, task::Poll}; diff --git a/client/network/common/src/error.rs b/client/network/src/error.rs similarity index 97% rename from client/network/common/src/error.rs rename to client/network/src/error.rs index 712b8c5de3f66..f0828fb821f35 100644 --- a/client/network/common/src/error.rs +++ b/client/network/src/error.rs @@ -18,7 +18,8 @@ //! Substrate network possible errors. -use crate::{config::TransportConfig, protocol::ProtocolName}; +use crate::{config::TransportConfig, types::ProtocolName}; + use libp2p::{Multiaddr, PeerId}; use std::fmt; diff --git a/client/network/common/src/protocol/event.rs b/client/network/src/event.rs similarity index 97% rename from client/network/common/src/protocol/event.rs rename to client/network/src/event.rs index 90c38b48c320f..3ecd8f9311429 100644 --- a/client/network/common/src/protocol/event.rs +++ b/client/network/src/event.rs @@ -19,11 +19,13 @@ //! Network event types. These are are not the part of the protocol, but rather //! events that happen on the network like DHT get/put results received. -use super::ProtocolName; -use crate::protocol::role::ObservedRole; +use crate::types::ProtocolName; + use bytes::Bytes; use libp2p::{core::PeerId, kad::record::Key}; +use sc_network_common::role::ObservedRole; + /// Events generated by DHT as a response to get_value and put_value requests. #[derive(Debug, Clone)] #[must_use] diff --git a/client/network/src/lib.rs b/client/network/src/lib.rs index f94a71681cd3d..c290f4b94db53 100644 --- a/client/network/src/lib.rs +++ b/client/network/src/lib.rs @@ -248,36 +248,40 @@ mod behaviour; mod discovery; mod peer_info; mod protocol; -mod request_responses; mod service; mod transport; pub mod config; +pub mod error; +pub mod event; pub mod network_state; +pub mod request_responses; +pub mod types; +pub mod utils; +pub use event::{DhtEvent, Event}; #[doc(inline)] pub use libp2p::{multiaddr, Multiaddr, PeerId}; +pub use request_responses::{IfDisconnected, RequestFailure, RequestResponseConfig}; pub use sc_network_common::{ - protocol::{ - event::{DhtEvent, Event}, - role::ObservedRole, - ProtocolName, - }, - request_responses::{IfDisconnected, RequestFailure}, - service::{ - KademliaKey, NetworkBlock, NetworkDHTProvider, NetworkRequest, NetworkSigner, - NetworkStateInfo, NetworkStatus, NetworkStatusProvider, NetworkSyncForkRequest, Signature, - SigningError, - }, + role::ObservedRole, sync::{ warp::{WarpSyncPhase, WarpSyncProgress}, ExtendedPeerInfo, StateDownloadProgress, SyncEventStream, SyncState, SyncStatusProvider, }, }; pub use service::{ - DecodingError, Keypair, NetworkService, NetworkWorker, NotificationSender, - NotificationSenderReady, OutboundFailure, PublicKey, + signature::Signature, + traits::{ + KademliaKey, NetworkBlock, NetworkDHTProvider, NetworkEventStream, NetworkNotification, + NetworkPeers, NetworkRequest, NetworkSigner, NetworkStateInfo, NetworkStatus, + NetworkStatusProvider, NetworkSyncForkRequest, NotificationSender as NotificationSenderT, + NotificationSenderError, NotificationSenderReady, + }, + DecodingError, Keypair, NetworkService, NetworkWorker, NotificationSender, OutboundFailure, + PublicKey, }; +pub use types::ProtocolName; pub use sc_peerset::ReputationChange; diff --git a/client/network/src/peer_info.rs b/client/network/src/peer_info.rs index 1cf0c928a4067..3f769736ff10e 100644 --- a/client/network/src/peer_info.rs +++ b/client/network/src/peer_info.rs @@ -16,6 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +use crate::utils::interval; + use fnv::FnvHashMap; use futures::prelude::*; use libp2p::{ @@ -36,8 +38,8 @@ use libp2p::{ Multiaddr, }; use log::{debug, error, trace}; -use sc_network_common::utils::interval; use smallvec::SmallVec; + use std::{ collections::hash_map::Entry, pin::Pin, diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index 8d604124233a0..06ca02c0ca8d5 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -16,7 +16,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::config; +use crate::{ + config::{self, NonReservedPeerMode}, + error, + types::ProtocolName, +}; use bytes::Bytes; use codec::{DecodeAll, Encode}; @@ -29,27 +33,25 @@ use libp2p::{ Multiaddr, PeerId, }; use log::{debug, error, warn}; -use message::{generic::Message as GenericMessage, Message}; -use notifications::{Notifications, NotificationsOut}; -use sc_network_common::{ - config::NonReservedPeerMode, - error, - protocol::{role::Roles, ProtocolName}, - sync::message::BlockAnnouncesHandshake, -}; + +use sc_network_common::{role::Roles, sync::message::BlockAnnouncesHandshake}; use sp_runtime::traits::Block as BlockT; + use std::{ collections::{HashMap, HashSet, VecDeque}, iter, task::Poll, }; +use message::{generic::Message as GenericMessage, Message}; +use notifications::{Notifications, NotificationsOut}; + +pub use notifications::{NotificationsSink, NotifsHandlerError, Ready}; + mod notifications; pub mod message; -pub use notifications::{NotificationsSink, NotifsHandlerError, Ready}; - /// Maximum size used for notifications in the block announce and transaction protocols. // Must be equal to `max(MAX_BLOCK_ANNOUNCE_SIZE, MAX_TRANSACTIONS_SIZE)`. pub(crate) const BLOCK_ANNOUNCES_TRANSACTIONS_SUBSTREAM_SIZE: u64 = 16 * 1024 * 1024; @@ -93,7 +95,7 @@ impl Protocol { pub fn new( roles: Roles, network_config: &config::NetworkConfiguration, - block_announces_protocol: sc_network_common::config::NonDefaultSetConfig, + block_announces_protocol: config::NonDefaultSetConfig, ) -> error::Result<(Self, sc_peerset::PeersetHandle, Vec<(PeerId, Multiaddr)>)> { let mut known_addresses = Vec::new(); diff --git a/client/network/src/protocol/message.rs b/client/network/src/protocol/message.rs index f7981f1714951..66dca2975375f 100644 --- a/client/network/src/protocol/message.rs +++ b/client/network/src/protocol/message.rs @@ -61,7 +61,7 @@ pub mod generic { use sc_client_api::StorageProof; use sc_network_common::{ message::RequestId, - protocol::role::Roles, + role::Roles, sync::message::{ generic::{BlockRequest, BlockResponse}, BlockAnnounce, diff --git a/client/network/src/protocol/notifications/behaviour.rs b/client/network/src/protocol/notifications/behaviour.rs index 093d5846db7de..74e27fa17c602 100644 --- a/client/network/src/protocol/notifications/behaviour.rs +++ b/client/network/src/protocol/notifications/behaviour.rs @@ -16,8 +16,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::protocol::notifications::handler::{ - self, NotificationsSink, NotifsHandlerIn, NotifsHandlerOut, NotifsHandlerProto, +use crate::{ + protocol::notifications::handler::{ + self, NotificationsSink, NotifsHandlerIn, NotifsHandlerOut, NotifsHandlerProto, + }, + types::ProtocolName, }; use bytes::BytesMut; @@ -35,7 +38,6 @@ use libp2p::{ use log::{error, trace, warn}; use parking_lot::RwLock; use rand::distributions::{Distribution as _, Uniform}; -use sc_network_common::protocol::ProtocolName; use sc_peerset::DropReason; use smallvec::SmallVec; use std::{ diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index 70157386ef32e..9d8d98fd8cf27 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -57,9 +57,12 @@ //! It is illegal to send a [`NotifsHandlerIn::Open`] before a previously-emitted //! [`NotifsHandlerIn::Open`] has gotten an answer. -use crate::protocol::notifications::upgrade::{ - NotificationsIn, NotificationsInSubstream, NotificationsOut, NotificationsOutSubstream, - UpgradeCollec, +use crate::{ + protocol::notifications::upgrade::{ + NotificationsIn, NotificationsInSubstream, NotificationsOut, NotificationsOutSubstream, + UpgradeCollec, + }, + types::ProtocolName, }; use bytes::BytesMut; @@ -77,7 +80,6 @@ use libp2p::{ }; use log::error; use parking_lot::{Mutex, RwLock}; -use sc_network_common::protocol::ProtocolName; use std::{ collections::VecDeque, mem, @@ -945,8 +947,9 @@ pub mod tests { Poll::Ready(Some(NotificationsSinkMessage::Notification { message })) => Poll::Ready(Some(message)), Poll::Pending => Poll::Ready(None), - Poll::Ready(Some(NotificationsSinkMessage::ForceClose)) | Poll::Ready(None) => - panic!("sink closed"), + Poll::Ready(Some(NotificationsSinkMessage::ForceClose)) | Poll::Ready(None) => { + panic!("sink closed") + }, }) .await } diff --git a/client/network/src/protocol/notifications/upgrade/collec.rs b/client/network/src/protocol/notifications/upgrade/collec.rs index 89999ff0c7534..791821b3f75da 100644 --- a/client/network/src/protocol/notifications/upgrade/collec.rs +++ b/client/network/src/protocol/notifications/upgrade/collec.rs @@ -103,8 +103,8 @@ impl>, O, E> Future for FutWithUsize { #[cfg(test)] mod tests { use super::*; + use crate::types::ProtocolName as ProtoName; use libp2p::core::upgrade::{ProtocolName, UpgradeInfo}; - use sc_network_common::protocol::ProtocolName as ProtoName; // TODO: move to mocks mockall::mock! { diff --git a/client/network/src/protocol/notifications/upgrade/notifications.rs b/client/network/src/protocol/notifications/upgrade/notifications.rs index bfdd9ccfa7eb9..4e1c033f33b68 100644 --- a/client/network/src/protocol/notifications/upgrade/notifications.rs +++ b/client/network/src/protocol/notifications/upgrade/notifications.rs @@ -16,7 +16,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use asynchronous_codec::Framed; /// Notifications protocol. /// /// The Substrate notifications protocol consists in the following: @@ -35,11 +34,15 @@ use asynchronous_codec::Framed; /// /// Notification substreams are unidirectional. If A opens a substream with B, then B is /// encouraged but not required to open a substream to A as well. +use crate::types::ProtocolName; + +use asynchronous_codec::Framed; use bytes::BytesMut; use futures::prelude::*; use libp2p::core::{upgrade, InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use log::{error, warn}; -use sc_network_common::protocol::ProtocolName; +use unsigned_varint::codec::UviBytes; + use std::{ convert::Infallible, io, mem, @@ -47,7 +50,6 @@ use std::{ task::{Context, Poll}, vec, }; -use unsigned_varint::codec::UviBytes; /// Maximum allowed size of the two handshake messages, in bytes. const MAX_HANDSHAKE_SIZE: usize = 1024; diff --git a/client/network/src/request_responses.rs b/client/network/src/request_responses.rs index 37c97e8282b4c..4628b0191a2e8 100644 --- a/client/network/src/request_responses.rs +++ b/client/network/src/request_responses.rs @@ -34,7 +34,8 @@ //! - If provided, a ["requests processing"](ProtocolConfig::inbound_queue) channel //! is used to handle incoming requests. -use crate::ReputationChange; +use crate::{types::ProtocolName, ReputationChange}; + use futures::{ channel::{mpsc, oneshot}, prelude::*, @@ -43,7 +44,7 @@ use libp2p::{ core::{connection::ConnectionId, Multiaddr, PeerId}, request_response::{ handler::RequestResponseHandler, ProtocolSupport, RequestResponse, RequestResponseCodec, - RequestResponseConfig, RequestResponseEvent, RequestResponseMessage, ResponseChannel, + RequestResponseEvent, RequestResponseMessage, ResponseChannel, }, swarm::{ behaviour::{ConnectionClosed, DialFailure, FromSwarm, ListenFailure}, @@ -52,12 +53,9 @@ use libp2p::{ PollParameters, }, }; -use sc_network_common::{ - protocol::ProtocolName, - request_responses::{ - IfDisconnected, IncomingRequest, OutgoingResponse, ProtocolConfig, RequestFailure, - }, -}; + +use sc_peerset::{PeersetHandle, BANNED_THRESHOLD}; + use std::{ collections::{hash_map::Entry, HashMap}, io, iter, @@ -66,8 +64,138 @@ use std::{ time::{Duration, Instant}, }; -pub use libp2p::request_response::{InboundFailure, OutboundFailure, RequestId}; -use sc_peerset::{PeersetHandle, BANNED_THRESHOLD}; +pub use libp2p::request_response::{ + InboundFailure, OutboundFailure, RequestId, RequestResponseConfig, +}; + +/// Error in a request. +#[derive(Debug, thiserror::Error)] +#[allow(missing_docs)] +pub enum RequestFailure { + #[error("We are not currently connected to the requested peer.")] + NotConnected, + #[error("Given protocol hasn't been registered.")] + UnknownProtocol, + #[error("Remote has closed the substream before answering, thereby signaling that it considers the request as valid, but refused to answer it.")] + Refused, + #[error("The remote replied, but the local node is no longer interested in the response.")] + Obsolete, + #[error("Problem on the network: {0}")] + Network(OutboundFailure), +} + +/// Configuration for a single request-response protocol. +#[derive(Debug, Clone)] +pub struct ProtocolConfig { + /// Name of the protocol on the wire. Should be something like `/foo/bar`. + pub name: ProtocolName, + + /// Fallback on the wire protocol names to support. + pub fallback_names: Vec, + + /// Maximum allowed size, in bytes, of a request. + /// + /// Any request larger than this value will be declined as a way to avoid allocating too + /// much memory for it. + pub max_request_size: u64, + + /// Maximum allowed size, in bytes, of a response. + /// + /// Any response larger than this value will be declined as a way to avoid allocating too + /// much memory for it. + pub max_response_size: u64, + + /// Duration after which emitted requests are considered timed out. + /// + /// If you expect the response to come back quickly, you should set this to a smaller duration. + pub request_timeout: Duration, + + /// Channel on which the networking service will send incoming requests. + /// + /// Every time a peer sends a request to the local node using this protocol, the networking + /// service will push an element on this channel. The receiving side of this channel then has + /// to pull this element, process the request, and send back the response to send back to the + /// peer. + /// + /// The size of the channel has to be carefully chosen. If the channel is full, the networking + /// service will discard the incoming request send back an error to the peer. Consequently, + /// the channel being full is an indicator that the node is overloaded. + /// + /// You can typically set the size of the channel to `T / d`, where `T` is the + /// `request_timeout` and `d` is the expected average duration of CPU and I/O it takes to + /// build a response. + /// + /// Can be `None` if the local node does not support answering incoming requests. + /// If this is `None`, then the local node will not advertise support for this protocol towards + /// other peers. If this is `Some` but the channel is closed, then the local node will + /// advertise support for this protocol, but any incoming request will lead to an error being + /// sent back. + pub inbound_queue: Option>, +} + +/// A single request received by a peer on a request-response protocol. +#[derive(Debug)] +pub struct IncomingRequest { + /// Who sent the request. + pub peer: PeerId, + + /// Request sent by the remote. Will always be smaller than + /// [`ProtocolConfig::max_request_size`]. + pub payload: Vec, + + /// Channel to send back the response. + /// + /// There are two ways to indicate that handling the request failed: + /// + /// 1. Drop `pending_response` and thus not changing the reputation of the peer. + /// + /// 2. Sending an `Err(())` via `pending_response`, optionally including reputation changes for + /// the given peer. + pub pending_response: oneshot::Sender, +} + +/// Response for an incoming request to be send by a request protocol handler. +#[derive(Debug)] +pub struct OutgoingResponse { + /// The payload of the response. + /// + /// `Err(())` if none is available e.g. due an error while handling the request. + pub result: Result, ()>, + + /// Reputation changes accrued while handling the request. To be applied to the reputation of + /// the peer sending the request. + pub reputation_changes: Vec, + + /// If provided, the `oneshot::Sender` will be notified when the request has been sent to the + /// peer. + /// + /// > **Note**: Operating systems typically maintain a buffer of a few dozen kilobytes of + /// > outgoing data for each TCP socket, and it is not possible for a user + /// > application to inspect this buffer. This channel here is not actually notified + /// > when the response has been fully sent out, but rather when it has fully been + /// > written to the buffer managed by the operating system. + pub sent_feedback: Option>, +} + +/// When sending a request, what to do on a disconnected recipient. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum IfDisconnected { + /// Try to connect to the peer. + TryConnect, + /// Just fail if the destination is not yet connected. + ImmediateError, +} + +/// Convenience functions for `IfDisconnected`. +impl IfDisconnected { + /// Shall we connect to a disconnected peer? + pub fn should_connect(self) -> bool { + match self { + Self::TryConnect => true, + Self::ImmediateError => false, + } + } +} /// Event generated by the [`RequestResponsesBehaviour`]. #[derive(Debug)] @@ -103,7 +231,12 @@ pub enum Event { }, /// A request protocol handler issued reputation changes for the given peer. - ReputationChanges { peer: PeerId, changes: Vec }, + ReputationChanges { + /// Peer whose reputation needs to be adjust. + peer: PeerId, + /// Reputation changes. + changes: Vec, + }, } /// Combination of a protocol name and a request id. @@ -344,7 +477,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { ) } }, - FromSwarm::DialFailure(DialFailure { peer_id, error, handler }) => + FromSwarm::DialFailure(DialFailure { peer_id, error, handler }) => { for (p_name, p_handler) in handler.into_iter() { if let Some((proto, _)) = self.protocols.get_mut(p_name.as_str()) { proto.on_swarm_event(FromSwarm::DialFailure(DialFailure { @@ -359,7 +492,8 @@ impl NetworkBehaviour for RequestResponsesBehaviour { p_name, ) } - }, + } + }, FromSwarm::ListenerClosed(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ListenerClosed(e)); diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 4a05393618cfb..6dc00b36ceb53 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -29,13 +29,27 @@ use crate::{ behaviour::{self, Behaviour, BehaviourOut}, - config::Params, + config::{MultiaddrWithPeerId, Params, TransportConfig}, discovery::DiscoveryConfig, + error::Error, + event::{DhtEvent, Event}, network_state::{ NetworkState, NotConnectedPeer as NetworkStateNotConnectedPeer, Peer as NetworkStatePeer, }, protocol::{self, NotificationsSink, NotifsHandlerError, Protocol, Ready}, - transport, ReputationChange, + request_responses::{IfDisconnected, RequestFailure}, + service::{ + signature::{Signature, SigningError}, + traits::{ + NetworkDHTProvider, NetworkEventStream, NetworkNotification, NetworkPeers, + NetworkRequest, NetworkSigner, NetworkStateInfo, NetworkStatus, NetworkStatusProvider, + NotificationSender as NotificationSenderT, NotificationSenderError, + NotificationSenderReady as NotificationSenderReadyT, + }, + }, + transport, + types::ProtocolName, + ReputationChange, }; use futures::{channel::oneshot, prelude::*}; @@ -55,26 +69,13 @@ use libp2p::{ use log::{debug, error, info, trace, warn}; use metrics::{Histogram, HistogramVec, MetricSources, Metrics}; use parking_lot::Mutex; -use sc_network_common::{ - config::{MultiaddrWithPeerId, TransportConfig}, - error::Error, - protocol::{ - event::{DhtEvent, Event}, - ProtocolName, - }, - request_responses::{IfDisconnected, RequestFailure}, - service::{ - NetworkDHTProvider, NetworkEventStream, NetworkNotification, NetworkPeers, NetworkSigner, - NetworkStateInfo, NetworkStatus, NetworkStatusProvider, - NotificationSender as NotificationSenderT, NotificationSenderError, - NotificationSenderReady as NotificationSenderReadyT, Signature, SigningError, - }, - ExHashT, -}; + +use sc_network_common::ExHashT; use sc_peerset::PeersetHandle; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender}; use sp_blockchain::HeaderBackend; use sp_runtime::traits::{Block as BlockT, Zero}; + use std::{ cmp, collections::{HashMap, HashSet}, @@ -90,14 +91,13 @@ use std::{ }; pub use behaviour::{InboundFailure, OutboundFailure, ResponseFailure}; +pub use libp2p::identity::{error::DecodingError, Keypair, PublicKey}; mod metrics; mod out_events; -#[cfg(test)] -mod tests; -pub use libp2p::identity::{error::DecodingError, Keypair, PublicKey}; -use sc_network_common::service::NetworkRequest; +pub mod signature; +pub mod traits; /// Custom error that can be produced by the [`ConnectionHandler`] of the [`NetworkBehaviour`]. /// Used as a template parameter of [`SwarmEvent`] below. @@ -1432,10 +1432,11 @@ where }, } }, - SwarmEvent::Behaviour(BehaviourOut::ReputationChanges { peer, changes }) => + SwarmEvent::Behaviour(BehaviourOut::ReputationChanges { peer, changes }) => { for change in changes { self.network_service.behaviour().user_protocol().report_peer(peer, change); - }, + } + }, SwarmEvent::Behaviour(BehaviourOut::PeerIdentify { peer_id, info: @@ -1467,10 +1468,11 @@ where .user_protocol_mut() .add_default_set_discovered_nodes(iter::once(peer_id)); }, - SwarmEvent::Behaviour(BehaviourOut::RandomKademliaStarted) => + SwarmEvent::Behaviour(BehaviourOut::RandomKademliaStarted) => { if let Some(metrics) = self.metrics.as_ref() { metrics.kademlia_random_queries_total.inc(); - }, + } + }, SwarmEvent::Behaviour(BehaviourOut::NotificationStreamOpened { remote, protocol, diff --git a/client/network/src/service/out_events.rs b/client/network/src/service/out_events.rs index 3771ea1643aec..398c26793fd41 100644 --- a/client/network/src/service/out_events.rs +++ b/client/network/src/service/out_events.rs @@ -31,11 +31,12 @@ //! - Send events by calling [`OutChannels::send`]. Events are cloned for each sender in the //! collection. +use crate::event::Event; + use futures::{prelude::*, ready, stream::FusedStream}; use log::error; use parking_lot::Mutex; use prometheus_endpoint::{register, CounterVec, GaugeVec, Opts, PrometheusError, Registry, U64}; -use sc_network_common::protocol::event::Event; use std::{ backtrace::Backtrace, cell::RefCell, diff --git a/client/network/common/src/service/signature.rs b/client/network/src/service/signature.rs similarity index 96% rename from client/network/common/src/service/signature.rs rename to client/network/src/service/signature.rs index 14addafc6bba2..e52dd6b1d2a29 100644 --- a/client/network/common/src/service/signature.rs +++ b/client/network/src/service/signature.rs @@ -19,10 +19,12 @@ // If you read this, you are very thorough, congratulations. use libp2p::{ - identity::{error::SigningError, Keypair, PublicKey}, + identity::{Keypair, PublicKey}, PeerId, }; +pub use libp2p::identity::error::SigningError; + /// A result of signing a message with a network identity. Since `PeerId` is potentially a hash of a /// `PublicKey`, you need to reveal the `PublicKey` next to the signature, so the verifier can check /// if the signature was made by the entity that controls a given `PeerId`. diff --git a/client/network/src/service/tests/mod.rs b/client/network/src/service/tests/mod.rs deleted file mode 100644 index f29e43e6ce366..0000000000000 --- a/client/network/src/service/tests/mod.rs +++ /dev/null @@ -1,240 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use crate::{config, NetworkService, NetworkWorker}; - -use futures::prelude::*; -use libp2p::Multiaddr; -use sc_consensus::{ImportQueue, Link}; -use sc_network_common::{ - config::{NonDefaultSetConfig, ProtocolId, SetConfig, TransportConfig}, - protocol::{event::Event, role::Roles}, - service::NetworkEventStream, -}; -use sc_network_light::light_client_requests::handler::LightClientRequestHandler; -use sc_network_sync::{ - block_request_handler::BlockRequestHandler, - engine::SyncingEngine, - service::network::{NetworkServiceHandle, NetworkServiceProvider}, - state_request_handler::StateRequestHandler, -}; -use sp_runtime::traits::Block as BlockT; -use std::sync::Arc; -use substrate_test_runtime_client::{ - runtime::{Block as TestBlock, Hash as TestHash}, - TestClientBuilder, TestClientBuilderExt as _, -}; - -#[cfg(test)] -mod service; - -type TestNetworkWorker = NetworkWorker; -type TestNetworkService = NetworkService; - -const PROTOCOL_NAME: &str = "/foo"; - -struct TestNetwork { - network: TestNetworkWorker, -} - -impl TestNetwork { - pub fn new(network: TestNetworkWorker) -> Self { - Self { network } - } - - pub fn start_network( - self, - ) -> (Arc, (impl Stream + std::marker::Unpin)) { - let worker = self.network; - let service = worker.service().clone(); - let event_stream = service.event_stream("test"); - - tokio::spawn(worker.run()); - - (service, event_stream) - } -} - -struct TestNetworkBuilder { - import_queue: Option>>, - link: Option>>, - client: Option>, - listen_addresses: Vec, - set_config: Option, - chain_sync_network: Option<(NetworkServiceProvider, NetworkServiceHandle)>, - config: Option, -} - -impl TestNetworkBuilder { - pub fn new() -> Self { - Self { - import_queue: None, - link: None, - client: None, - listen_addresses: Vec::new(), - set_config: None, - chain_sync_network: None, - config: None, - } - } - - pub fn with_config(mut self, config: config::NetworkConfiguration) -> Self { - self.config = Some(config); - self - } - - pub fn with_listen_addresses(mut self, addresses: Vec) -> Self { - self.listen_addresses = addresses; - self - } - - pub fn with_set_config(mut self, set_config: SetConfig) -> Self { - self.set_config = Some(set_config); - self - } - - pub fn build(mut self) -> TestNetwork { - let client = self.client.as_mut().map_or( - Arc::new(TestClientBuilder::with_default_backend().build_with_longest_chain().0), - |v| v.clone(), - ); - - let network_config = self.config.unwrap_or(config::NetworkConfiguration { - extra_sets: vec![NonDefaultSetConfig { - notifications_protocol: PROTOCOL_NAME.into(), - fallback_names: Vec::new(), - max_notification_size: 1024 * 1024, - handshake: None, - set_config: self.set_config.unwrap_or_default(), - }], - listen_addresses: self.listen_addresses, - transport: TransportConfig::MemoryOnly, - ..config::NetworkConfiguration::new_local() - }); - - #[derive(Clone)] - struct PassThroughVerifier(bool); - - #[async_trait::async_trait] - impl sc_consensus::Verifier for PassThroughVerifier { - async fn verify( - &mut self, - mut block: sc_consensus::BlockImportParams, - ) -> Result, String> { - block.finalized = self.0; - block.fork_choice = Some(sc_consensus::ForkChoiceStrategy::LongestChain); - Ok(block) - } - } - - let mut import_queue = - self.import_queue.unwrap_or(Box::new(sc_consensus::BasicQueue::new( - PassThroughVerifier(false), - Box::new(client.clone()), - None, - &sp_core::testing::TaskExecutor::new(), - None, - ))); - - let protocol_id = ProtocolId::from("test-protocol-name"); - let fork_id = Some(String::from("test-fork-id")); - - let block_request_protocol_config = { - let (handler, protocol_config) = - BlockRequestHandler::new(&protocol_id, None, client.clone(), 50); - tokio::spawn(handler.run().boxed()); - protocol_config - }; - - let state_request_protocol_config = { - let (handler, protocol_config) = - StateRequestHandler::new(&protocol_id, None, client.clone(), 50); - tokio::spawn(handler.run().boxed()); - protocol_config - }; - - let light_client_request_protocol_config = { - let (handler, protocol_config) = - LightClientRequestHandler::new(&protocol_id, None, client.clone()); - tokio::spawn(handler.run().boxed()); - protocol_config - }; - - let (chain_sync_network_provider, chain_sync_network_handle) = - self.chain_sync_network.unwrap_or(NetworkServiceProvider::new()); - - let (engine, chain_sync_service, block_announce_config) = SyncingEngine::new( - Roles::from(&config::Role::Full), - client.clone(), - None, - &network_config, - protocol_id.clone(), - &None, - Box::new(sp_consensus::block_validation::DefaultBlockAnnounceValidator), - None, - chain_sync_network_handle, - import_queue.service(), - block_request_protocol_config.name.clone(), - state_request_protocol_config.name.clone(), - None, - ) - .unwrap(); - let mut link = self.link.unwrap_or(Box::new(chain_sync_service.clone())); - let worker = NetworkWorker::< - substrate_test_runtime_client::runtime::Block, - substrate_test_runtime_client::runtime::Hash, - >::new(config::Params { - block_announce_config, - role: config::Role::Full, - executor: Box::new(|f| { - tokio::spawn(f); - }), - network_config, - chain: client.clone(), - protocol_id, - fork_id, - metrics_registry: None, - request_response_protocol_configs: [ - block_request_protocol_config, - state_request_protocol_config, - light_client_request_protocol_config, - ] - .to_vec(), - }) - .unwrap(); - - let service = worker.service().clone(); - tokio::spawn(async move { - let _ = chain_sync_network_provider.run(service).await; - }); - tokio::spawn(async move { - loop { - futures::future::poll_fn(|cx| { - import_queue.poll_actions(cx, &mut *link); - std::task::Poll::Ready(()) - }) - .await; - tokio::time::sleep(std::time::Duration::from_millis(250)).await; - } - }); - let stream = worker.service().event_stream("syncing"); - tokio::spawn(engine.run(stream)); - - TestNetwork::new(worker) - } -} diff --git a/client/network/common/src/service.rs b/client/network/src/service/traits.rs similarity index 99% rename from client/network/common/src/service.rs rename to client/network/src/service/traits.rs index d3c5c2f439450..3f9b7e552027b 100644 --- a/client/network/common/src/service.rs +++ b/client/network/src/service/traits.rs @@ -20,17 +20,20 @@ use crate::{ config::MultiaddrWithPeerId, - protocol::{event::Event, ProtocolName}, + event::Event, request_responses::{IfDisconnected, RequestFailure}, + service::signature::Signature, + types::ProtocolName, }; + use futures::{channel::oneshot, Stream}; -pub use libp2p::{identity::error::SigningError, kad::record::Key as KademliaKey}; use libp2p::{Multiaddr, PeerId}; + use sc_peerset::ReputationChange; -pub use signature::Signature; + use std::{collections::HashSet, future::Future, pin::Pin, sync::Arc}; -mod signature; +pub use libp2p::{identity::error::SigningError, kad::record::Key as KademliaKey}; /// Signer with network identity pub trait NetworkSigner { diff --git a/client/network/common/src/protocol.rs b/client/network/src/types.rs similarity index 99% rename from client/network/common/src/protocol.rs rename to client/network/src/types.rs index bfeb1daf5d53b..b0e32ae109149 100644 --- a/client/network/common/src/protocol.rs +++ b/client/network/src/types.rs @@ -16,6 +16,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +//! `sc-network` type definitions + +use libp2p::core::upgrade; + use std::{ borrow::Borrow, fmt, @@ -24,11 +28,6 @@ use std::{ sync::Arc, }; -use libp2p::core::upgrade; - -pub mod event; -pub mod role; - /// The protocol name transmitted on the wire. #[derive(Debug, Clone)] pub enum ProtocolName { diff --git a/client/network/common/src/utils.rs b/client/network/src/utils.rs similarity index 98% rename from client/network/common/src/utils.rs rename to client/network/src/utils.rs index c32d264a943e7..8db2cf4e7920d 100644 --- a/client/network/common/src/utils.rs +++ b/client/network/src/utils.rs @@ -16,9 +16,12 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +//! `sc-network` utilities + use futures::{stream::unfold, FutureExt, Stream, StreamExt}; use futures_timer::Delay; use linked_hash_set::LinkedHashSet; + use std::{hash::Hash, num::NonZeroUsize, time::Duration}; /// Creates a stream that returns a new value every `duration`. diff --git a/client/network/sync/Cargo.toml b/client/network/sync/Cargo.toml index 52ab0d15e1670..298cbf1801f2e 100644 --- a/client/network/sync/Cargo.toml +++ b/client/network/sync/Cargo.toml @@ -32,6 +32,7 @@ fork-tree = { version = "3.0.0", path = "../../../utils/fork-tree" } prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } sc-client-api = { version = "4.0.0-dev", path = "../../api" } sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" } +sc-network = { version = "0.10.0-dev", path = "../" } sc-network-common = { version = "0.10.0-dev", path = "../common" } sc-peerset = { version = "4.0.0-dev", path = "../../peerset" } sc-utils = { version = "4.0.0-dev", path = "../../utils" } diff --git a/client/network/sync/src/block_request_handler.rs b/client/network/sync/src/block_request_handler.rs index 38aca2cde3fd2..921efd7def622 100644 --- a/client/network/sync/src/block_request_handler.rs +++ b/client/network/sync/src/block_request_handler.rs @@ -18,6 +18,7 @@ //! `crate::request_responses::RequestResponsesBehaviour`. use crate::schema::v1::{block_request::FromBlock, BlockResponse, Direction}; + use codec::{Decode, Encode}; use futures::{ channel::{mpsc, oneshot}, @@ -27,17 +28,19 @@ use libp2p::PeerId; use log::debug; use lru::LruCache; use prost::Message; + use sc_client_api::BlockBackend; -use sc_network_common::{ +use sc_network::{ config::ProtocolId, request_responses::{IncomingRequest, OutgoingResponse, ProtocolConfig}, - sync::message::BlockAttributes, }; +use sc_network_common::sync::message::BlockAttributes; use sp_blockchain::HeaderBackend; use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, Header, One, Zero}, }; + use std::{ cmp::min, hash::{Hash, Hasher}, diff --git a/client/network/sync/src/engine.rs b/client/network/sync/src/engine.rs index 25cd3968c2924..e6e62101ffcd0 100644 --- a/client/network/sync/src/engine.rs +++ b/client/network/sync/src/engine.rs @@ -24,22 +24,27 @@ use crate::{ ChainSync, ClientError, SyncingService, }; +use codec::{Decode, DecodeAll, Encode}; use futures::{FutureExt, Stream, StreamExt}; +use futures_timer::Delay; use libp2p::PeerId; use lru::LruCache; use prometheus_endpoint::{ register, Gauge, GaugeVec, MetricSource, Opts, PrometheusError, Registry, SourcedGauge, U64, }; -use codec::{Decode, DecodeAll, Encode}; -use futures_timer::Delay; use sc_client_api::{BlockBackend, HeaderBackend, ProofProvider}; use sc_consensus::import_queue::ImportQueueService; -use sc_network_common::{ +use sc_network::{ config::{ NetworkConfiguration, NonDefaultSetConfig, ProtocolId, SyncMode as SyncOperationMode, }, - protocol::{event::Event, role::Roles, ProtocolName}, + event::Event, + utils::LruHashSet, + ProtocolName, +}; +use sc_network_common::{ + role::Roles, sync::{ message::{ generic::{BlockData, BlockResponse}, @@ -49,7 +54,6 @@ use sc_network_common::{ BadPeer, ChainSync as ChainSyncT, ExtendedPeerInfo, PollBlockAnnounceValidation, SyncEvent, SyncMode, }, - utils::LruHashSet, }; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender}; use sp_blockchain::HeaderMetadata; diff --git a/client/network/sync/src/lib.rs b/client/network/sync/src/lib.rs index 23269b02bd128..45d14ffa7bb37 100644 --- a/client/network/sync/src/lib.rs +++ b/client/network/sync/src/lib.rs @@ -28,23 +28,13 @@ //! the network, or whenever a block has been successfully verified, call the appropriate method in //! order to update it. -pub mod block_request_handler; -pub mod blocks; -pub mod engine; -pub mod mock; -mod schema; -pub mod service; -pub mod state; -pub mod state_request_handler; -pub mod warp; -pub mod warp_request_handler; - use crate::{ blocks::BlockCollection, schema::v1::{StateRequest, StateResponse}, state::StateSync, warp::{WarpProofImportResult, WarpSync}, }; + use codec::{Decode, DecodeAll, Encode}; use extra_requests::ExtraRequests; use futures::{ @@ -52,18 +42,22 @@ use futures::{ }; use libp2p::{request_response::OutboundFailure, PeerId}; use log::{debug, error, info, trace, warn}; -use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64}; use prost::Message; + +use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64}; use sc_client_api::{BlockBackend, ProofProvider}; use sc_consensus::{ import_queue::ImportQueueService, BlockImportError, BlockImportStatus, IncomingBlock, }; -use sc_network_common::{ +use sc_network::{ config::{ NonDefaultSetConfig, NonReservedPeerMode, NotificationHandshake, ProtocolId, SetConfig, }, - protocol::{role::Roles, ProtocolName}, request_responses::{IfDisconnected, RequestFailure}, + types::ProtocolName, +}; +use sc_network_common::{ + role::Roles, sync::{ message::{ BlockAnnounce, BlockAnnouncesHandshake, BlockAttributes, BlockData, BlockRequest, @@ -76,7 +70,6 @@ use sc_network_common::{ SyncState, SyncStatus, }, }; -pub use service::chain_sync::SyncingService; use sp_arithmetic::traits::Saturating; use sp_blockchain::{Error as ClientError, HeaderBackend, HeaderMetadata}; use sp_consensus::{ @@ -90,6 +83,7 @@ use sp_runtime::{ }, EncodedJustification, Justifications, }; + use std::{ collections::{hash_map::Entry, HashMap, HashSet}, iter, @@ -97,9 +91,21 @@ use std::{ pin::Pin, sync::Arc, }; -use warp::TargetBlockImportResult; + +pub use service::chain_sync::SyncingService; mod extra_requests; +mod schema; + +pub mod block_request_handler; +pub mod blocks; +pub mod engine; +pub mod mock; +pub mod service; +pub mod state; +pub mod state_request_handler; +pub mod warp; +pub mod warp_request_handler; /// Maximum blocks to request in a single packet. const MAX_BLOCKS_TO_REQUEST: usize = 64; @@ -927,9 +933,9 @@ where match warp_sync.import_target_block( blocks.pop().expect("`blocks` len checked above."), ) { - TargetBlockImportResult::Success => + warp::TargetBlockImportResult::Success => return Ok(OnBlockData::Continue), - TargetBlockImportResult::BadResponse => + warp::TargetBlockImportResult::BadResponse => return Err(BadPeer(*who, rep::VERIFICATION_FAIL)), } } else if blocks.is_empty() { @@ -3160,7 +3166,7 @@ mod test { use futures::{executor::block_on, future::poll_fn}; use sc_block_builder::BlockBuilderProvider; use sc_network_common::{ - protocol::role::Role, + role::Role, sync::message::{BlockData, BlockState, FromBlock}, }; use sp_blockchain::HeaderBackend; diff --git a/client/network/sync/src/service/chain_sync.rs b/client/network/sync/src/service/chain_sync.rs index 99b4197740eda..f9e0e401fdf8f 100644 --- a/client/network/sync/src/service/chain_sync.rs +++ b/client/network/sync/src/service/chain_sync.rs @@ -20,9 +20,9 @@ use futures::{channel::oneshot, Stream}; use libp2p::PeerId; use sc_consensus::{BlockImportError, BlockImportStatus, JustificationSyncLink, Link}; -use sc_network_common::{ - service::{NetworkBlock, NetworkSyncForkRequest}, - sync::{ExtendedPeerInfo, SyncEvent, SyncEventStream, SyncStatus, SyncStatusProvider}, +use sc_network::{NetworkBlock, NetworkSyncForkRequest}; +use sc_network_common::sync::{ + ExtendedPeerInfo, SyncEvent, SyncEventStream, SyncStatus, SyncStatusProvider, }; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedSender}; use sp_runtime::traits::{Block as BlockT, NumberFor}; diff --git a/client/network/sync/src/service/mock.rs b/client/network/sync/src/service/mock.rs index 2853616adfb4d..c882633993c8b 100644 --- a/client/network/sync/src/service/mock.rs +++ b/client/network/sync/src/service/mock.rs @@ -18,18 +18,18 @@ use futures::channel::oneshot; use libp2p::{Multiaddr, PeerId}; + use sc_consensus::{BlockImportError, BlockImportStatus}; -use sc_network_common::{ +use sc_network::{ config::MultiaddrWithPeerId, - protocol::ProtocolName, request_responses::{IfDisconnected, RequestFailure}, - service::{ - NetworkNotification, NetworkPeers, NetworkRequest, NetworkSyncForkRequest, - NotificationSender, NotificationSenderError, - }, + types::ProtocolName, + NetworkNotification, NetworkPeers, NetworkRequest, NetworkSyncForkRequest, + NotificationSenderError, NotificationSenderT, }; use sc_peerset::ReputationChange; use sp_runtime::traits::{Block as BlockT, NumberFor}; + use std::collections::HashSet; mockall::mock! { @@ -135,7 +135,7 @@ mockall::mock! { &self, target: PeerId, protocol: ProtocolName, - ) -> Result, NotificationSenderError>; + ) -> Result, NotificationSenderError>; fn set_notification_handshake(&self, protocol: ProtocolName, handshake: Vec); } } diff --git a/client/network/sync/src/service/network.rs b/client/network/sync/src/service/network.rs index a1f4f27bbbd99..f87de1c4c3ecc 100644 --- a/client/network/sync/src/service/network.rs +++ b/client/network/sync/src/service/network.rs @@ -18,13 +18,15 @@ use futures::{channel::oneshot, StreamExt}; use libp2p::PeerId; -use sc_network_common::{ - protocol::ProtocolName, + +use sc_network::{ request_responses::{IfDisconnected, RequestFailure}, - service::{NetworkNotification, NetworkPeers, NetworkRequest}, + types::ProtocolName, + NetworkNotification, NetworkPeers, NetworkRequest, }; use sc_peerset::ReputationChange; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender}; + use std::sync::Arc; /// Network-related services required by `sc-network-sync` diff --git a/client/network/sync/src/state_request_handler.rs b/client/network/sync/src/state_request_handler.rs index 2f615f4ead753..0ce2c541bf92e 100644 --- a/client/network/sync/src/state_request_handler.rs +++ b/client/network/sync/src/state_request_handler.rs @@ -18,6 +18,7 @@ //! `crate::request_responses::RequestResponsesBehaviour`. use crate::schema::v1::{KeyValueStateEntry, StateEntry, StateRequest, StateResponse}; + use codec::{Decode, Encode}; use futures::{ channel::{mpsc, oneshot}, @@ -27,12 +28,14 @@ use libp2p::PeerId; use log::{debug, trace}; use lru::LruCache; use prost::Message; + use sc_client_api::{BlockBackend, ProofProvider}; -use sc_network_common::{ +use sc_network::{ config::ProtocolId, request_responses::{IncomingRequest, OutgoingResponse, ProtocolConfig}, }; use sp_runtime::traits::Block as BlockT; + use std::{ hash::{Hash, Hasher}, num::NonZeroUsize, diff --git a/client/network/sync/src/warp_request_handler.rs b/client/network/sync/src/warp_request_handler.rs index fcb0d116bcdac..7061d6485d092 100644 --- a/client/network/sync/src/warp_request_handler.rs +++ b/client/network/sync/src/warp_request_handler.rs @@ -22,14 +22,16 @@ use futures::{ stream::StreamExt, }; use log::debug; -use sc_network_common::{ + +use sc_network::{ config::ProtocolId, request_responses::{ IncomingRequest, OutgoingResponse, ProtocolConfig as RequestResponseConfig, }, - sync::warp::{EncodedProof, WarpProofRequest, WarpSyncProvider}, }; +use sc_network_common::sync::warp::{EncodedProof, WarpProofRequest, WarpSyncProvider}; use sp_runtime::traits::Block as BlockT; + use std::{sync::Arc, time::Duration}; const MAX_RESPONSE_SIZE: u64 = 16 * 1024 * 1024; diff --git a/client/network/test/src/lib.rs b/client/network/test/src/lib.rs index a79e17e2fb6d1..75b8287b08dcf 100644 --- a/client/network/test/src/lib.rs +++ b/client/network/test/src/lib.rs @@ -20,6 +20,8 @@ #[cfg(test)] mod block_import; #[cfg(test)] +mod service; +#[cfg(test)] mod sync; use std::{ @@ -46,14 +48,18 @@ use sc_consensus::{ ForkChoiceStrategy, ImportQueue, ImportResult, JustificationImport, JustificationSyncLink, LongestChain, Verifier, }; -use sc_network::{Multiaddr, NetworkService, NetworkWorker}; -use sc_network_common::{ +use sc_network::{ config::{ MultiaddrWithPeerId, NetworkConfiguration, NonDefaultSetConfig, NonReservedPeerMode, - ProtocolId, RequestResponseConfig, Role, SyncMode, TransportConfig, + ProtocolId, Role, SyncMode, TransportConfig, }, - protocol::{role::Roles, ProtocolName}, - service::{NetworkBlock, NetworkEventStream, NetworkStateInfo, NetworkSyncForkRequest}, + request_responses::ProtocolConfig as RequestResponseConfig, + types::ProtocolName, + Multiaddr, NetworkBlock, NetworkEventStream, NetworkService, NetworkStateInfo, + NetworkSyncForkRequest, NetworkWorker, +}; +use sc_network_common::{ + role::Roles, sync::warp::{ AuthorityList, EncodedProof, SetId, VerificationResult, WarpSyncParams, WarpSyncProvider, }, diff --git a/client/network/src/service/tests/service.rs b/client/network/test/src/service.rs similarity index 72% rename from client/network/src/service/tests/service.rs rename to client/network/test/src/service.rs index 9c4c0ad6e0cd9..b1de2a91ebcc9 100644 --- a/client/network/src/service/tests/service.rs +++ b/client/network/test/src/service.rs @@ -16,24 +16,228 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::{config, service::tests::TestNetworkBuilder, NetworkService}; - use futures::prelude::*; -use libp2p::PeerId; -use sc_network_common::{ - config::{MultiaddrWithPeerId, NonDefaultSetConfig, SetConfig, TransportConfig}, - protocol::event::Event, - service::{NetworkNotification, NetworkPeers, NetworkStateInfo}, +use libp2p::{Multiaddr, PeerId}; + +use sc_consensus::{ImportQueue, Link}; +use sc_network::{ + config::{self, MultiaddrWithPeerId, ProtocolId, TransportConfig}, + event::Event, + NetworkEventStream, NetworkNotification, NetworkPeers, NetworkService, NetworkStateInfo, + NetworkWorker, +}; +use sc_network_common::role::Roles; +use sc_network_light::light_client_requests::handler::LightClientRequestHandler; +use sc_network_sync::{ + block_request_handler::BlockRequestHandler, + engine::SyncingEngine, + service::network::{NetworkServiceHandle, NetworkServiceProvider}, + state_request_handler::StateRequestHandler, }; +use sp_runtime::traits::Block as BlockT; +use substrate_test_runtime_client::{ + runtime::{Block as TestBlock, Hash as TestHash}, + TestClientBuilder, TestClientBuilderExt as _, +}; + use std::{sync::Arc, time::Duration}; -type TestNetworkService = NetworkService< - substrate_test_runtime_client::runtime::Block, - substrate_test_runtime_client::runtime::Hash, ->; +type TestNetworkWorker = NetworkWorker; +type TestNetworkService = NetworkService; const PROTOCOL_NAME: &str = "/foo"; +struct TestNetwork { + network: TestNetworkWorker, +} + +impl TestNetwork { + pub fn new(network: TestNetworkWorker) -> Self { + Self { network } + } + + pub fn start_network( + self, + ) -> (Arc, (impl Stream + std::marker::Unpin)) { + let worker = self.network; + let service = worker.service().clone(); + let event_stream = service.event_stream("test"); + + tokio::spawn(worker.run()); + + (service, event_stream) + } +} + +struct TestNetworkBuilder { + import_queue: Option>>, + link: Option>>, + client: Option>, + listen_addresses: Vec, + set_config: Option, + chain_sync_network: Option<(NetworkServiceProvider, NetworkServiceHandle)>, + config: Option, +} + +impl TestNetworkBuilder { + pub fn new() -> Self { + Self { + import_queue: None, + link: None, + client: None, + listen_addresses: Vec::new(), + set_config: None, + chain_sync_network: None, + config: None, + } + } + + pub fn with_config(mut self, config: config::NetworkConfiguration) -> Self { + self.config = Some(config); + self + } + + pub fn with_listen_addresses(mut self, addresses: Vec) -> Self { + self.listen_addresses = addresses; + self + } + + pub fn with_set_config(mut self, set_config: config::SetConfig) -> Self { + self.set_config = Some(set_config); + self + } + + pub fn build(mut self) -> TestNetwork { + let client = self.client.as_mut().map_or( + Arc::new(TestClientBuilder::with_default_backend().build_with_longest_chain().0), + |v| v.clone(), + ); + + let network_config = self.config.unwrap_or(config::NetworkConfiguration { + extra_sets: vec![config::NonDefaultSetConfig { + notifications_protocol: PROTOCOL_NAME.into(), + fallback_names: Vec::new(), + max_notification_size: 1024 * 1024, + handshake: None, + set_config: self.set_config.unwrap_or_default(), + }], + listen_addresses: self.listen_addresses, + transport: TransportConfig::MemoryOnly, + ..config::NetworkConfiguration::new_local() + }); + + #[derive(Clone)] + struct PassThroughVerifier(bool); + + #[async_trait::async_trait] + impl sc_consensus::Verifier for PassThroughVerifier { + async fn verify( + &mut self, + mut block: sc_consensus::BlockImportParams, + ) -> Result, String> { + block.finalized = self.0; + block.fork_choice = Some(sc_consensus::ForkChoiceStrategy::LongestChain); + Ok(block) + } + } + + let mut import_queue = + self.import_queue.unwrap_or(Box::new(sc_consensus::BasicQueue::new( + PassThroughVerifier(false), + Box::new(client.clone()), + None, + &sp_core::testing::TaskExecutor::new(), + None, + ))); + + let protocol_id = ProtocolId::from("test-protocol-name"); + let fork_id = Some(String::from("test-fork-id")); + + let block_request_protocol_config = { + let (handler, protocol_config) = + BlockRequestHandler::new(&protocol_id, None, client.clone(), 50); + tokio::spawn(handler.run().boxed()); + protocol_config + }; + + let state_request_protocol_config = { + let (handler, protocol_config) = + StateRequestHandler::new(&protocol_id, None, client.clone(), 50); + tokio::spawn(handler.run().boxed()); + protocol_config + }; + + let light_client_request_protocol_config = { + let (handler, protocol_config) = + LightClientRequestHandler::new(&protocol_id, None, client.clone()); + tokio::spawn(handler.run().boxed()); + protocol_config + }; + + let (chain_sync_network_provider, chain_sync_network_handle) = + self.chain_sync_network.unwrap_or(NetworkServiceProvider::new()); + + let (engine, chain_sync_service, block_announce_config) = SyncingEngine::new( + Roles::from(&config::Role::Full), + client.clone(), + None, + &network_config, + protocol_id.clone(), + &None, + Box::new(sp_consensus::block_validation::DefaultBlockAnnounceValidator), + None, + chain_sync_network_handle, + import_queue.service(), + block_request_protocol_config.name.clone(), + state_request_protocol_config.name.clone(), + None, + ) + .unwrap(); + let mut link = self.link.unwrap_or(Box::new(chain_sync_service.clone())); + let worker = NetworkWorker::< + substrate_test_runtime_client::runtime::Block, + substrate_test_runtime_client::runtime::Hash, + >::new(config::Params { + block_announce_config, + role: config::Role::Full, + executor: Box::new(|f| { + tokio::spawn(f); + }), + network_config, + chain: client.clone(), + protocol_id, + fork_id, + metrics_registry: None, + request_response_protocol_configs: [ + block_request_protocol_config, + state_request_protocol_config, + light_client_request_protocol_config, + ] + .to_vec(), + }) + .unwrap(); + + let service = worker.service().clone(); + tokio::spawn(async move { + let _ = chain_sync_network_provider.run(service).await; + }); + tokio::spawn(async move { + loop { + futures::future::poll_fn(|cx| { + import_queue.poll_actions(cx, &mut *link); + std::task::Poll::Ready(()) + }) + .await; + tokio::time::sleep(std::time::Duration::from_millis(250)).await; + } + }); + let stream = worker.service().event_stream("syncing"); + tokio::spawn(engine.run(stream)); + + TestNetwork::new(worker) + } +} + /// Builds two nodes and their associated events stream. /// The nodes are connected together and have the `PROTOCOL_NAME` protocol registered. fn build_nodes_one_proto() -> ( @@ -50,7 +254,7 @@ fn build_nodes_one_proto() -> ( .start_network(); let (node2, events_stream2) = TestNetworkBuilder::new() - .with_set_config(SetConfig { + .with_set_config(config::SetConfig { reserved_nodes: vec![MultiaddrWithPeerId { multiaddr: listen_addr, peer_id: node1.local_peer_id(), @@ -208,7 +412,7 @@ async fn lots_of_incoming_peers_works() { let (main_node, _) = TestNetworkBuilder::new() .with_listen_addresses(vec![listen_addr.clone()]) - .with_set_config(SetConfig { in_peers: u32::MAX, ..Default::default() }) + .with_set_config(config::SetConfig { in_peers: u32::MAX, ..Default::default() }) .build() .start_network(); @@ -220,7 +424,7 @@ async fn lots_of_incoming_peers_works() { for _ in 0..32 { let (_dialing_node, event_stream) = TestNetworkBuilder::new() - .with_set_config(SetConfig { + .with_set_config(config::SetConfig { reserved_nodes: vec![MultiaddrWithPeerId { multiaddr: listen_addr.clone(), peer_id: main_node_peer_id, @@ -289,10 +493,11 @@ async fn notifications_back_pressure() { while received_notifications < TOTAL_NOTIFS { match events_stream2.next().await.unwrap() { - Event::NotificationStreamOpened { protocol, .. } => + Event::NotificationStreamOpened { protocol, .. } => { if let None = sync_protocol_name { sync_protocol_name = Some(protocol); - }, + } + }, Event::NotificationStreamClosed { protocol, .. } => { if Some(&protocol) != sync_protocol_name.as_ref() { panic!() @@ -344,7 +549,7 @@ async fn fallback_name_working() { let listen_addr = config::build_multiaddr![Memory(rand::random::())]; let (node1, mut events_stream1) = TestNetworkBuilder::new() .with_config(config::NetworkConfiguration { - extra_sets: vec![NonDefaultSetConfig { + extra_sets: vec![config::NonDefaultSetConfig { notifications_protocol: NEW_PROTOCOL_NAME.into(), fallback_names: vec![PROTOCOL_NAME.into()], max_notification_size: 1024 * 1024, @@ -359,7 +564,7 @@ async fn fallback_name_working() { .start_network(); let (_, mut events_stream2) = TestNetworkBuilder::new() - .with_set_config(SetConfig { + .with_set_config(config::SetConfig { reserved_nodes: vec![MultiaddrWithPeerId { multiaddr: listen_addr, peer_id: node1.local_peer_id(), @@ -500,7 +705,7 @@ async fn ensure_reserved_node_addresses_consistent_with_transport_memory() { .with_config(config::NetworkConfiguration { listen_addresses: vec![listen_addr.clone()], transport: TransportConfig::MemoryOnly, - default_peers_set: SetConfig { + default_peers_set: config::SetConfig { reserved_nodes: vec![reserved_node], ..Default::default() }, @@ -527,7 +732,7 @@ async fn ensure_reserved_node_addresses_consistent_with_transport_not_memory() { let _ = TestNetworkBuilder::new() .with_config(config::NetworkConfiguration { listen_addresses: vec![listen_addr.clone()], - default_peers_set: SetConfig { + default_peers_set: config::SetConfig { reserved_nodes: vec![reserved_node], ..Default::default() }, diff --git a/client/network/transactions/Cargo.toml b/client/network/transactions/Cargo.toml index cab702fbd7a6c..3616473d3baed 100644 --- a/client/network/transactions/Cargo.toml +++ b/client/network/transactions/Cargo.toml @@ -20,6 +20,7 @@ libp2p = "0.50.0" log = "0.4.17" pin-project = "1.0.12" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } +sc-network = { version = "0.10.0-dev", path = "../" } sc-network-common = { version = "0.10.0-dev", path = "../common" } sc-peerset = { version = "4.0.0-dev", path = "../../peerset" } sc-utils = { version = "4.0.0-dev", path = "../../utils" } diff --git a/client/network/transactions/src/lib.rs b/client/network/transactions/src/lib.rs index 48bb394946671..381dd654b600b 100644 --- a/client/network/transactions/src/lib.rs +++ b/client/network/transactions/src/lib.rs @@ -27,22 +27,29 @@ //! `Future` that processes transactions. use crate::config::*; + use codec::{Decode, Encode}; use futures::{prelude::*, stream::FuturesUnordered}; use libp2p::{multiaddr, PeerId}; use log::{debug, trace, warn}; + use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64}; -use sc_network_common::{ +use sc_network::{ config::{NonDefaultSetConfig, NonReservedPeerMode, ProtocolId, SetConfig}, error, - protocol::{event::Event, role::ObservedRole, ProtocolName}, - service::{NetworkEventStream, NetworkNotification, NetworkPeers}, - sync::{SyncEvent, SyncEventStream}, + event::Event, + types::ProtocolName, utils::{interval, LruHashSet}, + NetworkEventStream, NetworkNotification, NetworkPeers, +}; +use sc_network_common::{ + role::ObservedRole, + sync::{SyncEvent, SyncEventStream}, ExHashT, }; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender}; use sp_runtime::traits::Block as BlockT; + use std::{ collections::{hash_map::Entry, HashMap}, iter, diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index dd6e2e44caf55..0307e3125f3ee 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -29,6 +29,7 @@ rand = "0.8.5" threadpool = "1.7" tracing = "0.1.29" sc-client-api = { version = "4.0.0-dev", path = "../api" } +sc-network = { version = "0.10.0-dev", path = "../network" } sc-network-common = { version = "0.10.0-dev", path = "../network/common" } sc-peerset = { version = "4.0.0-dev", path = "../peerset" } sc-utils = { version = "4.0.0-dev", path = "../utils" } diff --git a/client/offchain/src/api.rs b/client/offchain/src/api.rs index 6fdd91cda2390..a15f03bab6f84 100644 --- a/client/offchain/src/api.rs +++ b/client/offchain/src/api.rs @@ -326,10 +326,8 @@ mod tests { use super::*; use libp2p::PeerId; use sc_client_db::offchain::LocalStorage; - use sc_network_common::{ - config::MultiaddrWithPeerId, - protocol::ProtocolName, - service::{NetworkPeers, NetworkStateInfo}, + use sc_network::{ + config::MultiaddrWithPeerId, types::ProtocolName, NetworkPeers, NetworkStateInfo, }; use sc_peerset::ReputationChange; use sp_core::offchain::{DbExternalities, Externalities}; diff --git a/client/offchain/src/lib.rs b/client/offchain/src/lib.rs index c69f01de19bf6..677d89267e3a6 100644 --- a/client/offchain/src/lib.rs +++ b/client/offchain/src/lib.rs @@ -42,7 +42,7 @@ use futures::{ prelude::*, }; use parking_lot::Mutex; -use sc_network_common::service::{NetworkPeers, NetworkStateInfo}; +use sc_network::{NetworkPeers, NetworkStateInfo}; use sp_api::{ApiExt, ProvideRuntimeApi}; use sp_core::{offchain, traits::SpawnNamed, ExecutionContext}; use sp_runtime::traits::{self, Header}; @@ -246,7 +246,7 @@ mod tests { use libp2p::{Multiaddr, PeerId}; use sc_block_builder::BlockBuilderProvider as _; use sc_client_api::Backend as _; - use sc_network_common::{config::MultiaddrWithPeerId, protocol::ProtocolName}; + use sc_network::{config::MultiaddrWithPeerId, types::ProtocolName}; use sc_peerset::ReputationChange; use sc_transaction_pool::{BasicPool, FullChainApi}; use sc_transaction_pool_api::{InPoolTransaction, TransactionPool}; diff --git a/client/rpc/src/system/tests.rs b/client/rpc/src/system/tests.rs index c0ee1e8f88005..b6bfec7736b08 100644 --- a/client/rpc/src/system/tests.rs +++ b/client/rpc/src/system/tests.rs @@ -99,7 +99,7 @@ fn api>>(sync: T) -> RpcModule> { ); }, Request::NetworkAddReservedPeer(peer, sender) => { - let _ = match sc_network_common::config::parse_str_addr(&peer) { + let _ = match sc_network::config::parse_str_addr(&peer) { Ok(_) => sender.send(Ok(())), Err(s) => sender.send(Err(error::Error::MalformattedPeerArg(s.to_string()))), diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index ea4b630003123..91ef65cf134e4 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -38,14 +38,11 @@ use sc_client_db::{Backend, DatabaseSettings}; use sc_consensus::import_queue::ImportQueue; use sc_executor::RuntimeVersionOf; use sc_keystore::LocalKeystore; -use sc_network::NetworkService; -use sc_network_bitswap::BitswapRequestHandler; -use sc_network_common::{ - config::SyncMode, - protocol::role::Roles, - service::{NetworkEventStream, NetworkStateInfo, NetworkStatusProvider}, - sync::warp::WarpSyncParams, +use sc_network::{ + config::SyncMode, NetworkEventStream, NetworkService, NetworkStateInfo, NetworkStatusProvider, }; +use sc_network_bitswap::BitswapRequestHandler; +use sc_network_common::{role::Roles, sync::warp::WarpSyncParams}; use sc_network_light::light_client_requests::handler::LightClientRequestHandler; use sc_network_sync::{ block_request_handler::BlockRequestHandler, engine::SyncingEngine, diff --git a/client/service/src/config.rs b/client/service/src/config.rs index 8e843b58f285e..c7d98a4533436 100644 --- a/client/service/src/config.rs +++ b/client/service/src/config.rs @@ -22,22 +22,18 @@ pub use sc_client_api::execution_extensions::{ExecutionStrategies, ExecutionStra pub use sc_client_db::{BlocksPruning, Database, DatabaseSource, PruningMode}; pub use sc_executor::{WasmExecutionMethod, WasmtimeInstantiationStrategy}; pub use sc_network::{ - config::{NetworkConfiguration, Role}, - Multiaddr, -}; -pub use sc_network_common::{ config::{ - MultiaddrWithPeerId, NodeKeyConfig, NonDefaultSetConfig, ProtocolId, SetConfig, - TransportConfig, + MultiaddrWithPeerId, NetworkConfiguration, NodeKeyConfig, NonDefaultSetConfig, ProtocolId, + Role, SetConfig, SyncMode, TransportConfig, }, request_responses::{ IncomingRequest, OutgoingResponse, ProtocolConfig as RequestResponseConfig, }, + Multiaddr, }; use prometheus_endpoint::Registry; use sc_chain_spec::ChainSpec; -use sc_network_common::config::SyncMode; pub use sc_telemetry::TelemetryEndpoints; pub use sc_transaction_pool::Options as TransactionPoolOptions; use sp_core::crypto::SecretString; diff --git a/client/service/src/error.rs b/client/service/src/error.rs index 6b71e46b4e0ef..c871342c771eb 100644 --- a/client/service/src/error.rs +++ b/client/service/src/error.rs @@ -40,7 +40,7 @@ pub enum Error { Consensus(#[from] sp_consensus::Error), #[error(transparent)] - Network(#[from] sc_network_common::error::Error), + Network(#[from] sc_network::error::Error), #[error(transparent)] Keystore(#[from] sc_keystore::Error), diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 9dab81a5b4ed9..54f11ec25a02a 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -41,10 +41,8 @@ use futures::{channel::mpsc, pin_mut, FutureExt, StreamExt}; use jsonrpsee::{core::Error as JsonRpseeError, RpcModule}; use log::{debug, error, warn}; use sc_client_api::{blockchain::HeaderBackend, BlockBackend, BlockchainEvents, ProofProvider}; -use sc_network::{NetworkStateInfo, PeerId}; -use sc_network_common::{ - config::MultiaddrWithPeerId, - service::{NetworkBlock, NetworkPeers}, +use sc_network::{ + config::MultiaddrWithPeerId, NetworkBlock, NetworkPeers, NetworkStateInfo, PeerId, }; use sc_network_sync::SyncingService; use sc_utils::mpsc::TracingUnboundedReceiver; diff --git a/client/service/src/metrics.rs b/client/service/src/metrics.rs index 967e3133dbea9..ece5758be7718 100644 --- a/client/service/src/metrics.rs +++ b/client/service/src/metrics.rs @@ -22,11 +22,8 @@ use crate::config::Configuration; use futures_timer::Delay; use prometheus_endpoint::{register, Gauge, GaugeVec, Opts, PrometheusError, Registry, U64}; use sc_client_api::{ClientInfo, UsageProvider}; -use sc_network::config::Role; -use sc_network_common::{ - service::{NetworkStatus, NetworkStatusProvider}, - sync::{SyncStatus, SyncStatusProvider}, -}; +use sc_network::{config::Role, NetworkStatus, NetworkStatusProvider}; +use sc_network_common::sync::{SyncStatus, SyncStatusProvider}; use sc_telemetry::{telemetry, TelemetryHandle, SUBSTRATE_INFO}; use sc_transaction_pool_api::{MaintainedTransactionPool, PoolStatus}; use sc_utils::metrics::register_globals; diff --git a/client/service/test/src/lib.rs b/client/service/test/src/lib.rs index b1a09a0620fcd..f80446a4d43eb 100644 --- a/client/service/test/src/lib.rs +++ b/client/service/test/src/lib.rs @@ -22,10 +22,9 @@ use futures::{task::Poll, Future, TryFutureExt as _}; use log::{debug, info}; use parking_lot::Mutex; use sc_client_api::{Backend, CallExecutor}; -use sc_network::{config::NetworkConfiguration, multiaddr}; -use sc_network_common::{ - config::{MultiaddrWithPeerId, TransportConfig}, - service::{NetworkBlock, NetworkPeers, NetworkStateInfo}, +use sc_network::{ + config::{MultiaddrWithPeerId, NetworkConfiguration, TransportConfig}, + multiaddr, NetworkBlock, NetworkPeers, NetworkStateInfo, }; use sc_network_sync::SyncingService; use sc_service::{ From 39510ecaa82f07f8671ec4d6d05ef572974ec9fe Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 14 Mar 2023 16:52:53 +0200 Subject: [PATCH 11/80] sc-consensus-beefy: fix on-demand async state machine (#13599) `futures_util::pending!()` macro only yields to the event loop once, resulting in many calls to the `OnDemandJustificationsEngine::next()` made by the tokio reactor even though the on-demand-engine is idle. Replace it with the correct `futures::future::pending::<()>()` function which forever yields to the event loop, which is what we want when the engine is idle. Signed-off-by: Adrian Catangiu --- .../outgoing_requests_engine.rs | 2 +- client/consensus/beefy/src/tests.rs | 23 ++++++++++++------- client/consensus/beefy/src/worker.rs | 10 ++++---- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs b/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs index c642e3dfe581c..fbf464bd639d9 100644 --- a/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs +++ b/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs @@ -207,7 +207,7 @@ impl OnDemandJustificationsEngine { pub async fn next(&mut self) -> Option> { let (peer, req_info, resp) = match &mut self.state { State::Idle => { - futures::pending!(); + futures::future::pending::<()>().await; return None }, State::AwaitingResponse(peer, req_info, receiver) => { diff --git a/client/consensus/beefy/src/tests.rs b/client/consensus/beefy/src/tests.rs index 44920aaa6faa9..27dc8d81915aa 100644 --- a/client/consensus/beefy/src/tests.rs +++ b/client/consensus/beefy/src/tests.rs @@ -934,7 +934,7 @@ async fn on_demand_beefy_justification_sync() { let dave_index = 3; // push 30 blocks - let hashes = net.generate_blocks_and_sync(35, session_len, &validator_set, false).await; + let mut hashes = net.generate_blocks_and_sync(30, session_len, &validator_set, false).await; let fast_peers = fast_peers.into_iter().enumerate(); let net = Arc::new(Mutex::new(net)); @@ -951,8 +951,16 @@ async fn on_demand_beefy_justification_sync() { // Spawn Dave, they are now way behind voting and can only catch up through on-demand justif // sync. tokio::spawn(dave_task); - // give Dave a chance to spawn and init. - run_for(Duration::from_millis(400), &net).await; + // Dave pushes and syncs 4 more blocks just to make sure he gets included in gossip. + { + let mut net_guard = net.lock(); + let built_hashes = + net_guard + .peer(dave_index) + .generate_blocks(4, BlockOrigin::File, |builder| builder.build().unwrap().block); + hashes.extend(built_hashes); + net_guard.run_until_sync().await; + } let (dave_best_blocks, _) = get_beefy_streams(&mut net.lock(), [(dave_index, BeefyKeyring::Dave)].into_iter()); @@ -965,7 +973,10 @@ async fn on_demand_beefy_justification_sync() { // Have the other peers do some gossip so Dave finds out about their progress. finalize_block_and_wait_for_beefy(&net, fast_peers, &[hashes[25], hashes[29]], &[25, 29]).await; - // Now verify Dave successfully finalized #1 (through on-demand justification request). + // Kick Dave's async loop by finalizing another block. + client.finalize_block(hashes[2], None).unwrap(); + + // And verify Dave successfully finalized #1 (through on-demand justification request). wait_for_best_beefy_blocks(dave_best_blocks, &net, &[1]).await; // Give all tasks some cpu cycles to burn through their events queues, @@ -978,10 +989,6 @@ async fn on_demand_beefy_justification_sync() { &[5, 10, 15, 20, 25], ) .await; - - let all_peers = all_peers.into_iter().enumerate(); - // Now that Dave has caught up, sanity check voting works for all of them. - finalize_block_and_wait_for_beefy(&net, all_peers, &[hashes[30], hashes[34]], &[30]).await; } #[tokio::test] diff --git a/client/consensus/beefy/src/worker.rs b/client/consensus/beefy/src/worker.rs index 3f29dc7abee5c..0abb38d022ef6 100644 --- a/client/consensus/beefy/src/worker.rs +++ b/client/consensus/beefy/src/worker.rs @@ -887,11 +887,6 @@ where // based on the new resulting 'state'. futures::select_biased! { // Use `select_biased!` to prioritize order below. - // Make sure to pump gossip engine. - _ = gossip_engine => { - error!(target: LOG_TARGET, "🥩 Gossip engine has terminated, closing worker."); - return; - }, // Process finality notifications first since these drive the voter. notification = finality_notifications.next() => { if let Some(notification) = notification { @@ -901,6 +896,11 @@ where return; } }, + // Make sure to pump gossip engine. + _ = gossip_engine => { + error!(target: LOG_TARGET, "🥩 Gossip engine has terminated, closing worker."); + return; + }, // Process incoming justifications as these can make some in-flight votes obsolete. justif = self.on_demand_justifications.next().fuse() => { if let Some(justif) = justif { From 03ea99e4b57d17d3029da87a3b196eb9d5178f5d Mon Sep 17 00:00:00 2001 From: cheme Date: Tue, 14 Mar 2023 22:03:50 +0100 Subject: [PATCH 12/80] update trie deps (#13601) --- Cargo.lock | 29 +++++++++---------- bin/node/bench/Cargo.toml | 2 +- client/db/Cargo.toml | 2 +- primitives/api/Cargo.toml | 2 +- primitives/core/Cargo.toml | 2 +- primitives/state-machine/Cargo.toml | 4 +-- primitives/trie/Cargo.toml | 12 ++++---- test-utils/runtime/Cargo.toml | 4 +-- utils/binary-merkle-tree/Cargo.toml | 2 +- .../rpc/state-trie-migration-rpc/Cargo.toml | 2 +- 10 files changed, 30 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4aac7f3c7ed99..0d048a99de668 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2856,9 +2856,9 @@ dependencies = [ [[package]] name = "hash-db" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" +checksum = "8e7d7786361d7425ae2fe4f9e407eb0efaa0840f5212d109cc018c40c35c6ab4" [[package]] name = "hash256-std-hasher" @@ -3484,9 +3484,9 @@ dependencies = [ [[package]] name = "keccak-hasher" -version = "0.15.3" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711adba9940a039f4374fc5724c0a5eaca84a2d558cce62256bfe26f0dbef05e" +checksum = "19ea4653859ca2266a86419d3f592d3f22e7a854b482f99180d2498507902048" dependencies = [ "hash-db", "hash256-std-hasher", @@ -4454,12 +4454,11 @@ dependencies = [ [[package]] name = "memory-db" -version = "0.31.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e0c7cba9ce19ac7ffd2053ac9f49843bbd3f4318feedfd74e85c19d5fb0ba66" +checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" dependencies = [ "hash-db", - "hashbrown 0.12.3", ] [[package]] @@ -11618,9 +11617,9 @@ dependencies = [ [[package]] name = "trie-bench" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac2b7695feb8041efc0adaa09ed3a692ca7b7c997395954fdc838b5b078346f6" +checksum = "4f54b4f9d51d368e62cf7e0730c7c1e18fc658cc84333656bab5b328f44aa964" dependencies = [ "criterion", "hash-db", @@ -11634,9 +11633,9 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879380c0061b165ba1f036325b7f3478bc1a947814d9fc36d22c5d8e960b11bd" +checksum = "634d75c77ea43f2ad8ea9d9c58de49dfc9c3995bdef32b503df7883ff054e7f1" dependencies = [ "hash-db", "hashbrown 0.13.2", @@ -11647,18 +11646,18 @@ dependencies = [ [[package]] name = "trie-root" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a36c5ca3911ed3c9a5416ee6c679042064b93fc637ded67e25f92e68d783891" +checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" dependencies = [ "hash-db", ] [[package]] name = "trie-standardmap" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3161ba520ab28cd8e6b68e1126f1009f6e335339d1a73b978139011703264c8" +checksum = "684aafb332fae6f83d7fe10b3fbfdbe39a1b3234c4e2a618f030815838519516" dependencies = [ "hash-db", "keccak-hasher", diff --git a/bin/node/bench/Cargo.toml b/bin/node/bench/Cargo.toml index dfff4db43a53b..be5e94ee4df8b 100644 --- a/bin/node/bench/Cargo.toml +++ b/bin/node/bench/Cargo.toml @@ -33,7 +33,7 @@ sc-basic-authorship = { version = "0.10.0-dev", path = "../../../client/basic-au sp-inherents = { version = "4.0.0-dev", path = "../../../primitives/inherents" } sp-timestamp = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/timestamp" } sp-tracing = { version = "6.0.0", path = "../../../primitives/tracing" } -hash-db = "0.15.2" +hash-db = "0.16.0" tempfile = "3.1.0" fs_extra = "1" rand = { version = "0.8.5", features = ["small_rng"] } diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index ed26f373733e4..c96e5c7405e74 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { package = "parity-scale-codec", version = "3.2.2", features = [ "derive", ] } -hash-db = "0.15.2" +hash-db = "0.16.0" kvdb = "0.13.0" kvdb-memorydb = "0.13.0" kvdb-rocksdb = { version = "0.17.0", optional = true } diff --git a/primitives/api/Cargo.toml b/primitives/api/Cargo.toml index 75197bcaea900..ae1b3294c281f 100644 --- a/primitives/api/Cargo.toml +++ b/primitives/api/Cargo.toml @@ -21,7 +21,7 @@ sp-runtime = { version = "7.0.0", default-features = false, path = "../runtime" sp-version = { version = "5.0.0", default-features = false, path = "../version" } sp-state-machine = { version = "0.13.0", default-features = false, optional = true, path = "../state-machine" } sp-trie = { version = "7.0.0", default-features = false, optional = true, path = "../trie" } -hash-db = { version = "0.15.2", optional = true } +hash-db = { version = "0.16.0", optional = true } thiserror = { version = "1.0.30", optional = true } log = { version = "0.4.17", default-features = false } diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index 7c045377571f6..092baeeda95f8 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -23,7 +23,7 @@ serde = { version = "1.0.136", optional = true, features = ["derive"] } bounded-collections = { version = "0.1.4", default-features = false } primitive-types = { version = "0.12.0", default-features = false, features = ["codec", "scale-info"] } impl-serde = { version = "0.4.0", optional = true } -hash-db = { version = "0.15.2", default-features = false } +hash-db = { version = "0.16.0", default-features = false } hash256-std-hasher = { version = "0.15.2", default-features = false } base58 = { version = "0.2.0", optional = true } rand = { version = "0.8.5", features = ["small_rng"], optional = true } diff --git a/primitives/state-machine/Cargo.toml b/primitives/state-machine/Cargo.toml index 56fbe0726b82e..9759547d7f384 100644 --- a/primitives/state-machine/Cargo.toml +++ b/primitives/state-machine/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } -hash-db = { version = "0.15.2", default-features = false } +hash-db = { version = "0.16.0", default-features = false } log = { version = "0.4.17", default-features = false } parking_lot = { version = "0.12.1", optional = true } rand = { version = "0.8.5", optional = true } @@ -33,7 +33,7 @@ array-bytes = "4.1" pretty_assertions = "1.2.1" rand = "0.8.5" sp-runtime = { version = "7.0.0", path = "../runtime" } -trie-db = "0.26.0" +trie-db = "0.27.0" assert_matches = "1.5" [features] diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index fae39ec34c0ea..21582296b67f8 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -21,16 +21,16 @@ harness = false ahash = { version = "0.8.2", optional = true } codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } hashbrown = { version = "0.12.3", optional = true } -hash-db = { version = "0.15.2", default-features = false } +hash-db = { version = "0.16.0", default-features = false } lazy_static = { version = "1.4.0", optional = true } -memory-db = { version = "0.31.0", default-features = false } +memory-db = { version = "0.32.0", default-features = false } nohash-hasher = { version = "0.2.0", optional = true } parking_lot = { version = "0.12.1", optional = true } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } thiserror = { version = "1.0.30", optional = true } tracing = { version = "0.1.29", optional = true } -trie-db = { version = "0.26.0", default-features = false } -trie-root = { version = "0.17.0", default-features = false } +trie-db = { version = "0.27.0", default-features = false } +trie-root = { version = "0.18.0", default-features = false } sp-core = { version = "7.0.0", default-features = false, path = "../core" } sp-std = { version = "5.0.0", default-features = false, path = "../std" } schnellru = { version = "0.2.1", optional = true } @@ -38,8 +38,8 @@ schnellru = { version = "0.2.1", optional = true } [dev-dependencies] array-bytes = "4.1" criterion = "0.4.0" -trie-bench = "0.36.0" -trie-standardmap = "0.15.2" +trie-bench = "0.37.0" +trie-standardmap = "0.16.0" sp-runtime = { version = "7.0.0", path = "../runtime" } [features] diff --git a/test-utils/runtime/Cargo.toml b/test-utils/runtime/Cargo.toml index e0f414b161cf5..1dcdec0dbf059 100644 --- a/test-utils/runtime/Cargo.toml +++ b/test-utils/runtime/Cargo.toml @@ -23,7 +23,7 @@ codec = { package = "parity-scale-codec", version = "3.2.2", default-features = scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../primitives/inherents" } sp-keyring = { version = "7.0.0", optional = true, path = "../../primitives/keyring" } -memory-db = { version = "0.31.0", default-features = false } +memory-db = { version = "0.32.0", default-features = false } sp-offchain = { version = "4.0.0-dev", default-features = false, path = "../../primitives/offchain" } sp-core = { version = "7.0.0", default-features = false, path = "../../primitives/core" } sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" } @@ -41,7 +41,7 @@ pallet-timestamp = { version = "4.0.0-dev", default-features = false, path = ".. sp-consensus-grandpa = { version = "4.0.0-dev", default-features = false, path = "../../primitives/consensus/grandpa" } sp-trie = { version = "7.0.0", default-features = false, path = "../../primitives/trie" } sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../primitives/transaction-pool" } -trie-db = { version = "0.26.0", default-features = false } +trie-db = { version = "0.27.0", default-features = false } sc-service = { version = "0.10.0-dev", default-features = false, optional = true, features = ["test-helpers"], path = "../../client/service" } sp-state-machine = { version = "0.13.0", default-features = false, path = "../../primitives/state-machine" } sp-externalities = { version = "0.13.0", default-features = false, path = "../../primitives/externalities" } diff --git a/utils/binary-merkle-tree/Cargo.toml b/utils/binary-merkle-tree/Cargo.toml index a59d27fb09bb9..a54dc4f2d0497 100644 --- a/utils/binary-merkle-tree/Cargo.toml +++ b/utils/binary-merkle-tree/Cargo.toml @@ -11,7 +11,7 @@ homepage = "https://substrate.io" [dependencies] array-bytes = { version = "4.1", optional = true } log = { version = "0.4", default-features = false, optional = true } -hash-db = { version = "0.15.2", default-features = false } +hash-db = { version = "0.16.0", default-features = false } [dev-dependencies] array-bytes = "4.1" diff --git a/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml b/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml index e6eccc6ff62e0..3689a87da8ae5 100644 --- a/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml +++ b/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml @@ -21,7 +21,7 @@ log = { version = "0.4.17", default-features = false } sp-core = { path = "../../../../primitives/core" } sp-state-machine = { path = "../../../../primitives/state-machine" } sp-trie = { path = "../../../../primitives/trie" } -trie-db = "0.26.0" +trie-db = "0.27.0" jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] } From 9eafc96a62d160cd97f8150b2742d7048e394bba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 14 Mar 2023 22:14:58 +0100 Subject: [PATCH 13/80] sp-api: Support expanding the macro code (#13573) * sp-api: Support expanding the macro code This pr introduces the `expander` crate to expand the generated source code into a file. This gives better error reporting when trying to fix issues in the macro itself as Rustc will point to the line in this file. The feature can be enabled by setting `SP_API_EXPAND=1` at compile time. Besides that the generated code is changed to fix warnings in the exanped version. * Fixes --- Cargo.lock | 21 +++++ primitives/api/proc-macro/Cargo.toml | 4 +- primitives/api/proc-macro/src/common.rs | 3 - .../api/proc-macro/src/decl_runtime_apis.rs | 35 ++++--- .../api/proc-macro/src/impl_runtime_apis.rs | 93 ++++++++++++------- .../proc-macro/src/mock_impl_runtime_apis.rs | 16 +--- primitives/api/proc-macro/src/utils.rs | 39 +++----- primitives/api/test/tests/decl_and_impl.rs | 8 +- .../test/tests/ui/impl_missing_version.stderr | 6 +- 9 files changed, 124 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d048a99de668..d0aea7729bd2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1997,6 +1997,19 @@ dependencies = [ "futures", ] +[[package]] +name = "expander" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f360349150728553f92e4c997a16af8915f418d3a0f21b440d34c5632f16ed84" +dependencies = [ + "blake2", + "fs-err", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "fake-simd" version = "0.1.2" @@ -2507,6 +2520,12 @@ dependencies = [ "sp-std", ] +[[package]] +name = "fs-err" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" + [[package]] name = "fs2" version = "0.4.3" @@ -9925,7 +9944,9 @@ dependencies = [ name = "sp-api-proc-macro" version = "4.0.0-dev" dependencies = [ + "Inflector", "blake2", + "expander", "proc-macro-crate", "proc-macro2", "quote", diff --git a/primitives/api/proc-macro/Cargo.toml b/primitives/api/proc-macro/Cargo.toml index 8acc15d6a0591..ba7c6312042c9 100644 --- a/primitives/api/proc-macro/Cargo.toml +++ b/primitives/api/proc-macro/Cargo.toml @@ -21,8 +21,10 @@ syn = { version = "1.0.98", features = ["full", "fold", "extra-traits", "visit"] proc-macro2 = "1.0.37" blake2 = { version = "0.10.4", default-features = false } proc-macro-crate = "1.1.3" +expander = "1.0.0" +Inflector = "0.11.4" # Required for the doc tests [features] -default = [ "std" ] +default = ["std"] std = [] diff --git a/primitives/api/proc-macro/src/common.rs b/primitives/api/proc-macro/src/common.rs index d29057723b8a4..725ad166fbe73 100644 --- a/primitives/api/proc-macro/src/common.rs +++ b/primitives/api/proc-macro/src/common.rs @@ -18,9 +18,6 @@ /// The ident used for the block generic parameter. pub const BLOCK_GENERIC_IDENT: &str = "Block"; -/// Unique identifier used to make the hidden includes unique for this macro. -pub const HIDDEN_INCLUDES_ID: &str = "DECL_RUNTIME_APIS"; - /// The `core_trait` attribute. pub const CORE_TRAIT_ATTRIBUTE: &str = "core_trait"; /// The `api_version` attribute. diff --git a/primitives/api/proc-macro/src/decl_runtime_apis.rs b/primitives/api/proc-macro/src/decl_runtime_apis.rs index d9a72adadec98..3c3056d34487b 100644 --- a/primitives/api/proc-macro/src/decl_runtime_apis.rs +++ b/primitives/api/proc-macro/src/decl_runtime_apis.rs @@ -17,14 +17,14 @@ use crate::utils::{ extract_parameter_names_types_and_borrows, fold_fn_decl_for_client_side, generate_crate_access, - generate_hidden_includes, generate_runtime_mod_name_for_trait, parse_runtime_api_version, - prefix_function_with_trait, replace_wild_card_parameter_names, return_type_extract_type, - versioned_trait_name, AllowSelfRefInParameters, + generate_runtime_mod_name_for_trait, parse_runtime_api_version, prefix_function_with_trait, + replace_wild_card_parameter_names, return_type_extract_type, versioned_trait_name, + AllowSelfRefInParameters, }; use crate::common::{ API_VERSION_ATTRIBUTE, BLOCK_GENERIC_IDENT, CHANGED_IN_ATTRIBUTE, CORE_TRAIT_ATTRIBUTE, - HIDDEN_INCLUDES_ID, RENAMED_ATTRIBUTE, SUPPORTED_ATTRIBUTE_NAMES, + RENAMED_ATTRIBUTE, SUPPORTED_ATTRIBUTE_NAMES, }; use proc_macro2::{Span, TokenStream}; @@ -62,7 +62,7 @@ impl Parse for RuntimeApiDecls { /// Extend the given generics with `Block: BlockT` as first generic parameter. fn extend_generics_with_block(generics: &mut Generics) { - let c = generate_crate_access(HIDDEN_INCLUDES_ID); + let c = generate_crate_access(); generics.lt_token = Some(Default::default()); generics.params.insert(0, parse_quote!( Block: #c::BlockT )); @@ -298,7 +298,7 @@ fn generate_runtime_decls(decls: &[ItemTrait]) -> Result { #[allow(dead_code)] #[allow(deprecated)] pub mod #mod_name { - use super::*; + pub use super::*; #( #versioned_api_traits )* @@ -495,10 +495,10 @@ impl<'a> ToClientSideDecl<'a> { __runtime_api_at_param__, #context, __runtime_api_impl_params_encoded__, - &|version| { + &|_version| { #( // Check if we need to call the function by an old name. - if version.apis.iter().any(|(s, v)| { + if _version.apis.iter().any(|(s, v)| { s == &#runtime_mod::ID && *v < #versions }) { return #old_names @@ -569,7 +569,7 @@ fn generate_runtime_api_version(version: u32) -> TokenStream { /// Generates the implementation of `RuntimeApiInfo` for the given trait. fn generate_runtime_info_impl(trait_: &ItemTrait, version: u64) -> TokenStream { let trait_name = &trait_.ident; - let crate_ = generate_crate_access(HIDDEN_INCLUDES_ID); + let crate_ = generate_crate_access(); let id = generate_runtime_api_id(&trait_name.to_string()); let version = generate_runtime_api_version(version as u32); @@ -620,7 +620,7 @@ fn generate_client_side_decls(decls: &[ItemTrait]) -> Result { for decl in decls { let decl = decl.clone(); - let crate_ = generate_crate_access(HIDDEN_INCLUDES_ID); + let crate_ = generate_crate_access(); let block_hash = quote!( ::Hash ); let mut found_attributes = HashMap::new(); let mut errors = Vec::new(); @@ -777,15 +777,20 @@ pub fn decl_runtime_apis_impl(input: proc_macro::TokenStream) -> proc_macro::Tok fn decl_runtime_apis_impl_inner(api_decls: &[ItemTrait]) -> Result { check_trait_decls(api_decls)?; - let hidden_includes = generate_hidden_includes(HIDDEN_INCLUDES_ID); let runtime_decls = generate_runtime_decls(api_decls)?; let client_side_decls = generate_client_side_decls(api_decls)?; - Ok(quote!( - #hidden_includes - + let decl = quote! { #runtime_decls #client_side_decls - )) + }; + + let decl = expander::Expander::new("decl_runtime_apis") + .dry(std::env::var("SP_API_EXPAND").is_err()) + .verbose(true) + .write_to_out_dir(decl) + .expect("Does not fail because of IO in OUT_DIR; qed"); + + Ok(decl) } diff --git a/primitives/api/proc-macro/src/impl_runtime_apis.rs b/primitives/api/proc-macro/src/impl_runtime_apis.rs index f32961f892bba..5ac07975df0f7 100644 --- a/primitives/api/proc-macro/src/impl_runtime_apis.rs +++ b/primitives/api/proc-macro/src/impl_runtime_apis.rs @@ -17,7 +17,7 @@ use crate::utils::{ extract_all_signature_types, extract_block_type_from_trait_path, extract_impl_trait, - extract_parameter_names_types_and_borrows, generate_crate_access, generate_hidden_includes, + extract_parameter_names_types_and_borrows, generate_crate_access, generate_runtime_mod_name_for_trait, parse_runtime_api_version, prefix_function_with_trait, versioned_trait_name, AllowSelfRefInParameters, RequireQualifiedTraitPath, }; @@ -38,9 +38,6 @@ use syn::{ use std::collections::HashSet; -/// Unique identifier used to make the hidden includes unique for this macro. -const HIDDEN_INCLUDES_ID: &str = "IMPL_RUNTIME_APIS"; - /// The structure used for parsing the runtime api implementations. struct RuntimeApiImpls { impls: Vec, @@ -73,7 +70,7 @@ fn generate_impl_call( let params = extract_parameter_names_types_and_borrows(signature, AllowSelfRefInParameters::No)?; - let c = generate_crate_access(HIDDEN_INCLUDES_ID); + let c = generate_crate_access(); let fn_name = &signature.ident; let fn_name_str = fn_name.to_string(); let pnames = params.iter().map(|v| &v.0); @@ -81,15 +78,33 @@ fn generate_impl_call( let ptypes = params.iter().map(|v| &v.1); let pborrow = params.iter().map(|v| &v.2); + let decode_params = if params.is_empty() { + quote!() + } else { + let let_binding = if params.len() == 1 { + quote! { + let #( #pnames )* : #( #ptypes )* + } + } else { + quote! { + let ( #( #pnames ),* ) : ( #( #ptypes ),* ) + } + }; + + quote!( + #let_binding = + match #c::DecodeLimit::decode_all_with_depth_limit( + #c::MAX_EXTRINSIC_DEPTH, + &mut #input, + ) { + Ok(res) => res, + Err(e) => panic!("Bad input data provided to {}: {}", #fn_name_str, e), + }; + ) + }; + Ok(quote!( - let (#( #pnames ),*) : ( #( #ptypes ),* ) = - match #c::DecodeLimit::decode_all_with_depth_limit( - #c::MAX_EXTRINSIC_DEPTH, - &mut #input, - ) { - Ok(res) => res, - Err(e) => panic!("Bad input data provided to {}: {}", #fn_name_str, e), - }; + #decode_params #[allow(deprecated)] <#runtime as #impl_trait>::#fn_name(#( #pborrow #pnames2 ),*) @@ -134,8 +149,8 @@ fn generate_impl_calls( /// Generate the dispatch function that is used in native to call into the runtime. fn generate_dispatch_function(impls: &[ItemImpl]) -> Result { - let data = Ident::new("__sp_api__input_data", Span::call_site()); - let c = generate_crate_access(HIDDEN_INCLUDES_ID); + let data = Ident::new("_sp_api_input_data_", Span::call_site()); + let c = generate_crate_access(); let impl_calls = generate_impl_calls(impls, &data)? .into_iter() @@ -161,7 +176,7 @@ fn generate_dispatch_function(impls: &[ItemImpl]) -> Result { /// Generate the interface functions that are used to call into the runtime in wasm. fn generate_wasm_interface(impls: &[ItemImpl]) -> Result { let input = Ident::new("input", Span::call_site()); - let c = generate_crate_access(HIDDEN_INCLUDES_ID); + let c = generate_crate_access(); let impl_calls = generate_impl_calls(impls, &input)? @@ -195,7 +210,7 @@ fn generate_wasm_interface(impls: &[ItemImpl]) -> Result { } fn generate_runtime_api_base_structures() -> Result { - let crate_ = generate_crate_access(HIDDEN_INCLUDES_ID); + let crate_ = generate_crate_access(); Ok(quote!( pub struct RuntimeApi {} @@ -414,7 +429,7 @@ impl<'a> ApiRuntimeImplToApiRuntimeApiImpl<'a> { fn process(mut self, input: ItemImpl) -> ItemImpl { let mut input = self.fold_item_impl(input); - let crate_ = generate_crate_access(HIDDEN_INCLUDES_ID); + let crate_ = generate_crate_access(); // Delete all functions, because all of them are default implemented by // `decl_runtime_apis!`. We only need to implement the `__runtime_api_internal_call_api_at` @@ -423,7 +438,7 @@ impl<'a> ApiRuntimeImplToApiRuntimeApiImpl<'a> { input.items.push(parse_quote! { fn __runtime_api_internal_call_api_at( &self, - at: <__SR_API_BLOCK__ as #crate_::BlockT>::Hash, + at: <__SrApiBlock__ as #crate_::BlockT>::Hash, context: #crate_::ExecutionContext, params: std::vec::Vec, fn_name: &dyn Fn(#crate_::RuntimeVersion) -> &'static str, @@ -435,7 +450,7 @@ impl<'a> ApiRuntimeImplToApiRuntimeApiImpl<'a> { } let res = (|| { - let version = #crate_::CallApiAt::<__SR_API_BLOCK__>::runtime_version_at( + let version = #crate_::CallApiAt::<__SrApiBlock__>::runtime_version_at( self.call, at, )?; @@ -450,7 +465,7 @@ impl<'a> ApiRuntimeImplToApiRuntimeApiImpl<'a> { recorder: &self.recorder, }; - #crate_::CallApiAt::<__SR_API_BLOCK__>::call_api_at( + #crate_::CallApiAt::<__SrApiBlock__>::call_api_at( self.call, params, ) @@ -469,7 +484,7 @@ impl<'a> ApiRuntimeImplToApiRuntimeApiImpl<'a> { impl<'a> Fold for ApiRuntimeImplToApiRuntimeApiImpl<'a> { fn fold_type_path(&mut self, input: TypePath) -> TypePath { let new_ty_path = - if input == *self.runtime_block { parse_quote!(__SR_API_BLOCK__) } else { input }; + if input == *self.runtime_block { parse_quote!(__SrApiBlock__) } else { input }; fold::fold_type_path(self, new_ty_path) } @@ -480,25 +495,26 @@ impl<'a> Fold for ApiRuntimeImplToApiRuntimeApiImpl<'a> { // Before we directly had the final block type and rust could determine that it is unwind // safe, but now we just have a generic parameter `Block`. - let crate_ = generate_crate_access(HIDDEN_INCLUDES_ID); + let crate_ = generate_crate_access(); // Implement the trait for the `RuntimeApiImpl` input.self_ty = - Box::new(parse_quote!( RuntimeApiImpl<__SR_API_BLOCK__, RuntimeApiImplCall> )); + Box::new(parse_quote!( RuntimeApiImpl<__SrApiBlock__, RuntimeApiImplCall> )); input.generics.params.push(parse_quote!( - __SR_API_BLOCK__: #crate_::BlockT + std::panic::UnwindSafe + + __SrApiBlock__: #crate_::BlockT + std::panic::UnwindSafe + std::panic::RefUnwindSafe )); - input.generics.params.push( - parse_quote!( RuntimeApiImplCall: #crate_::CallApiAt<__SR_API_BLOCK__> + 'static ), - ); + input + .generics + .params + .push(parse_quote!( RuntimeApiImplCall: #crate_::CallApiAt<__SrApiBlock__> + 'static )); let where_clause = input.generics.make_where_clause(); where_clause.predicates.push(parse_quote! { RuntimeApiImplCall::StateBackend: - #crate_::StateBackend<#crate_::HashFor<__SR_API_BLOCK__>> + #crate_::StateBackend<#crate_::HashFor<__SrApiBlock__>> }); where_clause.predicates.push(parse_quote! { &'static RuntimeApiImplCall: Send }); @@ -511,7 +527,7 @@ impl<'a> Fold for ApiRuntimeImplToApiRuntimeApiImpl<'a> { }); where_clause.predicates.push(parse_quote! { - __SR_API_BLOCK__::Header: std::panic::UnwindSafe + std::panic::RefUnwindSafe + __SrApiBlock__::Header: std::panic::UnwindSafe + std::panic::RefUnwindSafe }); input.attrs = filter_cfg_attrs(&input.attrs); @@ -574,7 +590,7 @@ fn generate_runtime_api_versions(impls: &[ItemImpl]) -> Result { let mut sections = Vec::::with_capacity(impls.len()); let mut processed_traits = HashSet::new(); - let c = generate_crate_access(HIDDEN_INCLUDES_ID); + let c = generate_crate_access(); for impl_ in impls { let api_ver = extract_api_version(&impl_.attrs, impl_.span())?.map(|a| a as u32); @@ -629,14 +645,11 @@ fn impl_runtime_apis_impl_inner(api_impls: &[ItemImpl]) -> Result { let dispatch_impl = generate_dispatch_function(api_impls)?; let api_impls_for_runtime = generate_api_impl_for_runtime(api_impls)?; let base_runtime_api = generate_runtime_api_base_structures()?; - let hidden_includes = generate_hidden_includes(HIDDEN_INCLUDES_ID); let runtime_api_versions = generate_runtime_api_versions(api_impls)?; let wasm_interface = generate_wasm_interface(api_impls)?; let api_impls_for_runtime_api = generate_api_impl_for_runtime_api(api_impls)?; - Ok(quote!( - #hidden_includes - + let impl_ = quote!( #base_runtime_api #api_impls_for_runtime @@ -652,7 +665,15 @@ fn impl_runtime_apis_impl_inner(api_impls: &[ItemImpl]) -> Result { #wasm_interface } - )) + ); + + let impl_ = expander::Expander::new("impl_runtime_apis") + .dry(std::env::var("SP_API_EXPAND").is_err()) + .verbose(true) + .write_to_out_dir(impl_) + .expect("Does not fail because of IO in OUT_DIR; qed"); + + Ok(impl_) } // Filters all attributes except the cfg ones. diff --git a/primitives/api/proc-macro/src/mock_impl_runtime_apis.rs b/primitives/api/proc-macro/src/mock_impl_runtime_apis.rs index 4c79787a1e8df..fc0a754e26730 100644 --- a/primitives/api/proc-macro/src/mock_impl_runtime_apis.rs +++ b/primitives/api/proc-macro/src/mock_impl_runtime_apis.rs @@ -17,8 +17,8 @@ use crate::utils::{ extract_block_type_from_trait_path, extract_impl_trait, - extract_parameter_names_types_and_borrows, generate_crate_access, generate_hidden_includes, - return_type_extract_type, AllowSelfRefInParameters, RequireQualifiedTraitPath, + extract_parameter_names_types_and_borrows, generate_crate_access, return_type_extract_type, + AllowSelfRefInParameters, RequireQualifiedTraitPath, }; use proc_macro2::{Span, TokenStream}; @@ -33,9 +33,6 @@ use syn::{ Attribute, ItemImpl, Pat, Type, TypePath, }; -/// Unique identifier used to make the hidden includes unique for this macro. -const HIDDEN_INCLUDES_ID: &str = "MOCK_IMPL_RUNTIME_APIS"; - /// The `advanced` attribute. /// /// If this attribute is given to a function, the function gets access to the `Hash` as first @@ -65,7 +62,7 @@ impl Parse for RuntimeApiImpls { /// Implement the `ApiExt` trait and the `Core` runtime api. fn implement_common_api_traits(block_type: TypePath, self_ty: Type) -> Result { - let crate_ = generate_crate_access(HIDDEN_INCLUDES_ID); + let crate_ = generate_crate_access(); Ok(quote!( impl #crate_::ApiExt<#block_type> for #self_ty { @@ -256,7 +253,7 @@ impl<'a> FoldRuntimeApiImpl<'a> { fn process(mut self, impl_item: syn::ItemImpl) -> syn::ItemImpl { let mut impl_item = self.fold_item_impl(impl_item); - let crate_ = generate_crate_access(HIDDEN_INCLUDES_ID); + let crate_ = generate_crate_access(); // We also need to overwrite all the `_with_context` methods. To do this, // we clone all methods and add them again with the new name plus one more argument. @@ -295,7 +292,7 @@ impl<'a> FoldRuntimeApiImpl<'a> { impl<'a> Fold for FoldRuntimeApiImpl<'a> { fn fold_impl_item_method(&mut self, mut input: syn::ImplItemMethod) -> syn::ImplItemMethod { let block = { - let crate_ = generate_crate_access(HIDDEN_INCLUDES_ID); + let crate_ = generate_crate_access(); let is_advanced = has_advanced_attribute(&mut input.attrs); let mut errors = Vec::new(); @@ -469,14 +466,11 @@ pub fn mock_impl_runtime_apis_impl(input: proc_macro::TokenStream) -> proc_macro } fn mock_impl_runtime_apis_impl_inner(api_impls: &[ItemImpl]) -> Result { - let hidden_includes = generate_hidden_includes(HIDDEN_INCLUDES_ID); let GeneratedRuntimeApiImpls { impls, block_type, self_ty } = generate_runtime_api_impls(api_impls)?; let api_traits = implement_common_api_traits(block_type, self_ty)?; Ok(quote!( - #hidden_includes - #impls #api_traits diff --git a/primitives/api/proc-macro/src/utils.rs b/primitives/api/proc-macro/src/utils.rs index dee29b1a52c49..4444a2624b669 100644 --- a/primitives/api/proc-macro/src/utils.rs +++ b/primitives/api/proc-macro/src/utils.rs @@ -24,29 +24,19 @@ use syn::{ use quote::{format_ident, quote}; -use std::env; - use proc_macro_crate::{crate_name, FoundCrate}; use crate::common::API_VERSION_ATTRIBUTE; -fn generate_hidden_includes_mod_name(unique_id: &'static str) -> Ident { - Ident::new(&format!("sp_api_hidden_includes_{}", unique_id), Span::call_site()) -} +use inflector::Inflector; -/// Generates the hidden includes that are required to make the macro independent from its scope. -pub fn generate_hidden_includes(unique_id: &'static str) -> TokenStream { - let mod_name = generate_hidden_includes_mod_name(unique_id); +/// Generates the access to the `sc_client` crate. +pub fn generate_crate_access() -> TokenStream { match crate_name("sp-api") { - Ok(FoundCrate::Itself) => quote!(), - Ok(FoundCrate::Name(client_name)) => { - let client_name = Ident::new(&client_name, Span::call_site()); - quote!( - #[doc(hidden)] - mod #mod_name { - pub extern crate #client_name as sp_api; - } - ) + Ok(FoundCrate::Itself) => quote!(sp_api), + Ok(FoundCrate::Name(renamed_name)) => { + let renamed_name = Ident::new(&renamed_name, Span::call_site()); + quote!(#renamed_name) }, Err(e) => { let err = Error::new(Span::call_site(), e).to_compile_error(); @@ -55,19 +45,12 @@ pub fn generate_hidden_includes(unique_id: &'static str) -> TokenStream { } } -/// Generates the access to the `sc_client` crate. -pub fn generate_crate_access(unique_id: &'static str) -> TokenStream { - if env::var("CARGO_PKG_NAME").unwrap() == "sp-api" { - quote!(sp_api) - } else { - let mod_name = generate_hidden_includes_mod_name(unique_id); - quote!( self::#mod_name::sp_api ) - } -} - /// Generates the name of the module that contains the trait declaration for the runtime. pub fn generate_runtime_mod_name_for_trait(trait_: &Ident) -> Ident { - Ident::new(&format!("runtime_decl_for_{}", trait_), Span::call_site()) + Ident::new( + &format!("runtime_decl_for_{}", trait_.to_string().to_snake_case()), + Span::call_site(), + ) } /// Get the type of a `syn::ReturnType`. diff --git a/primitives/api/test/tests/decl_and_impl.rs b/primitives/api/test/tests/decl_and_impl.rs index 78990d5467d0e..f07adbfa709b5 100644 --- a/primitives/api/test/tests/decl_and_impl.rs +++ b/primitives/api/test/tests/decl_and_impl.rs @@ -166,17 +166,17 @@ fn test_client_side_function_signature() { #[test] fn check_runtime_api_info() { - assert_eq!(&>::ID, &runtime_decl_for_Api::ID); - assert_eq!(>::VERSION, runtime_decl_for_Api::VERSION); + assert_eq!(&>::ID, &runtime_decl_for_api::ID); + assert_eq!(>::VERSION, runtime_decl_for_api::VERSION); assert_eq!(>::VERSION, 1); assert_eq!( >::VERSION, - runtime_decl_for_ApiWithCustomVersion::VERSION, + runtime_decl_for_api_with_custom_version::VERSION, ); assert_eq!( &>::ID, - &runtime_decl_for_ApiWithCustomVersion::ID, + &runtime_decl_for_api_with_custom_version::ID, ); assert_eq!(>::VERSION, 2); diff --git a/primitives/api/test/tests/ui/impl_missing_version.stderr b/primitives/api/test/tests/ui/impl_missing_version.stderr index c0abeffe0cccf..b8ecc466c7fcd 100644 --- a/primitives/api/test/tests/ui/impl_missing_version.stderr +++ b/primitives/api/test/tests/ui/impl_missing_version.stderr @@ -1,10 +1,10 @@ -error[E0433]: failed to resolve: could not find `ApiV4` in `runtime_decl_for_Api` +error[E0433]: failed to resolve: could not find `ApiV4` in `runtime_decl_for_api` --> tests/ui/impl_missing_version.rs:21:13 | 21 | impl self::Api for Runtime { - | ^^^ could not find `ApiV4` in `runtime_decl_for_Api` + | ^^^ could not find `ApiV4` in `runtime_decl_for_api` -error[E0405]: cannot find trait `ApiV4` in module `self::runtime_decl_for_Api` +error[E0405]: cannot find trait `ApiV4` in module `self::runtime_decl_for_api` --> tests/ui/impl_missing_version.rs:21:13 | 11 | pub trait Api { From e44038af6440a8f941de64412794707c62e4b4e4 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 14 Mar 2023 23:53:03 +0100 Subject: [PATCH 14/80] frame epm: expose `feasibility_check` in MinerConfig (#13555) * frame epm: expose feasibity_check in miner The goal with this commit is to expose the `feasibity_check` such that anyone that implements the `MinerConfig trait` can utilize it * cleanup * fix tests --- bin/node/runtime/src/lib.rs | 1 + .../election-provider-multi-phase/src/lib.rs | 127 +++++------------- .../election-provider-multi-phase/src/mock.rs | 3 + .../src/signed.rs | 2 +- .../src/unsigned.rs | 98 +++++++++++++- 5 files changed, 134 insertions(+), 97 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 614dbc4d958c8..d8426d3b35e15 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -702,6 +702,7 @@ impl pallet_election_provider_multi_phase::MinerConfig for Runtime { type Solution = NposSolution16; type MaxVotesPerVoter = <::DataProvider as ElectionDataProvider>::MaxVotesPerVoter; + type MaxWinners = MaxActiveValidators; // The unsigned submissions have to respect the weight of the submit_unsigned call, thus their // weight estimate function is wired to this call's weight. diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 3ba90f4112a35..80bab68074c87 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -247,10 +247,7 @@ use sp_arithmetic::{ traits::{CheckedAdd, Zero}, UpperOf, }; -use sp_npos_elections::{ - assignment_ratio_to_staked_normalized, BoundedSupports, ElectionScore, EvaluateSupport, - Supports, VoteWeight, -}; +use sp_npos_elections::{BoundedSupports, ElectionScore, IdentifierT, Supports, VoteWeight}; use sp_runtime::{ transaction_validity::{ InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity, @@ -430,13 +427,17 @@ impl Default for RawSolution { DefaultNoBound, scale_info::TypeInfo, )] -#[scale_info(skip_type_params(T))] -pub struct ReadySolution { +#[scale_info(skip_type_params(AccountId, MaxWinners))] +pub struct ReadySolution +where + AccountId: IdentifierT, + MaxWinners: Get, +{ /// The final supports of the solution. /// /// This is target-major vector, storing each winners, total backing, and each individual /// backer. - pub supports: BoundedSupports, + pub supports: BoundedSupports, /// The score of the solution. /// /// This is needed to potentially challenge the solution. @@ -451,11 +452,11 @@ pub struct ReadySolution { /// These are stored together because they are often accessed together. #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, Default, TypeInfo)] #[scale_info(skip_type_params(T))] -pub struct RoundSnapshot { +pub struct RoundSnapshot { /// All of the voters. - pub voters: Vec>, + pub voters: Vec, /// All of the targets. - pub targets: Vec, + pub targets: Vec, } /// Encodes the length of a solution or a snapshot. @@ -614,6 +615,7 @@ pub mod pallet { type MinerConfig: crate::unsigned::MinerConfig< AccountId = Self::AccountId, MaxVotesPerVoter = ::MaxVotesPerVoter, + MaxWinners = Self::MaxWinners, >; /// Maximum number of signed submissions that can be queued. @@ -733,6 +735,11 @@ pub mod pallet { fn max_votes_per_voter() -> u32 { ::MaxVotesPerVoter::get() } + + #[pallet::constant_name(MinerMaxWinners)] + fn max_winners() -> u32 { + ::MaxWinners::get() + } } #[pallet::hooks] @@ -1247,14 +1254,15 @@ pub mod pallet { /// Current best solution, signed or unsigned, queued to be returned upon `elect`. #[pallet::storage] #[pallet::getter(fn queued_solution)] - pub type QueuedSolution = StorageValue<_, ReadySolution>; + pub type QueuedSolution = + StorageValue<_, ReadySolution>; /// Snapshot data of the round. /// /// This is created at the beginning of the signed phase and cleared upon calling `elect`. #[pallet::storage] #[pallet::getter(fn snapshot)] - pub type Snapshot = StorageValue<_, RoundSnapshot>; + pub type Snapshot = StorageValue<_, RoundSnapshot>>; /// Desired number of targets to elect for this round. /// @@ -1385,7 +1393,7 @@ impl Pallet { // instead of using storage APIs, we do a manual encoding into a fixed-size buffer. // `encoded_size` encodes it without storing it anywhere, this should not cause any // allocation. - let snapshot = RoundSnapshot:: { voters, targets }; + let snapshot = RoundSnapshot::> { voters, targets }; let size = snapshot.encoded_size(); log!(debug, "snapshot pre-calculated size {:?}", size); let mut buffer = Vec::with_capacity(size); @@ -1479,89 +1487,22 @@ impl Pallet { pub fn feasibility_check( raw_solution: RawSolution>, compute: ElectionCompute, - ) -> Result, FeasibilityError> { - let RawSolution { solution, score, round } = raw_solution; - - // First, check round. - ensure!(Self::round() == round, FeasibilityError::InvalidRound); - - // Winners are not directly encoded in the solution. - let winners = solution.unique_targets(); - + ) -> Result, FeasibilityError> { let desired_targets = Self::desired_targets().ok_or(FeasibilityError::SnapshotUnavailable)?; - ensure!(winners.len() as u32 == desired_targets, FeasibilityError::WrongWinnerCount); - // Fail early if targets requested by data provider exceed maximum winners supported. - ensure!( - desired_targets <= ::MaxWinners::get(), - FeasibilityError::TooManyDesiredTargets - ); - - // Ensure that the solution's score can pass absolute min-score. - let submitted_score = raw_solution.score; - ensure!( - Self::minimum_untrusted_score().map_or(true, |min_score| { - submitted_score.strict_threshold_better(min_score, Perbill::zero()) - }), - FeasibilityError::UntrustedScoreTooLow - ); - - // Read the entire snapshot. - let RoundSnapshot { voters: snapshot_voters, targets: snapshot_targets } = - Self::snapshot().ok_or(FeasibilityError::SnapshotUnavailable)?; - - // ----- Start building. First, we need some closures. - let cache = helpers::generate_voter_cache::(&snapshot_voters); - let voter_at = helpers::voter_at_fn::(&snapshot_voters); - let target_at = helpers::target_at_fn::(&snapshot_targets); - let voter_index = helpers::voter_index_fn_usize::(&cache); - - // Then convert solution -> assignment. This will fail if any of the indices are gibberish, - // namely any of the voters or targets. - let assignments = solution - .into_assignment(voter_at, target_at) - .map_err::(Into::into)?; - - // Ensure that assignments is correct. - let _ = assignments.iter().try_for_each(|assignment| { - // Check that assignment.who is actually a voter (defensive-only). - // NOTE: while using the index map from `voter_index` is better than a blind linear - // search, this *still* has room for optimization. Note that we had the index when - // we did `solution -> assignment` and we lost it. Ideal is to keep the index - // around. - - // Defensive-only: must exist in the snapshot. - let snapshot_index = - voter_index(&assignment.who).ok_or(FeasibilityError::InvalidVoter)?; - // Defensive-only: index comes from the snapshot, must exist. - let (_voter, _stake, targets) = - snapshot_voters.get(snapshot_index).ok_or(FeasibilityError::InvalidVoter)?; - - // Check that all of the targets are valid based on the snapshot. - if assignment.distribution.iter().any(|(d, _)| !targets.contains(d)) { - return Err(FeasibilityError::InvalidVote) - } - Ok(()) - })?; - - // ----- Start building support. First, we need one more closure. - let stake_of = helpers::stake_of_fn::(&snapshot_voters, &cache); - - // This might fail if the normalization fails. Very unlikely. See `integrity_test`. - let staked_assignments = assignment_ratio_to_staked_normalized(assignments, stake_of) - .map_err::(Into::into)?; - let supports = sp_npos_elections::to_supports(&staked_assignments); - - // Finally, check that the claimed score was indeed correct. - let known_score = supports.evaluate(); - ensure!(known_score == score, FeasibilityError::InvalidScore); - - // Size of winners in miner solution is equal to `desired_targets` <= `MaxWinners`. - let supports = supports - .try_into() - .defensive_map_err(|_| FeasibilityError::BoundedConversionFailed)?; - Ok(ReadySolution { supports, compute, score }) + let snapshot = Self::snapshot().ok_or(FeasibilityError::SnapshotUnavailable)?; + let round = Self::round(); + let minimum_untrusted_score = Self::minimum_untrusted_score(); + + Miner::::feasibility_check( + raw_solution, + compute, + desired_targets, + snapshot, + round, + minimum_untrusted_score, + ) } /// Perform the tasks to be done after a new `elect` has been triggered: diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 8dee94bb39716..da7a0cf1dd263 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -297,6 +297,8 @@ parameter_types! { pub static MockWeightInfo: MockedWeightInfo = MockedWeightInfo::Real; pub static MaxElectingVoters: VoterIndex = u32::max_value(); pub static MaxElectableTargets: TargetIndex = TargetIndex::max_value(); + + #[derive(Debug)] pub static MaxWinners: u32 = 200; pub static EpochLength: u64 = 30; @@ -359,6 +361,7 @@ impl MinerConfig for Runtime { type MaxLength = MinerMaxLength; type MaxWeight = MinerMaxWeight; type MaxVotesPerVoter = ::MaxVotesPerVoter; + type MaxWinners = MaxWinners; type Solution = TestNposSolution; fn solution_weight(v: u32, t: u32, a: u32, d: u32) -> Weight { diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index 75bbcfcf9e537..b8a27fdfafde5 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -462,7 +462,7 @@ impl Pallet { /// /// Infallible pub fn finalize_signed_phase_accept_solution( - ready_solution: ReadySolution, + ready_solution: ReadySolution, who: &T::AccountId, deposit: BalanceOf, call_fee: BalanceOf, diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index 3d80f8f4d9315..9c09cb48c7c05 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -23,12 +23,17 @@ use crate::{ }; use codec::Encode; use frame_election_provider_support::{NposSolution, NposSolver, PerThing128, VoteWeight}; -use frame_support::{dispatch::DispatchResult, ensure, traits::Get, BoundedVec}; +use frame_support::{ + dispatch::DispatchResult, + ensure, + traits::{DefensiveResult, Get}, + BoundedVec, +}; use frame_system::offchain::SubmitTransaction; use scale_info::TypeInfo; use sp_npos_elections::{ assignment_ratio_to_staked_normalized, assignment_staked_to_ratio_normalized, ElectionResult, - ElectionScore, + ElectionScore, EvaluateSupport, }; use sp_runtime::{ offchain::storage::{MutateStorageError, StorageValueRef}, @@ -351,7 +356,7 @@ impl Pallet { // ensure score is being improved. Panic henceforth. ensure!( - Self::queued_solution().map_or(true, |q: ReadySolution<_>| raw_solution + Self::queued_solution().map_or(true, |q: ReadySolution<_, _>| raw_solution .score .strict_threshold_better(q.score, T::BetterUnsignedThreshold::get())), Error::::PreDispatchWeakSubmission, @@ -387,6 +392,8 @@ pub trait MinerConfig { /// /// The weight is computed using `solution_weight`. type MaxWeight: Get; + /// The maximum number of winners that can be elected. + type MaxWinners: Get; /// Something that can compute the weight of a solution. /// /// This weight estimate is then used to trim the solution, based on [`MinerConfig::MaxWeight`]. @@ -689,6 +696,91 @@ impl Miner { ); final_decision } + + /// Checks the feasibility of a solution. + pub fn feasibility_check( + raw_solution: RawSolution>, + compute: ElectionCompute, + desired_targets: u32, + snapshot: RoundSnapshot>, + current_round: u32, + minimum_untrusted_score: Option, + ) -> Result, FeasibilityError> { + let RawSolution { solution, score, round } = raw_solution; + let RoundSnapshot { voters: snapshot_voters, targets: snapshot_targets } = snapshot; + + // First, check round. + ensure!(current_round == round, FeasibilityError::InvalidRound); + + // Winners are not directly encoded in the solution. + let winners = solution.unique_targets(); + + ensure!(winners.len() as u32 == desired_targets, FeasibilityError::WrongWinnerCount); + // Fail early if targets requested by data provider exceed maximum winners supported. + ensure!(desired_targets <= T::MaxWinners::get(), FeasibilityError::TooManyDesiredTargets); + + // Ensure that the solution's score can pass absolute min-score. + let submitted_score = raw_solution.score; + ensure!( + minimum_untrusted_score.map_or(true, |min_score| { + submitted_score.strict_threshold_better(min_score, sp_runtime::Perbill::zero()) + }), + FeasibilityError::UntrustedScoreTooLow + ); + + // ----- Start building. First, we need some closures. + let cache = helpers::generate_voter_cache::(&snapshot_voters); + let voter_at = helpers::voter_at_fn::(&snapshot_voters); + let target_at = helpers::target_at_fn::(&snapshot_targets); + let voter_index = helpers::voter_index_fn_usize::(&cache); + + // Then convert solution -> assignment. This will fail if any of the indices are gibberish, + // namely any of the voters or targets. + let assignments = solution + .into_assignment(voter_at, target_at) + .map_err::(Into::into)?; + + // Ensure that assignments is correct. + let _ = assignments.iter().try_for_each(|assignment| { + // Check that assignment.who is actually a voter (defensive-only). + // NOTE: while using the index map from `voter_index` is better than a blind linear + // search, this *still* has room for optimization. Note that we had the index when + // we did `solution -> assignment` and we lost it. Ideal is to keep the index + // around. + + // Defensive-only: must exist in the snapshot. + let snapshot_index = + voter_index(&assignment.who).ok_or(FeasibilityError::InvalidVoter)?; + // Defensive-only: index comes from the snapshot, must exist. + let (_voter, _stake, targets) = + snapshot_voters.get(snapshot_index).ok_or(FeasibilityError::InvalidVoter)?; + + // Check that all of the targets are valid based on the snapshot. + if assignment.distribution.iter().any(|(d, _)| !targets.contains(d)) { + return Err(FeasibilityError::InvalidVote) + } + Ok(()) + })?; + + // ----- Start building support. First, we need one more closure. + let stake_of = helpers::stake_of_fn::(&snapshot_voters, &cache); + + // This might fail if the normalization fails. Very unlikely. See `integrity_test`. + let staked_assignments = assignment_ratio_to_staked_normalized(assignments, stake_of) + .map_err::(Into::into)?; + let supports = sp_npos_elections::to_supports(&staked_assignments); + + // Finally, check that the claimed score was indeed correct. + let known_score = supports.evaluate(); + ensure!(known_score == score, FeasibilityError::InvalidScore); + + // Size of winners in miner solution is equal to `desired_targets` <= `MaxWinners`. + let supports = supports + .try_into() + .defensive_map_err(|_| FeasibilityError::BoundedConversionFailed)?; + + Ok(ReadySolution { supports, compute, score }) + } } #[cfg(test)] From ae83a672f2bbe6a4f7391f6a5b2b6fd7ad4f8651 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 15 Mar 2023 12:07:55 +0800 Subject: [PATCH 15/80] Nomination Pool Commission (#13128) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * + nomination pool commission * fmt * use register_update() * Update frame/nomination-pools/src/lib.rs Co-authored-by: Gonçalo Pestana * Update frame/nomination-pools/src/lib.rs Co-authored-by: Gonçalo Pestana * fmt * amend comments * + test for set_commission * fix * Update frame/nomination-pools/fuzzer/src/call.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * rm comment * use PalletError * some feedback item amendments * update weights * revert PalletError stuff * ".git/.scripts/commands/fmt/fmt.sh" * make pool_events_since_last_call more modular * fmt * fix call indexes + test * add payout teste * add event to max_commisson updating current * begin refactor * some debugging * update * more tests * rewardpol not working * commission refactor * pending rewards returns commission * fmt * add claim_commission call * + claim_commission * fix benchmarks * weight 0 for now * + claim_commission benchmark * fmt * apply commission to benchmarks * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_nomination_pools * ".git/.scripts/commands/fmt/fmt.sh" * clippy * + pending * add RewardPool.total_rewards_acounted * fixes * println * more logs * Fix plus cleanups * fix assert * tidy up * tests work + tidy up * rm unused * clippy fix * persist reward_pool update * claim_commission_works tests * . * some test formatting * add high level docs * add calls * docs * rename * rename * docs * rename * fmt * use matches! * Update frame/nomination-pools/src/lib.rs Co-authored-by: Gonçalo Pestana * Update frame/nomination-pools/src/lib.rs Co-authored-by: Gonçalo Pestana * Update frame/nomination-pools/src/tests.rs Co-authored-by: Gonçalo Pestana * comment * Update frame/nomination-pools/src/lib.rs Co-authored-by: Gonçalo Pestana * . * weights order * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_nomination_pools * use from_parts * comment * ".git/.scripts/commands/fmt/fmt.sh" * revert clippy suggestions on old migrations * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_nomination_pools * add InitialGlobalMaxCommission * fix migration * reward counter comments & explanations * format * add commission implementation note * fmt * revert InitialGlobalMaxCommission * global max commission migration generic * text * 100% commission no payout test * add commission_accumulates_on_multiple_rewards * non-zero fuzzer GlobalMaxCommission * add last_recorded_total_payouts_needs_commission * commission event fix + claim commission test --------- Co-authored-by: Gonçalo Pestana Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: command-bot <> Co-authored-by: Bastian Köcher --- .../nomination-pools/benchmarking/src/lib.rs | 161 +- .../nomination-pools/benchmarking/src/mock.rs | 3 +- frame/nomination-pools/fuzzer/src/call.rs | 7 +- frame/nomination-pools/src/lib.rs | 686 ++++++- frame/nomination-pools/src/migration.rs | 101 +- frame/nomination-pools/src/mock.rs | 39 +- frame/nomination-pools/src/tests.rs | 1602 ++++++++++++++++- frame/nomination-pools/src/weights.rs | 590 +++--- .../nomination-pools/test-staking/src/mock.rs | 3 +- 9 files changed, 2730 insertions(+), 462 deletions(-) diff --git a/frame/nomination-pools/benchmarking/src/lib.rs b/frame/nomination-pools/benchmarking/src/lib.rs index 094289ee03265..d58bbaf3d117c 100644 --- a/frame/nomination-pools/benchmarking/src/lib.rs +++ b/frame/nomination-pools/benchmarking/src/lib.rs @@ -31,10 +31,14 @@ use frame_support::{assert_ok, ensure, traits::Get}; use frame_system::RawOrigin as RuntimeOrigin; use pallet_nomination_pools::{ BalanceOf, BondExtra, BondedPoolInner, BondedPools, ClaimPermission, ClaimPermissions, - ConfigOp, MaxPoolMembers, MaxPoolMembersPerPool, MaxPools, Metadata, MinCreateBond, - MinJoinBond, Pallet as Pools, PoolMembers, PoolRoles, PoolState, RewardPools, SubPoolsStorage, + Commission, CommissionChangeRate, ConfigOp, GlobalMaxCommission, MaxPoolMembers, + MaxPoolMembersPerPool, MaxPools, Metadata, MinCreateBond, MinJoinBond, Pallet as Pools, + PoolMembers, PoolRoles, PoolState, RewardPools, SubPoolsStorage, +}; +use sp_runtime::{ + traits::{Bounded, StaticLookup, Zero}, + Perbill, }; -use sp_runtime::traits::{Bounded, StaticLookup, Zero}; use sp_staking::{EraIndex, StakingInterface}; // `frame_benchmarking::benchmarks!` macro needs this use pallet_nomination_pools::Call; @@ -69,6 +73,7 @@ fn create_funded_user_with_balance( fn create_pool_account( n: u32, balance: BalanceOf, + commission: Option, ) -> (T::AccountId, T::AccountId) { let ed = CurrencyOf::::minimum_balance(); let pool_creator: T::AccountId = @@ -84,6 +89,16 @@ fn create_pool_account( ) .unwrap(); + if let Some(c) = commission { + let pool_id = pallet_nomination_pools::LastPoolId::::get(); + Pools::::set_commission( + RuntimeOrigin::Signed(pool_creator.clone()).into(), + pool_id, + Some((c, pool_creator.clone())), + ) + .expect("pool just created, commission can be set by root; qed"); + } + let pool_account = pallet_nomination_pools::BondedPools::::iter() .find(|(_, bonded_pool)| bonded_pool.roles.depositor == pool_creator) .map(|(pool_id, _)| Pools::::create_bonded_account(pool_id)) @@ -134,14 +149,18 @@ impl ListScenario { sp_std::mem::forget(i); // Create accounts with the origin weight - let (pool_creator1, pool_origin1) = create_pool_account::(USER_SEED + 1, origin_weight); + let (pool_creator1, pool_origin1) = + create_pool_account::(USER_SEED + 1, origin_weight, Some(Perbill::from_percent(50))); + T::Staking::nominate( &pool_origin1, // NOTE: these don't really need to be validators. vec![account("random_validator", 0, USER_SEED)], )?; - let (_, pool_origin2) = create_pool_account::(USER_SEED + 2, origin_weight); + let (_, pool_origin2) = + create_pool_account::(USER_SEED + 2, origin_weight, Some(Perbill::from_percent(50))); + T::Staking::nominate( &pool_origin2, vec![account("random_validator", 0, USER_SEED)].clone(), @@ -157,7 +176,9 @@ impl ListScenario { dest_weight_as_vote.try_into().map_err(|_| "could not convert u64 to Balance")?; // Create an account with the worst case destination weight - let (_, pool_dest1) = create_pool_account::(USER_SEED + 3, dest_weight); + let (_, pool_dest1) = + create_pool_account::(USER_SEED + 3, dest_weight, Some(Perbill::from_percent(50))); + T::Staking::nominate(&pool_dest1, vec![account("random_validator", 0, USER_SEED)])?; let weight_of = pallet_staking::Pallet::::weight_of_fn(); @@ -269,18 +290,19 @@ frame_benchmarking::benchmarks! { }: _(RuntimeOrigin::Signed(claimer), T::Lookup::unlookup(scenario.creator1.clone()), BondExtra::Rewards) verify { + // commission of 50% deducted here. assert!( T::Staking::active_stake(&scenario.origin1).unwrap() >= - scenario.dest_weight + scenario.dest_weight / 2u32.into() ); } claim_payout { let claimer: T::AccountId = account("claimer", USER_SEED + 4, 0); - + let commission = Perbill::from_percent(50); let origin_weight = Pools::::depositor_min_bond() * 2u32.into(); let ed = CurrencyOf::::minimum_balance(); - let (depositor, pool_account) = create_pool_account::(0, origin_weight); + let (depositor, pool_account) = create_pool_account::(0, origin_weight, Some(commission)); let reward_account = Pools::::create_reward_account(1); // Send funds to the reward account of the pool @@ -301,11 +323,11 @@ frame_benchmarking::benchmarks! { verify { assert_eq!( CurrencyOf::::free_balance(&depositor), - origin_weight * 2u32.into() + origin_weight + commission * origin_weight ); assert_eq!( CurrencyOf::::free_balance(&reward_account), - ed + Zero::zero() + ed + commission * origin_weight ); } @@ -345,7 +367,7 @@ frame_benchmarking::benchmarks! { let s in 0 .. MAX_SPANS; let min_create_bond = Pools::::depositor_min_bond(); - let (depositor, pool_account) = create_pool_account::(0, min_create_bond); + let (depositor, pool_account) = create_pool_account::(0, min_create_bond, None); // Add a new member let min_join_bond = MinJoinBond::::get().max(CurrencyOf::::minimum_balance()); @@ -387,7 +409,7 @@ frame_benchmarking::benchmarks! { let s in 0 .. MAX_SPANS; let min_create_bond = Pools::::depositor_min_bond(); - let (depositor, pool_account) = create_pool_account::(0, min_create_bond); + let (depositor, pool_account) = create_pool_account::(0, min_create_bond, None); // Add a new member let min_join_bond = MinJoinBond::::get().max(CurrencyOf::::minimum_balance()); @@ -433,7 +455,7 @@ frame_benchmarking::benchmarks! { let s in 0 .. MAX_SPANS; let min_create_bond = Pools::::depositor_min_bond(); - let (depositor, pool_account) = create_pool_account::(0, min_create_bond); + let (depositor, pool_account) = create_pool_account::(0, min_create_bond, None); let depositor_lookup = T::Lookup::unlookup(depositor.clone()); // We set the pool to the destroying state so the depositor can leave @@ -523,15 +545,16 @@ frame_benchmarking::benchmarks! { assert_eq!( new_pool, BondedPoolInner { - points: min_create_bond, - state: PoolState::Open, + commission: Commission::default(), member_counter: 1, + points: min_create_bond, roles: PoolRoles { depositor: depositor.clone(), root: Some(depositor.clone()), nominator: Some(depositor.clone()), bouncer: Some(depositor.clone()), }, + state: PoolState::Open, } ); assert_eq!( @@ -545,7 +568,7 @@ frame_benchmarking::benchmarks! { // Create a pool let min_create_bond = Pools::::depositor_min_bond() * 2u32.into(); - let (depositor, pool_account) = create_pool_account::(0, min_create_bond); + let (depositor, pool_account) = create_pool_account::(0, min_create_bond, None); // Create some accounts to nominate. For the sake of benchmarking they don't need to be // actual validators @@ -562,15 +585,16 @@ frame_benchmarking::benchmarks! { assert_eq!( new_pool, BondedPoolInner { - points: min_create_bond, - state: PoolState::Open, + commission: Commission::default(), member_counter: 1, + points: min_create_bond, roles: PoolRoles { depositor: depositor.clone(), root: Some(depositor.clone()), nominator: Some(depositor.clone()), bouncer: Some(depositor.clone()), - } + }, + state: PoolState::Open, } ); assert_eq!( @@ -582,7 +606,7 @@ frame_benchmarking::benchmarks! { set_state { // Create a pool let min_create_bond = Pools::::depositor_min_bond(); - let (depositor, pool_account) = create_pool_account::(0, min_create_bond); + let (depositor, pool_account) = create_pool_account::(0, min_create_bond, None); BondedPools::::mutate(&1, |maybe_pool| { // Force the pool into an invalid state maybe_pool.as_mut().map(|mut pool| pool.points = min_create_bond * 10u32.into()); @@ -599,7 +623,7 @@ frame_benchmarking::benchmarks! { let n in 1 .. ::MaxMetadataLen::get(); // Create a pool - let (depositor, pool_account) = create_pool_account::(0, Pools::::depositor_min_bond() * 2u32.into()); + let (depositor, pool_account) = create_pool_account::(0, Pools::::depositor_min_bond() * 2u32.into(), None); // Create metadata of the max possible size let metadata: Vec = (0..n).map(|_| 42).collect(); @@ -617,18 +641,20 @@ frame_benchmarking::benchmarks! { ConfigOp::Set(BalanceOf::::max_value()), ConfigOp::Set(u32::MAX), ConfigOp::Set(u32::MAX), - ConfigOp::Set(u32::MAX) + ConfigOp::Set(u32::MAX), + ConfigOp::Set(Perbill::max_value()) ) verify { assert_eq!(MinJoinBond::::get(), BalanceOf::::max_value()); assert_eq!(MinCreateBond::::get(), BalanceOf::::max_value()); assert_eq!(MaxPools::::get(), Some(u32::MAX)); assert_eq!(MaxPoolMembers::::get(), Some(u32::MAX)); assert_eq!(MaxPoolMembersPerPool::::get(), Some(u32::MAX)); + assert_eq!(GlobalMaxCommission::::get(), Some(Perbill::max_value())); } update_roles { let first_id = pallet_nomination_pools::LastPoolId::::get() + 1; - let (root, _) = create_pool_account::(0, Pools::::depositor_min_bond() * 2u32.into()); + let (root, _) = create_pool_account::(0, Pools::::depositor_min_bond() * 2u32.into(), None); let random: T::AccountId = account("but is anything really random in computers..?", 0, USER_SEED); }:_( RuntimeOrigin::Signed(root.clone()), @@ -650,7 +676,7 @@ frame_benchmarking::benchmarks! { chill { // Create a pool - let (depositor, pool_account) = create_pool_account::(0, Pools::::depositor_min_bond() * 2u32.into()); + let (depositor, pool_account) = create_pool_account::(0, Pools::::depositor_min_bond() * 2u32.into(), None); // Nominate with the pool. let validators: Vec<_> = (0..T::MaxNominations::get()) @@ -666,10 +692,68 @@ frame_benchmarking::benchmarks! { assert!(T::Staking::nominations(Pools::::create_bonded_account(1)).is_none()); } + set_commission { + // Create a pool - do not set a commission yet. + let (depositor, pool_account) = create_pool_account::(0, Pools::::depositor_min_bond() * 2u32.into(), None); + // set a max commission + Pools::::set_commission_max(RuntimeOrigin::Signed(depositor.clone()).into(), 1u32.into(), Perbill::from_percent(50)).unwrap(); + // set a change rate + Pools::::set_commission_change_rate(RuntimeOrigin::Signed(depositor.clone()).into(), 1u32.into(), CommissionChangeRate { + max_increase: Perbill::from_percent(20), + min_delay: 0u32.into(), + }).unwrap(); + + }:_(RuntimeOrigin::Signed(depositor.clone()), 1u32.into(), Some((Perbill::from_percent(20), depositor.clone()))) + verify { + assert_eq!(BondedPools::::get(1).unwrap().commission, Commission { + current: Some((Perbill::from_percent(20), depositor)), + max: Some(Perbill::from_percent(50)), + change_rate: Some(CommissionChangeRate { + max_increase: Perbill::from_percent(20), + min_delay: 0u32.into() + }), + throttle_from: Some(1u32.into()), + }); + } + + set_commission_max { + // Create a pool, setting a commission that will update when max commission is set. + let (depositor, pool_account) = create_pool_account::(0, Pools::::depositor_min_bond() * 2u32.into(), Some(Perbill::from_percent(50))); + }:_(RuntimeOrigin::Signed(depositor.clone()), 1u32.into(), Perbill::from_percent(50)) + verify { + assert_eq!( + BondedPools::::get(1).unwrap().commission, Commission { + current: Some((Perbill::from_percent(50), depositor)), + max: Some(Perbill::from_percent(50)), + change_rate: None, + throttle_from: Some(0u32.into()), + }); + } + + set_commission_change_rate { + // Create a pool + let (depositor, pool_account) = create_pool_account::(0, Pools::::depositor_min_bond() * 2u32.into(), None); + }:_(RuntimeOrigin::Signed(depositor.clone()), 1u32.into(), CommissionChangeRate { + max_increase: Perbill::from_percent(50), + min_delay: 1000u32.into(), + }) + verify { + assert_eq!( + BondedPools::::get(1).unwrap().commission, Commission { + current: None, + max: None, + change_rate: Some(CommissionChangeRate { + max_increase: Perbill::from_percent(50), + min_delay: 1000u32.into(), + }), + throttle_from: Some(1_u32.into()), + }); + } + set_claim_permission { // Create a pool let min_create_bond = Pools::::depositor_min_bond(); - let (depositor, pool_account) = create_pool_account::(0, min_create_bond); + let (depositor, pool_account) = create_pool_account::(0, min_create_bond, None); // Join pool let min_join_bond = MinJoinBond::::get().max(CurrencyOf::::minimum_balance()); @@ -688,6 +772,31 @@ frame_benchmarking::benchmarks! { assert_eq!(ClaimPermissions::::get(joiner), ClaimPermission::PermissionlessAll); } + claim_commission { + let claimer: T::AccountId = account("claimer_member", USER_SEED + 4, 0); + let commission = Perbill::from_percent(50); + let origin_weight = Pools::::depositor_min_bond() * 2u32.into(); + let ed = CurrencyOf::::minimum_balance(); + let (depositor, pool_account) = create_pool_account::(0, origin_weight, Some(commission)); + let reward_account = Pools::::create_reward_account(1); + CurrencyOf::::make_free_balance_be(&reward_account, ed + origin_weight); + + // member claims a payout to make some commission available. + let _ = Pools::::claim_payout(RuntimeOrigin::Signed(claimer).into()); + + whitelist_account!(depositor); + }:_(RuntimeOrigin::Signed(depositor.clone()), 1u32.into()) + verify { + assert_eq!( + CurrencyOf::::free_balance(&depositor), + origin_weight + commission * origin_weight + ); + assert_eq!( + CurrencyOf::::free_balance(&reward_account), + ed + commission * origin_weight + ); + } + impl_benchmark_test_suite!( Pallet, crate::mock::new_test_ext(), diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index f6b2022bce518..4a1a52868e367 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -20,7 +20,7 @@ use frame_election_provider_support::VoteWeight; use frame_support::{pallet_prelude::*, parameter_types, traits::ConstU64, PalletId}; use sp_runtime::{ traits::{Convert, IdentityLookup}, - FixedU128, + FixedU128, Perbill, }; type AccountId = u128; @@ -195,6 +195,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { max_pools: Some(3), max_members_per_pool: Some(3), max_members: Some(3 * 3), + global_max_commission: Some(Perbill::from_percent(50)), } .assimilate_storage(&mut storage); sp_io::TestExternalities::from(storage) diff --git a/frame/nomination-pools/fuzzer/src/call.rs b/frame/nomination-pools/fuzzer/src/call.rs index 5e82471201546..027fb2b69138c 100644 --- a/frame/nomination-pools/fuzzer/src/call.rs +++ b/frame/nomination-pools/fuzzer/src/call.rs @@ -33,11 +33,11 @@ use pallet_nomination_pools::{ mock::*, pallet as pools, pallet::{BondedPools, Call as PoolsCall, Event as PoolsEvents, PoolMembers}, - BondExtra, BondedPool, LastPoolId, MaxPoolMembers, MaxPoolMembersPerPool, MaxPools, - MinCreateBond, MinJoinBond, PoolId, + BondExtra, BondedPool, GlobalMaxCommission, LastPoolId, MaxPoolMembers, MaxPoolMembersPerPool, + MaxPools, MinCreateBond, MinJoinBond, PoolId, }; use rand::{seq::SliceRandom, Rng}; -use sp_runtime::{assert_eq_error_rate, Perquintill}; +use sp_runtime::{assert_eq_error_rate, Perbill, Perquintill}; const ERA: BlockNumber = 1000; const MAX_ED_MULTIPLE: Balance = 10_000; @@ -224,6 +224,7 @@ fn main() { MaxPoolMembers::::set(Some(10_000)); MaxPoolMembersPerPool::::set(Some(1000)); MaxPools::::set(Some(1_000)); + GlobalMaxCommission::::set(Some(Perbill::from_percent(25))); MinCreateBond::::set(10 * ExistentialDeposit::get()); MinJoinBond::::set(5 * ExistentialDeposit::get()); diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index c1dda69ab5d67..e73d4b4173ecf 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -50,6 +50,11 @@ //! not nominating proper validators. //! * reward account: A similar key-less account, that is set as the `Payee` account for the bonded //! account for all staking rewards. +//! * change rate: The rate at which pool commission can be changed. A change rate consists of a +//! `max_increase` and `min_delay`, dictating the maximum percentage increase that can be applied +//! to the commission per number of blocks. +//! * throttle: An attempted commission increase is throttled if the attempted change falls outside +//! the change rate bounds. //! //! ## Usage //! @@ -125,8 +130,33 @@ //! other members have left. Once they fully withdraw their funds, the pool is destroyed. //! * Nominator: can select which validators the pool nominates. //! * Bouncer: can change the pools state and kick members if the pool is blocked. -//! * Root: can change the nominator, bouncer, or itself and can perform any of the actions the -//! nominator or bouncer can. +//! * Root: can change the nominator, bouncer, or itself, manage and claim commission, and can +//! perform any of the actions the nominator or bouncer can. +//! +//! ## Commission +//! +//! A pool can optionally have a commission configuration, via the `root` role, set with +//! [`Call::set_commission`] and claimed with [`Call::claim_commission`]. A payee account must be +//! supplied with the desired commission percentage. Beyond the commission itself, a pool can have a +//! maximum commission and a change rate. +//! +//! Importantly, both max commission [`Call::set_commission_max`] and change rate +//! [`Call::set_commission_change_rate`] can not be removed once set, and can only be set to more +//! restrictive values (i.e. a lower max commission or a slower change rate) in subsequent updates. +//! +//! If set, a pool's commission is bound to [`GlobalMaxCommission`] at the time it is applied to +//! pending rewards. [`GlobalMaxCommission`] is intended to be updated only via governance. +//! +//! When a pool is dissolved, any outstanding pending commission that has not been claimed will be +//! transferred to the depositor. +//! +//! Implementation note: Commission is analogous to a separate member account of the pool, with its +//! own reward counter in the form of `current_pending_commission`. +//! +//! Crucially, commission is applied to rewards based on the current commission in effect at the +//! time rewards are transferred into the reward pool. This is to prevent the malicious behaviour of +//! changing the commission rate to a very high value after rewards are accumulated, and thus claim +//! an unexpectedly high chunk of the reward. //! //! ### Dismantling //! @@ -232,11 +262,14 @@ //! //! ### Reward pool //! -//! When a pool is first bonded it sets up an deterministic, inaccessible account as its reward -//! destination. +//! When a pool is first bonded it sets up a deterministic, inaccessible account as its reward +//! destination. This reward account combined with `RewardPool` compose a reward pool. //! -//! The reward pool is not really a pool anymore, as it does not track points anymore. Instead, it -//! tracks, a virtual value called `reward_counter`, among a few other values. +//! Reward pools are completely separate entities to bonded pools. Along with its account, a reward +//! pool also tracks its outstanding and claimed rewards as counters, in addition to pending and +//! claimed commission. These counters are updated with `RewardPool::update_records`. The current +//! reward counter of the pool (the total outstanding rewards, in points) is also callable with the +//! `RewardPool::current_reward_counter` method. //! //! See [this link](https://hackmd.io/PFGn6wI5TbCmBYoEA_f2Uw) for an in-depth explanation of the //! reward pool mechanism. @@ -247,13 +280,12 @@ //! //! ### Unbonding sub pools //! -//! When a member unbonds, it's balance is unbonded in the bonded pool's account and tracked in -//! an unbonding pool associated with the active era. If no such pool exists, one is created. To -//! track which unbonding sub pool a member belongs too, a member tracks it's -//! `unbonding_era`. +//! When a member unbonds, it's balance is unbonded in the bonded pool's account and tracked in an +//! unbonding pool associated with the active era. If no such pool exists, one is created. To track +//! which unbonding sub pool a member belongs too, a member tracks it's `unbonding_era`. //! -//! When a member initiates unbonding it's claim on the bonded pool -//! (`balance_to_unbond`) is computed as: +//! When a member initiates unbonding it's claim on the bonded pool (`balance_to_unbond`) is +//! computed as: //! //! ```text //! balance_to_unbond = (bonded_pool.balance / bonded_pool.points) * member.points; @@ -262,8 +294,8 @@ //! If this is the first transfer into an unbonding pool arbitrary amount of points can be issued //! per balance. In this implementation unbonding pools are initialized with a 1 point to 1 balance //! ratio (see [`POINTS_TO_BALANCE_INIT_RATIO`]). Otherwise, the unbonding pools hold the same -//! points to balance ratio properties as the bonded pool, so member points in the -//! unbonding pool are issued based on +//! points to balance ratio properties as the bonded pool, so member points in the unbonding pool +//! are issued based on //! //! ```text //! new_points_issued = (points_before_transfer / balance_before_transfer) * balance_to_unbond; @@ -296,14 +328,14 @@ //! `pallet_staking::StakingLedger::slash`, which passes the information to this pallet via //! [`sp_staking::OnStakerSlash::on_slash`]. //! -//! Unbonding pools need to be slashed to ensure all nominators whom where in the bonded pool -//! while it was backing a validator that equivocated are punished. Without these measures a -//! member could unbond right after a validator equivocated with no consequences. +//! Unbonding pools need to be slashed to ensure all nominators whom where in the bonded pool while +//! it was backing a validator that equivocated are punished. Without these measures a member could +//! unbond right after a validator equivocated with no consequences. //! -//! This strategy is unfair to members who joined after the slash, because they get slashed as -//! well, but spares members who unbond. The latter is much more important for security: if a -//! pool's validators are attacking the network, their members need to unbond fast! Avoiding -//! slashes gives them an incentive to do that if validators get repeatedly slashed. +//! This strategy is unfair to members who joined after the slash, because they get slashed as well, +//! but spares members who unbond. The latter is much more important for security: if a pool's +//! validators are attacking the network, their members need to unbond fast! Avoiding slashes gives +//! them an incentive to do that if validators get repeatedly slashed. //! //! To be fair to joiners, this implementation also need joining pools, which are actively staking, //! in addition to the unbonding pools. For maintenance simplicity these are not implemented. @@ -332,21 +364,22 @@ use frame_support::{ Currency, Defensive, DefensiveOption, DefensiveResult, DefensiveSaturating, ExistenceRequirement, Get, }, - DefaultNoBound, + DefaultNoBound, PalletError, }; use scale_info::TypeInfo; use sp_core::U256; use sp_runtime::{ traits::{ - AccountIdConversion, CheckedAdd, CheckedSub, Convert, Saturating, StaticLookup, Zero, + AccountIdConversion, Bounded, CheckedAdd, CheckedSub, Convert, Saturating, StaticLookup, + Zero, }, - FixedPointNumber, + FixedPointNumber, Perbill, }; use sp_staking::{EraIndex, OnStakerSlash, StakingInterface}; use sp_std::{collections::btree_map::BTreeMap, fmt::Debug, ops::Div, vec::Vec}; /// The log target of this pallet. -pub const LOG_TARGET: &'static str = "runtime::nomination-pools"; +pub const LOG_TARGET: &str = "runtime::nomination-pools"; // syntactic sugar for logging. #[macro_export] @@ -430,19 +463,11 @@ pub enum ClaimPermission { impl ClaimPermission { fn can_bond_extra(&self) -> bool { - match self { - ClaimPermission::PermissionlessAll => true, - ClaimPermission::PermissionlessCompound => true, - _ => false, - } + matches!(self, ClaimPermission::PermissionlessAll | ClaimPermission::PermissionlessCompound) } fn can_claim_payout(&self) -> bool { - match self { - ClaimPermission::PermissionlessAll => true, - ClaimPermission::PermissionlessWithdraw => true, - _ => false, - } + matches!(self, ClaimPermission::PermissionlessAll | ClaimPermission::PermissionlessWithdraw) } } @@ -623,25 +648,232 @@ pub struct PoolRoles { pub bouncer: Option, } +/// Pool commission. +/// +/// The pool `root` can set commission configuration after pool creation. By default, all commission +/// values are `None`. Pool `root` can also set `max` and `change_rate` configurations before +/// setting an initial `current` commission. +/// +/// `current` is a tuple of the commission percentage and payee of commission. `throttle_from` +/// keeps track of which block `current` was last updated. A `max` commission value can only be +/// decreased after the initial value is set, to prevent commission from repeatedly increasing. +/// +/// An optional commission `change_rate` allows the pool to set strict limits to how much commission +/// can change in each update, and how often updates can take place. +#[derive( + Encode, Decode, DefaultNoBound, MaxEncodedLen, TypeInfo, DebugNoBound, PartialEq, Copy, Clone, +)] +#[codec(mel_bound(T: Config))] +#[scale_info(skip_type_params(T))] +pub struct Commission { + /// Optional commission rate of the pool along with the account commission is paid to. + pub current: Option<(Perbill, T::AccountId)>, + /// Optional maximum commission that can be set by the pool `root`. Once set, this value can + /// only be updated to a decreased value. + pub max: Option, + /// Optional configuration around how often commission can be updated, and when the last + /// commission update took place. + pub change_rate: Option>, + /// The block from where throttling should be checked from. This value will be updated on all + /// commission updates and when setting an initial `change_rate`. + pub throttle_from: Option, +} + +impl Commission { + /// Returns true if the current commission updating to `to` would exhaust the change rate + /// limits. + /// + /// A commission update will be throttled (disallowed) if: + /// 1. not enough blocks have passed since the `throttle_from` block, if exists, or + /// 2. the new commission is greater than the maximum allowed increase. + fn throttling(&self, to: &Perbill) -> bool { + if let Some(t) = self.change_rate.as_ref() { + let commission_as_percent = + self.current.as_ref().map(|(x, _)| *x).unwrap_or(Perbill::zero()); + + // do not throttle if `to` is the same or a decrease in commission. + if *to <= commission_as_percent { + return false + } + // Test for `max_increase` throttling. + // + // Throttled if the attempted increase in commission is greater than `max_increase`. + if (*to).saturating_sub(commission_as_percent) > t.max_increase { + return true + } + + // Test for `min_delay` throttling. + // + // Note: matching `None` is defensive only. `throttle_from` should always exist where + // `change_rate` has already been set, so this scenario should never happen. + return self.throttle_from.map_or_else( + || { + defensive!("throttle_from should exist if change_rate is set"); + true + }, + |f| { + // if `min_delay` is zero (no delay), not throttling. + if t.min_delay == Zero::zero() { + false + } else { + // throttling if blocks passed is less than `min_delay`. + let blocks_surpassed = + >::block_number().saturating_sub(f); + blocks_surpassed < t.min_delay + } + }, + ) + } + false + } + + /// Gets the pool's current commission, or returns Perbill::zero if none is set. + /// Bounded to global max if current is greater than `GlobalMaxCommission`. + fn current(&self) -> Perbill { + self.current + .as_ref() + .map_or(Perbill::zero(), |(c, _)| *c) + .min(GlobalMaxCommission::::get().unwrap_or(Bounded::max_value())) + } + + /// Set the pool's commission. + /// + /// Update commission based on `current`. If a `None` is supplied, allow the commission to be + /// removed without any change rate restrictions. Updates `throttle_from` to the current block. + /// If the supplied commission is zero, `None` will be inserted and `payee` will be ignored. + fn try_update_current(&mut self, current: &Option<(Perbill, T::AccountId)>) -> DispatchResult { + self.current = match current { + None => None, + Some((commission, payee)) => { + ensure!(!self.throttling(commission), Error::::CommissionChangeThrottled); + ensure!( + self.max.map_or(true, |m| commission <= &m), + Error::::CommissionExceedsMaximum + ); + if commission.is_zero() { + None + } else { + Some((*commission, payee.clone())) + } + }, + }; + self.register_update(); + Ok(()) + } + + /// Set the pool's maximum commission. + /// + /// The pool's maximum commission can initially be set to any value, and only smaller values + /// thereafter. If larger values are attempted, this function will return a dispatch error. + /// + /// If `current.0` is larger than the updated max commission value, `current.0` will also be + /// updated to the new maximum. This will also register a `throttle_from` update. + /// A `PoolCommissionUpdated` event is triggered if `current.0` is updated. + fn try_update_max(&mut self, pool_id: PoolId, new_max: Perbill) -> DispatchResult { + if let Some(old) = self.max.as_mut() { + if new_max > *old { + return Err(Error::::MaxCommissionRestricted.into()) + } + *old = new_max; + } else { + self.max = Some(new_max) + }; + let updated_current = self + .current + .as_mut() + .map(|(c, _)| { + let u = *c > new_max; + *c = (*c).min(new_max); + u + }) + .unwrap_or(false); + + if updated_current { + if let Some((_, payee)) = self.current.as_ref() { + Pallet::::deposit_event(Event::::PoolCommissionUpdated { + pool_id, + current: Some((new_max, payee.clone())), + }); + } + self.register_update(); + } + Ok(()) + } + + /// Set the pool's commission `change_rate`. + /// + /// Once a change rate configuration has been set, only more restrictive values can be set + /// thereafter. These restrictions translate to increased `min_delay` values and decreased + /// `max_increase` values. + /// + /// Update `throttle_from` to the current block upon setting change rate for the first time, so + /// throttling can be checked from this block. + fn try_update_change_rate( + &mut self, + change_rate: CommissionChangeRate, + ) -> DispatchResult { + ensure!(!&self.less_restrictive(&change_rate), Error::::CommissionChangeRateNotAllowed); + + if self.change_rate.is_none() { + self.register_update(); + } + self.change_rate = Some(change_rate); + Ok(()) + } + + /// Updates a commission's `throttle_from` field to the current block. + fn register_update(&mut self) { + self.throttle_from = Some(>::block_number()); + } + + /// Checks whether a change rate is less restrictive than the current change rate, if any. + /// + /// No change rate will always be less restrictive than some change rate, so where no + /// `change_rate` is currently set, `false` is returned. + fn less_restrictive(&self, new: &CommissionChangeRate) -> bool { + self.change_rate + .as_ref() + .map(|c| new.max_increase > c.max_increase || new.min_delay < c.min_delay) + .unwrap_or(false) + } +} + +/// Pool commission change rate preferences. +/// +/// The pool root is able to set a commission change rate for their pool. A commission change rate +/// consists of 2 values; (1) the maximum allowed commission change, and (2) the minimum amount of +/// blocks that must elapse before commission updates are allowed again. +/// +/// Commission change rates are not applied to decreases in commission. +#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, Debug, PartialEq, Copy, Clone)] +pub struct CommissionChangeRate { + /// The maximum amount the commission can be updated by per `min_delay` period. + pub max_increase: Perbill, + /// How often an update can take place. + pub min_delay: BlockNumber, +} + /// Pool permissions and state #[derive(Encode, Decode, MaxEncodedLen, TypeInfo, DebugNoBound, PartialEq, Clone)] #[codec(mel_bound(T: Config))] #[scale_info(skip_type_params(T))] pub struct BondedPoolInner { - /// Total points of all the members in the pool who are actively bonded. - pub points: BalanceOf, - /// The current state of the pool. - pub state: PoolState, + /// The commission rate of the pool. + pub commission: Commission, /// Count of members that belong to the pool. pub member_counter: u32, + /// Total points of all the members in the pool who are actively bonded. + pub points: BalanceOf, /// See [`PoolRoles`]. pub roles: PoolRoles, + /// The current state of the pool. + pub state: PoolState, } /// A wrapper for bonded pools, with utility functions. /// -/// The main purpose of this is to wrap a [`BondedPoolInner`], with the account + id of the pool, -/// for easier access. +/// The main purpose of this is to wrap a [`BondedPoolInner`], with the account +/// + id of the pool, for easier access. #[derive(RuntimeDebugNoBound)] #[cfg_attr(feature = "std", derive(Clone, PartialEq))] pub struct BondedPool { @@ -670,10 +902,11 @@ impl BondedPool { Self { id, inner: BondedPoolInner { + commission: Commission::default(), + member_counter: Zero::zero(), + points: Zero::zero(), roles, state: PoolState::Open, - points: Zero::zero(), - member_counter: Zero::zero(), }, } } @@ -695,7 +928,7 @@ impl BondedPool { /// Consume self and put into storage. fn put(self) { - BondedPools::::insert(self.id, BondedPoolInner { ..self.inner }); + BondedPools::::insert(self.id, self.inner); } /// Consume self and remove from storage. @@ -800,6 +1033,10 @@ impl BondedPool { self.is_root(who) || self.is_bouncer(who) } + fn can_manage_commission(&self, who: &T::AccountId) -> bool { + self.is_root(who) + } + fn is_destroying(&self) -> bool { matches!(self.state, PoolState::Destroying) } @@ -952,7 +1189,7 @@ impl BondedPool { // Cache the value let bonded_account = self.bonded_account(); T::Currency::transfer( - &who, + who, &bonded_account, amount, match ty { @@ -1011,6 +1248,10 @@ pub struct RewardPool { last_recorded_total_payouts: BalanceOf, /// Total amount that this pool has paid out so far to the members. total_rewards_claimed: BalanceOf, + /// The amount of commission pending to be claimed. + total_commission_pending: BalanceOf, + /// The amount of commission that has been claimed. + total_commission_claimed: BalanceOf, } impl RewardPool { @@ -1024,13 +1265,40 @@ impl RewardPool { self.total_rewards_claimed = self.total_rewards_claimed.saturating_add(reward); } - /// Update the recorded values of the pool. - fn update_records(&mut self, id: PoolId, bonded_points: BalanceOf) -> Result<(), Error> { + /// Update the recorded values of the reward pool. + /// + /// This function MUST be called whenever the points in the bonded pool change, AND whenever the + /// the pools commission is updated. The reason for the former is that a change in pool points + /// will alter the share of the reward balance among pool members, and the reason for the latter + /// is that a change in commission will alter the share of the reward balance among the pool. + fn update_records( + &mut self, + id: PoolId, + bonded_points: BalanceOf, + commission: Perbill, + ) -> Result<(), Error> { let balance = Self::current_balance(id); - self.last_recorded_reward_counter = self.current_reward_counter(id, bonded_points)?; + + let (current_reward_counter, new_pending_commission) = + self.current_reward_counter(id, bonded_points, commission)?; + + // Store the reward counter at the time of this update. This is used in subsequent calls to + // `current_reward_counter`, whereby newly pending rewards (in points) are added to this + // value. + self.last_recorded_reward_counter = current_reward_counter; + + // Add any new pending commission that has been calculated from `current_reward_counter` to + // determine the total pending commission at the time of this update. + self.total_commission_pending = + self.total_commission_pending.saturating_add(new_pending_commission); + + // Store the total payouts at the time of this update. Total payouts are essentially the + // entire historical balance of the reward pool, equating to the current balance + the total + // rewards that have left the pool + the total commission that has left the pool. self.last_recorded_total_payouts = balance - .checked_add(&self.total_rewards_claimed) + .checked_add(&self.total_rewards_claimed.saturating_add(self.total_commission_claimed)) .ok_or(Error::::OverflowRisk)?; + Ok(()) } @@ -1040,15 +1308,27 @@ impl RewardPool { &self, id: PoolId, bonded_points: BalanceOf, - ) -> Result> { + commission: Perbill, + ) -> Result<(T::RewardCounter, BalanceOf), Error> { let balance = Self::current_balance(id); - let payouts_since_last_record = balance + + // Calculate the current payout balance. The first 3 values of this calculation added + // together represent what the balance would be if no payouts were made. The + // `last_recorded_total_payouts` is then subtracted from this value to cancel out previously + // recorded payouts, leaving only the remaining payouts that have not been claimed. + let current_payout_balance = balance .saturating_add(self.total_rewards_claimed) + .saturating_add(self.total_commission_claimed) .saturating_sub(self.last_recorded_total_payouts); + // Split the `current_payout_balance` into claimable rewards and claimable commission + // according to the current commission rate. + let new_pending_commission = commission * current_payout_balance; + let new_pending_rewards = current_payout_balance.saturating_sub(new_pending_commission); + // * accuracy notes regarding the multiplication in `checked_from_rational`: - // `payouts_since_last_record` is a subset of the total_issuance at the very - // worse. `bonded_points` are similarly, in a non-slashed pool, have the same granularity as + // `current_payout_balance` is a subset of the total_issuance at the very worse. + // `bonded_points` are similarly, in a non-slashed pool, have the same granularity as // balance, and are thus below within the range of total_issuance. In the worse case // scenario, for `saturating_from_rational`, we have: // @@ -1066,22 +1346,26 @@ impl RewardPool { // represented as `FixedU128`, which means it is less than `total_issuance * 10^18`. // // * accuracy notes regarding `checked_from_rational` collapsing to zero, meaning that no - // reward can be claimed: + // reward can be claimed: // - // largest `bonded_points`, such that the reward counter is non-zero, with `FixedU128` - // will be when the payout is being computed. This essentially means `payout/bonded_points` - // needs to be more than 1/1^18. Thus, assuming that `bonded_points` will always be less - // than `10 * dot_total_issuance`, if the reward_counter is the smallest possible value, - // the value of the reward being calculated is: + // largest `bonded_points`, such that the reward counter is non-zero, with `FixedU128` will + // be when the payout is being computed. This essentially means `payout/bonded_points` needs + // to be more than 1/1^18. Thus, assuming that `bonded_points` will always be less than `10 + // * dot_total_issuance`, if the reward_counter is the smallest possible value, the value of + // the + // reward being calculated is: // // x / 10^20 = 1/ 10^18 // // x = 100 // // which is basically 10^-8 DOTs. See `smallest_claimable_reward` for an example of this. - T::RewardCounter::checked_from_rational(payouts_since_last_record, bonded_points) - .and_then(|ref r| self.last_recorded_reward_counter.checked_add(r)) - .ok_or(Error::::OverflowRisk) + let current_reward_counter = + T::RewardCounter::checked_from_rational(new_pending_rewards, bonded_points) + .and_then(|ref r| self.last_recorded_reward_counter.checked_add(r)) + .ok_or(Error::::OverflowRisk)?; + + Ok((current_reward_counter, new_pending_commission)) } /// Current free balance of the reward pool. @@ -1209,9 +1493,10 @@ pub mod pallet { use super::*; use frame_support::traits::StorageVersion; use frame_system::{ensure_signed, pallet_prelude::*}; + use sp_runtime::Perbill; /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(3); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] @@ -1313,6 +1598,12 @@ pub mod pallet { #[pallet::storage] pub type MaxPoolMembersPerPool = StorageValue<_, u32, OptionQuery>; + /// The maximum commission that can be charged by a pool. Used on commission payouts to bound + /// pool commissions that are > `GlobalMaxCommission`, necessary if a future + /// `GlobalMaxCommission` is lower than some current pool commissions. + #[pallet::storage] + pub type GlobalMaxCommission = StorageValue<_, Perbill, OptionQuery>; + /// Active members. /// /// TWOX-NOTE: SAFE since `AccountId` is a secure hash. @@ -1326,13 +1617,13 @@ pub mod pallet { pub type BondedPools = CountedStorageMap<_, Twox64Concat, PoolId, BondedPoolInner>; - /// Reward pools. This is where there rewards for each pool accumulate. When a members payout - /// is claimed, the balance comes out fo the reward pool. Keyed by the bonded pools account. + /// Reward pools. This is where there rewards for each pool accumulate. When a members payout is + /// claimed, the balance comes out fo the reward pool. Keyed by the bonded pools account. #[pallet::storage] pub type RewardPools = CountedStorageMap<_, Twox64Concat, PoolId, RewardPool>; - /// Groups of unbonding pools. Each group of unbonding pools belongs to a bonded pool, - /// hence the name sub-pools. Keyed by the bonded pools account. + /// Groups of unbonding pools. Each group of unbonding pools belongs to a + /// bonded pool, hence the name sub-pools. Keyed by the bonded pools account. #[pallet::storage] pub type SubPoolsStorage = CountedStorageMap<_, Twox64Concat, PoolId, SubPools>; @@ -1365,6 +1656,7 @@ pub mod pallet { pub max_pools: Option, pub max_members_per_pool: Option, pub max_members: Option, + pub global_max_commission: Option, } #[cfg(feature = "std")] @@ -1376,6 +1668,7 @@ pub mod pallet { max_pools: Some(16), max_members_per_pool: Some(32), max_members: Some(16 * 32), + global_max_commission: None, } } } @@ -1394,6 +1687,9 @@ pub mod pallet { if let Some(max_members) = self.max_members { MaxPoolMembers::::put(max_members); } + if let Some(global_max_commission) = self.global_max_commission { + GlobalMaxCommission::::put(global_max_commission); + } } } @@ -1456,6 +1752,17 @@ pub mod pallet { PoolSlashed { pool_id: PoolId, balance: BalanceOf }, /// The unbond pool at `era` of pool `pool_id` has been slashed to `balance`. UnbondingPoolSlashed { pool_id: PoolId, era: EraIndex, balance: BalanceOf }, + /// A pool's commission setting has been changed. + PoolCommissionUpdated { pool_id: PoolId, current: Option<(Perbill, T::AccountId)> }, + /// A pool's maximum commission setting has been changed. + PoolMaxCommissionUpdated { pool_id: PoolId, max_commission: Perbill }, + /// A pool's commission `change_rate` has been changed. + PoolCommissionChangeRateUpdated { + pool_id: PoolId, + change_rate: CommissionChangeRate, + }, + /// Pool commission has been claimed. + PoolCommissionClaimed { pool_id: PoolId, commission: BalanceOf }, } #[pallet::error] @@ -1511,6 +1818,18 @@ pub mod pallet { Defensive(DefensiveError), /// Partial unbonding now allowed permissionlessly. PartialUnbondNotAllowedPermissionlessly, + /// The pool's max commission cannot be set higher than the existing value. + MaxCommissionRestricted, + /// The supplied commission exceeds the max allowed commission. + CommissionExceedsMaximum, + /// Not enough blocks have surpassed since the last commission update. + CommissionChangeThrottled, + /// The submitted changes to commission change rate are not allowed. + CommissionChangeRateNotAllowed, + /// There is no pending commission to claim. + NoPendingCommission, + /// No commission current has been set. + NoCommissionCurrentSet, /// Pool id currently in use. PoolIdInUse, /// Pool id provided is not correct/usable. @@ -1519,7 +1838,7 @@ pub mod pallet { BondExtraRestricted, } - #[derive(Encode, Decode, PartialEq, TypeInfo, frame_support::PalletError, RuntimeDebug)] + #[derive(Encode, Decode, PartialEq, TypeInfo, PalletError, RuntimeDebug)] pub enum DefensiveError { /// There isn't enough space in the unbond pool. NotEnoughSpaceInUnbondPool, @@ -1571,7 +1890,11 @@ pub mod pallet { let mut reward_pool = RewardPools::::get(pool_id) .defensive_ok_or::>(DefensiveError::RewardPoolNotFound.into())?; // IMPORTANT: reward pool records must be updated with the old points. - reward_pool.update_records(pool_id, bonded_pool.points)?; + reward_pool.update_records( + pool_id, + bonded_pool.points, + bonded_pool.commission.current(), + )?; bonded_pool.try_inc_members()?; let points_issued = bonded_pool.try_bond_funds(&who, amount, BondType::Later)?; @@ -1622,7 +1945,7 @@ pub mod pallet { } /// A bonded member can use this to claim their payout based on the rewards that the pool - /// has accumulated since their last claimed payout (OR since joining if this is there first + /// has accumulated since their last claimed payout (OR since joining if this is their first /// time claiming rewards). The payout will be transferred to the member's account. /// /// The member will earn rewards pro rata based on the members stake vs the sum of the @@ -1684,7 +2007,11 @@ pub mod pallet { // Claim the the payout prior to unbonding. Once the user is unbonding their points no // longer exist in the bonded pool and thus they can no longer claim their payouts. It // is not strictly necessary to claim the rewards, but we do it here for UX. - let _ = reward_pool.update_records(bonded_pool.id, bonded_pool.points)?; + reward_pool.update_records( + bonded_pool.id, + bonded_pool.points, + bonded_pool.commission.current(), + )?; let _ = Self::do_reward_payout(&who, &mut member, &mut bonded_pool, &mut reward_pool)?; let current_era = T::Staking::current_era(); @@ -1731,7 +2058,7 @@ pub mod pallet { }); // Now that we know everything has worked write the items to storage. - SubPoolsStorage::insert(&member.pool_id, sub_pools); + SubPoolsStorage::insert(member.pool_id, sub_pools); Self::put_member_with_pools(&member_account, member, bonded_pool, reward_pool); Ok(()) } @@ -1820,10 +2147,10 @@ pub mod pallet { .iter() .fold(BalanceOf::::zero(), |accumulator, (era, unlocked_points)| { sum_unlocked_points = sum_unlocked_points.saturating_add(*unlocked_points); - if let Some(era_pool) = sub_pools.with_era.get_mut(&era) { + if let Some(era_pool) = sub_pools.with_era.get_mut(era) { let balance_to_unbond = era_pool.dissolve(*unlocked_points); if era_pool.points.is_zero() { - sub_pools.with_era.remove(&era); + sub_pools.with_era.remove(era); } accumulator.saturating_add(balance_to_unbond) } else { @@ -1872,12 +2199,12 @@ pub mod pallet { None } else { bonded_pool.dec_members().put(); - SubPoolsStorage::::insert(&member.pool_id, sub_pools); + SubPoolsStorage::::insert(member.pool_id, sub_pools); Some(T::WeightInfo::withdraw_unbonded_update(num_slashing_spans)) } } else { // we certainly don't need to delete any pools, because no one is being removed. - SubPoolsStorage::::insert(&member.pool_id, sub_pools); + SubPoolsStorage::::insert(member.pool_id, sub_pools); PoolMembers::::insert(&member_account, member); Some(T::WeightInfo::withdraw_unbonded_update(num_slashing_spans)) }; @@ -2002,8 +2329,8 @@ pub mod pallet { /// Set a new metadata for the pool. /// - /// The dispatch origin of this call must be signed by the bouncer, or the root role - /// of the pool. + /// The dispatch origin of this call must be signed by the bouncer, or the root role of the + /// pool. #[pallet::call_index(10)] #[pallet::weight(T::WeightInfo::set_metadata(metadata.len() as u32))] pub fn set_metadata( @@ -2036,6 +2363,7 @@ pub mod pallet { /// * `max_pools` - Set [`MaxPools`]. /// * `max_members` - Set [`MaxPoolMembers`]. /// * `max_members_per_pool` - Set [`MaxPoolMembersPerPool`]. + /// * `global_max_commission` - Set [`GlobalMaxCommission`]. #[pallet::call_index(11)] #[pallet::weight(T::WeightInfo::set_configs())] pub fn set_configs( @@ -2045,6 +2373,7 @@ pub mod pallet { max_pools: ConfigOp, max_members: ConfigOp, max_members_per_pool: ConfigOp, + global_max_commission: ConfigOp, ) -> DispatchResult { ensure_root(origin)?; @@ -2063,6 +2392,7 @@ pub mod pallet { config_op_exp!(MaxPools::, max_pools); config_op_exp!(MaxPoolMembers::, max_members); config_op_exp!(MaxPoolMembersPerPool::, max_members_per_pool); + config_op_exp!(GlobalMaxCommission::, global_max_commission); Ok(()) } @@ -2195,6 +2525,103 @@ pub mod pallet { let signer = ensure_signed(origin)?; Self::do_claim_payout(signer, other) } + + /// Set the commission of a pool. + // + /// Both a commission percentage and a commission payee must be provided in the `current` + /// tuple. Where a `current` of `None` is provided, any current commission will be removed. + /// + /// - If a `None` is supplied to `new_commission`, existing commission will be removed. + #[pallet::call_index(17)] + #[pallet::weight(T::WeightInfo::set_commission())] + pub fn set_commission( + origin: OriginFor, + pool_id: PoolId, + new_commission: Option<(Perbill, T::AccountId)>, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + let mut bonded_pool = BondedPool::::get(pool_id).ok_or(Error::::PoolNotFound)?; + ensure!(bonded_pool.can_manage_commission(&who), Error::::DoesNotHavePermission); + + let mut reward_pool = RewardPools::::get(pool_id) + .defensive_ok_or::>(DefensiveError::RewardPoolNotFound.into())?; + // IMPORTANT: make sure that everything up to this point is using the current commission + // before it updates. Note that `try_update_current` could still fail at this point. + reward_pool.update_records( + pool_id, + bonded_pool.points, + bonded_pool.commission.current(), + )?; + RewardPools::insert(pool_id, reward_pool); + + bonded_pool.commission.try_update_current(&new_commission)?; + bonded_pool.put(); + Self::deposit_event(Event::::PoolCommissionUpdated { + pool_id, + current: new_commission, + }); + Ok(()) + } + + /// Set the maximum commission of a pool. + /// + /// - Initial max can be set to any `Perbill`, and only smaller values thereafter. + /// - Current commission will be lowered in the event it is higher than a new max + /// commission. + #[pallet::call_index(18)] + #[pallet::weight(T::WeightInfo::set_commission_max())] + pub fn set_commission_max( + origin: OriginFor, + pool_id: PoolId, + max_commission: Perbill, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + let mut bonded_pool = BondedPool::::get(pool_id).ok_or(Error::::PoolNotFound)?; + ensure!(bonded_pool.can_manage_commission(&who), Error::::DoesNotHavePermission); + + bonded_pool.commission.try_update_max(pool_id, max_commission)?; + bonded_pool.put(); + + Self::deposit_event(Event::::PoolMaxCommissionUpdated { pool_id, max_commission }); + Ok(()) + } + + /// Set the commission change rate for a pool. + /// + /// Initial change rate is not bounded, whereas subsequent updates can only be more + /// restrictive than the current. + #[pallet::call_index(19)] + #[pallet::weight(T::WeightInfo::set_commission_change_rate())] + pub fn set_commission_change_rate( + origin: OriginFor, + pool_id: PoolId, + change_rate: CommissionChangeRate, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + let mut bonded_pool = BondedPool::::get(pool_id).ok_or(Error::::PoolNotFound)?; + ensure!(bonded_pool.can_manage_commission(&who), Error::::DoesNotHavePermission); + + bonded_pool.commission.try_update_change_rate(change_rate)?; + bonded_pool.put(); + + Self::deposit_event(Event::::PoolCommissionChangeRateUpdated { + pool_id, + change_rate, + }); + Ok(()) + } + + /// Claim pending commission. + /// + /// The dispatch origin of this call must be signed by the `root` role of the pool. Pending + /// commission is paid out and added to total claimed commission`. Total pending commission + /// is reset to zero. the current. + #[pallet::call_index(20)] + #[pallet::weight(0)] + pub fn claim_commission(origin: OriginFor, pool_id: PoolId) -> DispatchResult { + let who = ensure_signed(origin)?; + Self::do_claim_commission(who, pool_id) + } } #[pallet::hooks] @@ -2259,7 +2686,8 @@ impl Pallet { Zero::zero() ); - // This shouldn't fail, but if it does we don't really care + // This shouldn't fail, but if it does we don't really care. Remaining balance can consist + // of unclaimed pending commission, errorneous transfers to the reward account, etc. let reward_pool_remaining = T::Currency::free_balance(&reward_account); let _ = T::Currency::transfer( &reward_account, @@ -2295,7 +2723,7 @@ impl Pallet { fn get_member_with_pools( who: &T::AccountId, ) -> Result<(PoolMember, BondedPool, RewardPool), Error> { - let member = PoolMembers::::get(&who).ok_or(Error::::PoolMemberNotFound)?; + let member = PoolMembers::::get(who).ok_or(Error::::PoolMemberNotFound)?; let bonded_pool = BondedPool::::get(member.pool_id).defensive_ok_or(DefensiveError::PoolNotFound)?; let reward_pool = @@ -2323,8 +2751,8 @@ impl Pallet { current_points: BalanceOf, new_funds: BalanceOf, ) -> BalanceOf { - let u256 = |x| T::BalanceToU256::convert(x); - let balance = |x| T::U256ToBalance::convert(x); + let u256 = T::BalanceToU256::convert; + let balance = T::U256ToBalance::convert; match (current_balance.is_zero(), current_points.is_zero()) { (_, true) => new_funds.saturating_mul(POINTS_TO_BALANCE_INIT_RATIO.into()), (true, false) => { @@ -2351,8 +2779,8 @@ impl Pallet { current_points: BalanceOf, points: BalanceOf, ) -> BalanceOf { - let u256 = |x| T::BalanceToU256::convert(x); - let balance = |x| T::U256ToBalance::convert(x); + let u256 = T::BalanceToU256::convert; + let balance = T::U256ToBalance::convert; if current_balance.is_zero() || current_points.is_zero() || points.is_zero() { // There is nothing to unbond return Zero::zero() @@ -2378,10 +2806,15 @@ impl Pallet { // a member who has no skin in the game anymore cannot claim any rewards. ensure!(!member.active_points().is_zero(), Error::::FullyUnbonding); - let current_reward_counter = - reward_pool.current_reward_counter(bonded_pool.id, bonded_pool.points)?; - let pending_rewards = member.pending_rewards(current_reward_counter)?; + let (current_reward_counter, _) = reward_pool.current_reward_counter( + bonded_pool.id, + bonded_pool.points, + bonded_pool.commission.current(), + )?; + // Determine the pending rewards. In scenarios where commission is 100%, `pending_rewards` + // will be zero. + let pending_rewards = member.pending_rewards(current_reward_counter)?; if pending_rewards.is_zero() { return Ok(pending_rewards) } @@ -2390,14 +2823,13 @@ impl Pallet { member.last_recorded_reward_counter = current_reward_counter; reward_pool.register_claimed_reward(pending_rewards); - // Transfer payout to the member. T::Currency::transfer( &bonded_pool.reward_account(), - &member_account, + member_account, pending_rewards, // defensive: the depositor has put existential deposit into the pool and it stays // untouched, reward account shall not die. - ExistenceRequirement::AllowDeath, + ExistenceRequirement::KeepAlive, )?; Self::deposit_event(Event::::PaidOut { @@ -2462,6 +2894,8 @@ impl Pallet { last_recorded_reward_counter: Zero::zero(), last_recorded_total_payouts: Zero::zero(), total_rewards_claimed: Zero::zero(), + total_commission_pending: Zero::zero(), + total_commission_claimed: Zero::zero(), }, ); ReversePoolIdLookup::::insert(bonded_pool.bonded_account(), pool_id); @@ -2496,7 +2930,11 @@ impl Pallet { // payout related stuff: we must claim the payouts, and updated recorded payout data // before updating the bonded pool points, similar to that of `join` transaction. - reward_pool.update_records(bonded_pool.id, bonded_pool.points)?; + reward_pool.update_records( + bonded_pool.id, + bonded_pool.points, + bonded_pool.commission.current(), + )?; let claimed = Self::do_reward_payout(&who, &mut member, &mut bonded_pool, &mut reward_pool)?; @@ -2522,6 +2960,51 @@ impl Pallet { Ok(()) } + fn do_claim_commission(who: T::AccountId, pool_id: PoolId) -> DispatchResult { + let bonded_pool = BondedPool::::get(pool_id).ok_or(Error::::PoolNotFound)?; + ensure!(bonded_pool.can_manage_commission(&who), Error::::DoesNotHavePermission); + + let mut reward_pool = RewardPools::::get(pool_id) + .defensive_ok_or::>(DefensiveError::RewardPoolNotFound.into())?; + + // IMPORTANT: make sure that any newly pending commission not yet processed is added to + // `total_commission_pending`. + reward_pool.update_records( + pool_id, + bonded_pool.points, + bonded_pool.commission.current(), + )?; + + let commission = reward_pool.total_commission_pending; + ensure!(!commission.is_zero(), Error::::NoPendingCommission); + + let payee = bonded_pool + .commission + .current + .as_ref() + .map(|(_, p)| p.clone()) + .ok_or(Error::::NoCommissionCurrentSet)?; + + // Payout claimed commission. + T::Currency::transfer( + &bonded_pool.reward_account(), + &payee, + commission, + ExistenceRequirement::KeepAlive, + )?; + + // Add pending commission to total claimed counter. + reward_pool.total_commission_claimed = + reward_pool.total_commission_claimed.saturating_add(commission); + // Reset total pending commission counter to zero. + reward_pool.total_commission_pending = Zero::zero(); + // Commit reward pool updates + RewardPools::::insert(pool_id, reward_pool); + + Self::deposit_event(Event::::PoolCommissionClaimed { pool_id, commission }); + Ok(()) + } + fn do_claim_payout(signer: T::AccountId, who: T::AccountId) -> DispatchResult { if signer != who { ensure!( @@ -2608,16 +3091,18 @@ impl Pallet { let mut all_members = 0u32; PoolMembers::::iter().for_each(|(_, d)| { let bonded_pool = BondedPools::::get(d.pool_id).unwrap(); - assert!(!d.total_points().is_zero(), "no member should have zero points: {:?}", d); + assert!(!d.total_points().is_zero(), "no member should have zero points: {d:?}"); *pools_members.entry(d.pool_id).or_default() += 1; all_members += 1; let reward_pool = RewardPools::::get(d.pool_id).unwrap(); if !bonded_pool.points.is_zero() { - let current_rc = - reward_pool.current_reward_counter(d.pool_id, bonded_pool.points).unwrap(); - *pools_members_pending_rewards.entry(d.pool_id).or_default() += - d.pending_rewards(current_rc).unwrap(); + let commission = bonded_pool.commission.current(); + let (current_rc, _) = reward_pool + .current_reward_counter(d.pool_id, bonded_pool.points, commission) + .unwrap(); + let pending_rewards = d.pending_rewards(current_rc).unwrap(); + *pools_members_pending_rewards.entry(d.pool_id).or_default() += pending_rewards; } // else this pool has been heavily slashed and cannot have any rewards anymore. }); @@ -2633,14 +3118,14 @@ impl Pallet { ); assert!( RewardPool::::current_balance(id) >= - pools_members_pending_rewards.get(&id).map(|x| *x).unwrap_or_default() + pools_members_pending_rewards.get(&id).copied().unwrap_or_default() ) }); BondedPools::::iter().for_each(|(id, inner)| { let bonded_pool = BondedPool { id, inner }; assert_eq!( - pools_members.get(&id).map(|x| *x).unwrap_or_default(), + pools_members.get(&id).copied().unwrap_or_default(), bonded_pool.member_counter ); assert!(MaxPoolMembersPerPool::::get() @@ -2706,8 +3191,9 @@ impl Pallet { if let Some((reward_pool, bonded_pool)) = RewardPools::::get(pool_member.pool_id) .zip(BondedPools::::get(pool_member.pool_id)) { - let current_reward_counter = reward_pool - .current_reward_counter(pool_member.pool_id, bonded_pool.points) + let commission = bonded_pool.commission.current(); + let (current_reward_counter, _) = reward_pool + .current_reward_counter(pool_member.pool_id, bonded_pool.points, commission) .ok()?; return pool_member.pending_rewards(current_reward_counter).ok() } diff --git a/frame/nomination-pools/src/migration.rs b/frame/nomination-pools/src/migration.rs index a1696326989e3..f6f166d7f5de2 100644 --- a/frame/nomination-pools/src/migration.rs +++ b/frame/nomination-pools/src/migration.rs @@ -52,9 +52,12 @@ pub mod v1 { impl OldBondedPoolInner { fn migrate_to_v1(self) -> BondedPoolInner { + // Note: `commission` field not introduced to `BondedPoolInner` until + // migration 4. BondedPoolInner { - member_counter: self.member_counter, points: self.points, + commission: Commission::default(), + member_counter: self.member_counter, state: self.state, roles: self.roles.migrate_to_v1(), } @@ -307,6 +310,8 @@ pub mod v2 { last_recorded_reward_counter: Zero::zero(), last_recorded_total_payouts: Zero::zero(), total_rewards_claimed: Zero::zero(), + total_commission_claimed: Zero::zero(), + total_commission_pending: Zero::zero(), }) }, ); @@ -449,3 +454,97 @@ pub mod v3 { } } } + +pub mod v4 { + use super::*; + + #[derive(Decode)] + pub struct OldBondedPoolInner { + pub points: BalanceOf, + pub state: PoolState, + pub member_counter: u32, + pub roles: PoolRoles, + } + + impl OldBondedPoolInner { + fn migrate_to_v4(self) -> BondedPoolInner { + BondedPoolInner { + commission: Commission::default(), + member_counter: self.member_counter, + points: self.points, + state: self.state, + roles: self.roles, + } + } + } + + /// This migration adds a `commission` field to every `BondedPoolInner`, if + /// any. + pub struct MigrateToV4(sp_std::marker::PhantomData<(T, U)>); + impl> OnRuntimeUpgrade for MigrateToV4 { + fn on_runtime_upgrade() -> Weight { + let current = Pallet::::current_storage_version(); + let onchain = Pallet::::on_chain_storage_version(); + + log!( + info, + "Running migration with current storage version {:?} / onchain {:?}", + current, + onchain + ); + + if current == 4 && onchain == 3 { + let initial_global_max_commission = U::get(); + GlobalMaxCommission::::set(Some(initial_global_max_commission)); + log!( + info, + "Set initial global max commission to {:?}.", + initial_global_max_commission + ); + + let mut translated = 0u64; + BondedPools::::translate::, _>(|_key, old_value| { + translated.saturating_inc(); + Some(old_value.migrate_to_v4()) + }); + + current.put::>(); + log!(info, "Upgraded {} pools, storage to version {:?}", translated, current); + + // reads: translated + onchain version. + // writes: translated + current.put + initial global commission. + T::DbWeight::get().reads_writes(translated + 1, translated + 2) + } else { + log!(info, "Migration did not execute. This probably should be removed"); + T::DbWeight::get().reads(1) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + ensure!( + Pallet::::current_storage_version() > Pallet::::on_chain_storage_version(), + "the on_chain version is equal or more than the current one" + ); + Ok(Vec::new()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_: Vec) -> Result<(), &'static str> { + // ensure all BondedPools items now contain an `inner.commission: Commission` field. + ensure!( + BondedPools::::iter().all(|(_, inner)| inner.commission.current.is_none() && + inner.commission.max.is_none() && + inner.commission.change_rate.is_none() && + inner.commission.throttle_from.is_none()), + "a commission value has been incorrectly set" + ); + ensure!( + GlobalMaxCommission::::get() == Some(U::get()), + "global maximum commission error" + ); + ensure!(Pallet::::on_chain_storage_version() == 4, "wrong storage version"); + Ok(()) + } + } +} diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index e8924c0b9c0fa..c6b094f0aa0f1 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -118,8 +118,8 @@ impl sp_staking::StakingInterface for StakingMock { fn stake(who: &Self::AccountId) -> Result, DispatchError> { match ( - UnbondingBalanceMap::get().get(who).map(|v| *v), - BondedBalanceMap::get().get(who).map(|v| *v), + UnbondingBalanceMap::get().get(who).copied(), + BondedBalanceMap::get().get(who).copied(), ) { (None, None) => Err(DispatchError::Other("balance not found")), (Some(v), None) => Ok(Stake { total: v, active: 0, stash: *who }), @@ -251,11 +251,17 @@ pub struct ExtBuilder { members: Vec<(AccountId, Balance)>, max_members: Option, max_members_per_pool: Option, + global_max_commission: Option, } impl Default for ExtBuilder { fn default() -> Self { - Self { members: Default::default(), max_members: Some(4), max_members_per_pool: Some(3) } + Self { + members: Default::default(), + max_members: Some(4), + max_members_per_pool: Some(3), + global_max_commission: Some(Perbill::from_percent(90)), + } } } @@ -297,6 +303,11 @@ impl ExtBuilder { self } + pub fn global_max_commission(mut self, commission: Option) -> Self { + self.global_max_commission = commission; + self + } + pub fn build(self) -> sp_io::TestExternalities { sp_tracing::try_init_simple(); let mut storage = @@ -308,6 +319,7 @@ impl ExtBuilder { max_pools: Some(2), max_members_per_pool: self.max_members_per_pool, max_members: self.max_members, + global_max_commission: self.global_max_commission, } .assimilate_storage(&mut storage); @@ -332,7 +344,7 @@ impl ExtBuilder { ext } - pub fn build_and_execute(self, test: impl FnOnce() -> ()) { + pub fn build_and_execute(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); Pools::do_try_state(CheckLevel::get()).unwrap(); @@ -354,6 +366,23 @@ parameter_types! { storage BalancesEvents: u32 = 0; } +/// Helper to run a specified amount of blocks. +pub fn run_blocks(n: u64) { + let current_block = System::block_number(); + run_to_block(n + current_block); +} + +/// Helper to run to a specific block. +pub fn run_to_block(n: u64) { + let current_block = System::block_number(); + assert!(n > current_block); + while System::block_number() < n { + Pools::on_finalize(System::block_number()); + System::set_block_number(System::block_number() + 1); + Pools::on_initialize(System::block_number()); + } +} + /// All events of this pallet. pub fn pool_events_since_last_call() -> Vec> { let events = System::events() @@ -380,7 +409,7 @@ pub fn balances_events_since_last_call() -> Vec> /// Same as `fully_unbond`, in permissioned setting. pub fn fully_unbond_permissioned(member: AccountId) -> DispatchResult { - let points = PoolMembers::::get(&member) + let points = PoolMembers::::get(member) .map(|d| d.active_points()) .unwrap_or_default(); Pools::unbond(RuntimeOrigin::signed(member), member, points) diff --git a/frame/nomination-pools/src/tests.rs b/frame/nomination-pools/src/tests.rs index 33eee01948d1f..a4fda2e5d91b3 100644 --- a/frame/nomination-pools/src/tests.rs +++ b/frame/nomination-pools/src/tests.rs @@ -3,23 +3,23 @@ // 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 +// 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 +// 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. +// 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 super::*; use crate::{mock::*, Event}; use frame_support::{assert_err, assert_noop, assert_ok, assert_storage_noop, bounded_btree_map}; use pallet_balances::Event as BEvent; -use sp_runtime::traits::Dispatchable; +use sp_runtime::{traits::Dispatchable, FixedU128}; macro_rules! unbonding_pools_with_era { ($($k:expr => $v:expr),* $(,)?) => {{ @@ -55,10 +55,11 @@ fn test_setup_works() { BondedPool:: { id: last_pool, inner: BondedPoolInner { - state: PoolState::Open, - points: 10, + commission: Commission::default(), member_counter: 1, - roles: DEFAULT_ROLES + points: 10, + roles: DEFAULT_ROLES, + state: PoolState::Open, }, } ); @@ -67,7 +68,9 @@ fn test_setup_works() { RewardPool:: { last_recorded_reward_counter: Zero::zero(), last_recorded_total_payouts: 0, - total_rewards_claimed: 0 + total_rewards_claimed: 0, + total_commission_claimed: 0, + total_commission_pending: 0, } ); assert_eq!( @@ -98,10 +101,11 @@ mod bonded_pool { let mut bonded_pool = BondedPool:: { id: 123123, inner: BondedPoolInner { - state: PoolState::Open, - points: 100, + commission: Commission::default(), member_counter: 1, + points: 100, roles: DEFAULT_ROLES, + state: PoolState::Open, }, }; @@ -153,10 +157,11 @@ mod bonded_pool { let mut bonded_pool = BondedPool:: { id: 123123, inner: BondedPoolInner { - state: PoolState::Open, - points: 100, + commission: Commission::default(), member_counter: 1, + points: 100, roles: DEFAULT_ROLES, + state: PoolState::Open, }, }; @@ -241,10 +246,11 @@ mod bonded_pool { let pool = BondedPool:: { id: 123, inner: BondedPoolInner { - state: PoolState::Open, - points: 100, + commission: Commission::default(), member_counter: 1, + points: 100, roles: DEFAULT_ROLES, + state: PoolState::Open, }, }; @@ -258,7 +264,7 @@ mod bonded_pool { // Simulate a slashed pool at `MaxPointsToBalance` + 1 slashed pool StakingMock::set_bonded_balance( pool.bonded_account(), - max_points_to_balance.saturating_add(1).into(), + max_points_to_balance.saturating_add(1), ); assert_ok!(pool.ok_to_join()); @@ -470,16 +476,17 @@ mod join { let bonded = |points, member_counter| BondedPool:: { id: 1, inner: BondedPoolInner { - state: PoolState::Open, - points, + commission: Commission::default(), member_counter, + points, roles: DEFAULT_ROLES, + state: PoolState::Open, }, }; ExtBuilder::default().with_check(0).build_and_execute(|| { // Given Balances::make_free_balance_be(&11, ExistentialDeposit::get() + 2); - assert!(!PoolMembers::::contains_key(&11)); + assert!(!PoolMembers::::contains_key(11)); // When assert_ok!(Pools::join(RuntimeOrigin::signed(11), 2, 1)); @@ -496,7 +503,7 @@ mod join { ); assert_eq!( - PoolMembers::::get(&11).unwrap(), + PoolMembers::::get(11).unwrap(), PoolMember:: { pool_id: 1, points: 2, ..Default::default() } ); assert_eq!(BondedPool::::get(1).unwrap(), bonded(12, 2)); @@ -507,7 +514,7 @@ mod join { // And Balances::make_free_balance_be(&12, ExistentialDeposit::get() + 12); - assert!(!PoolMembers::::contains_key(&12)); + assert!(!PoolMembers::::contains_key(12)); // When assert_ok!(Pools::join(RuntimeOrigin::signed(12), 12, 1)); @@ -519,7 +526,7 @@ mod join { ); assert_eq!( - PoolMembers::::get(&12).unwrap(), + PoolMembers::::get(12).unwrap(), PoolMember:: { pool_id: 1, points: 24, ..Default::default() } ); assert_eq!(BondedPool::::get(1).unwrap(), bonded(12 + 24, 3)); @@ -530,7 +537,7 @@ mod join { fn join_errors_correctly() { ExtBuilder::default().with_check(0).build_and_execute(|| { // 10 is already part of the default pool created. - assert_eq!(PoolMembers::::get(&10).unwrap().pool_id, 1); + assert_eq!(PoolMembers::::get(10).unwrap().pool_id, 1); assert_noop!( Pools::join(RuntimeOrigin::signed(10), 420, 123), @@ -553,10 +560,11 @@ mod join { BondedPool:: { id: 123, inner: BondedPoolInner { + commission: Commission::default(), member_counter: 1, - state: PoolState::Open, points: 100, roles: DEFAULT_ROLES, + state: PoolState::Open, }, } .put(); @@ -622,10 +630,11 @@ mod join { BondedPool:: { id: 123, inner: BondedPoolInner { - state: PoolState::Open, - points: 100, + commission: Commission::default(), member_counter: 1, + points: 100, roles: DEFAULT_ROLES, + state: PoolState::Open, }, } .put(); @@ -722,6 +731,8 @@ mod claim_payout { last_recorded_reward_counter: last_recorded_reward_counter.into(), last_recorded_total_payouts, total_rewards_claimed, + total_commission_claimed: 0, + total_commission_pending: 0, } } @@ -754,7 +765,7 @@ mod claim_payout { assert_eq!(PoolMembers::::get(10).unwrap(), del(10, 1)); // pool's 'last_recorded_reward_counter' and 'last_recorded_total_payouts' don't // really change unless if someone bonds/unbonds. - assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 10)); + assert_eq!(RewardPools::::get(1).unwrap(), rew(0, 0, 10)); assert_eq!(Balances::free_balance(&10), 10); assert_eq!(Balances::free_balance(&default_reward_account()), ed + 90); @@ -767,7 +778,7 @@ mod claim_payout { vec![Event::PaidOut { member: 40, pool_id: 1, payout: 40 }] ); assert_eq!(PoolMembers::::get(40).unwrap(), del(40, 1)); - assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 50)); + assert_eq!(RewardPools::::get(1).unwrap(), rew(0, 0, 50)); assert_eq!(Balances::free_balance(&40), 40); assert_eq!(Balances::free_balance(&default_reward_account()), ed + 50); @@ -780,9 +791,9 @@ mod claim_payout { vec![Event::PaidOut { member: 50, pool_id: 1, payout: 50 }] ); assert_eq!(PoolMembers::::get(50).unwrap(), del(50, 1)); - assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 100)); + assert_eq!(RewardPools::::get(1).unwrap(), rew(0, 0, 100)); assert_eq!(Balances::free_balance(&50), 50); - assert_eq!(Balances::free_balance(&default_reward_account()), ed + 0); + assert_eq!(Balances::free_balance(&default_reward_account()), ed); // Given the reward pool has some new rewards assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 50)); @@ -796,7 +807,7 @@ mod claim_payout { vec![Event::PaidOut { member: 10, pool_id: 1, payout: 5 }] ); assert_eq!(PoolMembers::::get(10).unwrap(), del_float(10, 1.5)); - assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 105)); + assert_eq!(RewardPools::::get(1).unwrap(), rew(0, 0, 105)); assert_eq!(Balances::free_balance(&10), 10 + 5); assert_eq!(Balances::free_balance(&default_reward_account()), ed + 45); @@ -809,7 +820,7 @@ mod claim_payout { vec![Event::PaidOut { member: 40, pool_id: 1, payout: 20 }] ); assert_eq!(PoolMembers::::get(40).unwrap(), del_float(40, 1.5)); - assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 125)); + assert_eq!(RewardPools::::get(1).unwrap(), rew(0, 0, 125)); assert_eq!(Balances::free_balance(&40), 40 + 20); assert_eq!(Balances::free_balance(&default_reward_account()), ed + 25); @@ -826,7 +837,7 @@ mod claim_payout { vec![Event::PaidOut { member: 50, pool_id: 1, payout: 50 }] ); assert_eq!(PoolMembers::::get(50).unwrap(), del_float(50, 2.0)); - assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 175)); + assert_eq!(RewardPools::::get(1).unwrap(), rew(0, 0, 175)); assert_eq!(Balances::free_balance(&50), 50 + 50); assert_eq!(Balances::free_balance(&default_reward_account()), ed + 25); @@ -839,7 +850,7 @@ mod claim_payout { vec![Event::PaidOut { member: 10, pool_id: 1, payout: 5 }] ); assert_eq!(PoolMembers::::get(10).unwrap(), del(10, 2)); - assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 180)); + assert_eq!(RewardPools::::get(1).unwrap(), rew(0, 0, 180)); assert_eq!(Balances::free_balance(&10), 15 + 5); assert_eq!(Balances::free_balance(&default_reward_account()), ed + 20); @@ -858,7 +869,7 @@ mod claim_payout { // We expect a payout of 40 assert_eq!(PoolMembers::::get(10).unwrap(), del(10, 6)); - assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 220)); + assert_eq!(RewardPools::::get(1).unwrap(), rew(0, 0, 220)); assert_eq!(Balances::free_balance(&10), 20 + 40); assert_eq!(Balances::free_balance(&default_reward_account()), ed + 380); @@ -875,7 +886,7 @@ mod claim_payout { vec![Event::PaidOut { member: 10, pool_id: 1, payout: 2 }] ); assert_eq!(PoolMembers::::get(10).unwrap(), del_float(10, 6.2)); - assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 222)); + assert_eq!(RewardPools::::get(1).unwrap(), rew(0, 0, 222)); assert_eq!(Balances::free_balance(&10), 60 + 2); assert_eq!(Balances::free_balance(&default_reward_account()), ed + 398); @@ -888,7 +899,7 @@ mod claim_payout { vec![Event::PaidOut { member: 40, pool_id: 1, payout: 188 }] ); assert_eq!(PoolMembers::::get(40).unwrap(), del_float(40, 6.2)); - assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 410)); + assert_eq!(RewardPools::::get(1).unwrap(), rew(0, 0, 410)); assert_eq!(Balances::free_balance(&40), 60 + 188); assert_eq!(Balances::free_balance(&default_reward_account()), ed + 210); @@ -901,9 +912,9 @@ mod claim_payout { vec![Event::PaidOut { member: 50, pool_id: 1, payout: 210 }] ); assert_eq!(PoolMembers::::get(50).unwrap(), del_float(50, 6.2)); - assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 620)); + assert_eq!(RewardPools::::get(1).unwrap(), rew(0, 0, 620)); assert_eq!(Balances::free_balance(&50), 100 + 210); - assert_eq!(Balances::free_balance(&default_reward_account()), ed + 0); + assert_eq!(Balances::free_balance(&default_reward_account()), ed); }); } @@ -930,6 +941,56 @@ mod claim_payout { }); } + #[test] + fn claim_payout_bounds_commission_above_global() { + ExtBuilder::default().build_and_execute(|| { + let (mut member, bonded_pool, mut reward_pool) = + Pools::get_member_with_pools(&10).unwrap(); + + // top up commission payee account to existential deposit + let _ = Balances::deposit_creating(&2, 5); + + // Set a commission pool 1 to 75%, with a payee set to `2` + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + bonded_pool.id, + Some((Perbill::from_percent(75), 2)), + )); + + // re-introduce the global maximum to 50% - 25% lower than the current commission of the + // pool. + GlobalMaxCommission::::set(Some(Perbill::from_percent(50))); + + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(75), 2)) + } + ] + ); + + // The pool earns 10 points + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 10)); + + assert_ok!(Pools::do_reward_payout( + &10, + &mut member, + &mut BondedPool::::get(1).unwrap(), + &mut reward_pool + )); + + // commission applied is 50%, not 75%. Has been bounded by `GlobalMaxCommission`. + assert_eq!( + pool_events_since_last_call(), + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 5 },] + ); + }) + } + #[test] fn do_reward_payout_works_with_a_pool_of_1() { let del = |last_recorded_reward_counter| del_float(10, last_recorded_reward_counter); @@ -987,7 +1048,7 @@ mod claim_payout { assert_eq!(member, del(1.5)); // Given the pool has earned no new rewards - Balances::make_free_balance_be(&default_reward_account(), ed + 0); + Balances::make_free_balance_be(&default_reward_account(), ed); // When let payout = @@ -2432,7 +2493,7 @@ mod unbond { assert_eq!( SubPoolsStorage::::get(1).unwrap().with_era, - unbonding_pools_with_era! { 0 + 3 => UnbondPool:: { points: 10, balance: 10 }} + unbonding_pools_with_era! { 3 => UnbondPool:: { points: 10, balance: 10 }} ); assert_eq!( @@ -2440,10 +2501,11 @@ mod unbond { BondedPool { id: 1, inner: BondedPoolInner { - state: PoolState::Destroying, - points: 0, + commission: Commission::default(), member_counter: 1, + points: 0, roles: DEFAULT_ROLES, + state: PoolState::Destroying, } } ); @@ -2469,17 +2531,18 @@ mod unbond { // Then assert_eq!( SubPoolsStorage::::get(1).unwrap().with_era, - unbonding_pools_with_era! { 0 + 3 => UnbondPool { points: 6, balance: 6 }} + unbonding_pools_with_era! { 3 => UnbondPool { points: 6, balance: 6 }} ); assert_eq!( BondedPool::::get(1).unwrap(), BondedPool { id: 1, inner: BondedPoolInner { - state: PoolState::Open, - points: 560, + commission: Commission::default(), member_counter: 3, + points: 560, roles: DEFAULT_ROLES, + state: PoolState::Open, } } ); @@ -2498,7 +2561,7 @@ mod unbond { assert_eq!(StakingMock::active_stake(&default_bonded_account()).unwrap(), 94); assert_eq!( PoolMembers::::get(40).unwrap().unbonding_eras, - member_unbonding_eras!(0 + 3 => 6) + member_unbonding_eras!(3 => 6) ); assert_eq!(Balances::free_balance(&40), 40 + 40); // We claim rewards when unbonding @@ -2508,25 +2571,26 @@ mod unbond { // Then assert_eq!( - SubPoolsStorage::::get(&1).unwrap().with_era, - unbonding_pools_with_era! { 0 + 3 => UnbondPool { points: 98, balance: 98 }} + SubPoolsStorage::::get(1).unwrap().with_era, + unbonding_pools_with_era! { 3 => UnbondPool { points: 98, balance: 98 }} ); assert_eq!( BondedPool::::get(1).unwrap(), BondedPool { id: 1, inner: BondedPoolInner { - state: PoolState::Destroying, - points: 10, + commission: Commission::default(), member_counter: 3, - roles: DEFAULT_ROLES + points: 10, + roles: DEFAULT_ROLES, + state: PoolState::Destroying, } } ); assert_eq!(StakingMock::active_stake(&default_bonded_account()).unwrap(), 2); assert_eq!( PoolMembers::::get(550).unwrap().unbonding_eras, - member_unbonding_eras!(0 + 3 => 92) + member_unbonding_eras!(3 => 92) ); assert_eq!(Balances::free_balance(&550), 550 + 550); assert_eq!( @@ -2559,10 +2623,11 @@ mod unbond { BondedPool { id: 1, inner: BondedPoolInner { - state: PoolState::Destroying, - points: 0, + commission: Commission::default(), member_counter: 1, - roles: DEFAULT_ROLES + points: 0, + roles: DEFAULT_ROLES, + state: PoolState::Destroying, } } ); @@ -2593,7 +2658,7 @@ mod unbond { SubPools { no_era: Default::default(), with_era: unbonding_pools_with_era! { - 0 + 3 => UnbondPool { balance: 10, points: 100 }, + 3 => UnbondPool { balance: 10, points: 100 }, 1 + 3 => UnbondPool { balance: 20, points: 20 }, 2 + 3 => UnbondPool { balance: 101, points: 101} }, @@ -2687,10 +2752,11 @@ mod unbond { BondedPool { id: 1, inner: BondedPoolInner { + commission: Commission::default(), + member_counter: 3, + points: 10, // Only 10 points because 200 + 100 was unbonded roles: DEFAULT_ROLES, state: PoolState::Blocked, - points: 10, // Only 10 points because 200 + 100 was unbonded - member_counter: 3, } } ); @@ -2700,7 +2766,7 @@ mod unbond { SubPools { no_era: Default::default(), with_era: unbonding_pools_with_era! { - 0 + 3 => UnbondPool { points: 100 + 200, balance: 100 + 200 } + 3 => UnbondPool { points: 100 + 200, balance: 100 + 200 } }, } ); @@ -2837,10 +2903,11 @@ mod unbond { BondedPool:: { id: 1, inner: BondedPoolInner { - state: PoolState::Open, - points: 10, + commission: Commission::default(), member_counter: 1, + points: 10, roles: DEFAULT_ROLES, + state: PoolState::Open, }, } .put(); @@ -3356,7 +3423,7 @@ mod withdraw_unbonded { assert_ok!(fully_unbond_permissioned(550)); assert_eq!( - SubPoolsStorage::::get(&1).unwrap().with_era, + SubPoolsStorage::::get(1).unwrap().with_era, unbonding_pools_with_era! { 3 => UnbondPool { points: 550 / 2 + 40 / 2, balance: 550 / 2 + 40 / 2 }} ); @@ -3406,7 +3473,7 @@ mod withdraw_unbonded { ); assert_eq!( - SubPoolsStorage::::get(&1).unwrap().with_era, + SubPoolsStorage::::get(1).unwrap().with_era, unbonding_pools_with_era! { 3 => UnbondPool { points: 550 / 2, balance: 550 / 2 }} ); @@ -3425,7 +3492,7 @@ mod withdraw_unbonded { Event::MemberRemoved { pool_id: 1, member: 550 } ] ); - assert!(SubPoolsStorage::::get(&1).unwrap().with_era.is_empty()); + assert!(SubPoolsStorage::::get(1).unwrap().with_era.is_empty()); // now, finally, the depositor can take out its share. unsafe_set_state(1, PoolState::Destroying); @@ -3433,7 +3500,7 @@ mod withdraw_unbonded { // because everyone else has left, the points assert_eq!( - SubPoolsStorage::::get(&1).unwrap().with_era, + SubPoolsStorage::::get(1).unwrap().with_era, unbonding_pools_with_era! { 6 => UnbondPool { points: 5, balance: 5 }} ); @@ -3487,10 +3554,10 @@ mod withdraw_unbonded { assert_eq!( SubPoolsStorage::::get(1).unwrap().with_era, //------------------------------balance decrease is not account for - unbonding_pools_with_era! { 0 + 3 => UnbondPool { points: 10, balance: 10 } } + unbonding_pools_with_era! { 3 => UnbondPool { points: 10, balance: 10 } } ); - CurrentEra::set(0 + 3); + CurrentEra::set(3); // When assert_ok!(Pools::withdraw_unbonded(RuntimeOrigin::signed(10), 10, 0)); @@ -3507,7 +3574,7 @@ mod withdraw_unbonded { // Insert the sub-pool let sub_pools = SubPools { no_era: Default::default(), - with_era: unbonding_pools_with_era! { 0 + 3 => UnbondPool { points: 10, balance: 10 }}, + with_era: unbonding_pools_with_era! { 3 => UnbondPool { points: 10, balance: 10 }}, }; SubPoolsStorage::::insert(1, sub_pools.clone()); @@ -3520,7 +3587,7 @@ mod withdraw_unbonded { PoolMembers::::insert(11, member.clone()); // Simulate calling `unbond` - member.unbonding_eras = member_unbonding_eras!(3 + 0 => 10); + member.unbonding_eras = member_unbonding_eras!(3 => 10); PoolMembers::::insert(11, member.clone()); // We are still in the bonding duration @@ -3530,7 +3597,7 @@ mod withdraw_unbonded { ); // If we error the member does not get removed - assert_eq!(PoolMembers::::get(&11), Some(member)); + assert_eq!(PoolMembers::::get(11), Some(member)); // and the sub pools do not get updated. assert_eq!(SubPoolsStorage::::get(1).unwrap(), sub_pools) }); @@ -3549,10 +3616,11 @@ mod withdraw_unbonded { BondedPool { id: 1, inner: BondedPoolInner { + commission: Commission::default(), + member_counter: 3, points: 10, + roles: DEFAULT_ROLES, state: PoolState::Open, - member_counter: 3, - roles: DEFAULT_ROLES } } ); @@ -3629,10 +3697,11 @@ mod withdraw_unbonded { BondedPool { id: 1, inner: BondedPoolInner { - points: 10, - state: PoolState::Open, + commission: Commission::default(), member_counter: 2, + points: 10, roles: DEFAULT_ROLES, + state: PoolState::Open, } } ); @@ -4225,15 +4294,16 @@ mod create { BondedPool { id: 2, inner: BondedPoolInner { + commission: Commission::default(), points: StakingMock::minimum_nominator_bond(), member_counter: 1, - state: PoolState::Open, roles: PoolRoles { depositor: 11, root: Some(123), nominator: Some(456), bouncer: Some(789) - } + }, + state: PoolState::Open, } } ); @@ -4289,10 +4359,11 @@ mod create { BondedPool:: { id: 2, inner: BondedPoolInner { - state: PoolState::Open, - points: 10, + commission: Commission::default(), member_counter: 1, + points: 10, roles: DEFAULT_ROLES, + state: PoolState::Open, }, } .put(); @@ -4369,7 +4440,7 @@ fn set_claimable_actor_works() { ExtBuilder::default().build_and_execute(|| { // Given Balances::make_free_balance_be(&11, ExistentialDeposit::get() + 2); - assert!(!PoolMembers::::contains_key(&11)); + assert!(!PoolMembers::::contains_key(11)); // When assert_ok!(Pools::join(RuntimeOrigin::signed(11), 2, 1)); @@ -4574,12 +4645,14 @@ mod set_configs { ConfigOp::Set(3u32), ConfigOp::Set(4u32), ConfigOp::Set(5u32), + ConfigOp::Set(Perbill::from_percent(6)) )); assert_eq!(MinJoinBond::::get(), 1); assert_eq!(MinCreateBond::::get(), 2); assert_eq!(MaxPools::::get(), Some(3)); assert_eq!(MaxPoolMembers::::get(), Some(4)); assert_eq!(MaxPoolMembersPerPool::::get(), Some(5)); + assert_eq!(GlobalMaxCommission::::get(), Some(Perbill::from_percent(6))); // Noop does nothing assert_storage_noop!(assert_ok!(Pools::set_configs( @@ -4589,6 +4662,7 @@ mod set_configs { ConfigOp::Noop, ConfigOp::Noop, ConfigOp::Noop, + ConfigOp::Noop, ))); // Removing works @@ -4599,12 +4673,14 @@ mod set_configs { ConfigOp::Remove, ConfigOp::Remove, ConfigOp::Remove, + ConfigOp::Remove, )); assert_eq!(MinJoinBond::::get(), 0); assert_eq!(MinCreateBond::::get(), 0); assert_eq!(MaxPools::::get(), None); assert_eq!(MaxPoolMembers::::get(), None); assert_eq!(MaxPoolMembersPerPool::::get(), None); + assert_eq!(GlobalMaxCommission::::get(), None); }); } } @@ -4949,8 +5025,6 @@ mod update_roles { } mod reward_counter_precision { - use sp_runtime::FixedU128; - use super::*; const DOT: Balance = 10u128.pow(10u32); @@ -4967,10 +5041,12 @@ mod reward_counter_precision { } fn default_pool_reward_counter() -> FixedU128 { - RewardPools::::get(1) + let bonded_pool = BondedPools::::get(1).unwrap(); + RewardPools::::get(1) .unwrap() - .current_reward_counter(1, BondedPools::::get(1).unwrap().points) + .current_reward_counter(1, bonded_pool.points, bonded_pool.commission.current()) .unwrap() + .0 } fn pending_rewards(of: AccountId) -> Option> { @@ -5292,3 +5368,1353 @@ mod reward_counter_precision { }); } } + +mod commission { + use super::*; + + #[test] + fn set_commission_works() { + ExtBuilder::default().build_and_execute(|| { + let pool_id = 1; + let root = 900; + + // Commission can be set by the `root` role. + + // When: + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(root), + pool_id, + Some((Perbill::from_percent(50), root)) + )); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id }, + Event::Bonded { member: 10, pool_id, bonded: 10, joined: true }, + Event::PoolCommissionUpdated { + pool_id, + current: Some((Perbill::from_percent(50), root)) + }, + ] + ); + + // Commission can be updated only, while keeping the same payee. + + // When: + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(root), + 1, + Some((Perbill::from_percent(25), root)) + )); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![Event::PoolCommissionUpdated { + pool_id, + current: Some((Perbill::from_percent(25), root)) + },] + ); + + // Payee can be updated only, while keeping the same commission. + + // Given: + let payee = 901; + + // When: + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(root), + pool_id, + Some((Perbill::from_percent(25), payee)) + )); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(25), payee)) + },] + ); + + // Pool earns 80 points and a payout is triggered. + + // Given: + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 80)); + assert_eq!( + PoolMembers::::get(10).unwrap(), + PoolMember:: { pool_id, points: 10, ..Default::default() } + ); + + // When: + assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![Event::PaidOut { member: 10, pool_id, payout: 60 }] + ); + assert_eq!(RewardPool::::current_balance(pool_id), 20); + + // Pending pool commission can be claimed by the root role. + + // When: + assert_ok!(Pools::claim_commission(RuntimeOrigin::signed(root), pool_id)); + + // Then: + assert_eq!(RewardPool::::current_balance(pool_id), 0); + assert_eq!( + pool_events_since_last_call(), + vec![Event::PoolCommissionClaimed { pool_id: 1, commission: 20 }] + ); + + // Commission can be removed from the pool completely. + + // When: + assert_ok!(Pools::set_commission(RuntimeOrigin::signed(root), pool_id, None)); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![Event::PoolCommissionUpdated { pool_id, current: None },] + ); + + // Given a pool now has a reward counter history, additional rewards and payouts can be + // made while maintaining a correct ledger of the reward pool. Pool earns 100 points, + // payout is triggered. + // + // Note that the `total_commission_pending` will not be updated until `update_records` + // is next called, which is not done in this test segment.. + + // Given: + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 100)); + + // When: + assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![Event::PaidOut { member: 10, pool_id, payout: 100 },] + ); + assert_eq!( + RewardPools::::get(pool_id).unwrap(), + RewardPool { + last_recorded_reward_counter: FixedU128::from_float(6.0), + last_recorded_total_payouts: 80, + total_rewards_claimed: 160, + total_commission_pending: 0, + total_commission_claimed: 20 + } + ); + + // When set commission is called again, update_records is called and + // `total_commission_pending` is updated, based on the current reward counter and pool + // balance. + // + // Note that commission is now 0%, so it should not come into play with subsequent + // payouts. + + // When: + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(root), + 1, + Some((Perbill::from_percent(10), root)) + )); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![Event::PoolCommissionUpdated { + pool_id, + current: Some((Perbill::from_percent(10), root)) + },] + ); + assert_eq!( + RewardPools::::get(pool_id).unwrap(), + RewardPool { + last_recorded_reward_counter: FixedU128::from_float(16.0), + last_recorded_total_payouts: 180, + total_rewards_claimed: 160, + total_commission_pending: 0, + total_commission_claimed: 20 + } + ); + + // Supplying a 0% commission along with a payee results in a `None` current value. + + // When: + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(root), + pool_id, + Some((Perbill::from_percent(0), root)) + )); + + // Then: + assert_eq!( + BondedPool::::get(1).unwrap().commission, + Commission { current: None, max: None, change_rate: None, throttle_from: Some(1) } + ); + assert_eq!( + pool_events_since_last_call(), + vec![Event::PoolCommissionUpdated { + pool_id, + current: Some((Perbill::from_percent(0), root)) + },] + ); + + // The payee can be updated even when commission has reached maximum commission. Both + // commission and max commission are set to 10% to test this. + + // Given: + assert_ok!(Pools::set_commission_max( + RuntimeOrigin::signed(root), + pool_id, + Perbill::from_percent(10) + )); + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(root), + pool_id, + Some((Perbill::from_percent(10), root)) + )); + + // When: + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(root), + pool_id, + Some((Perbill::from_percent(10), payee)) + )); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::PoolMaxCommissionUpdated { + pool_id, + max_commission: Perbill::from_percent(10) + }, + Event::PoolCommissionUpdated { + pool_id, + current: Some((Perbill::from_percent(10), root)) + }, + Event::PoolCommissionUpdated { + pool_id, + current: Some((Perbill::from_percent(10), payee)) + } + ] + ); + }); + } + + #[test] + fn commission_reward_counter_works_one_member() { + ExtBuilder::default().build_and_execute(|| { + let pool_id = 1; + let root = 900; + let member = 10; + + // Set the pool commission to 10% to test commission shares. Pool is topped up 40 points + // and `member` immediately claims their pending rewards. Reward pooll should still have + // 10% share. + + // Given: + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(root), + 1, + Some((Perbill::from_percent(10), root)), + )); + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 40)); + + // When: + assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); + + // Then: + assert_eq!(RewardPool::::current_balance(pool_id), 4); + + // Set pool commission to 20% and repeat the same process. + + // When: + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(root), + 1, + Some((Perbill::from_percent(20), root)), + )); + + // Then: + assert_eq!( + RewardPools::::get(pool_id).unwrap(), + RewardPool { + last_recorded_reward_counter: FixedU128::from_float(3.6), + last_recorded_total_payouts: 40, + total_rewards_claimed: 36, + total_commission_pending: 4, + total_commission_claimed: 0 + } + ); + + // The current reward counter should yield the correct pending rewards of zero. + + // Given: + let (current_reward_counter, _) = RewardPools::::get(pool_id) + .unwrap() + .current_reward_counter( + pool_id, + BondedPools::::get(pool_id).unwrap().points, + Perbill::from_percent(20), + ) + .unwrap(); + + // Then: + assert_eq!( + PoolMembers::::get(member) + .unwrap() + .pending_rewards(current_reward_counter) + .unwrap(), + 0 + ); + + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(10), 900)) + }, + Event::PaidOut { member: 10, pool_id: 1, payout: 36 }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(20), 900)) + } + ] + ); + }) + } + + #[test] + fn set_commission_handles_errors() { + ExtBuilder::default().build_and_execute(|| { + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + ] + ); + + // Provided pool does not exist. + assert_noop!( + Pools::set_commission( + RuntimeOrigin::signed(900), + 9999, + Some((Perbill::from_percent(1), 900)), + ), + Error::::PoolNotFound + ); + + // Sender does not have permission to set commission. + assert_noop!( + Pools::set_commission( + RuntimeOrigin::signed(1), + 1, + Some((Perbill::from_percent(5), 900)), + ), + Error::::DoesNotHavePermission + ); + + // Commission increases will be throttled if outside of change_rate allowance. + // Commission is set to 5%. + // Change rate is set to 1% max increase, 2 block delay. + + // When: + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(5), 900)), + )); + assert_ok!(Pools::set_commission_change_rate( + RuntimeOrigin::signed(900), + 1, + CommissionChangeRate { max_increase: Perbill::from_percent(1), min_delay: 2_u64 } + )); + assert_eq!( + BondedPool::::get(1).unwrap().commission, + Commission { + current: Some((Perbill::from_percent(5), 900)), + max: None, + change_rate: Some(CommissionChangeRate { + max_increase: Perbill::from_percent(1), + min_delay: 2_u64 + }), + throttle_from: Some(1_u64), + } + ); + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(5), 900)) + }, + Event::PoolCommissionChangeRateUpdated { + pool_id: 1, + change_rate: CommissionChangeRate { + max_increase: Perbill::from_percent(1), + min_delay: 2 + } + } + ] + ); + + // Now try to increase commission to 10% (5% increase). This should be throttled. + // Then: + assert_noop!( + Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(10), 900)) + ), + Error::::CommissionChangeThrottled + ); + + run_blocks(2); + + // Increase commission by 1% and provide an initial payee. This should succeed and set + // the `throttle_from` field. + + // When: + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(6), 900)) + )); + assert_eq!( + BondedPool::::get(1).unwrap().commission, + Commission { + current: Some((Perbill::from_percent(6), 900)), + max: None, + change_rate: Some(CommissionChangeRate { + max_increase: Perbill::from_percent(1), + min_delay: 2_u64 + }), + throttle_from: Some(3_u64), + } + ); + assert_eq!( + pool_events_since_last_call(), + vec![Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(6), 900)) + },] + ); + + // Attempt to increase the commission an additional 1% (now 7%). This will fail as + // `throttle_from` is now the current block. At least 2 blocks need to pass before we + // can set commission again. + + // Then: + assert_noop!( + Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(7), 900)) + ), + Error::::CommissionChangeThrottled + ); + + run_blocks(2); + + // Can now successfully increase the commission again, to 7%. + + // When: + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(7), 900)), + )); + assert_eq!( + pool_events_since_last_call(), + vec![Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(7), 900)) + },] + ); + + run_blocks(2); + + // Now surpassed the `min_delay` threshold, but the `max_increase` threshold is + // still at play. An attempted commission change now to 8% (+2% increase) should fail. + + // Then: + assert_noop!( + Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(9), 900)), + ), + Error::::CommissionChangeThrottled + ); + + // Now set a max commission to the current 5%. This will also update the current + // commission to 5%. + + // When: + assert_ok!(Pools::set_commission_max( + RuntimeOrigin::signed(900), + 1, + Perbill::from_percent(5) + )); + assert_eq!( + BondedPool::::get(1).unwrap().commission, + Commission { + current: Some((Perbill::from_percent(5), 900)), + max: Some(Perbill::from_percent(5)), + change_rate: Some(CommissionChangeRate { + max_increase: Perbill::from_percent(1), + min_delay: 2 + }), + throttle_from: Some(7) + } + ); + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(5), 900)) + }, + Event::PoolMaxCommissionUpdated { + pool_id: 1, + max_commission: Perbill::from_percent(5) + } + ] + ); + + // Run 2 blocks into the future so we are eligible to update commission again. + run_blocks(2); + + // Now attempt again to increase the commission by 1%, to 6%. This is within the change + // rate allowance, but `max_commission` will now prevent us from going any higher. + + // Then: + assert_noop!( + Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(6), 900)), + ), + Error::::CommissionExceedsMaximum + ); + }); + } + + #[test] + fn set_commission_max_works_with_error_tests() { + ExtBuilder::default().build_and_execute(|| { + // Provided pool does not exist + assert_noop!( + Pools::set_commission_max( + RuntimeOrigin::signed(900), + 9999, + Perbill::from_percent(1) + ), + Error::::PoolNotFound + ); + // Sender does not have permission to set commission + assert_noop!( + Pools::set_commission_max(RuntimeOrigin::signed(1), 1, Perbill::from_percent(5)), + Error::::DoesNotHavePermission + ); + + // Set a max commission commission pool 1 to 80% + assert_ok!(Pools::set_commission_max( + RuntimeOrigin::signed(900), + 1, + Perbill::from_percent(80) + )); + assert_eq!( + BondedPools::::get(1).unwrap().commission.max, + Some(Perbill::from_percent(80)) + ); + + // We attempt to increase the max commission to 90%, but increasing is + // disallowed due to pool's max commission. + assert_noop!( + Pools::set_commission_max(RuntimeOrigin::signed(900), 1, Perbill::from_percent(90)), + Error::::MaxCommissionRestricted + ); + + // We will now set a commission to 75% and then amend the max commission + // to 50%. The max commission change should decrease the current + // commission to 50%. + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(75), 900)) + )); + assert_ok!(Pools::set_commission_max( + RuntimeOrigin::signed(900), + 1, + Perbill::from_percent(50) + )); + assert_eq!( + BondedPools::::get(1).unwrap().commission, + Commission { + current: Some((Perbill::from_percent(50), 900)), + max: Some(Perbill::from_percent(50)), + change_rate: None, + throttle_from: Some(1), + } + ); + + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PoolMaxCommissionUpdated { + pool_id: 1, + max_commission: Perbill::from_percent(80) + }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(75), 900)) + }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(50), 900)) + }, + Event::PoolMaxCommissionUpdated { + pool_id: 1, + max_commission: Perbill::from_percent(50) + } + ] + ); + }); + } + + #[test] + fn set_commission_change_rate_works_with_errors() { + ExtBuilder::default().build_and_execute(|| { + // Provided pool does not exist + assert_noop!( + Pools::set_commission_change_rate( + RuntimeOrigin::signed(900), + 9999, + CommissionChangeRate { + max_increase: Perbill::from_percent(5), + min_delay: 1000_u64 + } + ), + Error::::PoolNotFound + ); + // Sender does not have permission to set commission + assert_noop!( + Pools::set_commission_change_rate( + RuntimeOrigin::signed(1), + 1, + CommissionChangeRate { + max_increase: Perbill::from_percent(5), + min_delay: 1000_u64 + } + ), + Error::::DoesNotHavePermission + ); + + // Set a commission change rate for pool 1 + assert_ok!(Pools::set_commission_change_rate( + RuntimeOrigin::signed(900), + 1, + CommissionChangeRate { max_increase: Perbill::from_percent(5), min_delay: 10_u64 } + )); + assert_eq!( + BondedPools::::get(1).unwrap().commission.change_rate, + Some(CommissionChangeRate { + max_increase: Perbill::from_percent(5), + min_delay: 10_u64 + }) + ); + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PoolCommissionChangeRateUpdated { + pool_id: 1, + change_rate: CommissionChangeRate { + max_increase: Perbill::from_percent(5), + min_delay: 10 + } + }, + ] + ); + + // We now try to half the min_delay - this will be disallowed. A greater delay between + // commission changes is seen as more restrictive. + assert_noop!( + Pools::set_commission_change_rate( + RuntimeOrigin::signed(900), + 1, + CommissionChangeRate { + max_increase: Perbill::from_percent(5), + min_delay: 5_u64 + } + ), + Error::::CommissionChangeRateNotAllowed + ); + + // We now try to increase the allowed max_increase - this will fail. A smaller allowed + // commission change is seen as more restrictive. + assert_noop!( + Pools::set_commission_change_rate( + RuntimeOrigin::signed(900), + 1, + CommissionChangeRate { + max_increase: Perbill::from_percent(10), + min_delay: 10_u64 + } + ), + Error::::CommissionChangeRateNotAllowed + ); + + // Successful more restrictive change of min_delay with the current max_increase + assert_ok!(Pools::set_commission_change_rate( + RuntimeOrigin::signed(900), + 1, + CommissionChangeRate { max_increase: Perbill::from_percent(5), min_delay: 20_u64 } + )); + + // Successful more restrictive change of max_increase with the current min_delay + assert_ok!(Pools::set_commission_change_rate( + RuntimeOrigin::signed(900), + 1, + CommissionChangeRate { max_increase: Perbill::from_percent(4), min_delay: 20_u64 } + )); + + // Successful more restrictive change of both max_increase and min_delay + assert_ok!(Pools::set_commission_change_rate( + RuntimeOrigin::signed(900), + 1, + CommissionChangeRate { max_increase: Perbill::from_percent(3), min_delay: 30_u64 } + )); + + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::PoolCommissionChangeRateUpdated { + pool_id: 1, + change_rate: CommissionChangeRate { + max_increase: Perbill::from_percent(5), + min_delay: 20 + } + }, + Event::PoolCommissionChangeRateUpdated { + pool_id: 1, + change_rate: CommissionChangeRate { + max_increase: Perbill::from_percent(4), + min_delay: 20 + } + }, + Event::PoolCommissionChangeRateUpdated { + pool_id: 1, + change_rate: CommissionChangeRate { + max_increase: Perbill::from_percent(3), + min_delay: 30 + } + } + ] + ); + }); + } + + #[test] + fn change_rate_does_not_apply_to_decreasing_commission() { + ExtBuilder::default().build_and_execute(|| { + // set initial commission of the pool to 10%. + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(10), 900)) + )); + + // Set a commission change rate for pool 1, 1% every 10 blocks + assert_ok!(Pools::set_commission_change_rate( + RuntimeOrigin::signed(900), + 1, + CommissionChangeRate { max_increase: Perbill::from_percent(1), min_delay: 10_u64 } + )); + assert_eq!( + BondedPools::::get(1).unwrap().commission.change_rate, + Some(CommissionChangeRate { + max_increase: Perbill::from_percent(1), + min_delay: 10_u64 + }) + ); + + // run `min_delay` blocks to allow a commission update. + run_blocks(10_u64); + + // Test `max_increase`: attempt to decrease the commission by 5%. Should succeed. + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(5), 900)) + )); + + // Test `min_delay`: *immediately* attempt to decrease the commission by 2%. Should + // succeed. + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(3), 900)) + )); + + // Attempt to *increase* the commission by 5%. Should fail. + assert_noop!( + Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(8), 900)) + ), + Error::::CommissionChangeThrottled + ); + + // Sanity check: the resulting pool Commission state. + assert_eq!( + BondedPools::::get(1).unwrap().commission, + Commission { + current: Some((Perbill::from_percent(3), 900)), + max: None, + change_rate: Some(CommissionChangeRate { + max_increase: Perbill::from_percent(1), + min_delay: 10_u64 + }), + throttle_from: Some(11), + } + ); + + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(10), 900)) + }, + Event::PoolCommissionChangeRateUpdated { + pool_id: 1, + change_rate: CommissionChangeRate { + max_increase: Perbill::from_percent(1), + min_delay: 10 + } + }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(5), 900)) + }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(3), 900)) + } + ] + ); + }); + } + + #[test] + fn set_commission_max_to_zero_works() { + ExtBuilder::default().build_and_execute(|| { + // 0% max commission test. + // set commission max 0%. + assert_ok!(Pools::set_commission_max(RuntimeOrigin::signed(900), 1, Zero::zero())); + + // a max commission of 0% essentially freezes the current commission, even when None. + // All commission update attempts will fail. + assert_noop!( + Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(1), 900)) + ), + Error::::CommissionExceedsMaximum + ); + }) + } + + #[test] + fn set_commission_change_rate_zero_max_increase_works() { + ExtBuilder::default().build_and_execute(|| { + // set commission change rate to 0% per 10 blocks + assert_ok!(Pools::set_commission_change_rate( + RuntimeOrigin::signed(900), + 1, + CommissionChangeRate { max_increase: Perbill::from_percent(0), min_delay: 10_u64 } + )); + + // even though there is a min delay of 10 blocks, a max increase of 0% essentially + // freezes the commission. All commission update attempts will fail. + assert_noop!( + Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(1), 900)) + ), + Error::::CommissionChangeThrottled + ); + }) + } + + #[test] + fn set_commission_change_rate_zero_min_delay_works() { + ExtBuilder::default().build_and_execute(|| { + // set commission change rate to 1% with a 0 block `min_delay`. + assert_ok!(Pools::set_commission_change_rate( + RuntimeOrigin::signed(900), + 1, + CommissionChangeRate { max_increase: Perbill::from_percent(1), min_delay: 0_u64 } + )); + assert_eq!( + BondedPools::::get(1).unwrap().commission, + Commission { + current: None, + max: None, + change_rate: Some(CommissionChangeRate { + max_increase: Perbill::from_percent(1), + min_delay: 0 + }), + throttle_from: Some(1) + } + ); + + // since there is no min delay, we should be able to immediately set the commission. + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(1), 900)) + )); + + // sanity check: increasing again to more than +1% will fail. + assert_noop!( + Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(3), 900)) + ), + Error::::CommissionChangeThrottled + ); + }) + } + + #[test] + fn set_commission_change_rate_zero_value_works() { + ExtBuilder::default().build_and_execute(|| { + // Check zero values play nice. 0 `min_delay` and 0% max_increase test. + // set commission change rate to 0% per 0 blocks. + assert_ok!(Pools::set_commission_change_rate( + RuntimeOrigin::signed(900), + 1, + CommissionChangeRate { max_increase: Perbill::from_percent(0), min_delay: 0_u64 } + )); + + // even though there is no min delay, a max increase of 0% essentially freezes the + // commission. All commission update attempts will fail. + assert_noop!( + Pools::set_commission( + RuntimeOrigin::signed(900), + 1, + Some((Perbill::from_percent(1), 900)) + ), + Error::::CommissionChangeThrottled + ); + + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PoolCommissionChangeRateUpdated { + pool_id: 1, + change_rate: CommissionChangeRate { + max_increase: Perbill::from_percent(0), + min_delay: 0_u64 + } + } + ] + ); + }) + } + + #[test] + fn do_reward_payout_with_various_commissions() { + ExtBuilder::default().build_and_execute(|| { + // turn off GlobalMaxCommission for this test. + GlobalMaxCommission::::set(None); + let pool_id = 1; + + // top up commission payee account to existential deposit + let _ = Balances::deposit_creating(&2, 5); + + // Set a commission pool 1 to 33%, with a payee set to `2` + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + pool_id, + Some((Perbill::from_percent(33), 2)), + )); + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(33), 2)) + }, + ] + ); + + // The pool earns 10 points + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 10)); + assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 7 },] + ); + + // The pool earns 17 points + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 17)); + assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 11 },] + ); + + // The pool earns 50 points + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 50)); + assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 34 },] + ); + + // The pool earns 10439 points + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 10439)); + assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 6994 },] + ); + + // Set the commission to 100% and ensure the following payout to the pool member will + // not happen. + + // When: + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + pool_id, + Some((Perbill::from_percent(100), 2)), + )); + + // Given: + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 200)); + assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(100), 2)) + },] + ); + }) + } + + #[test] + fn commission_accumulates_on_multiple_rewards() { + ExtBuilder::default().build_and_execute(|| { + let pool_id = 1; + + // Given: + + // Set initial commission of pool 1 to 10%. + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + pool_id, + Some((Perbill::from_percent(10), 2)), + )); + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(10), 2)) + }, + ] + ); + + // When: + + // The pool earns 100 points + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 100)); + + // Change commission to 20% + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + pool_id, + Some((Perbill::from_percent(20), 2)), + )); + assert_eq!( + pool_events_since_last_call(), + vec![Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(20), 2)) + },] + ); + + // The pool earns 100 points + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 100)); + + // Then: + + // Claim payout: + assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); + + // Claim commission: + assert_ok!(Pools::claim_commission(RuntimeOrigin::signed(900), pool_id)); + + // Then: + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::PaidOut { member: 10, pool_id: 1, payout: 90 + 80 }, + Event::PoolCommissionClaimed { pool_id: 1, commission: 30 } + ] + ); + }) + } + + #[test] + fn last_recorded_total_payouts_needs_commission() { + ExtBuilder::default().build_and_execute(|| { + let pool_id = 1; + + // Given: + + // Set initial commission of pool 1 to 10%. + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + pool_id, + Some((Perbill::from_percent(10), 2)), + )); + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(10), 2)) + }, + ] + ); + + // When: + + // The pool earns 100 points + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 100)); + + // Claim payout: + assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); + + // Claim commission: + assert_ok!(Pools::claim_commission(RuntimeOrigin::signed(900), pool_id)); + + // Then: + + assert_eq!( + RewardPools::::get(1).unwrap().last_recorded_total_payouts, + 90 + 10 + ); + + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::PaidOut { member: 10, pool_id: 1, payout: 90 }, + Event::PoolCommissionClaimed { pool_id: 1, commission: 10 } + ] + ); + }) + } + + #[test] + fn do_reward_payout_with_100_percent_commission() { + ExtBuilder::default().build_and_execute(|| { + // turn off GlobalMaxCommission for this test. + GlobalMaxCommission::::set(None); + + let (mut member, bonded_pool, mut reward_pool) = + Pools::get_member_with_pools(&10).unwrap(); + + // top up commission payee account to existential deposit + let _ = Balances::deposit_creating(&2, 5); + + // Set a commission pool 1 to 100%, with a payee set to `2` + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + bonded_pool.id, + Some((Perbill::from_percent(100), 2)), + )); + + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(100), 2)) + } + ] + ); + + // The pool earns 10 points + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 10)); + + // execute the payout + assert_ok!(Pools::do_reward_payout( + &10, + &mut member, + &mut BondedPool::::get(1).unwrap(), + &mut reward_pool + )); + }) + } + + #[test] + fn global_max_prevents_100_percent_commission_payout() { + ExtBuilder::default().build_and_execute(|| { + // Note: GlobalMaxCommission is set at 90%. + + let (mut member, bonded_pool, mut reward_pool) = + Pools::get_member_with_pools(&10).unwrap(); + + // top up the commission payee account to existential deposit + let _ = Balances::deposit_creating(&2, 5); + + // Set a commission pool 1 to 100%, with a payee set to `2` + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + bonded_pool.id, + Some((Perbill::from_percent(100), 2)), + )); + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PoolCommissionUpdated { + pool_id: 1, + current: Some((Perbill::from_percent(100), 2)) + } + ] + ); + + // The pool earns 10 points + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 10)); + + // execute the payout + assert_ok!(Pools::do_reward_payout( + &10, + &mut member, + &mut BondedPool::::get(1).unwrap(), + &mut reward_pool + )); + + // Confirm the commission was only 9 points out of 10 points, and the payout was 1 out + // of 10 points, reflecting the 90% global max commission. + assert_eq!( + pool_events_since_last_call(), + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 1 },] + ); + }) + } + + #[test] + fn claim_commission_works() { + ExtBuilder::default().build_and_execute(|| { + let pool_id = 1; + + let _ = Balances::deposit_creating(&900, 5); + assert_ok!(Pools::set_commission( + RuntimeOrigin::signed(900), + pool_id, + Some((Perbill::from_percent(50), 900)) + )); + assert_eq!( + pool_events_since_last_call(), + vec![ + Event::Created { depositor: 10, pool_id }, + Event::Bonded { member: 10, pool_id, bonded: 10, joined: true }, + Event::PoolCommissionUpdated { + pool_id, + current: Some((Perbill::from_percent(50), 900)) + }, + ] + ); + + // Pool earns 80 points, payout is triggered. + assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 80)); + assert_eq!( + PoolMembers::::get(10).unwrap(), + PoolMember:: { pool_id, points: 10, ..Default::default() } + ); + + assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); + assert_eq!( + pool_events_since_last_call(), + vec![Event::PaidOut { member: 10, pool_id, payout: 40 }] + ); + + // Given: + assert_eq!(RewardPool::::current_balance(pool_id), 40); + + // Pool does not exist + assert_noop!( + Pools::claim_commission(RuntimeOrigin::signed(900), 9999,), + Error::::PoolNotFound + ); + + // Does not have permission. + assert_noop!( + Pools::claim_commission(RuntimeOrigin::signed(10), pool_id,), + Error::::DoesNotHavePermission + ); + + // When: + assert_ok!(Pools::claim_commission(RuntimeOrigin::signed(900), pool_id)); + + // Then: + assert_eq!(RewardPool::::current_balance(pool_id), 0); + + // No more pending commission. + assert_noop!( + Pools::claim_commission(RuntimeOrigin::signed(900), pool_id,), + Error::::NoPendingCommission + ); + }) + } +} diff --git a/frame/nomination-pools/src/weights.rs b/frame/nomination-pools/src/weights.rs index ca7de7be6e7c6..cf0048fa48dd9 100644 --- a/frame/nomination-pools/src/weights.rs +++ b/frame/nomination-pools/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_nomination_pools //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-ehxwxxsd-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -33,7 +33,7 @@ // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json // --pallet=pallet_nomination_pools // --chain=dev // --header=./HEADER-APACHE2 @@ -64,7 +64,11 @@ pub trait WeightInfo { fn set_configs() -> Weight; fn update_roles() -> Weight; fn chill() -> Weight; + fn set_commission() -> Weight; + fn set_commission_max() -> Weight; + fn set_commission_change_rate() -> Weight; fn set_claim_permission() -> Weight; + fn claim_commission() -> Weight; } /// Weights for pallet_nomination_pools using the Substrate node and recommended hardware. @@ -75,13 +79,15 @@ impl WeightInfo for SubstrateWeight { /// Storage: NominationPools PoolMembers (r:1 w:1) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:1) /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: System Account (r:2 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: NominationPools MaxPoolMembersPerPool (r:1 w:0) @@ -98,20 +104,21 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn join() -> Weight { // Proof Size summary in bytes: - // Measured: `3573` - // Estimated: `37988` - // Minimum execution time: 169_857 nanoseconds. - Weight::from_parts(173_895_000, 0) - .saturating_add(Weight::from_parts(0, 37988)) - .saturating_add(T::DbWeight::get().reads(17_u64)) + // Measured: `3650` + // Estimated: `52435` + // Minimum execution time: 160_401_000 picoseconds. + Weight::from_parts(161_798_000, 52435) + .saturating_add(T::DbWeight::get().reads(18_u64)) .saturating_add(T::DbWeight::get().writes(12_u64)) } /// Storage: NominationPools PoolMembers (r:1 w:1) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: System Account (r:3 w:2) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) @@ -126,12 +133,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `3615` - // Estimated: `38583` - // Minimum execution time: 167_372 nanoseconds. - Weight::from_parts(168_776_000, 0) - .saturating_add(Weight::from_parts(0, 38583)) - .saturating_add(T::DbWeight::get().reads(14_u64)) + // Measured: `3692` + // Estimated: `49070` + // Minimum execution time: 157_668_000 picoseconds. + Weight::from_parts(161_129_000, 49070) + .saturating_add(T::DbWeight::get().reads(15_u64)) .saturating_add(T::DbWeight::get().writes(12_u64)) } /// Storage: NominationPools ClaimPermissions (r:1 w:0) @@ -139,9 +145,11 @@ impl WeightInfo for SubstrateWeight { /// Storage: NominationPools PoolMembers (r:1 w:1) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: System Account (r:3 w:3) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) @@ -156,12 +164,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra_other() -> Weight { // Proof Size summary in bytes: - // Measured: `3680` - // Estimated: `41099` - // Minimum execution time: 186_346 nanoseconds. - Weight::from_parts(191_308_000, 0) - .saturating_add(Weight::from_parts(0, 41099)) - .saturating_add(T::DbWeight::get().reads(15_u64)) + // Measured: `3757` + // Estimated: `52576` + // Minimum execution time: 176_034_000 picoseconds. + Weight::from_parts(176_956_000, 52576) + .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(13_u64)) } /// Storage: NominationPools ClaimPermissions (r:1 w:0) @@ -169,31 +176,34 @@ impl WeightInfo for SubstrateWeight { /// Storage: NominationPools PoolMembers (r:1 w:1) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn claim_payout() -> Weight { // Proof Size summary in bytes: - // Measured: `1254` - // Estimated: `13005` - // Minimum execution time: 61_423 nanoseconds. - Weight::from_parts(63_219_000, 0) - .saturating_add(Weight::from_parts(0, 13005)) - .saturating_add(T::DbWeight::get().reads(5_u64)) + // Measured: `1331` + // Estimated: `19532` + // Minimum execution time: 61_551_000 picoseconds. + Weight::from_parts(62_201_000, 19532) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: NominationPools PoolMembers (r:1 w:1) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:1) /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: System Account (r:2 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Staking CurrentEra (r:1 w:0) @@ -212,20 +222,17 @@ impl WeightInfo for SubstrateWeight { /// Proof: NominationPools SubPoolsStorage (max_values: None, max_size: Some(24382), added: 26857, mode: MaxEncodedLen) /// Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) /// Proof: NominationPools CounterForSubPoolsStorage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: NominationPools ClaimPermissions (r:0 w:1) - /// Proof: NominationPools ClaimPermissions (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) fn unbond() -> Weight { // Proof Size summary in bytes: - // Measured: `3858` - // Estimated: `67379` - // Minimum execution time: 174_532 nanoseconds. - Weight::from_parts(180_032_000, 0) - .saturating_add(Weight::from_parts(0, 67379)) - .saturating_add(T::DbWeight::get().reads(18_u64)) - .saturating_add(T::DbWeight::get().writes(14_u64)) + // Measured: `3935` + // Estimated: `82816` + // Minimum execution time: 162_755_000 picoseconds. + Weight::from_parts(163_518_000, 82816) + .saturating_add(T::DbWeight::get().reads(19_u64)) + .saturating_add(T::DbWeight::get().writes(13_u64)) } /// Storage: NominationPools BondedPools (r:1 w:0) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:1) @@ -237,13 +244,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 100]`. fn pool_withdraw_unbonded(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1779` - // Estimated: `13025` - // Minimum execution time: 55_327 nanoseconds. - Weight::from_parts(58_947_746, 0) - .saturating_add(Weight::from_parts(0, 13025)) - // Standard Error: 1_589 - .saturating_add(Weight::from_parts(40_696, 0).saturating_mul(s.into())) + // Measured: `1783` + // Estimated: `18031` + // Minimum execution time: 54_752_000 picoseconds. + Weight::from_parts(56_248_171, 18031) + // Standard Error: 1_891 + .saturating_add(Weight::from_parts(4_767, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -252,7 +258,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: Staking CurrentEra (r:1 w:0) /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools SubPoolsStorage (r:1 w:1) /// Proof: NominationPools SubPoolsStorage (max_values: None, max_size: Some(24382), added: 26857, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) @@ -265,25 +271,26 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: NominationPools CounterForPoolMembers (r:1 w:1) /// Proof: NominationPools CounterForPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools ClaimPermissions (r:0 w:1) + /// Proof: NominationPools ClaimPermissions (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2303` - // Estimated: `45696` - // Minimum execution time: 105_923 nanoseconds. - Weight::from_parts(110_572_476, 0) - .saturating_add(Weight::from_parts(0, 45696)) - // Standard Error: 2_438 - .saturating_add(Weight::from_parts(69_045, 0).saturating_mul(s.into())) + // Measured: `2307` + // Estimated: `54662` + // Minimum execution time: 106_166_000 picoseconds. + Weight::from_parts(107_806_373, 54662) + // Standard Error: 6_985 + .saturating_add(Weight::from_parts(18_449, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) } /// Storage: NominationPools PoolMembers (r:1 w:1) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: Staking CurrentEra (r:1 w:0) /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools SubPoolsStorage (r:1 w:1) /// Proof: NominationPools SubPoolsStorage (max_values: None, max_size: Some(24382), added: 26857, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:1) @@ -307,7 +314,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: NominationPools CounterForReversePoolIdLookup (r:1 w:1) /// Proof: NominationPools CounterForReversePoolIdLookup (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) /// Storage: NominationPools CounterForRewardPools (r:1 w:1) /// Proof: NominationPools CounterForRewardPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) @@ -318,16 +325,19 @@ impl WeightInfo for SubstrateWeight { /// Proof: NominationPools CounterForBondedPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Staking Payee (r:0 w:1) /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: NominationPools ClaimPermissions (r:0 w:1) + /// Proof: NominationPools ClaimPermissions (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. - fn withdraw_unbonded_kill(_s: u32, ) -> Weight { + fn withdraw_unbonded_kill(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2690` - // Estimated: `68812` - // Minimum execution time: 169_700 nanoseconds. - Weight::from_parts(178_693_541, 0) - .saturating_add(Weight::from_parts(0, 68812)) + // Measured: `2694` + // Estimated: `87714` + // Minimum execution time: 170_047_000 picoseconds. + Weight::from_parts(172_125_770, 87714) + // Standard Error: 2_599 + .saturating_add(Weight::from_parts(9_964, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(20_u64)) - .saturating_add(T::DbWeight::get().writes(17_u64)) + .saturating_add(T::DbWeight::get().writes(18_u64)) } /// Storage: NominationPools LastPoolId (r:1 w:1) /// Proof: NominationPools LastPoolId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -360,7 +370,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: Balances Locks (r:1 w:1) /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) /// Storage: NominationPools CounterForRewardPools (r:1 w:1) /// Proof: NominationPools CounterForRewardPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools ReversePoolIdLookup (r:1 w:1) @@ -368,21 +378,20 @@ impl WeightInfo for SubstrateWeight { /// Storage: NominationPools CounterForReversePoolIdLookup (r:1 w:1) /// Proof: NominationPools CounterForReversePoolIdLookup (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: Staking Payee (r:0 w:1) /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn create() -> Weight { // Proof Size summary in bytes: // Measured: `1321` - // Estimated: `31522` - // Minimum execution time: 145_976 nanoseconds. - Weight::from_parts(150_664_000, 0) - .saturating_add(Weight::from_parts(0, 31522)) + // Estimated: `51410` + // Minimum execution time: 149_672_000 picoseconds. + Weight::from_parts(153_613_000, 51410) .saturating_add(T::DbWeight::get().reads(21_u64)) .saturating_add(T::DbWeight::get().writes(15_u64)) } /// Storage: NominationPools BondedPools (r:1 w:0) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:0) @@ -408,36 +417,34 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1909` - // Estimated: `21998 + n * (2520 ±0)` - // Minimum execution time: 69_288 nanoseconds. - Weight::from_parts(71_075_293, 0) - .saturating_add(Weight::from_parts(0, 21998)) - // Standard Error: 10_508 - .saturating_add(Weight::from_parts(1_384_674, 0).saturating_mul(n.into())) + // Measured: `1913` + // Estimated: `33934 + n * (2520 ±0)` + // Minimum execution time: 68_892_000 picoseconds. + Weight::from_parts(69_062_946, 33934) + // Standard Error: 6_448 + .saturating_add(Weight::from_parts(1_422_774, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(5_u64)) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(n.into())) } /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:0) /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) fn set_state() -> Weight { // Proof Size summary in bytes: - // Measured: `1498` - // Estimated: `8752` - // Minimum execution time: 36_410 nanoseconds. - Weight::from_parts(37_585_000, 0) - .saturating_add(Weight::from_parts(0, 8752)) + // Measured: `1502` + // Estimated: `11778` + // Minimum execution time: 36_447_000 picoseconds. + Weight::from_parts(36_837_000, 11778) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: NominationPools BondedPools (r:1 w:0) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools Metadata (r:1 w:1) /// Proof: NominationPools Metadata (max_values: None, max_size: Some(270), added: 2745, mode: MaxEncodedLen) /// Storage: NominationPools CounterForMetadata (r:1 w:1) @@ -445,13 +452,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[1, 256]`. fn set_metadata(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `5883` - // Minimum execution time: 14_322 nanoseconds. - Weight::from_parts(15_328_204, 0) - .saturating_add(Weight::from_parts(0, 5883)) - // Standard Error: 161 - .saturating_add(Weight::from_parts(1_406, 0).saturating_mul(n.into())) + // Measured: `563` + // Estimated: `8909` + // Minimum execution time: 15_221_000 picoseconds. + Weight::from_parts(15_632_286, 8909) + // Standard Error: 343 + .saturating_add(Weight::from_parts(2_299, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -463,31 +469,31 @@ impl WeightInfo for SubstrateWeight { /// Proof: NominationPools MaxPoolMembersPerPool (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools MinCreateBond (r:0 w:1) /// Proof: NominationPools MinCreateBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:0 w:1) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools MaxPools (r:0 w:1) /// Proof: NominationPools MaxPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn set_configs() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_968 nanoseconds. - Weight::from_parts(6_245_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(5_u64)) + // Minimum execution time: 7_409_000 picoseconds. + Weight::from_parts(7_702_000, 0) + .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) fn update_roles() -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `2639` - // Minimum execution time: 18_979 nanoseconds. - Weight::from_parts(19_795_000, 0) - .saturating_add(Weight::from_parts(0, 2639)) + // Measured: `563` + // Estimated: `3685` + // Minimum execution time: 20_451_000 picoseconds. + Weight::from_parts(20_703_000, 3685) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: NominationPools BondedPools (r:1 w:0) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:0) @@ -506,14 +512,52 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill() -> Weight { // Proof Size summary in bytes: - // Measured: `2136` - // Estimated: `20489` - // Minimum execution time: 68_145 nanoseconds. - Weight::from_parts(70_444_000, 0) - .saturating_add(Weight::from_parts(0, 20489)) + // Measured: `2140` + // Estimated: `29455` + // Minimum execution time: 66_001_000 picoseconds. + Weight::from_parts(66_894_000, 29455) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn set_commission() -> Weight { + // Proof Size summary in bytes: + // Measured: `866` + // Estimated: `12324` + // Minimum execution time: 34_011_000 picoseconds. + Weight::from_parts(34_521_000, 12324) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) + fn set_commission_max() -> Weight { + // Proof Size summary in bytes: + // Measured: `603` + // Estimated: `3685` + // Minimum execution time: 19_524_000 picoseconds. + Weight::from_parts(19_855_000, 3685) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) + fn set_commission_change_rate() -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `3685` + // Minimum execution time: 20_457_000 picoseconds. + Weight::from_parts(20_698_000, 3685) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } /// Storage: NominationPools PoolMembers (r:1 w:0) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: NominationPools ClaimPermissions (r:1 w:1) @@ -521,13 +565,29 @@ impl WeightInfo for SubstrateWeight { fn set_claim_permission() -> Weight { // Proof Size summary in bytes: // Measured: `542` - // Estimated: `5228` - // Minimum execution time: 15_112 nanoseconds. - Weight::from_parts(15_897_000, 0) - .saturating_add(Weight::from_parts(0, 5228)) + // Estimated: `7208` + // Minimum execution time: 15_183_000 picoseconds. + Weight::from_parts(15_597_000, 7208) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } + /// Storage: NominationPools BondedPools (r:1 w:0) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn claim_commission() -> Weight { + // Proof Size summary in bytes: + // Measured: `1096` + // Estimated: `12324` + // Minimum execution time: 48_957_000 picoseconds. + Weight::from_parts(50_207_000, 12324) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } } // For backwards compatibility and tests @@ -537,13 +597,15 @@ impl WeightInfo for () { /// Storage: NominationPools PoolMembers (r:1 w:1) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:1) /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: System Account (r:2 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: NominationPools MaxPoolMembersPerPool (r:1 w:0) @@ -560,20 +622,21 @@ impl WeightInfo for () { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn join() -> Weight { // Proof Size summary in bytes: - // Measured: `3573` - // Estimated: `37988` - // Minimum execution time: 169_857 nanoseconds. - Weight::from_parts(173_895_000, 0) - .saturating_add(Weight::from_parts(0, 37988)) - .saturating_add(RocksDbWeight::get().reads(17_u64)) + // Measured: `3650` + // Estimated: `52435` + // Minimum execution time: 160_401_000 picoseconds. + Weight::from_parts(161_798_000, 52435) + .saturating_add(RocksDbWeight::get().reads(18_u64)) .saturating_add(RocksDbWeight::get().writes(12_u64)) } /// Storage: NominationPools PoolMembers (r:1 w:1) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: System Account (r:3 w:2) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) @@ -588,12 +651,11 @@ impl WeightInfo for () { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `3615` - // Estimated: `38583` - // Minimum execution time: 167_372 nanoseconds. - Weight::from_parts(168_776_000, 0) - .saturating_add(Weight::from_parts(0, 38583)) - .saturating_add(RocksDbWeight::get().reads(14_u64)) + // Measured: `3692` + // Estimated: `49070` + // Minimum execution time: 157_668_000 picoseconds. + Weight::from_parts(161_129_000, 49070) + .saturating_add(RocksDbWeight::get().reads(15_u64)) .saturating_add(RocksDbWeight::get().writes(12_u64)) } /// Storage: NominationPools ClaimPermissions (r:1 w:0) @@ -601,9 +663,11 @@ impl WeightInfo for () { /// Storage: NominationPools PoolMembers (r:1 w:1) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: System Account (r:3 w:3) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) @@ -618,12 +682,11 @@ impl WeightInfo for () { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra_other() -> Weight { // Proof Size summary in bytes: - // Measured: `3680` - // Estimated: `41099` - // Minimum execution time: 186_346 nanoseconds. - Weight::from_parts(191_308_000, 0) - .saturating_add(Weight::from_parts(0, 41099)) - .saturating_add(RocksDbWeight::get().reads(15_u64)) + // Measured: `3757` + // Estimated: `52576` + // Minimum execution time: 176_034_000 picoseconds. + Weight::from_parts(176_956_000, 52576) + .saturating_add(RocksDbWeight::get().reads(16_u64)) .saturating_add(RocksDbWeight::get().writes(13_u64)) } /// Storage: NominationPools ClaimPermissions (r:1 w:0) @@ -631,31 +694,34 @@ impl WeightInfo for () { /// Storage: NominationPools PoolMembers (r:1 w:1) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn claim_payout() -> Weight { // Proof Size summary in bytes: - // Measured: `1254` - // Estimated: `13005` - // Minimum execution time: 61_423 nanoseconds. - Weight::from_parts(63_219_000, 0) - .saturating_add(Weight::from_parts(0, 13005)) - .saturating_add(RocksDbWeight::get().reads(5_u64)) + // Measured: `1331` + // Estimated: `19532` + // Minimum execution time: 61_551_000 picoseconds. + Weight::from_parts(62_201_000, 19532) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } /// Storage: NominationPools PoolMembers (r:1 w:1) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:1) /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: System Account (r:2 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Staking CurrentEra (r:1 w:0) @@ -674,20 +740,17 @@ impl WeightInfo for () { /// Proof: NominationPools SubPoolsStorage (max_values: None, max_size: Some(24382), added: 26857, mode: MaxEncodedLen) /// Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) /// Proof: NominationPools CounterForSubPoolsStorage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: NominationPools ClaimPermissions (r:0 w:1) - /// Proof: NominationPools ClaimPermissions (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) fn unbond() -> Weight { // Proof Size summary in bytes: - // Measured: `3858` - // Estimated: `67379` - // Minimum execution time: 174_532 nanoseconds. - Weight::from_parts(180_032_000, 0) - .saturating_add(Weight::from_parts(0, 67379)) - .saturating_add(RocksDbWeight::get().reads(18_u64)) - .saturating_add(RocksDbWeight::get().writes(14_u64)) + // Measured: `3935` + // Estimated: `82816` + // Minimum execution time: 162_755_000 picoseconds. + Weight::from_parts(163_518_000, 82816) + .saturating_add(RocksDbWeight::get().reads(19_u64)) + .saturating_add(RocksDbWeight::get().writes(13_u64)) } /// Storage: NominationPools BondedPools (r:1 w:0) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:1) @@ -699,13 +762,12 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 100]`. fn pool_withdraw_unbonded(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1779` - // Estimated: `13025` - // Minimum execution time: 55_327 nanoseconds. - Weight::from_parts(58_947_746, 0) - .saturating_add(Weight::from_parts(0, 13025)) - // Standard Error: 1_589 - .saturating_add(Weight::from_parts(40_696, 0).saturating_mul(s.into())) + // Measured: `1783` + // Estimated: `18031` + // Minimum execution time: 54_752_000 picoseconds. + Weight::from_parts(56_248_171, 18031) + // Standard Error: 1_891 + .saturating_add(Weight::from_parts(4_767, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -714,7 +776,7 @@ impl WeightInfo for () { /// Storage: Staking CurrentEra (r:1 w:0) /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools SubPoolsStorage (r:1 w:1) /// Proof: NominationPools SubPoolsStorage (max_values: None, max_size: Some(24382), added: 26857, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) @@ -727,25 +789,26 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: NominationPools CounterForPoolMembers (r:1 w:1) /// Proof: NominationPools CounterForPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools ClaimPermissions (r:0 w:1) + /// Proof: NominationPools ClaimPermissions (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2303` - // Estimated: `45696` - // Minimum execution time: 105_923 nanoseconds. - Weight::from_parts(110_572_476, 0) - .saturating_add(Weight::from_parts(0, 45696)) - // Standard Error: 2_438 - .saturating_add(Weight::from_parts(69_045, 0).saturating_mul(s.into())) + // Measured: `2307` + // Estimated: `54662` + // Minimum execution time: 106_166_000 picoseconds. + Weight::from_parts(107_806_373, 54662) + // Standard Error: 6_985 + .saturating_add(Weight::from_parts(18_449, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) - .saturating_add(RocksDbWeight::get().writes(7_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) } /// Storage: NominationPools PoolMembers (r:1 w:1) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: Staking CurrentEra (r:1 w:0) /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools SubPoolsStorage (r:1 w:1) /// Proof: NominationPools SubPoolsStorage (max_values: None, max_size: Some(24382), added: 26857, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:1) @@ -769,7 +832,7 @@ impl WeightInfo for () { /// Storage: NominationPools CounterForReversePoolIdLookup (r:1 w:1) /// Proof: NominationPools CounterForReversePoolIdLookup (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) /// Storage: NominationPools CounterForRewardPools (r:1 w:1) /// Proof: NominationPools CounterForRewardPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) @@ -780,16 +843,19 @@ impl WeightInfo for () { /// Proof: NominationPools CounterForBondedPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Staking Payee (r:0 w:1) /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: NominationPools ClaimPermissions (r:0 w:1) + /// Proof: NominationPools ClaimPermissions (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. - fn withdraw_unbonded_kill(_s: u32, ) -> Weight { + fn withdraw_unbonded_kill(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2690` - // Estimated: `68812` - // Minimum execution time: 169_700 nanoseconds. - Weight::from_parts(178_693_541, 0) - .saturating_add(Weight::from_parts(0, 68812)) + // Measured: `2694` + // Estimated: `87714` + // Minimum execution time: 170_047_000 picoseconds. + Weight::from_parts(172_125_770, 87714) + // Standard Error: 2_599 + .saturating_add(Weight::from_parts(9_964, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(20_u64)) - .saturating_add(RocksDbWeight::get().writes(17_u64)) + .saturating_add(RocksDbWeight::get().writes(18_u64)) } /// Storage: NominationPools LastPoolId (r:1 w:1) /// Proof: NominationPools LastPoolId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -822,7 +888,7 @@ impl WeightInfo for () { /// Storage: Balances Locks (r:1 w:1) /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: NominationPools RewardPools (r:1 w:1) - /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) /// Storage: NominationPools CounterForRewardPools (r:1 w:1) /// Proof: NominationPools CounterForRewardPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools ReversePoolIdLookup (r:1 w:1) @@ -830,21 +896,20 @@ impl WeightInfo for () { /// Storage: NominationPools CounterForReversePoolIdLookup (r:1 w:1) /// Proof: NominationPools CounterForReversePoolIdLookup (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: Staking Payee (r:0 w:1) /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn create() -> Weight { // Proof Size summary in bytes: // Measured: `1321` - // Estimated: `31522` - // Minimum execution time: 145_976 nanoseconds. - Weight::from_parts(150_664_000, 0) - .saturating_add(Weight::from_parts(0, 31522)) + // Estimated: `51410` + // Minimum execution time: 149_672_000 picoseconds. + Weight::from_parts(153_613_000, 51410) .saturating_add(RocksDbWeight::get().reads(21_u64)) .saturating_add(RocksDbWeight::get().writes(15_u64)) } /// Storage: NominationPools BondedPools (r:1 w:0) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:0) @@ -870,36 +935,34 @@ impl WeightInfo for () { /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1909` - // Estimated: `21998 + n * (2520 ±0)` - // Minimum execution time: 69_288 nanoseconds. - Weight::from_parts(71_075_293, 0) - .saturating_add(Weight::from_parts(0, 21998)) - // Standard Error: 10_508 - .saturating_add(Weight::from_parts(1_384_674, 0).saturating_mul(n.into())) + // Measured: `1913` + // Estimated: `33934 + n * (2520 ±0)` + // Minimum execution time: 68_892_000 picoseconds. + Weight::from_parts(69_062_946, 33934) + // Standard Error: 6_448 + .saturating_add(Weight::from_parts(1_422_774, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(5_u64)) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(n.into())) } /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:0) /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) fn set_state() -> Weight { // Proof Size summary in bytes: - // Measured: `1498` - // Estimated: `8752` - // Minimum execution time: 36_410 nanoseconds. - Weight::from_parts(37_585_000, 0) - .saturating_add(Weight::from_parts(0, 8752)) + // Measured: `1502` + // Estimated: `11778` + // Minimum execution time: 36_447_000 picoseconds. + Weight::from_parts(36_837_000, 11778) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: NominationPools BondedPools (r:1 w:0) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: NominationPools Metadata (r:1 w:1) /// Proof: NominationPools Metadata (max_values: None, max_size: Some(270), added: 2745, mode: MaxEncodedLen) /// Storage: NominationPools CounterForMetadata (r:1 w:1) @@ -907,13 +970,12 @@ impl WeightInfo for () { /// The range of component `n` is `[1, 256]`. fn set_metadata(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `5883` - // Minimum execution time: 14_322 nanoseconds. - Weight::from_parts(15_328_204, 0) - .saturating_add(Weight::from_parts(0, 5883)) - // Standard Error: 161 - .saturating_add(Weight::from_parts(1_406, 0).saturating_mul(n.into())) + // Measured: `563` + // Estimated: `8909` + // Minimum execution time: 15_221_000 picoseconds. + Weight::from_parts(15_632_286, 8909) + // Standard Error: 343 + .saturating_add(Weight::from_parts(2_299, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -925,31 +987,31 @@ impl WeightInfo for () { /// Proof: NominationPools MaxPoolMembersPerPool (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools MinCreateBond (r:0 w:1) /// Proof: NominationPools MinCreateBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:0 w:1) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: NominationPools MaxPools (r:0 w:1) /// Proof: NominationPools MaxPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn set_configs() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_968 nanoseconds. - Weight::from_parts(6_245_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) + // Minimum execution time: 7_409_000 picoseconds. + Weight::from_parts(7_702_000, 0) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: NominationPools BondedPools (r:1 w:1) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) fn update_roles() -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `2639` - // Minimum execution time: 18_979 nanoseconds. - Weight::from_parts(19_795_000, 0) - .saturating_add(Weight::from_parts(0, 2639)) + // Measured: `563` + // Estimated: `3685` + // Minimum execution time: 20_451_000 picoseconds. + Weight::from_parts(20_703_000, 3685) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: NominationPools BondedPools (r:1 w:0) - /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:0) @@ -968,14 +1030,52 @@ impl WeightInfo for () { /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill() -> Weight { // Proof Size summary in bytes: - // Measured: `2136` - // Estimated: `20489` - // Minimum execution time: 68_145 nanoseconds. - Weight::from_parts(70_444_000, 0) - .saturating_add(Weight::from_parts(0, 20489)) + // Measured: `2140` + // Estimated: `29455` + // Minimum execution time: 66_001_000 picoseconds. + Weight::from_parts(66_894_000, 29455) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn set_commission() -> Weight { + // Proof Size summary in bytes: + // Measured: `866` + // Estimated: `12324` + // Minimum execution time: 34_011_000 picoseconds. + Weight::from_parts(34_521_000, 12324) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) + fn set_commission_max() -> Weight { + // Proof Size summary in bytes: + // Measured: `603` + // Estimated: `3685` + // Minimum execution time: 19_524_000 picoseconds. + Weight::from_parts(19_855_000, 3685) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) + fn set_commission_change_rate() -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `3685` + // Minimum execution time: 20_457_000 picoseconds. + Weight::from_parts(20_698_000, 3685) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } /// Storage: NominationPools PoolMembers (r:1 w:0) /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) /// Storage: NominationPools ClaimPermissions (r:1 w:1) @@ -983,11 +1083,27 @@ impl WeightInfo for () { fn set_claim_permission() -> Weight { // Proof Size summary in bytes: // Measured: `542` - // Estimated: `5228` - // Minimum execution time: 15_112 nanoseconds. - Weight::from_parts(15_897_000, 0) - .saturating_add(Weight::from_parts(0, 5228)) + // Estimated: `7208` + // Minimum execution time: 15_183_000 picoseconds. + Weight::from_parts(15_597_000, 7208) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } + /// Storage: NominationPools BondedPools (r:1 w:0) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: NominationPools GlobalMaxCommission (r:1 w:0) + /// Proof: NominationPools GlobalMaxCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn claim_commission() -> Weight { + // Proof Size summary in bytes: + // Measured: `1096` + // Estimated: `12324` + // Minimum execution time: 48_957_000 picoseconds. + Weight::from_parts(50_207_000, 12324) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } } diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 85d0dd6c50677..0550c8e0ca708 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -25,7 +25,7 @@ use frame_support::{ }; use sp_runtime::{ traits::{Convert, IdentityLookup}, - FixedU128, + FixedU128, Perbill, }; type AccountId = u128; @@ -209,6 +209,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { max_pools: Some(3), max_members_per_pool: Some(5), max_members: Some(3 * 5), + global_max_commission: Some(Perbill::from_percent(90)), } .assimilate_storage(&mut storage) .unwrap(); From d3fd5432ae6f6fcec87844b6eeb21f80ab4e31eb Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Wed, 15 Mar 2023 10:36:23 -0600 Subject: [PATCH 16/80] Pallet dispatchable+storage doc module. (#13341) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc-only pallet * cargo fmt * generics fix for dispatchables * use a module instead * add doc comment warning that the dispatchable functions are generated * clean up * fix typo * hide Instance4-Instance16 from `pallet` module docs * revamp Instance1-16 comment * Document storage types Signed-off-by: Oliver Tale-Yazdi * fmt Signed-off-by: Oliver Tale-Yazdi * remove unused variables * crate::Call => Call Co-authored-by: Bastian Köcher * fix indentation Co-authored-by: Bastian Köcher * remove unneeded block Co-authored-by: Bastian Köcher * don't need a Vec Co-authored-by: Bastian Köcher * add "doc only" to coment Co-authored-by: Bastian Köcher * crate::Call => Call Co-authored-by: Bastian Köcher * cargo fmt --------- Signed-off-by: Oliver Tale-Yazdi Co-authored-by: Sam Johnson Co-authored-by: Oliver Tale-Yazdi Co-authored-by: Bastian Köcher Co-authored-by: parity-processbot <> --- .../procedural/src/pallet/expand/doc_only.rs | 79 +++++++++++++++++++ .../procedural/src/pallet/expand/mod.rs | 3 + frame/support/src/instances.rs | 49 ++++++++---- 3 files changed, 115 insertions(+), 16 deletions(-) create mode 100644 frame/support/procedural/src/pallet/expand/doc_only.rs diff --git a/frame/support/procedural/src/pallet/expand/doc_only.rs b/frame/support/procedural/src/pallet/expand/doc_only.rs new file mode 100644 index 0000000000000..32c9329f29498 --- /dev/null +++ b/frame/support/procedural/src/pallet/expand/doc_only.rs @@ -0,0 +1,79 @@ +// This file is part of Substrate. + +// Copyright (C) 2023 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 proc_macro2::Span; + +use crate::pallet::Def; + +pub fn expand_doc_only(def: &mut Def) -> proc_macro2::TokenStream { + let storage_names = def.storages.iter().map(|storage| &storage.ident); + let storage_docs = def.storages.iter().map(|storage| &storage.docs); + let dispatchables = if let Some(call_def) = &def.call { + let type_impl_generics = def.type_impl_generics(Span::call_site()); + call_def + .methods + .iter() + .map(|method| { + let name = &method.name; + let args = &method + .args + .iter() + .map(|(_, arg_name, arg_type)| quote::quote!( #arg_name: #arg_type, )) + .collect::(); + let docs = &method.docs; + let line_2 = + format!(" designed to document the [`{}`][`Call::{}`] variant of", name, name); + quote::quote!( + #( #[doc = #docs] )* + /// + /// --- + /// + /// NOTE: This function is an automatically generated, doc only, uncallable stub. + #[ doc = #line_2 ] + /// the pallet [`Call`] enum. You should not attempt to call this function + /// directly. + pub fn #name<#type_impl_generics>(#args) { unreachable!(); } + ) + }) + .collect::() + } else { + quote::quote!() + }; + + quote::quote!( + /// Auto-generated docs-only module listing all defined storage types for this pallet. + /// Note that members of this module cannot be used directly and are only provided for + /// documentation purposes. + #[cfg(doc)] + pub mod storage_types { + use super::*; + #( + #( #[doc = #storage_docs] )* + pub struct #storage_names(); + )* + } + + /// Auto-generated docs-only module listing all defined dispatchables for this pallet. + /// Note that members of this module cannot be used directly and are only provided for + /// documentation purposes. + #[cfg(doc)] + pub mod dispatchables { + use super::*; + #dispatchables + } + ) +} diff --git a/frame/support/procedural/src/pallet/expand/mod.rs b/frame/support/procedural/src/pallet/expand/mod.rs index 09a25a7101ee7..926ab0ec82d73 100644 --- a/frame/support/procedural/src/pallet/expand/mod.rs +++ b/frame/support/procedural/src/pallet/expand/mod.rs @@ -18,6 +18,7 @@ mod call; mod config; mod constants; +mod doc_only; mod documentation; mod error; mod event; @@ -72,6 +73,7 @@ pub fn expand(mut def: Def) -> proc_macro2::TokenStream { let origins = origin::expand_origins(&mut def); let validate_unsigned = validate_unsigned::expand_validate_unsigned(&mut def); let tt_default_parts = tt_default_parts::expand_tt_default_parts(&mut def); + let doc_only = doc_only::expand_doc_only(&mut def); if get_doc_literals(&def.item.attrs).is_empty() { def.item.attrs.push(syn::parse_quote!( @@ -103,6 +105,7 @@ pub fn expand(mut def: Def) -> proc_macro2::TokenStream { #origins #validate_unsigned #tt_default_parts + #doc_only ); def.item diff --git a/frame/support/src/instances.rs b/frame/support/src/instances.rs index 482051c1f36d0..396018d5cbd52 100644 --- a/frame/support/src/instances.rs +++ b/frame/support/src/instances.rs @@ -31,66 +31,83 @@ //! NOTE: [`frame_support::pallet`] will reexport them inside the module, in order to make them //! accessible to [`frame_support::construct_runtime`]. -/// Instance1 to be used for instantiable pallet define with `pallet` macro. +/// `Instance1` to be used for instantiable palllets defined with the +/// [`#[pallet]`](`frame_support::pallet`) macro. Instances 2-16 are also available but are hidden +/// from docs. #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance1; -/// Instance2 to be used for instantiable pallet define with `pallet` macro. +/// `Instance2` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance2; -/// Instance3 to be used for instantiable pallet define with `pallet` macro. +/// `Instance3` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance3; -/// Instance4 to be used for instantiable pallet define with `pallet` macro. +/// `Instance4` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance4; -/// Instance5 to be used for instantiable pallet define with `pallet` macro. +/// `Instance5` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance5; -/// Instance6 to be used for instantiable pallet define with `pallet` macro. +/// `Instance6` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance6; -/// Instance7 to be used for instantiable pallet define with `pallet` macro. +/// `Instance7` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance7; -/// Instance8 to be used for instantiable pallet define with `pallet` macro. +/// `Instance8` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance8; -/// Instance9 to be used for instantiable pallet define with `pallet` macro. +/// `Instance9` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance9; -/// Instance10 to be used for instantiable pallet define with `pallet` macro. +/// `Instance10` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance10; -/// Instance11 to be used for instantiable pallet define with `pallet` macro. +/// `Instance11` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance11; -/// Instance12 to be used for instantiable pallet define with `pallet` macro. +/// `Instance12` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance12; -/// Instance13 to be used for instantiable pallet define with `pallet` macro. +/// `Instance13` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance13; -/// Instance14 to be used for instantiable pallet define with `pallet` macro. +/// `Instance14` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance14; -/// Instance15 to be used for instantiable pallet define with `pallet` macro. +/// `Instance15` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance15; -/// Instance16 to be used for instantiable pallet define with `pallet` macro. +/// `Instance16` to be used for instantiable palllets defined with the `#[pallet]` macro. +#[doc(hidden)] #[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)] pub struct Instance16; From ba87188cce8c0a11c9542d7363cd5ddd46db2740 Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Wed, 15 Mar 2023 17:37:34 +0100 Subject: [PATCH 17/80] timestamp gitlab ci job outputs (#13605) * timestamp gitlab ci job outputs Based on previous work by @alvicsam in #13047. * inline timestamp script Some of our jobs don't check out the substrate repo. * include .timestamp in pipelines overriding the default before_script Still not including it in the zombienet jobs, they have their own timestamping anyway. * move timestamp.yml to shared pipeline repo https://gitlab.parity.io/parity/infrastructure/ci_cd/shared --- .gitlab-ci.yml | 4 ++++ scripts/ci/gitlab/pipeline/build.yml | 3 +++ scripts/ci/gitlab/pipeline/test.yml | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 94fb3c608b771..44f98db3bf185 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -113,6 +113,7 @@ variables: .kubernetes-env: image: "${CI_IMAGE}" before_script: + - !reference [.timestamp, before_script] - !reference [.job-switcher, before_script] - !reference [.prepare-env, before_script] tags: @@ -141,6 +142,7 @@ variables: .docker-env: image: "${CI_IMAGE}" before_script: + - !reference [.timestamp, before_script] - !reference [.job-switcher, before_script] - !reference [.prepare-env, before_script] - !reference [.rust-info-script, script] @@ -310,6 +312,8 @@ include: - local: scripts/ci/gitlab/default-pipeline.yml rules: - if: $PIPELINE != "automatic-crate-publishing" + - project: parity/infrastructure/ci_cd/shared + file: /common/timestamp.yml #### stage: notify diff --git a/scripts/ci/gitlab/pipeline/build.yml b/scripts/ci/gitlab/pipeline/build.yml index 02f25a02a2c22..0a36599c70e24 100644 --- a/scripts/ci/gitlab/pipeline/build.yml +++ b/scripts/ci/gitlab/pipeline/build.yml @@ -62,6 +62,7 @@ build-linux-substrate: - job: test-linux-stable artifacts: false before_script: + - !reference [.timestamp, before_script] - !reference [.job-switcher, before_script] - mkdir -p ./artifacts/substrate/ - !reference [.rusty-cachier, before_script] @@ -95,6 +96,7 @@ build-linux-substrate: # this variable gets overriden by "rusty-cachier environment inject", use the value as default CARGO_TARGET_DIR: "$CI_PROJECT_DIR/target" before_script: + - !reference [.timestamp, before_script] - !reference [.job-switcher, before_script] - mkdir -p ./artifacts/subkey - !reference [.rusty-cachier, before_script] @@ -120,6 +122,7 @@ build-subkey-macos: # duplicating before_script & script sections from .build-subkey hidden job # to overwrite rusty-cachier integration as it doesn't work on macos before_script: + # skip timestamp script, the osx bash doesn't support printf %()T - !reference [.job-switcher, before_script] - mkdir -p ./artifacts/subkey script: diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index 49dbb194fb651..fd031d9aa56c3 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -83,6 +83,7 @@ cargo-check-benches: - .collect-artifacts - .pipeline-stopper-artifacts before_script: + - !reference [.timestamp, before_script] # perform rusty-cachier operations before any further modifications to the git repo to make cargo feel cheated not so much - !reference [.rust-info-script, script] - !reference [.job-switcher, before_script] @@ -145,7 +146,8 @@ node-bench-regression-guard: artifacts: true variables: CI_IMAGE: "paritytech/node-bench-regression-guard:latest" - before_script: [""] + before_script: + - !reference [.timestamp, before_script] script: - echo "------- IMPORTANT -------" - echo "node-bench-regression-guard depends on the results of a cargo-check-benches job" @@ -419,6 +421,7 @@ cargo-check-each-crate-macos: - .collect-artifacts - .pipeline-stopper-artifacts before_script: + # skip timestamp script, the osx bash doesn't support printf %()T - !reference [.job-switcher, before_script] - !reference [.rust-info-script, script] - !reference [.pipeline-stopper-vars, script] From bd52212085051561aee5784ff48b295894b6509d Mon Sep 17 00:00:00 2001 From: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Date: Wed, 15 Mar 2023 19:49:28 +0200 Subject: [PATCH 18/80] Metadata V15: Expose API to fetch metadata for version (#13287) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * impl_runtime_apis: Generate getters for `metadata_at` functions Signed-off-by: Alexandru Vasile * runtime: Implement new `Metadata` runtime trait Signed-off-by: Alexandru Vasile * runtime: Move `metadata_at` functions to construct_runtime macro Signed-off-by: Alexandru Vasile * contruct_runtime: Use `OpaqueMetadata` from hidden imports Signed-off-by: Alexandru Vasile * Adjust testing Signed-off-by: Alexandru Vasile * frame/tests: Add tests for the new API Signed-off-by: Alexandru Vasile * frame/tests: Adjust metdata naming Signed-off-by: Alexandru Vasile * frame/support: Expose `metadata-v14` feature flag Signed-off-by: Alexandru Vasile * frame/support: Expose metadata only under feature flags Signed-off-by: Alexandru Vasile * frame/support: Expose v14 metadata by default Signed-off-by: Alexandru Vasile * frame/support: Expose metadata feature for testing Signed-off-by: Alexandru Vasile * frame/support: Test metadata under different feature flags Signed-off-by: Alexandru Vasile * Update primitives/api/src/lib.rs Co-authored-by: Bastian Köcher * Update primitives/api/src/lib.rs Co-authored-by: Bastian Köcher * client/tests: Adjust testing to reflect trait Metadata change Signed-off-by: Alexandru Vasile * frame/metadata-ir: Add intermediate representation types for metadata Signed-off-by: Alexandru Vasile * frame/metadata-ir: Convert metadata to V14 Signed-off-by: Alexandru Vasile * frame/metadata-ir: Add API to convert metadata to multiple versions Signed-off-by: Alexandru Vasile * frame/metadata-ir: Expose V14 under feature flag Signed-off-by: Alexandru Vasile * frame/support: Adjust to metadata IR Signed-off-by: Alexandru Vasile * frame/support: More adjustments Signed-off-by: Alexandru Vasile * frame/support: Guard v14 details under feature flag Signed-off-by: Alexandru Vasile * frame/support: Adjust testing Signed-off-by: Alexandru Vasile * CI: Ensure `quick-benchmarks` uses `metadata-v14` Signed-off-by: Alexandru Vasile * frame/support: Use `metadata-v14` for benchmarks Signed-off-by: Alexandru Vasile * Adjust cargo fmt Signed-off-by: Alexandru Vasile * kitchensink-runtime: Add feature flag for `metadata-v14` Signed-off-by: Alexandru Vasile * frame/support/test: Adjust testing Signed-off-by: Alexandru Vasile * frame/support/test: Check crates locally Signed-off-by: Alexandru Vasile * Activate metadata-v14 for pallets Signed-off-by: Alexandru Vasile * Remove metadata-v14 feature flag Signed-off-by: Alexandru Vasile * frame/metadata_ir: Move `api.rs` to `mod.rs` Signed-off-by: Alexandru Vasile * frame/support: Handle latest metadata conversion via IR Signed-off-by: Alexandru Vasile * frame/tests: Add constant for metadata version 14 Signed-off-by: Alexandru Vasile * frame/support/test: Fix merge conflict Signed-off-by: Alexandru Vasile * Update frame/support/Cargo.toml Co-authored-by: Bastian Köcher * Update frame/support/src/metadata_ir/mod.rs Co-authored-by: Bastian Köcher * Update frame/support/test/Cargo.toml Co-authored-by: Bastian Köcher * Update primitives/api/src/lib.rs Co-authored-by: Bastian Köcher * frame/metadata: Collect pallet documentation for MetadataIR Signed-off-by: Alexandru Vasile * frame/tests: Check pallet documentation is propagated to MetadataIR Signed-off-by: Alexandru Vasile * frame/support: Improve documentation Signed-off-by: Alexandru Vasile --------- Signed-off-by: Alexandru Vasile Co-authored-by: parity-processbot <> Co-authored-by: Bastian Köcher --- bin/node-template/runtime/src/lib.rs | 8 + bin/node/runtime/src/lib.rs | 8 + client/rpc-spec-v2/src/chain_head/tests.rs | 2 +- client/rpc/src/state/tests.rs | 2 +- .../src/construct_runtime/expand/metadata.rs | 43 ++- frame/support/procedural/src/lib.rs | 6 +- .../procedural/src/pallet/expand/call.rs | 2 +- .../procedural/src/pallet/expand/constants.rs | 4 +- .../src/pallet/expand/documentation.rs | 4 +- .../src/pallet/expand/pallet_struct.rs | 6 +- .../procedural/src/pallet/expand/storage.rs | 4 +- .../procedural/src/storage/metadata.rs | 26 +- frame/support/procedural/src/storage/mod.rs | 14 +- frame/support/src/dispatch.rs | 16 +- frame/support/src/hash.rs | 18 +- frame/support/src/lib.rs | 92 ++--- frame/support/src/metadata_ir/mod.rs | 82 +++++ frame/support/src/metadata_ir/types.rs | 329 ++++++++++++++++++ frame/support/src/metadata_ir/v14.rs | 158 +++++++++ .../support/src/storage/types/counted_map.rs | 20 +- frame/support/src/storage/types/double_map.rs | 30 +- frame/support/src/storage/types/key.rs | 6 +- frame/support/src/storage/types/map.rs | 26 +- frame/support/src/storage/types/mod.rs | 12 +- frame/support/src/storage/types/nmap.rs | 70 ++-- frame/support/src/storage/types/value.rs | 22 +- frame/support/test/tests/decl_storage.rs | 207 +++++------ frame/support/test/tests/instance.rs | 32 +- frame/support/test/tests/pallet.rs | 40 +++ primitives/api/src/lib.rs | 12 + test-utils/runtime/src/lib.rs | 17 +- 31 files changed, 1002 insertions(+), 316 deletions(-) create mode 100644 frame/support/src/metadata_ir/mod.rs create mode 100644 frame/support/src/metadata_ir/types.rs create mode 100644 frame/support/src/metadata_ir/v14.rs diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index ac01aa95f4f12..41871c06bd923 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -354,6 +354,14 @@ impl_runtime_apis! { fn metadata() -> OpaqueMetadata { OpaqueMetadata::new(Runtime::metadata().into()) } + + fn metadata_at_version(version: u32) -> Option { + Runtime::metadata_at_version(version) + } + + fn metadata_versions() -> sp_std::vec::Vec { + Runtime::metadata_versions() + } } impl sp_block_builder::BlockBuilder for Runtime { diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index d8426d3b35e15..5d1dea02e8256 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1942,6 +1942,14 @@ impl_runtime_apis! { fn metadata() -> OpaqueMetadata { OpaqueMetadata::new(Runtime::metadata().into()) } + + fn metadata_at_version(version: u32) -> Option { + Runtime::metadata_at_version(version) + } + + fn metadata_versions() -> sp_std::vec::Vec { + Runtime::metadata_versions() + } } impl sp_block_builder::BlockBuilder for Runtime { diff --git a/client/rpc-spec-v2/src/chain_head/tests.rs b/client/rpc-spec-v2/src/chain_head/tests.rs index 0886efa94a756..fcd906dcf5be0 100644 --- a/client/rpc-spec-v2/src/chain_head/tests.rs +++ b/client/rpc-spec-v2/src/chain_head/tests.rs @@ -170,7 +170,7 @@ async fn follow_with_runtime() { let runtime_str = "{\"specName\":\"test\",\"implName\":\"parity-test\",\"authoringVersion\":1,\ \"specVersion\":2,\"implVersion\":2,\"apis\":[[\"0xdf6acb689907609b\",4],\ - [\"0x37e397fc7c91f5e4\",1],[\"0xd2bc9897eed08f15\",3],[\"0x40fe3ad401f8959a\",6],\ + [\"0x37e397fc7c91f5e4\",2],[\"0xd2bc9897eed08f15\",3],[\"0x40fe3ad401f8959a\",6],\ [\"0xc6e9a76309f39b09\",1],[\"0xdd718d5cc53262d4\",1],[\"0xcbca25e39f142387\",2],\ [\"0xf78b278be53f454c\",2],[\"0xab3c0572291feb8b\",1],[\"0xbc9d89904f5b923f\",1]],\ \"transactionVersion\":1,\"stateVersion\":1}"; diff --git a/client/rpc/src/state/tests.rs b/client/rpc/src/state/tests.rs index 53f8f1d48bc95..1ccc609e4f0e4 100644 --- a/client/rpc/src/state/tests.rs +++ b/client/rpc/src/state/tests.rs @@ -484,7 +484,7 @@ async fn should_return_runtime_version() { let result = "{\"specName\":\"test\",\"implName\":\"parity-test\",\"authoringVersion\":1,\ \"specVersion\":2,\"implVersion\":2,\"apis\":[[\"0xdf6acb689907609b\",4],\ - [\"0x37e397fc7c91f5e4\",1],[\"0xd2bc9897eed08f15\",3],[\"0x40fe3ad401f8959a\",6],\ + [\"0x37e397fc7c91f5e4\",2],[\"0xd2bc9897eed08f15\",3],[\"0x40fe3ad401f8959a\",6],\ [\"0xc6e9a76309f39b09\",1],[\"0xdd718d5cc53262d4\",1],[\"0xcbca25e39f142387\",2],\ [\"0xf78b278be53f454c\",2],[\"0xab3c0572291feb8b\",1],[\"0xbc9d89904f5b923f\",1]],\ \"transactionVersion\":1,\"stateVersion\":1}"; diff --git a/frame/support/procedural/src/construct_runtime/expand/metadata.rs b/frame/support/procedural/src/construct_runtime/expand/metadata.rs index e9996121757d7..ba6a621af7523 100644 --- a/frame/support/procedural/src/construct_runtime/expand/metadata.rs +++ b/frame/support/procedural/src/construct_runtime/expand/metadata.rs @@ -48,6 +48,7 @@ pub fn expand_runtime_metadata( let event = expand_pallet_metadata_events(&filtered_names, runtime, scrate, decl); let constants = expand_pallet_metadata_constants(runtime, decl); let errors = expand_pallet_metadata_errors(runtime, decl); + let docs = expand_pallet_metadata_docs(runtime, decl); let attr = decl.cfg_pattern.iter().fold(TokenStream::new(), |acc, pattern| { let attr = TokenStream::from_str(&format!("#[cfg({})]", pattern.original())) .expect("was successfully parsed before; qed"); @@ -59,7 +60,7 @@ pub fn expand_runtime_metadata( quote! { #attr - #scrate::metadata::PalletMetadata { + #scrate::metadata_ir::PalletMetadataIR { name: stringify!(#name), index: #index, storage: #storage, @@ -67,6 +68,7 @@ pub fn expand_runtime_metadata( event: #event, constants: #constants, error: #errors, + docs: #docs, } } }) @@ -74,10 +76,10 @@ pub fn expand_runtime_metadata( quote! { impl #runtime { - pub fn metadata() -> #scrate::metadata::RuntimeMetadataPrefixed { - #scrate::metadata::RuntimeMetadataLastVersion::new( - #scrate::sp_std::vec![ #(#pallets),* ], - #scrate::metadata::ExtrinsicMetadata { + fn metadata_ir() -> #scrate::metadata_ir::MetadataIR { + #scrate::metadata_ir::MetadataIR { + pallets: #scrate::sp_std::vec![ #(#pallets),* ], + extrinsic: #scrate::metadata_ir::ExtrinsicMetadataIR { ty: #scrate::scale_info::meta_type::<#extrinsic>(), version: <#extrinsic as #scrate::sp_runtime::traits::ExtrinsicMetadata>::VERSION, signed_extensions: < @@ -86,15 +88,29 @@ pub fn expand_runtime_metadata( >::SignedExtensions as #scrate::sp_runtime::traits::SignedExtension >::metadata() .into_iter() - .map(|meta| #scrate::metadata::SignedExtensionMetadata { + .map(|meta| #scrate::metadata_ir::SignedExtensionMetadataIR { identifier: meta.identifier, ty: meta.ty, additional_signed: meta.additional_signed, }) .collect(), }, - #scrate::scale_info::meta_type::<#runtime>() - ).into() + ty: #scrate::scale_info::meta_type::<#runtime>() + } + } + + pub fn metadata() -> #scrate::metadata::RuntimeMetadataPrefixed { + #scrate::metadata_ir::into_latest(#runtime::metadata_ir()) + } + + pub fn metadata_at_version(version: u32) -> Option<#scrate::OpaqueMetadata> { + #scrate::metadata_ir::into_version(#runtime::metadata_ir(), version).map(|prefixed| { + #scrate::OpaqueMetadata::new(prefixed.into()) + }) + } + + pub fn metadata_versions() -> #scrate::sp_std::vec::Vec { + #scrate::metadata_ir::supported_versions() } } } @@ -157,7 +173,7 @@ fn expand_pallet_metadata_events( quote! { Some( - #scrate::metadata::PalletEventMetadata { + #scrate::metadata_ir::PalletEventMetadataIR { ty: #scrate::scale_info::meta_type::<#pallet_event>() } ) @@ -184,3 +200,12 @@ fn expand_pallet_metadata_errors(runtime: &Ident, decl: &Pallet) -> TokenStream #path::Pallet::<#runtime #(, #path::#instance)*>::error_metadata() } } + +fn expand_pallet_metadata_docs(runtime: &Ident, decl: &Pallet) -> TokenStream { + let path = &decl.path; + let instance = decl.instance.as_ref().into_iter(); + + quote! { + #path::Pallet::<#runtime #(, #path::#instance)*>::pallet_documentation_metadata() + } +} diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 1d5dde20e2034..0515a4b7d2f91 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -495,7 +495,7 @@ pub fn construct_runtime(input: TokenStream) -> TokenStream { /// #[doc = include_str!("../README.md")] /// #[pallet_doc("../doc1.md")] /// #[pallet_doc("../doc2.md")] -/// pub struct Pallet(_); +/// pub mod pallet {} /// ``` /// /// The runtime metadata for this pallet contains the following @@ -514,7 +514,7 @@ pub fn construct_runtime(input: TokenStream) -> TokenStream { /// /// Documentation for pallet 1 /// /// Documentation for pallet 2 /// /// Content of README.md -/// pub struct Pallet(_); +/// pub mod pallet {} /// ``` /// /// If you want to specify the file from which the documentation is loaded, you can use the @@ -531,7 +531,7 @@ pub fn construct_runtime(input: TokenStream) -> TokenStream { /// /// This approach is beneficial when you use the `include_str` macro at the beginning of the file /// and want that documentation to extend to the runtime metadata, without reiterating the -/// documentation on the module itself. +/// documentation on the pallet module itself. #[proc_macro_attribute] pub fn pallet(attr: TokenStream, item: TokenStream) -> TokenStream { pallet::pallet(attr, item) diff --git a/frame/support/procedural/src/pallet/expand/call.rs b/frame/support/procedural/src/pallet/expand/call.rs index 3db454eb6211b..7672609a9881e 100644 --- a/frame/support/procedural/src/pallet/expand/call.rs +++ b/frame/support/procedural/src/pallet/expand/call.rs @@ -362,7 +362,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { impl<#type_impl_gen> #pallet_ident<#type_use_gen> #where_clause { #[doc(hidden)] - pub fn call_functions() -> #frame_support::metadata::PalletCallMetadata { + pub fn call_functions() -> #frame_support::metadata_ir::PalletCallMetadataIR { #frame_support::scale_info::meta_type::<#call_ident<#type_use_gen>>().into() } } diff --git a/frame/support/procedural/src/pallet/expand/constants.rs b/frame/support/procedural/src/pallet/expand/constants.rs index 21ac1de3642d5..21fa492a75b56 100644 --- a/frame/support/procedural/src/pallet/expand/constants.rs +++ b/frame/support/procedural/src/pallet/expand/constants.rs @@ -85,7 +85,7 @@ pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream { let default_byte_impl = &const_.default_byte_impl; quote::quote!({ - #frame_support::metadata::PalletConstantMetadata { + #frame_support::metadata_ir::PalletConstantMetadataIR { name: #ident_str, ty: #frame_support::scale_info::meta_type::<#const_type>(), value: { #default_byte_impl }, @@ -99,7 +99,7 @@ pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream { #[doc(hidden)] pub fn pallet_constants_metadata() - -> #frame_support::sp_std::vec::Vec<#frame_support::metadata::PalletConstantMetadata> + -> #frame_support::sp_std::vec::Vec<#frame_support::metadata_ir::PalletConstantMetadataIR> { #frame_support::sp_std::vec![ #( #consts ),* ] } diff --git a/frame/support/procedural/src/pallet/expand/documentation.rs b/frame/support/procedural/src/pallet/expand/documentation.rs index e158448a89711..1aa46cf572847 100644 --- a/frame/support/procedural/src/pallet/expand/documentation.rs +++ b/frame/support/procedural/src/pallet/expand/documentation.rs @@ -145,7 +145,7 @@ impl ToTokens for DocMetaValue { /// Implement a `pallet_documentation_metadata` function to fetch the /// documentation that is included in the metadata. /// -/// The documentation is placed at the top of the module similar to: +/// The documentation is placed on the pallet similar to: /// /// ```ignore /// #[pallet] @@ -163,7 +163,7 @@ impl ToTokens for DocMetaValue { /// which is the file path that holds the documentation to be added to the metadata. /// /// Unlike the `doc` attribute, the documentation provided to the `proc_macro` attribute is -/// not inserted at the beginning of the module. +/// not added to the pallet. pub fn expand_documentation(def: &mut Def) -> proc_macro2::TokenStream { let frame_support = &def.frame_support; let type_impl_gen = &def.type_impl_generics(proc_macro2::Span::call_site()); diff --git a/frame/support/procedural/src/pallet/expand/pallet_struct.rs b/frame/support/procedural/src/pallet/expand/pallet_struct.rs index 27fe9d3401ea2..7acfb9090698e 100644 --- a/frame/support/procedural/src/pallet/expand/pallet_struct.rs +++ b/frame/support/procedural/src/pallet/expand/pallet_struct.rs @@ -82,8 +82,8 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream { quote::quote_spanned!(def.pallet_struct.attr_span => impl<#type_impl_gen> #pallet_ident<#type_use_gen> #config_where_clause { #[doc(hidden)] - pub fn error_metadata() -> Option<#frame_support::metadata::PalletErrorMetadata> { - Some(#frame_support::metadata::PalletErrorMetadata { + pub fn error_metadata() -> Option<#frame_support::metadata_ir::PalletErrorMetadataIR> { + Some(#frame_support::metadata_ir::PalletErrorMetadataIR { ty: #frame_support::scale_info::meta_type::<#error_ident<#type_use_gen>>() }) } @@ -93,7 +93,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream { quote::quote_spanned!(def.pallet_struct.attr_span => impl<#type_impl_gen> #pallet_ident<#type_use_gen> #config_where_clause { #[doc(hidden)] - pub fn error_metadata() -> Option<#frame_support::metadata::PalletErrorMetadata> { + pub fn error_metadata() -> Option<#frame_support::metadata_ir::PalletErrorMetadataIR> { None } } diff --git a/frame/support/procedural/src/pallet/expand/storage.rs b/frame/support/procedural/src/pallet/expand/storage.rs index 05d61bb522180..8ba9ee7681ca9 100644 --- a/frame/support/procedural/src/pallet/expand/storage.rs +++ b/frame/support/procedural/src/pallet/expand/storage.rs @@ -639,8 +639,8 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { #completed_where_clause { #[doc(hidden)] - pub fn storage_metadata() -> #frame_support::metadata::PalletStorageMetadata { - #frame_support::metadata::PalletStorageMetadata { + pub fn storage_metadata() -> #frame_support::metadata_ir::PalletStorageMetadataIR { + #frame_support::metadata_ir::PalletStorageMetadataIR { prefix: < ::PalletInfo as #frame_support::traits::PalletInfo diff --git a/frame/support/procedural/src/storage/metadata.rs b/frame/support/procedural/src/storage/metadata.rs index 3e3e0576f63b5..5561d0564597b 100644 --- a/frame/support/procedural/src/storage/metadata.rs +++ b/frame/support/procedural/src/storage/metadata.rs @@ -27,7 +27,7 @@ fn storage_line_metadata_type(scrate: &TokenStream, line: &StorageLineDefExt) -> match &line.storage_type { StorageLineTypeDef::Simple(_) => { quote! { - #scrate::metadata::StorageEntryType::Plain( + #scrate::metadata_ir::StorageEntryTypeIR::Plain( #scrate::scale_info::meta_type::<#value_type>() ) } @@ -36,8 +36,8 @@ fn storage_line_metadata_type(scrate: &TokenStream, line: &StorageLineDefExt) -> let hasher = map.hasher.into_metadata(); let key = &map.key; quote! { - #scrate::metadata::StorageEntryType::Map { - hashers: #scrate::sp_std::vec! [ #scrate::metadata::#hasher ], + #scrate::metadata_ir::StorageEntryTypeIR::Map { + hashers: #scrate::sp_std::vec! [ #scrate::metadata_ir::#hasher ], key: #scrate::scale_info::meta_type::<#key>(), value: #scrate::scale_info::meta_type::<#value_type>(), } @@ -49,10 +49,10 @@ fn storage_line_metadata_type(scrate: &TokenStream, line: &StorageLineDefExt) -> let key1 = &map.key1; let key2 = &map.key2; quote! { - #scrate::metadata::StorageEntryType::Map { + #scrate::metadata_ir::StorageEntryTypeIR::Map { hashers: #scrate::sp_std::vec! [ - #scrate::metadata::#hasher1, - #scrate::metadata::#hasher2, + #scrate::metadata_ir::#hasher1, + #scrate::metadata_ir::#hasher2, ], key: #scrate::scale_info::meta_type::<(#key1, #key2)>(), value: #scrate::scale_info::meta_type::<#value_type>(), @@ -67,9 +67,9 @@ fn storage_line_metadata_type(scrate: &TokenStream, line: &StorageLineDefExt) -> .map(|hasher| hasher.to_storage_hasher_struct()) .collect::>(); quote! { - #scrate::metadata::StorageEntryType::Map { + #scrate::metadata_ir::StorageEntryTypeIR::Map { hashers: #scrate::sp_std::vec! [ - #( #scrate::metadata::StorageHasher::#hashers, )* + #( #scrate::metadata_ir::StorageHasherIR::#hashers, )* ], key: #scrate::scale_info::meta_type::<#key_tuple>(), value: #scrate::scale_info::meta_type::<#value_type>(), @@ -159,9 +159,9 @@ pub fn impl_metadata(def: &DeclStorageDefExt) -> TokenStream { let str_name = line.name.to_string(); let modifier = if line.is_option { - quote!(#scrate::metadata::StorageEntryModifier::Optional) + quote!(#scrate::metadata_ir::StorageEntryModifierIR::Optional) } else { - quote!(#scrate::metadata::StorageEntryModifier::Default) + quote!(#scrate::metadata_ir::StorageEntryModifierIR::Default) }; let ty = storage_line_metadata_type(scrate, line); @@ -172,7 +172,7 @@ pub fn impl_metadata(def: &DeclStorageDefExt) -> TokenStream { let docs = get_doc_literals(&line.attrs); let entry = quote! { - #scrate::metadata::StorageEntryMetadata { + #scrate::metadata_ir::StorageEntryMetadataIR { name: #str_name, modifier: #modifier, ty: #ty, @@ -194,7 +194,7 @@ pub fn impl_metadata(def: &DeclStorageDefExt) -> TokenStream { }; let store_metadata = quote!( - #scrate::metadata::PalletStorageMetadata { + #scrate::metadata_ir::PalletStorageMetadataIR { prefix: #prefix, entries: #scrate::sp_std::vec![ #entries ], } @@ -209,7 +209,7 @@ pub fn impl_metadata(def: &DeclStorageDefExt) -> TokenStream { impl #module_impl #module_struct #where_clause { #[doc(hidden)] - pub fn storage_metadata() -> #scrate::metadata::PalletStorageMetadata { + pub fn storage_metadata() -> #scrate::metadata_ir::PalletStorageMetadataIR { #store_metadata } } diff --git a/frame/support/procedural/src/storage/mod.rs b/frame/support/procedural/src/storage/mod.rs index 1e48a1fbb06d1..3d3b1443d393f 100644 --- a/frame/support/procedural/src/storage/mod.rs +++ b/frame/support/procedural/src/storage/mod.rs @@ -454,13 +454,13 @@ impl HasherKind { fn into_metadata(&self) -> proc_macro2::TokenStream { match self { - HasherKind::Blake2_256 => quote!(StorageHasher::Blake2_256), - HasherKind::Blake2_128 => quote!(StorageHasher::Blake2_128), - HasherKind::Blake2_128Concat => quote!(StorageHasher::Blake2_128Concat), - HasherKind::Twox256 => quote!(StorageHasher::Twox256), - HasherKind::Twox128 => quote!(StorageHasher::Twox128), - HasherKind::Twox64Concat => quote!(StorageHasher::Twox64Concat), - HasherKind::Identity => quote!(StorageHasher::Identity), + HasherKind::Blake2_256 => quote!(StorageHasherIR::Blake2_256), + HasherKind::Blake2_128 => quote!(StorageHasherIR::Blake2_128), + HasherKind::Blake2_128Concat => quote!(StorageHasherIR::Blake2_128Concat), + HasherKind::Twox256 => quote!(StorageHasherIR::Twox256), + HasherKind::Twox128 => quote!(StorageHasherIR::Twox128), + HasherKind::Twox64Concat => quote!(StorageHasherIR::Twox64Concat), + HasherKind::Identity => quote!(StorageHasherIR::Identity), } } } diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index c5f4cc60c1f1b..390555b02d1bb 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -2977,7 +2977,7 @@ macro_rules! __dispatch_impl_metadata { { #[doc(hidden)] #[allow(dead_code)] - pub fn call_functions() -> $crate::metadata::PalletCallMetadata { + pub fn call_functions() -> $crate::metadata_ir::PalletCallMetadataIR { $crate::scale_info::meta_type::<$call_type<$trait_instance $(, $instance)?>>().into() } } @@ -2998,7 +2998,7 @@ macro_rules! __impl_error_metadata { { #[doc(hidden)] #[allow(dead_code)] - pub fn error_metadata() -> Option<$crate::metadata::PalletErrorMetadata> { + pub fn error_metadata() -> Option<$crate::metadata_ir::PalletErrorMetadataIR> { None } } @@ -3013,8 +3013,8 @@ macro_rules! __impl_error_metadata { { #[doc(hidden)] #[allow(dead_code)] - pub fn error_metadata() -> Option<$crate::metadata::PalletErrorMetadata> { - Some($crate::metadata::PalletErrorMetadata { + pub fn error_metadata() -> Option<$crate::metadata_ir::PalletErrorMetadataIR> { + Some($crate::metadata_ir::PalletErrorMetadataIR { ty: $crate::scale_info::meta_type::<$( $error_type )*>() }) } @@ -3109,7 +3109,7 @@ macro_rules! __impl_module_constants_metadata { { #[doc(hidden)] #[allow(dead_code)] - pub fn pallet_constants_metadata() -> $crate::sp_std::vec::Vec<$crate::metadata::PalletConstantMetadata> { + pub fn pallet_constants_metadata() -> $crate::sp_std::vec::Vec<$crate::metadata_ir::PalletConstantMetadataIR> { // Create the `ByteGetter`s $( #[allow(non_upper_case_types)] @@ -3133,7 +3133,7 @@ macro_rules! __impl_module_constants_metadata { )* $crate::sp_std::vec![ $( - $crate::metadata::PalletConstantMetadata { + $crate::metadata_ir::PalletConstantMetadataIR { name: stringify!($name), ty: $crate::scale_info::meta_type::<$type>(), value: $default_byte_name::<$const_trait_instance $(, $const_instance)?>( @@ -3207,7 +3207,7 @@ mod tests { use super::*; use crate::{ dispatch::{DispatchClass, DispatchInfo, Pays}, - metadata::*, + metadata_ir::*, traits::{ CallerTrait, CrateVersion, Get, GetCallName, IntegrityTest, OnFinalize, OnIdle, OnInitialize, OnRuntimeUpgrade, PalletInfo, @@ -3405,7 +3405,7 @@ mod tests { fn module_json_metadata() { let metadata = Module::::call_functions(); let expected_metadata = - PalletCallMetadata { ty: scale_info::meta_type::>() }; + PalletCallMetadataIR { ty: scale_info::meta_type::>() }; assert_eq!(expected_metadata, metadata); } diff --git a/frame/support/src/hash.rs b/frame/support/src/hash.rs index bf9eb2f88b0b1..115ce605d542e 100644 --- a/frame/support/src/hash.rs +++ b/frame/support/src/hash.rs @@ -17,7 +17,7 @@ //! Hash utilities. -use crate::metadata; +use crate::metadata_ir; use codec::{Codec, MaxEncodedLen}; use sp_io::hashing::{blake2_128, blake2_256, twox_128, twox_256, twox_64}; use sp_std::prelude::Vec; @@ -59,7 +59,7 @@ impl Hashable for T { /// Hasher to use to hash keys to insert to storage. pub trait StorageHasher: 'static { - const METADATA: metadata::StorageHasher; + const METADATA: metadata_ir::StorageHasherIR; type Output: AsRef<[u8]>; fn hash(x: &[u8]) -> Self::Output; @@ -80,7 +80,7 @@ pub trait ReversibleStorageHasher: StorageHasher { /// Store the key directly. pub struct Identity; impl StorageHasher for Identity { - const METADATA: metadata::StorageHasher = metadata::StorageHasher::Identity; + const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Identity; type Output = Vec; fn hash(x: &[u8]) -> Vec { x.to_vec() @@ -98,7 +98,7 @@ impl ReversibleStorageHasher for Identity { /// Hash storage keys with `concat(twox64(key), key)` pub struct Twox64Concat; impl StorageHasher for Twox64Concat { - const METADATA: metadata::StorageHasher = metadata::StorageHasher::Twox64Concat; + const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Twox64Concat; type Output = Vec; fn hash(x: &[u8]) -> Vec { twox_64(x).iter().chain(x.iter()).cloned().collect::>() @@ -120,7 +120,7 @@ impl ReversibleStorageHasher for Twox64Concat { /// Hash storage keys with `concat(blake2_128(key), key)` pub struct Blake2_128Concat; impl StorageHasher for Blake2_128Concat { - const METADATA: metadata::StorageHasher = metadata::StorageHasher::Blake2_128Concat; + const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Blake2_128Concat; type Output = Vec; fn hash(x: &[u8]) -> Vec { blake2_128(x).iter().chain(x.iter()).cloned().collect::>() @@ -142,7 +142,7 @@ impl ReversibleStorageHasher for Blake2_128Concat { /// Hash storage keys with blake2 128 pub struct Blake2_128; impl StorageHasher for Blake2_128 { - const METADATA: metadata::StorageHasher = metadata::StorageHasher::Blake2_128; + const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Blake2_128; type Output = [u8; 16]; fn hash(x: &[u8]) -> [u8; 16] { blake2_128(x) @@ -155,7 +155,7 @@ impl StorageHasher for Blake2_128 { /// Hash storage keys with blake2 256 pub struct Blake2_256; impl StorageHasher for Blake2_256 { - const METADATA: metadata::StorageHasher = metadata::StorageHasher::Blake2_256; + const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Blake2_256; type Output = [u8; 32]; fn hash(x: &[u8]) -> [u8; 32] { blake2_256(x) @@ -168,7 +168,7 @@ impl StorageHasher for Blake2_256 { /// Hash storage keys with twox 128 pub struct Twox128; impl StorageHasher for Twox128 { - const METADATA: metadata::StorageHasher = metadata::StorageHasher::Twox128; + const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Twox128; type Output = [u8; 16]; fn hash(x: &[u8]) -> [u8; 16] { twox_128(x) @@ -181,7 +181,7 @@ impl StorageHasher for Twox128 { /// Hash storage keys with twox 256 pub struct Twox256; impl StorageHasher for Twox256 { - const METADATA: metadata::StorageHasher = metadata::StorageHasher::Twox256; + const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Twox256; type Output = [u8; 32]; fn hash(x: &[u8]) -> [u8; 32] { twox_256(x) diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 4e9bc32b0043b..b845828455793 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -50,7 +50,7 @@ pub use paste; pub use scale_info; #[cfg(feature = "std")] pub use serde; -pub use sp_core::Void; +pub use sp_core::{OpaqueMetadata, Void}; #[doc(hidden)] pub use sp_core_hashing_proc_macro; #[doc(hidden)] @@ -80,10 +80,10 @@ pub mod error; pub mod crypto; pub mod dispatch_context; pub mod instances; +pub mod metadata_ir; pub mod migrations; pub mod traits; pub mod weights; - #[doc(hidden)] pub mod unsigned { #[doc(hidden)] @@ -827,9 +827,9 @@ pub use serde::{Deserialize, Serialize}; #[cfg(test)] pub mod tests { use super::*; - use crate::metadata::{ - PalletStorageMetadata, StorageEntryMetadata, StorageEntryModifier, StorageEntryType, - StorageHasher, + use crate::metadata_ir::{ + PalletStorageMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, + StorageEntryTypeIR, StorageHasherIR, }; use codec::{Codec, EncodeLike}; use frame_support::traits::CrateVersion; @@ -1310,101 +1310,107 @@ pub mod tests { }); } - fn expected_metadata() -> PalletStorageMetadata { - PalletStorageMetadata { + fn expected_metadata() -> PalletStorageMetadataIR { + PalletStorageMetadataIR { prefix: "Test", entries: vec![ - StorageEntryMetadata { + StorageEntryMetadataIR { name: "Value", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0, 0, 0, 0, 0, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "Data", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Twox64Concat], + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { + hashers: vec![StorageHasherIR::Twox64Concat], key: scale_info::meta_type::(), value: scale_info::meta_type::(), }, default: vec![0, 0, 0, 0, 0, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "OptionLinkedMap", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat], + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Map { + hashers: vec![StorageHasherIR::Blake2_128Concat], key: scale_info::meta_type::(), value: scale_info::meta_type::(), }, default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GenericData", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Identity], + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { + hashers: vec![StorageHasherIR::Identity], key: scale_info::meta_type::(), value: scale_info::meta_type::(), }, default: vec![0, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GenericData2", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat], + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Map { + hashers: vec![StorageHasherIR::Blake2_128Concat], key: scale_info::meta_type::(), value: scale_info::meta_type::(), }, default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "DataDM", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Twox64Concat, StorageHasher::Blake2_128Concat], + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { + hashers: vec![ + StorageHasherIR::Twox64Concat, + StorageHasherIR::Blake2_128Concat, + ], key: scale_info::meta_type::<(u32, u32)>(), value: scale_info::meta_type::(), }, default: vec![0, 0, 0, 0, 0, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GenericDataDM", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat, StorageHasher::Identity], + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { + hashers: vec![StorageHasherIR::Blake2_128Concat, StorageHasherIR::Identity], key: scale_info::meta_type::<(u32, u32)>(), value: scale_info::meta_type::(), }, default: vec![0, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GenericData2DM", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat, StorageHasher::Twox64Concat], + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Map { + hashers: vec![ + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Twox64Concat, + ], key: scale_info::meta_type::<(u32, u32)>(), value: scale_info::meta_type::(), }, default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "AppendableDM", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { hashers: vec![ - StorageHasher::Blake2_128Concat, - StorageHasher::Blake2_128Concat, + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Blake2_128Concat, ], key: scale_info::meta_type::<(u32, u32)>(), value: scale_info::meta_type::>(), diff --git a/frame/support/src/metadata_ir/mod.rs b/frame/support/src/metadata_ir/mod.rs new file mode 100644 index 0000000000000..bab205d63c118 --- /dev/null +++ b/frame/support/src/metadata_ir/mod.rs @@ -0,0 +1,82 @@ +// 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. + +//! Intermediate representation of the runtime metadata. + +mod types; +use frame_metadata::{RuntimeMetadataPrefixed, RuntimeMetadataV14}; +pub use types::*; + +mod v14; + +/// Metadata V14. +const V14: u32 = 14; + +/// Transform the IR to the specified version. +/// +/// Use [`supported_versions`] to find supported versions. +pub fn into_version(metadata: MetadataIR, version: u32) -> Option { + match version { + // Latest stable version. + V14 => { + let v14: frame_metadata::v14::RuntimeMetadataV14 = metadata.into(); + Some(v14.into()) + }, + _ => None, + } +} + +/// Returns the supported metadata versions. +pub fn supported_versions() -> sp_std::vec::Vec { + sp_std::vec![V14,] +} + +/// Transform the IR to the latest stable metadata version. +pub fn into_latest(metadata: MetadataIR) -> RuntimeMetadataPrefixed { + let latest: RuntimeMetadataV14 = metadata.into(); + latest.into() +} + +#[cfg(test)] +mod test { + use super::*; + use crate::metadata_ir::ExtrinsicMetadataIR; + use frame_metadata::{v14::META_RESERVED, RuntimeMetadata}; + use scale_info::meta_type; + + fn ir_metadata() -> MetadataIR { + MetadataIR { + pallets: vec![], + extrinsic: ExtrinsicMetadataIR { + ty: meta_type::<()>(), + version: 0, + signed_extensions: vec![], + }, + ty: meta_type::<()>(), + } + } + + #[test] + fn into_version_14() { + let ir = ir_metadata(); + let metadata = into_version(ir, V14).expect("Should return prefixed metadata"); + + assert_eq!(metadata.0, META_RESERVED); + + assert!(matches!(metadata.1, RuntimeMetadata::V14(_))); + } +} diff --git a/frame/support/src/metadata_ir/types.rs b/frame/support/src/metadata_ir/types.rs new file mode 100644 index 0000000000000..087fd3dcad249 --- /dev/null +++ b/frame/support/src/metadata_ir/types.rs @@ -0,0 +1,329 @@ +// 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 codec::Encode; +use scale_info::{ + form::{Form, MetaForm, PortableForm}, + prelude::vec::Vec, + IntoPortable, MetaType, Registry, +}; + +/// The intermediate representation for the runtime metadata. +/// Contains the needed context that allows conversion to multiple metadata versions. +/// +/// # Note +/// +/// Further fields could be added or removed to ensure proper conversion. +/// When the IR does not contain enough information to generate a specific version +/// of the runtime metadata an appropriate default value is used (ie, empty vector). +pub struct MetadataIR { + /// Pallet metadata. + pub pallets: Vec>, + /// Metadata of the extrinsic. + pub extrinsic: ExtrinsicMetadataIR, + /// The type of the `Runtime`. + pub ty: T::Type, +} + +/// The intermediate representation for a pallet metadata. +#[derive(Clone, PartialEq, Eq, Encode, Debug)] +pub struct PalletMetadataIR { + /// Pallet name. + pub name: T::String, + /// Pallet storage metadata. + pub storage: Option>, + /// Pallet calls metadata. + pub calls: Option>, + /// Pallet event metadata. + pub event: Option>, + /// Pallet constants metadata. + pub constants: Vec>, + /// Pallet error metadata. + pub error: Option>, + /// Define the index of the pallet, this index will be used for the encoding of pallet event, + /// call and origin variants. + pub index: u8, + /// Pallet documentation. + pub docs: Vec, +} + +impl IntoPortable for PalletMetadataIR { + type Output = PalletMetadataIR; + + fn into_portable(self, registry: &mut Registry) -> Self::Output { + PalletMetadataIR { + name: self.name.into_portable(registry), + storage: self.storage.map(|storage| storage.into_portable(registry)), + calls: self.calls.map(|calls| calls.into_portable(registry)), + event: self.event.map(|event| event.into_portable(registry)), + constants: registry.map_into_portable(self.constants), + error: self.error.map(|error| error.into_portable(registry)), + index: self.index, + docs: registry.map_into_portable(self.docs), + } + } +} + +/// Metadata of the extrinsic used by the runtime. +#[derive(Clone, PartialEq, Eq, Encode, Debug)] +pub struct ExtrinsicMetadataIR { + /// The type of the extrinsic. + pub ty: T::Type, + /// Extrinsic version. + pub version: u8, + /// The signed extensions in the order they appear in the extrinsic. + pub signed_extensions: Vec>, +} + +impl IntoPortable for ExtrinsicMetadataIR { + type Output = ExtrinsicMetadataIR; + + fn into_portable(self, registry: &mut Registry) -> Self::Output { + ExtrinsicMetadataIR { + ty: registry.register_type(&self.ty), + version: self.version, + signed_extensions: registry.map_into_portable(self.signed_extensions), + } + } +} + +/// Metadata of an extrinsic's signed extension. +#[derive(Clone, PartialEq, Eq, Encode, Debug)] +pub struct SignedExtensionMetadataIR { + /// The unique signed extension identifier, which may be different from the type name. + pub identifier: T::String, + /// The type of the signed extension, with the data to be included in the extrinsic. + pub ty: T::Type, + /// The type of the additional signed data, with the data to be included in the signed payload + pub additional_signed: T::Type, +} + +impl IntoPortable for SignedExtensionMetadataIR { + type Output = SignedExtensionMetadataIR; + + fn into_portable(self, registry: &mut Registry) -> Self::Output { + SignedExtensionMetadataIR { + identifier: self.identifier.into_portable(registry), + ty: registry.register_type(&self.ty), + additional_signed: registry.register_type(&self.additional_signed), + } + } +} + +/// All metadata of the pallet's storage. +#[derive(Clone, PartialEq, Eq, Encode, Debug)] +/// The common prefix used by all storage entries. +pub struct PalletStorageMetadataIR { + /// The common prefix used by all storage entries. + pub prefix: T::String, + /// Metadata for all storage entries. + pub entries: Vec>, +} + +impl IntoPortable for PalletStorageMetadataIR { + type Output = PalletStorageMetadataIR; + + fn into_portable(self, registry: &mut Registry) -> Self::Output { + PalletStorageMetadataIR { + prefix: self.prefix.into_portable(registry), + entries: registry.map_into_portable(self.entries), + } + } +} + +/// Metadata about one storage entry. +#[derive(Clone, PartialEq, Eq, Encode, Debug)] +pub struct StorageEntryMetadataIR { + /// Variable name of the storage entry. + pub name: T::String, + /// An `Option` modifier of that storage entry. + pub modifier: StorageEntryModifierIR, + /// Type of the value stored in the entry. + pub ty: StorageEntryTypeIR, + /// Default value (SCALE encoded). + pub default: Vec, + /// Storage entry documentation. + pub docs: Vec, +} + +impl IntoPortable for StorageEntryMetadataIR { + type Output = StorageEntryMetadataIR; + + fn into_portable(self, registry: &mut Registry) -> Self::Output { + StorageEntryMetadataIR { + name: self.name.into_portable(registry), + modifier: self.modifier, + ty: self.ty.into_portable(registry), + default: self.default, + docs: registry.map_into_portable(self.docs), + } + } +} + +/// A storage entry modifier indicates how a storage entry is returned when fetched and what the +/// value will be if the key is not present. Specifically this refers to the "return type" when +/// fetching a storage entry, and what the value will be if the key is not present. +/// +/// `Optional` means you should expect an `Option`, with `None` returned if the key is not +/// present. `Default` means you should expect a `T` with the default value of default if the key is +/// not present. +#[derive(Clone, PartialEq, Eq, Encode, Debug)] +pub enum StorageEntryModifierIR { + /// The storage entry returns an `Option`, with `None` if the key is not present. + Optional, + /// The storage entry returns `T::Default` if the key is not present. + Default, +} + +/// Hasher used by storage maps +#[derive(Clone, PartialEq, Eq, Encode, Debug)] +pub enum StorageHasherIR { + /// 128-bit Blake2 hash. + Blake2_128, + /// 256-bit Blake2 hash. + Blake2_256, + /// Multiple 128-bit Blake2 hashes concatenated. + Blake2_128Concat, + /// 128-bit XX hash. + Twox128, + /// 256-bit XX hash. + Twox256, + /// Multiple 64-bit XX hashes concatenated. + Twox64Concat, + /// Identity hashing (no hashing). + Identity, +} + +/// A type of storage value. +#[derive(Clone, PartialEq, Eq, Encode, Debug)] +pub enum StorageEntryTypeIR { + /// Plain storage entry (just the value). + Plain(T::Type), + /// A storage map. + Map { + /// One or more hashers, should be one hasher per key element. + hashers: Vec, + /// The type of the key, can be a tuple with elements for each of the hashers. + key: T::Type, + /// The type of the value. + value: T::Type, + }, +} + +impl IntoPortable for StorageEntryTypeIR { + type Output = StorageEntryTypeIR; + + fn into_portable(self, registry: &mut Registry) -> Self::Output { + match self { + Self::Plain(plain) => StorageEntryTypeIR::Plain(registry.register_type(&plain)), + Self::Map { hashers, key, value } => StorageEntryTypeIR::Map { + hashers, + key: registry.register_type(&key), + value: registry.register_type(&value), + }, + } + } +} + +/// Metadata for all calls in a pallet +#[derive(Clone, PartialEq, Eq, Encode, Debug)] +pub struct PalletCallMetadataIR { + /// The corresponding enum type for the pallet call. + pub ty: T::Type, +} + +impl IntoPortable for PalletCallMetadataIR { + type Output = PalletCallMetadataIR; + + fn into_portable(self, registry: &mut Registry) -> Self::Output { + PalletCallMetadataIR { ty: registry.register_type(&self.ty) } + } +} + +impl From for PalletCallMetadataIR { + fn from(ty: MetaType) -> Self { + Self { ty } + } +} + +/// Metadata about the pallet Event type. +#[derive(Clone, PartialEq, Eq, Encode, Debug)] +pub struct PalletEventMetadataIR { + /// The Event type. + pub ty: T::Type, +} + +impl IntoPortable for PalletEventMetadataIR { + type Output = PalletEventMetadataIR; + + fn into_portable(self, registry: &mut Registry) -> Self::Output { + PalletEventMetadataIR { ty: registry.register_type(&self.ty) } + } +} + +impl From for PalletEventMetadataIR { + fn from(ty: MetaType) -> Self { + Self { ty } + } +} + +/// Metadata about one pallet constant. +#[derive(Clone, PartialEq, Eq, Encode, Debug)] +pub struct PalletConstantMetadataIR { + /// Name of the pallet constant. + pub name: T::String, + /// Type of the pallet constant. + pub ty: T::Type, + /// Value stored in the constant (SCALE encoded). + pub value: Vec, + /// Documentation of the constant. + pub docs: Vec, +} + +impl IntoPortable for PalletConstantMetadataIR { + type Output = PalletConstantMetadataIR; + + fn into_portable(self, registry: &mut Registry) -> Self::Output { + PalletConstantMetadataIR { + name: self.name.into_portable(registry), + ty: registry.register_type(&self.ty), + value: self.value, + docs: registry.map_into_portable(self.docs), + } + } +} + +/// Metadata about a pallet error. +#[derive(Clone, PartialEq, Eq, Encode, Debug)] +pub struct PalletErrorMetadataIR { + /// The error type information. + pub ty: T::Type, +} + +impl IntoPortable for PalletErrorMetadataIR { + type Output = PalletErrorMetadataIR; + + fn into_portable(self, registry: &mut Registry) -> Self::Output { + PalletErrorMetadataIR { ty: registry.register_type(&self.ty) } + } +} + +impl From for PalletErrorMetadataIR { + fn from(ty: MetaType) -> Self { + Self { ty } + } +} diff --git a/frame/support/src/metadata_ir/v14.rs b/frame/support/src/metadata_ir/v14.rs new file mode 100644 index 0000000000000..e1b7a24f76577 --- /dev/null +++ b/frame/support/src/metadata_ir/v14.rs @@ -0,0 +1,158 @@ +// 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. + +//! Convert the IR to V14 metadata. + +use super::types::{ + ExtrinsicMetadataIR, MetadataIR, PalletCallMetadataIR, PalletConstantMetadataIR, + PalletErrorMetadataIR, PalletEventMetadataIR, PalletMetadataIR, PalletStorageMetadataIR, + SignedExtensionMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, StorageEntryTypeIR, + StorageHasherIR, +}; + +use frame_metadata::v14::{ + ExtrinsicMetadata, PalletCallMetadata, PalletConstantMetadata, PalletErrorMetadata, + PalletEventMetadata, PalletMetadata, PalletStorageMetadata, RuntimeMetadataV14, + SignedExtensionMetadata, StorageEntryMetadata, StorageEntryModifier, StorageEntryType, + StorageHasher, +}; + +impl From for RuntimeMetadataV14 { + fn from(ir: MetadataIR) -> Self { + RuntimeMetadataV14::new( + ir.pallets.into_iter().map(Into::into).collect(), + ir.extrinsic.into(), + ir.ty, + ) + } +} + +impl From for PalletMetadata { + fn from(ir: PalletMetadataIR) -> Self { + PalletMetadata { + name: ir.name, + storage: ir.storage.map(Into::into), + calls: ir.calls.map(Into::into), + event: ir.event.map(Into::into), + constants: ir.constants.into_iter().map(Into::into).collect(), + error: ir.error.map(Into::into), + index: ir.index, + // Note: ir.docs not part of v14. + } + } +} + +impl From for StorageEntryModifier { + fn from(ir: StorageEntryModifierIR) -> Self { + match ir { + StorageEntryModifierIR::Optional => StorageEntryModifier::Optional, + StorageEntryModifierIR::Default => StorageEntryModifier::Default, + } + } +} + +impl From for StorageHasher { + fn from(ir: StorageHasherIR) -> Self { + match ir { + StorageHasherIR::Blake2_128 => StorageHasher::Blake2_128, + StorageHasherIR::Blake2_256 => StorageHasher::Blake2_256, + StorageHasherIR::Blake2_128Concat => StorageHasher::Blake2_128Concat, + StorageHasherIR::Twox128 => StorageHasher::Twox128, + StorageHasherIR::Twox256 => StorageHasher::Twox256, + StorageHasherIR::Twox64Concat => StorageHasher::Twox64Concat, + StorageHasherIR::Identity => StorageHasher::Identity, + } + } +} + +impl From for StorageEntryType { + fn from(ir: StorageEntryTypeIR) -> Self { + match ir { + StorageEntryTypeIR::Plain(ty) => StorageEntryType::Plain(ty), + StorageEntryTypeIR::Map { hashers, key, value } => StorageEntryType::Map { + hashers: hashers.into_iter().map(Into::into).collect(), + key, + value, + }, + } + } +} + +impl From for StorageEntryMetadata { + fn from(ir: StorageEntryMetadataIR) -> Self { + StorageEntryMetadata { + name: ir.name, + modifier: ir.modifier.into(), + ty: ir.ty.into(), + default: ir.default, + docs: ir.docs, + } + } +} + +impl From for PalletStorageMetadata { + fn from(ir: PalletStorageMetadataIR) -> Self { + PalletStorageMetadata { + prefix: ir.prefix, + entries: ir.entries.into_iter().map(Into::into).collect(), + } + } +} + +impl From for PalletCallMetadata { + fn from(ir: PalletCallMetadataIR) -> Self { + PalletCallMetadata { ty: ir.ty } + } +} + +impl From for PalletEventMetadata { + fn from(ir: PalletEventMetadataIR) -> Self { + PalletEventMetadata { ty: ir.ty } + } +} + +impl From for PalletConstantMetadata { + fn from(ir: PalletConstantMetadataIR) -> Self { + PalletConstantMetadata { name: ir.name, ty: ir.ty, value: ir.value, docs: ir.docs } + } +} + +impl From for PalletErrorMetadata { + fn from(ir: PalletErrorMetadataIR) -> Self { + PalletErrorMetadata { ty: ir.ty } + } +} + +impl From for SignedExtensionMetadata { + fn from(ir: SignedExtensionMetadataIR) -> Self { + SignedExtensionMetadata { + identifier: ir.identifier, + ty: ir.ty, + additional_signed: ir.additional_signed, + } + } +} + +impl From for ExtrinsicMetadata { + fn from(ir: ExtrinsicMetadataIR) -> Self { + ExtrinsicMetadata { + ty: ir.ty, + version: ir.version, + signed_extensions: ir.signed_extensions.into_iter().map(Into::into).collect(), + } + } +} diff --git a/frame/support/src/storage/types/counted_map.rs b/frame/support/src/storage/types/counted_map.rs index 24b00be485e49..e57942cbe0667 100644 --- a/frame/support/src/storage/types/counted_map.rs +++ b/frame/support/src/storage/types/counted_map.rs @@ -18,7 +18,7 @@ //! Storage counted map type. use crate::{ - metadata::StorageEntryMetadata, + metadata_ir::StorageEntryMetadataIR, storage::{ generator::StorageMap as _, types::{ @@ -459,7 +459,7 @@ where OnEmpty: Get + 'static, MaxValues: Get>, { - fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec) { + fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec) { ::Map::build_metadata(docs, entries); CounterFor::::build_metadata( if cfg!(feature = "no-metadata-docs") { @@ -512,7 +512,7 @@ mod test { use super::*; use crate::{ hash::*, - metadata::{StorageEntryModifier, StorageEntryType, StorageHasher}, + metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}, storage::{bounded_vec::BoundedVec, types::ValueQuery}, traits::ConstU32, }; @@ -1147,21 +1147,21 @@ mod test { assert_eq!( entries, vec![ - StorageEntryMetadata { + StorageEntryMetadataIR { name: "foo", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Twox64Concat], + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { + hashers: vec![StorageHasherIR::Twox64Concat], key: scale_info::meta_type::(), value: scale_info::meta_type::(), }, default: 97u32.encode(), docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "counter_for_foo", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0, 0, 0, 0], docs: if cfg!(feature = "no-metadata-docs") { vec![] diff --git a/frame/support/src/storage/types/double_map.rs b/frame/support/src/storage/types/double_map.rs index 6a4bdc1e68d72..08ac1709c4b68 100644 --- a/frame/support/src/storage/types/double_map.rs +++ b/frame/support/src/storage/types/double_map.rs @@ -19,7 +19,7 @@ //! StoragePrefixedDoubleMap traits and their methods directly. use crate::{ - metadata::{StorageEntryMetadata, StorageEntryType}, + metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}, storage::{ types::{OptionQuery, QueryKindTrait, StorageEntryMetadataBuilder}, KeyLenOf, StorageAppend, StorageDecodeLength, StoragePrefixedMap, StorageTryAppend, @@ -656,13 +656,13 @@ where OnEmpty: Get + 'static, MaxValues: Get>, { - fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec) { + fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec) { let docs = if cfg!(feature = "no-metadata-docs") { vec![] } else { docs }; - let entry = StorageEntryMetadata { + let entry = StorageEntryMetadataIR { name: Prefix::STORAGE_PREFIX, modifier: QueryKind::METADATA, - ty: StorageEntryType::Map { + ty: StorageEntryTypeIR::Map { hashers: vec![Hasher1::METADATA, Hasher2::METADATA], key: scale_info::meta_type::<(Key1, Key2)>(), value: scale_info::meta_type::(), @@ -736,7 +736,7 @@ mod test { use super::*; use crate::{ hash::*, - metadata::{StorageEntryModifier, StorageEntryType, StorageHasher}, + metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}, storage::types::ValueQuery, }; use sp_io::{hashing::twox_128, TestExternalities}; @@ -916,13 +916,13 @@ mod test { assert_eq!( entries, vec![ - StorageEntryMetadata { + StorageEntryMetadataIR { name: "foo", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Map { + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Map { hashers: vec![ - StorageHasher::Blake2_128Concat, - StorageHasher::Twox64Concat + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Twox64Concat ], key: scale_info::meta_type::<(u16, u8)>(), value: scale_info::meta_type::(), @@ -930,13 +930,13 @@ mod test { default: Option::::None.encode(), docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "foo", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { hashers: vec![ - StorageHasher::Blake2_128Concat, - StorageHasher::Twox64Concat + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Twox64Concat ], key: scale_info::meta_type::<(u16, u8)>(), value: scale_info::meta_type::(), diff --git a/frame/support/src/storage/types/key.rs b/frame/support/src/storage/types/key.rs index 901bdb8b0514c..bf87e593b063a 100755 --- a/frame/support/src/storage/types/key.rs +++ b/frame/support/src/storage/types/key.rs @@ -41,7 +41,7 @@ pub trait KeyGenerator { type HashFn: FnOnce(&[u8]) -> Vec; type HArg; - const HASHER_METADATA: &'static [crate::metadata::StorageHasher]; + const HASHER_METADATA: &'static [crate::metadata_ir::StorageHasherIR]; /// Given a `key` tuple, calculate the final key by encoding each element individually and /// hashing them using the corresponding hasher in the `KeyGenerator`. @@ -74,7 +74,7 @@ impl KeyGenerator for Key type HashFn = Box Vec>; type HArg = (Self::HashFn,); - const HASHER_METADATA: &'static [crate::metadata::StorageHasher] = &[H::METADATA]; + const HASHER_METADATA: &'static [crate::metadata_ir::StorageHasherIR] = &[H::METADATA]; fn final_key + TupleToEncodedIter>(key: KArg) -> Vec { H::hash(&key.to_encoded_iter().next().expect("should have at least one element!")) @@ -114,7 +114,7 @@ impl KeyGenerator for Tuple { for_tuples!( type HArg = ( #(Tuple::HashFn),* ); ); type HashFn = Box Vec>; - const HASHER_METADATA: &'static [crate::metadata::StorageHasher] = + const HASHER_METADATA: &'static [crate::metadata_ir::StorageHasherIR] = &[for_tuples!( #(Tuple::Hasher::METADATA),* )]; fn final_key + TupleToEncodedIter>(key: KArg) -> Vec { diff --git a/frame/support/src/storage/types/map.rs b/frame/support/src/storage/types/map.rs index 53cf74d26f17c..2110732b2f69c 100644 --- a/frame/support/src/storage/types/map.rs +++ b/frame/support/src/storage/types/map.rs @@ -19,7 +19,7 @@ //! methods directly. use crate::{ - metadata::{StorageEntryMetadata, StorageEntryType}, + metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}, storage::{ types::{OptionQuery, QueryKindTrait, StorageEntryMetadataBuilder}, KeyLenOf, StorageAppend, StorageDecodeLength, StoragePrefixedMap, StorageTryAppend, @@ -409,13 +409,13 @@ where OnEmpty: Get + 'static, MaxValues: Get>, { - fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec) { + fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec) { let docs = if cfg!(feature = "no-metadata-docs") { vec![] } else { docs }; - let entry = StorageEntryMetadata { + let entry = StorageEntryMetadataIR { name: Prefix::STORAGE_PREFIX, modifier: QueryKind::METADATA, - ty: StorageEntryType::Map { + ty: StorageEntryTypeIR::Map { hashers: vec![Hasher::METADATA], key: scale_info::meta_type::(), value: scale_info::meta_type::(), @@ -483,7 +483,7 @@ mod test { use super::*; use crate::{ hash::*, - metadata::{StorageEntryModifier, StorageEntryType, StorageHasher}, + metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}, storage::types::ValueQuery, }; use sp_io::{hashing::twox_128, TestExternalities}; @@ -706,22 +706,22 @@ mod test { assert_eq!( entries, vec![ - StorageEntryMetadata { + StorageEntryMetadataIR { name: "foo", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat], + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Map { + hashers: vec![StorageHasherIR::Blake2_128Concat], key: scale_info::meta_type::(), value: scale_info::meta_type::(), }, default: Option::::None.encode(), docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "foo", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat], + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { + hashers: vec![StorageHasherIR::Blake2_128Concat], key: scale_info::meta_type::(), value: scale_info::meta_type::(), }, diff --git a/frame/support/src/storage/types/mod.rs b/frame/support/src/storage/types/mod.rs index 9a6f15d1ee820..3a5bae2e608b7 100644 --- a/frame/support/src/storage/types/mod.rs +++ b/frame/support/src/storage/types/mod.rs @@ -18,7 +18,7 @@ //! Storage types to build abstraction on storage, they implements storage traits such as //! StorageMap and others. -use crate::metadata::{StorageEntryMetadata, StorageEntryModifier}; +use crate::metadata_ir::{StorageEntryMetadataIR, StorageEntryModifierIR}; use codec::FullCodec; use sp_std::prelude::*; @@ -50,7 +50,7 @@ pub use value::StorageValue; /// value. pub trait QueryKindTrait { /// Metadata for the storage kind. - const METADATA: StorageEntryModifier; + const METADATA: StorageEntryModifierIR; /// Type returned on query type Query: FullCodec + 'static; @@ -73,7 +73,7 @@ impl QueryKindTrait for OptionQuery where Value: FullCodec + 'static, { - const METADATA: StorageEntryModifier = StorageEntryModifier::Optional; + const METADATA: StorageEntryModifierIR = StorageEntryModifierIR::Optional; type Query = Option; @@ -95,7 +95,7 @@ where Error: FullCodec + 'static, OnEmpty: crate::traits::Get>, { - const METADATA: StorageEntryModifier = StorageEntryModifier::Optional; + const METADATA: StorageEntryModifierIR = StorageEntryModifierIR::Optional; type Query = Result; @@ -118,7 +118,7 @@ where Value: FullCodec + 'static, OnEmpty: crate::traits::Get, { - const METADATA: StorageEntryModifier = StorageEntryModifier::Default; + const METADATA: StorageEntryModifierIR = StorageEntryModifierIR::Default; type Query = Value; @@ -136,5 +136,5 @@ where /// Implemented by each of the storage types: value, map, countedmap, doublemap and nmap. pub trait StorageEntryMetadataBuilder { /// Build into `entries` the storage metadata entries of a storage given some `docs`. - fn build_metadata(doc: Vec<&'static str>, entries: &mut Vec); + fn build_metadata(doc: Vec<&'static str>, entries: &mut Vec); } diff --git a/frame/support/src/storage/types/nmap.rs b/frame/support/src/storage/types/nmap.rs index d971035968ff2..9b63ca7b0f417 100755 --- a/frame/support/src/storage/types/nmap.rs +++ b/frame/support/src/storage/types/nmap.rs @@ -19,7 +19,7 @@ //! StoragePrefixedDoubleMap traits and their methods directly. use crate::{ - metadata::{StorageEntryMetadata, StorageEntryType}, + metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}, storage::{ types::{ EncodeLikeTuple, HasKeyPrefix, HasReversibleKeyPrefix, OptionQuery, QueryKindTrait, @@ -550,13 +550,13 @@ where OnEmpty: Get + 'static, MaxValues: Get>, { - fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec) { + fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec) { let docs = if cfg!(feature = "no-metadata-docs") { vec![] } else { docs }; - let entry = StorageEntryMetadata { + let entry = StorageEntryMetadataIR { name: Prefix::STORAGE_PREFIX, modifier: QueryKind::METADATA, - ty: StorageEntryType::Map { + ty: StorageEntryTypeIR::Map { key: scale_info::meta_type::(), hashers: Key::HASHER_METADATA.to_vec(), value: scale_info::meta_type::(), @@ -620,7 +620,7 @@ mod test { use super::*; use crate::{ hash::{StorageHasher as _, *}, - metadata::{StorageEntryModifier, StorageHasher}, + metadata_ir::{StorageEntryModifierIR, StorageHasherIR}, storage::types::{Key as NMapKey, ValueQuery}, }; use sp_io::{hashing::twox_128, TestExternalities}; @@ -791,22 +791,22 @@ mod test { assert_eq!( entries, vec![ - StorageEntryMetadata { + StorageEntryMetadataIR { name: "Foo", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat], + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Map { + hashers: vec![StorageHasherIR::Blake2_128Concat], key: scale_info::meta_type::(), value: scale_info::meta_type::(), }, default: Option::::None.encode(), docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "Foo", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat], + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { + hashers: vec![StorageHasherIR::Blake2_128Concat], key: scale_info::meta_type::(), value: scale_info::meta_type::(), }, @@ -991,13 +991,13 @@ mod test { assert_eq!( entries, vec![ - StorageEntryMetadata { + StorageEntryMetadataIR { name: "Foo", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Map { + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Map { hashers: vec![ - StorageHasher::Blake2_128Concat, - StorageHasher::Twox64Concat + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Twox64Concat ], key: scale_info::meta_type::<(u16, u8)>(), value: scale_info::meta_type::(), @@ -1005,13 +1005,13 @@ mod test { default: Option::::None.encode(), docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "Foo", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { hashers: vec![ - StorageHasher::Blake2_128Concat, - StorageHasher::Twox64Concat + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Twox64Concat ], key: scale_info::meta_type::<(u16, u8)>(), value: scale_info::meta_type::(), @@ -1232,14 +1232,14 @@ mod test { assert_eq!( entries, vec![ - StorageEntryMetadata { + StorageEntryMetadataIR { name: "Foo", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Map { + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Map { hashers: vec![ - StorageHasher::Blake2_128Concat, - StorageHasher::Blake2_128Concat, - StorageHasher::Twox64Concat + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Twox64Concat ], key: scale_info::meta_type::<(u16, u16, u16)>(), value: scale_info::meta_type::(), @@ -1247,14 +1247,14 @@ mod test { default: Option::::None.encode(), docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "Foo", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { hashers: vec![ - StorageHasher::Blake2_128Concat, - StorageHasher::Blake2_128Concat, - StorageHasher::Twox64Concat + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Twox64Concat ], key: scale_info::meta_type::<(u16, u16, u16)>(), value: scale_info::meta_type::(), diff --git a/frame/support/src/storage/types/value.rs b/frame/support/src/storage/types/value.rs index 64fb432b2dab1..d5fbb0656bbd1 100644 --- a/frame/support/src/storage/types/value.rs +++ b/frame/support/src/storage/types/value.rs @@ -18,7 +18,7 @@ //! Storage value type. Implements StorageValue trait and its method directly. use crate::{ - metadata::{StorageEntryMetadata, StorageEntryType}, + metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}, storage::{ generator::StorageValue as StorageValueT, types::{OptionQuery, QueryKindTrait, StorageEntryMetadataBuilder}, @@ -221,13 +221,13 @@ where QueryKind: QueryKindTrait, OnEmpty: crate::traits::Get + 'static, { - fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec) { + fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec) { let docs = if cfg!(feature = "no-metadata-docs") { vec![] } else { docs }; - let entry = StorageEntryMetadata { + let entry = StorageEntryMetadataIR { name: Prefix::STORAGE_PREFIX, modifier: QueryKind::METADATA, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: OnEmpty::get().encode(), docs, }; @@ -278,7 +278,7 @@ where #[cfg(test)] mod test { use super::*; - use crate::{metadata::StorageEntryModifier, storage::types::ValueQuery}; + use crate::{metadata_ir::StorageEntryModifierIR, storage::types::ValueQuery}; use sp_io::{hashing::twox_128, TestExternalities}; struct Prefix; @@ -363,17 +363,17 @@ mod test { assert_eq!( entries, vec![ - StorageEntryMetadata { + StorageEntryMetadataIR { name: "foo", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: Option::::None.encode(), docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "foo", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: 97u32.encode(), docs: vec![], } diff --git a/frame/support/test/tests/decl_storage.rs b/frame/support/test/tests/decl_storage.rs index c2ee7742426bb..bee1dc83d5589 100644 --- a/frame/support/test/tests/decl_storage.rs +++ b/frame/support/test/tests/decl_storage.rs @@ -19,7 +19,7 @@ // Do not complain about unused `dispatch` and `dispatch_aux`. #[allow(dead_code)] mod tests { - use frame_support::metadata::*; + use frame_support::metadata_ir::*; use sp_io::TestExternalities; frame_support::decl_module! { @@ -104,195 +104,195 @@ mod tests { type Origin2 = u32; } - fn expected_metadata() -> PalletStorageMetadata { - PalletStorageMetadata { + fn expected_metadata() -> PalletStorageMetadataIR { + PalletStorageMetadataIR { prefix: "TestStorage", entries: vec![ - StorageEntryMetadata { + StorageEntryMetadataIR { name: "U32", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0], docs: vec![" Hello, this is doc!"], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "PUBU32", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "U32MYDEF", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "PUBU32MYDEF", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GETU32", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "PUBGETU32", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GETU32WITHCONFIG", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "PUBGETU32WITHCONFIG", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GETU32MYDEF", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "PUBGETU32MYDEF", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![3, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GETU32WITHCONFIGMYDEF", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![2, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "PUBGETU32WITHCONFIGMYDEF", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![1, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "PUBGETU32WITHCONFIGMYDEFOPT", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GetU32WithBuilder", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GetOptU32WithBuilderSome", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GetOptU32WithBuilderNone", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "MAPU32", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat], + 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![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "PUBMAPU32", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat], + 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![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GETMAPU32", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat], + 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![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "PUBGETMAPU32", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat], + 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![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "GETMAPU32MYDEF", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat], + 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![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "PUBGETMAPU32MYDEF", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Blake2_128Concat], + 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![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "DOUBLEMAP", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Map { + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Map { hashers: vec![ - StorageHasher::Blake2_128Concat, - StorageHasher::Blake2_128Concat, + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Blake2_128Concat, ], key: scale_info::meta_type::<(u32, u32)>(), value: scale_info::meta_type::<[u8; 4]>(), @@ -300,13 +300,13 @@ mod tests { default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "DOUBLEMAP2", - modifier: StorageEntryModifier::Optional, - ty: StorageEntryType::Map { + modifier: StorageEntryModifierIR::Optional, + ty: StorageEntryTypeIR::Map { hashers: vec![ - StorageHasher::Blake2_128Concat, - StorageHasher::Blake2_128Concat, + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Blake2_128Concat, ], key: scale_info::meta_type::<(u32, u32)>(), value: scale_info::meta_type::<[u8; 4]>(), @@ -314,47 +314,50 @@ mod tests { default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "COMPLEXTYPE1", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::<(Option,)>()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::<(Option,)>()), default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "COMPLEXTYPE2", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::<( + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::<( [[(u16, Option<()>); 32]; 12], u32, )>()), default: [0u8; 1156].to_vec(), docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "COMPLEXTYPE3", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::<[u32; 25]>()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::<[u32; 25]>()), default: [0u8; 100].to_vec(), docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "NMAP", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { key: scale_info::meta_type::<(u32, u16)>(), - hashers: vec![StorageHasher::Blake2_128Concat, StorageHasher::Twox64Concat], + hashers: vec![ + StorageHasherIR::Blake2_128Concat, + StorageHasherIR::Twox64Concat, + ], value: scale_info::meta_type::(), }, default: vec![0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "NMAP2", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { key: scale_info::meta_type::(), - hashers: vec![StorageHasher::Blake2_128Concat], + hashers: vec![StorageHasherIR::Blake2_128Concat], value: scale_info::meta_type::(), }, default: vec![0], diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 8780e18405f27..9b08e175b1ca8 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -20,9 +20,9 @@ use codec::{Codec, Decode, Encode, EncodeLike, MaxEncodedLen}; use frame_support::{ inherent::{InherentData, InherentIdentifier, MakeFatalError, ProvideInherent}, - metadata::{ - PalletStorageMetadata, StorageEntryMetadata, StorageEntryModifier, StorageEntryType, - StorageHasher, + metadata_ir::{ + PalletStorageMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, + StorageEntryTypeIR, StorageHasherIR, }, traits::{ConstU32, Get}, Parameter, StorageDoubleMap, StorageMap, StorageValue, @@ -410,33 +410,33 @@ fn storage_with_instance_basic_operation() { }); } -fn expected_metadata() -> PalletStorageMetadata { - PalletStorageMetadata { +fn expected_metadata() -> PalletStorageMetadataIR { + PalletStorageMetadataIR { prefix: "Instance2Module2", entries: vec![ - StorageEntryMetadata { + StorageEntryMetadataIR { name: "Value", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Plain(scale_info::meta_type::()), + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), default: vec![0, 0, 0, 0], docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "Map", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Identity], + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { + hashers: vec![StorageHasherIR::Identity], key: scale_info::meta_type::(), value: scale_info::meta_type::(), }, default: [0u8; 8].to_vec(), docs: vec![], }, - StorageEntryMetadata { + StorageEntryMetadataIR { name: "DoubleMap", - modifier: StorageEntryModifier::Default, - ty: StorageEntryType::Map { - hashers: vec![StorageHasher::Identity, StorageHasher::Identity], + modifier: StorageEntryModifierIR::Default, + ty: StorageEntryTypeIR::Map { + hashers: vec![StorageHasherIR::Identity, StorageHasherIR::Identity], key: scale_info::meta_type::<(u64, u64)>(), value: scale_info::meta_type::(), }, diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index fbebbef455f7b..b9e531fb42105 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -37,6 +37,9 @@ use sp_io::{ }; use sp_runtime::{DispatchError, ModuleError}; +/// Latest stable metadata version used for testing. +const LATEST_METADATA_VERSION: u32 = 14; + pub struct SomeType1; impl From for u64 { fn from(_t: SomeType1) -> Self { @@ -1593,6 +1596,43 @@ fn metadata() { pretty_assertions::assert_eq!(actual_metadata.pallets, expected_metadata.pallets); } +#[test] +fn metadata_at_version() { + use frame_support::metadata::*; + use sp_core::Decode; + + let metadata = Runtime::metadata(); + let at_metadata = match Runtime::metadata_at_version(LATEST_METADATA_VERSION) { + Some(opaque) => { + let bytes = &*opaque; + let metadata: RuntimeMetadataPrefixed = Decode::decode(&mut &bytes[..]).unwrap(); + metadata + }, + _ => panic!("metadata has been bumped, test needs to be updated"), + }; + + assert_eq!(metadata, at_metadata); +} + +#[test] +fn metadata_versions() { + assert_eq!(vec![LATEST_METADATA_VERSION], Runtime::metadata_versions()); +} + +#[test] +fn metadata_ir_pallet_runtime_docs() { + let ir = Runtime::metadata_ir(); + let pallet = ir + .pallets + .iter() + .find(|pallet| pallet.name == "Example") + .expect("Pallet should be present"); + + let readme = "Support code for the runtime.\n\nLicense: Apache-2.0"; + let expected = vec![" Pallet documentation", readme, readme]; + assert_eq!(pallet.docs, expected); +} + #[test] fn test_pallet_runtime_docs() { let docs = crate::pallet::Pallet::::pallet_documentation_metadata(); diff --git a/primitives/api/src/lib.rs b/primitives/api/src/lib.rs index 7542ca3f20ccd..ff101c3add947 100644 --- a/primitives/api/src/lib.rs +++ b/primitives/api/src/lib.rs @@ -729,8 +729,20 @@ decl_runtime_apis! { } /// The `Metadata` api trait that returns metadata for the runtime. + #[api_version(2)] pub trait Metadata { /// Returns the metadata of a runtime. fn metadata() -> OpaqueMetadata; + + /// Returns the metadata at a given version. + /// + /// If the given `version` isn't supported, this will return `None`. + /// Use [`Self::metadata_versions`] to find out about supported metadata version of the runtime. + fn metadata_at_version(version: u32) -> Option; + + /// Returns the supported metadata versions. + /// + /// This can be used to call `metadata_at_version`. + fn metadata_versions() -> sp_std::vec::Vec; } } diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 83b4e2977b5cd..c9a0ac04d63ba 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -437,7 +437,6 @@ cfg_if! { #[derive(Clone, Eq, PartialEq, TypeInfo)] pub struct Runtime; - impl GetNodeBlockType for Runtime { type NodeBlock = Block; } @@ -729,6 +728,14 @@ cfg_if! { fn metadata() -> OpaqueMetadata { unimplemented!() } + + fn metadata_at_version(_version: u32) -> Option { + unimplemented!() + } + + fn metadata_versions() -> sp_std::vec::Vec { + unimplemented!() + } } impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { @@ -1021,6 +1028,14 @@ cfg_if! { fn metadata() -> OpaqueMetadata { unimplemented!() } + + fn metadata_at_version(_version: u32) -> Option { + unimplemented!() + } + + fn metadata_versions() -> sp_std::vec::Vec { + unimplemented!() + } } impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { From 36ed84069343c55ec4280b2d3cc49c49e3b019d2 Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Wed, 15 Mar 2023 19:27:18 +0100 Subject: [PATCH 19/80] pin specific version of timestamp script (#13613) --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 44f98db3bf185..6cf06273650f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -313,6 +313,7 @@ include: rules: - if: $PIPELINE != "automatic-crate-publishing" - project: parity/infrastructure/ci_cd/shared + ref: v0.1 file: /common/timestamp.yml #### stage: notify From 8b5306e1a607a14e08e13fd521f747319ecb6846 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 15 Mar 2023 21:43:22 +0100 Subject: [PATCH 20/80] Add dedicated `FeePolynomial` struct (#13612) * Add FeePolynomial struct Signed-off-by: Oliver Tale-Yazdi * Add Weight::without_{ref_time, proof_size} Signed-off-by: Oliver Tale-Yazdi * Docs Signed-off-by: Oliver Tale-Yazdi * Cleanup code Signed-off-by: Oliver Tale-Yazdi * Add docs Signed-off-by: Oliver Tale-Yazdi * doc Signed-off-by: Oliver Tale-Yazdi * Fix docs Signed-off-by: Oliver Tale-Yazdi * docs Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi --- primitives/weights/src/lib.rs | 95 ++++++++++++++++++++++------- primitives/weights/src/weight_v2.rs | 10 +++ 2 files changed, 82 insertions(+), 23 deletions(-) diff --git a/primitives/weights/src/lib.rs b/primitives/weights/src/lib.rs index 8a842307355bf..faa641a0f0c53 100644 --- a/primitives/weights/src/lib.rs +++ b/primitives/weights/src/lib.rs @@ -30,7 +30,7 @@ use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; use smallvec::SmallVec; use sp_arithmetic::{ - traits::{BaseArithmetic, SaturatedConversion, Saturating, Unsigned}, + traits::{BaseArithmetic, SaturatedConversion, Unsigned}, Perbill, }; use sp_core::Get; @@ -118,9 +118,77 @@ pub struct WeightToFeeCoefficient { pub degree: u8, } -/// A list of coefficients that represent one polynomial. +impl WeightToFeeCoefficient +where + Balance: BaseArithmetic + From + Copy + Unsigned, +{ + /// Evaluate the term at `x` and saturatingly amalgamate into `result`. + /// + /// The unsigned value for the term is calculated as: + /// ```ignore + /// (frac * x^(degree) + integer * x^(degree)) + /// ``` + /// Depending on the value of `negative`, it is added or subtracted from the `result`. + pub fn saturating_eval(&self, mut result: Balance, x: Balance) -> Balance { + let power = x.saturating_pow(self.degree.into()); + + let frac = self.coeff_frac * power; // Overflow safe. + let integer = self.coeff_integer.saturating_mul(power); + // Do not add them together here to avoid an underflow. + + if self.negative { + result = result.saturating_sub(frac); + result = result.saturating_sub(integer); + } else { + result = result.saturating_add(frac); + result = result.saturating_add(integer); + } + + result + } +} + +/// A list of coefficients that represent a polynomial. pub type WeightToFeeCoefficients = SmallVec<[WeightToFeeCoefficient; 4]>; +/// A list of coefficients that represent a polynomial. +/// +/// Can be [eval](Self::eval)uated at a specific `u64` to get the fee. The evaluations happens by +/// summing up all term [results](`WeightToFeeCoefficient::saturating_eval`). The order of the +/// coefficients matters since it uses saturating arithmetic. This struct does therefore not model a +/// polynomial in the mathematical sense (polynomial ring). +/// +/// For visualization purposes, the formulas of the unsigned terms look like: +/// +/// ```ignore +/// (c[0].frac * x^(c[0].degree) + c[0].integer * x^(c[0].degree)) +/// (c[1].frac * x^(c[1].degree) + c[1].integer * x^(c[1].degree)) +/// ... +/// ``` +/// Depending on the value of `c[i].negative`, each term is added or subtracted from the result. +/// The result is initialized as zero. +pub struct FeePolynomial { + coefficients: SmallVec<[WeightToFeeCoefficient; 4]>, +} + +impl From> for FeePolynomial { + fn from(coefficients: WeightToFeeCoefficients) -> Self { + Self { coefficients } + } +} + +impl FeePolynomial +where + Balance: BaseArithmetic + From + Copy + Unsigned, +{ + /// Evaluate the polynomial at a specific `x`. + pub fn eval(&self, x: u64) -> Balance { + self.coefficients.iter().fold(Balance::zero(), |acc, term| { + term.saturating_eval(acc, Balance::saturated_from(x)) + }) + } +} + /// A trait that describes the weight to fee calculation. pub trait WeightToFee { /// The type that is returned as result from calculation. @@ -157,27 +225,8 @@ where /// This should not be overridden in most circumstances. Calculation is done in the /// `Balance` type and never overflows. All evaluation is saturating. fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::polynomial() - .iter() - .fold(Self::Balance::saturated_from(0u32), |mut acc, args| { - let w = Self::Balance::saturated_from(weight.ref_time()) - .saturating_pow(args.degree.into()); - - // The sum could get negative. Therefore we only sum with the accumulator. - // The Perbill Mul implementation is non overflowing. - let frac = args.coeff_frac * w; - let integer = args.coeff_integer.saturating_mul(w); - - if args.negative { - acc = acc.saturating_sub(frac); - acc = acc.saturating_sub(integer); - } else { - acc = acc.saturating_add(frac); - acc = acc.saturating_add(integer); - } - - acc - }) + let poly: FeePolynomial = Self::polynomial().into(); + poly.eval(weight.ref_time()) } } diff --git a/primitives/weights/src/weight_v2.rs b/primitives/weights/src/weight_v2.rs index ca137145920bb..76c40c16cbf03 100644 --- a/primitives/weights/src/weight_v2.rs +++ b/primitives/weights/src/weight_v2.rs @@ -74,6 +74,16 @@ impl Weight { &mut self.proof_size } + /// Return self but discard any reference time. + pub const fn without_ref_time(&self) -> Self { + Self { ref_time: 0, proof_size: self.proof_size } + } + + /// Return self but discard any proof size. + pub const fn without_proof_size(&self) -> Self { + Self { ref_time: self.ref_time, proof_size: 0 } + } + pub const MAX: Self = Self { ref_time: u64::MAX, proof_size: u64::MAX }; /// Get the conservative min of `self` and `other` weight. From 86731af2629fdedc39a31bd9666fdd1b5df5ed2d Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 15 Mar 2023 18:04:28 -0300 Subject: [PATCH 21/80] Make Pay trait from salaries pallet more generic (#13609) * Make Pay trait from salaries pallet more generic * Rename and add missing * Update frame/support/src/traits/tokens/pay.rs * Update pay.rs * Update pay.rs * Update pay.rs * Add better documentation for the AssetKind associated type --------- Co-authored-by: Gavin Wood Co-authored-by: parity-processbot <> --- bin/node/runtime/src/lib.rs | 6 +- frame/salary/src/lib.rs | 74 ++---------------- frame/salary/src/tests.rs | 11 ++- frame/support/src/traits/tokens.rs | 2 + frame/support/src/traits/tokens/pay.rs | 103 +++++++++++++++++++++++++ 5 files changed, 122 insertions(+), 74 deletions(-) create mode 100644 frame/support/src/traits/tokens/pay.rs diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 5d1dea02e8256..9f4ad2ed26474 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -33,7 +33,7 @@ use frame_support::{ parameter_types, traits::{ fungible::ItemOf, - tokens::{nonfungibles_v2::Inspect, GetSalary}, + tokens::{nonfungibles_v2::Inspect, GetSalary, PayFromAccount}, AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU16, ConstU32, Currency, EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, Nothing, OnUnbalanced, U128CurrencyToVote, WithdrawReasons, @@ -56,7 +56,7 @@ use pallet_election_provider_multi_phase::SolutionAccuracyOf; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_nfts::PalletFeatures; use pallet_nis::WithMaximumOf; -use pallet_session::historical::{self as pallet_session_historical}; +use pallet_session::historical as pallet_session_historical; pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use sp_api::impl_runtime_apis; @@ -1567,7 +1567,7 @@ impl GetSalary for SalaryForRank { impl pallet_salary::Config for Runtime { type WeightInfo = (); type RuntimeEvent = RuntimeEvent; - type Paymaster = pallet_salary::PayFromAccount; + type Paymaster = PayFromAccount; type Members = RankedCollective; type Salary = SalaryForRank; type RegistrationPeriod = ConstU32<200>; diff --git a/frame/salary/src/lib.rs b/frame/salary/src/lib.rs index 6f9e63271cc2f..0b2b4b47d8b70 100644 --- a/frame/salary/src/lib.rs +++ b/frame/salary/src/lib.rs @@ -20,18 +20,17 @@ #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "128"] -use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; +use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_arithmetic::traits::{Saturating, Zero}; -use sp_core::TypedGet; use sp_runtime::Perbill; -use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; +use sp_std::{marker::PhantomData, prelude::*}; use frame_support::{ dispatch::DispatchResultWithPostInfo, ensure, traits::{ - tokens::{fungible, Balance, GetSalary}, + tokens::{GetSalary, Pay, PaymentStatus}, RankedMembers, }, RuntimeDebug, @@ -50,67 +49,6 @@ pub use weights::WeightInfo; /// Payroll cycle. pub type Cycle = u32; -/// Status for making a payment via the `Pay::pay` trait function. -#[derive(Encode, Decode, Eq, PartialEq, Clone, TypeInfo, MaxEncodedLen, RuntimeDebug)] -pub enum PaymentStatus { - /// Payment is in progress. Nothing to report yet. - InProgress, - /// Payment status is unknowable. It will never be reported successful or failed. - Unknown, - /// Payment happened successfully. - Success, - /// Payment failed. It may safely be retried. - Failure, -} - -/// Can be implemented by `PayFromAccount` using a `fungible` impl, but can also be implemented with -/// XCM/MultiAsset and made generic over assets. -pub trait Pay { - /// The type by which we measure units of the currency in which we make payments. - type Balance: Balance; - /// The type by which we identify the individuals to whom a payment may be made. - type AccountId; - /// An identifier given to an individual payment. - type Id: FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy; - /// Make a payment and return an identifier for later evaluation of success in some off-chain - /// mechanism (likely an event, but possibly not on this chain). - fn pay(who: &Self::AccountId, amount: Self::Balance) -> Result; - /// Check how a payment has proceeded. `id` must have been a previously returned by `pay` for - /// the result of this call to be meaningful. - fn check_payment(id: Self::Id) -> PaymentStatus; - /// Ensure that a call to pay with the given parameters will be successful if done immediately - /// after this call. Used in benchmarking code. - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful(who: &Self::AccountId, amount: Self::Balance); - /// Ensure that a call to `check_payment` with the given parameters will return either `Success` - /// or `Failure`. - #[cfg(feature = "runtime-benchmarks")] - fn ensure_concluded(id: Self::Id); -} - -/// Simple implementation of `Pay` which makes a payment from a "pot" - i.e. a single account. -pub struct PayFromAccount(sp_std::marker::PhantomData<(F, A)>); -impl + fungible::Mutate> Pay - for PayFromAccount -{ - type Balance = F::Balance; - type AccountId = A::Type; - type Id = (); - fn pay(who: &Self::AccountId, amount: Self::Balance) -> Result { - >::transfer(&A::get(), who, amount, false).map_err(|_| ())?; - Ok(()) - } - fn check_payment(_: ()) -> PaymentStatus { - PaymentStatus::Success - } - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful(_: &Self::AccountId, amount: Self::Balance) { - >::mint_into(&A::get(), amount).unwrap(); - } - #[cfg(feature = "runtime-benchmarks")] - fn ensure_concluded(_: Self::Id) {} -} - /// The status of the pallet instance. #[derive(Encode, Decode, Eq, PartialEq, Clone, TypeInfo, MaxEncodedLen, RuntimeDebug)] pub struct StatusType { @@ -168,7 +106,7 @@ pub mod pallet { /// Means by which we can make payments to accounts. This also defines the currency and the /// balance which we use to denote that currency. - type Paymaster: Pay::AccountId>; + type Paymaster: Pay::AccountId, AssetKind = ()>; /// The current membership of payees. type Members: RankedMembers::AccountId>; @@ -498,8 +436,8 @@ pub mod pallet { claimant.last_active = status.cycle_index; - let id = - T::Paymaster::pay(&beneficiary, payout).map_err(|()| Error::::PayError)?; + let id = T::Paymaster::pay(&beneficiary, (), payout) + .map_err(|()| Error::::PayError)?; claimant.status = Attempted { registered, id, amount: payout }; diff --git a/frame/salary/src/tests.rs b/frame/salary/src/tests.rs index e54b9612b152c..1b7bc6cbb6df5 100644 --- a/frame/salary/src/tests.rs +++ b/frame/salary/src/tests.rs @@ -99,11 +99,16 @@ fn set_status(id: u64, s: PaymentStatus) { pub struct TestPay; impl Pay for TestPay { - type AccountId = u64; + type Beneficiary = u64; type Balance = u64; type Id = u64; + type AssetKind = (); - fn pay(who: &Self::AccountId, amount: Self::Balance) -> Result { + fn pay( + who: &Self::Beneficiary, + _: Self::AssetKind, + amount: Self::Balance, + ) -> Result { PAID.with(|paid| *paid.borrow_mut().entry(*who).or_default() += amount); Ok(LAST_ID.with(|lid| { let x = *lid.borrow(); @@ -115,7 +120,7 @@ impl Pay for TestPay { STATUS.with(|s| s.borrow().get(&id).cloned().unwrap_or(PaymentStatus::Unknown)) } #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful(_: &Self::AccountId, _: Self::Balance) {} + fn ensure_successful(_: &Self::Beneficiary, _: Self::Balance) {} #[cfg(feature = "runtime-benchmarks")] fn ensure_concluded(id: Self::Id) { set_status(id, PaymentStatus::Failure) diff --git a/frame/support/src/traits/tokens.rs b/frame/support/src/traits/tokens.rs index e1a96f621bd4f..2d2bd63ada551 100644 --- a/frame/support/src/traits/tokens.rs +++ b/frame/support/src/traits/tokens.rs @@ -27,7 +27,9 @@ pub mod nonfungible_v2; pub mod nonfungibles; pub mod nonfungibles_v2; pub use imbalance::Imbalance; +pub mod pay; pub use misc::{ AssetId, Balance, BalanceConversion, BalanceStatus, ConvertRank, DepositConsequence, ExistenceRequirement, GetSalary, Locker, WithdrawConsequence, WithdrawReasons, }; +pub use pay::{Pay, PayFromAccount, PaymentStatus}; diff --git a/frame/support/src/traits/tokens/pay.rs b/frame/support/src/traits/tokens/pay.rs new file mode 100644 index 0000000000000..1c6a147b5f22e --- /dev/null +++ b/frame/support/src/traits/tokens/pay.rs @@ -0,0 +1,103 @@ +// 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. + +//! The Pay trait and associated types. + +use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; +use scale_info::TypeInfo; +use sp_core::{RuntimeDebug, TypedGet}; +use sp_std::fmt::Debug; + +use super::{fungible, Balance}; + +/// Can be implemented by `PayFromAccount` using a `fungible` impl, but can also be implemented with +/// XCM/MultiAsset and made generic over assets. +pub trait Pay { + /// The type by which we measure units of the currency in which we make payments. + type Balance: Balance; + /// The type by which we identify the beneficiaries to whom a payment may be made. + type Beneficiary; + /// The type for the kinds of asset that are going to be paid. + /// + /// The unit type can be used here to indicate there's only one kind of asset to do payments + /// with. When implementing, it should be clear from the context what that asset is. + type AssetKind; + /// An identifier given to an individual payment. + type Id: FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy; + /// Make a payment and return an identifier for later evaluation of success in some off-chain + /// mechanism (likely an event, but possibly not on this chain). + fn pay( + who: &Self::Beneficiary, + asset_kind: Self::AssetKind, + amount: Self::Balance, + ) -> Result; + /// Check how a payment has proceeded. `id` must have been previously returned by `pay` for + /// the result of this call to be meaningful. Once this returns anything other than + /// `InProgress` for some `id` it must return `Unknown` rather than the actual result + /// value. + fn check_payment(id: Self::Id) -> PaymentStatus; + /// Ensure that a call to pay with the given parameters will be successful if done immediately + /// after this call. Used in benchmarking code. + #[cfg(feature = "runtime-benchmarks")] + fn ensure_successful(who: &Self::Beneficiary, amount: Self::Balance); + /// Ensure that a call to `check_payment` with the given parameters will return either `Success` + /// or `Failure`. + #[cfg(feature = "runtime-benchmarks")] + fn ensure_concluded(id: Self::Id); +} + +/// Status for making a payment via the `Pay::pay` trait function. +#[derive(Encode, Decode, Eq, PartialEq, Clone, TypeInfo, MaxEncodedLen, RuntimeDebug)] +pub enum PaymentStatus { + /// Payment is in progress. Nothing to report yet. + InProgress, + /// Payment status is unknowable. It may already have reported the result, or if not then + /// it will never be reported successful or failed. + Unknown, + /// Payment happened successfully. + Success, + /// Payment failed. It may safely be retried. + Failure, +} + +/// Simple implementation of `Pay` which makes a payment from a "pot" - i.e. a single account. +pub struct PayFromAccount(sp_std::marker::PhantomData<(F, A)>); +impl + fungible::Mutate> Pay + for PayFromAccount +{ + type Balance = F::Balance; + type Beneficiary = A::Type; + type AssetKind = (); + type Id = (); + fn pay( + who: &Self::Beneficiary, + _: Self::AssetKind, + amount: Self::Balance, + ) -> Result { + >::transfer(&A::get(), who, amount, false).map_err(|_| ())?; + Ok(()) + } + fn check_payment(_: ()) -> PaymentStatus { + PaymentStatus::Success + } + #[cfg(feature = "runtime-benchmarks")] + fn ensure_successful(_: &Self::Beneficiary, amount: Self::Balance) { + >::mint_into(&A::get(), amount).unwrap(); + } + #[cfg(feature = "runtime-benchmarks")] + fn ensure_concluded(_: Self::Id) {} +} From 9f933c4d87a4682233328daaafbc9bbe2cc8e778 Mon Sep 17 00:00:00 2001 From: Sacha Lansky Date: Thu, 16 Mar 2023 08:29:20 +0000 Subject: [PATCH 22/80] Fix typos (#13616) --- frame/examples/offchain-worker/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index 418ad5d139ef3..1a63955c04741 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -166,7 +166,7 @@ pub mod pallet { /// /// By implementing `fn offchain_worker` you declare a new offchain worker. /// This function will be called when the node is fully synced and a new best block is - /// succesfuly imported. + /// successfully imported. /// Note that it's not guaranteed for offchain workers to run on EVERY block, there might /// be cases where some blocks are skipped, or for some the worker runs twice (re-orgs), /// so the code should be able to handle that. @@ -224,7 +224,7 @@ pub mod pallet { /// The transaction needs to be signed (see `ensure_signed`) check, so that the caller /// pays a fee to execute it. /// This makes sure that it's not easy (or rather cheap) to attack the chain by submitting - /// excesive transactions, but note that it doesn't ensure the price oracle is actually + /// excessive transactions, but note that it doesn't ensure the price oracle is actually /// working and receives (and provides) meaningful data. /// This example is not focused on correctness of the oracle itself, but rather its /// purpose is to showcase offchain worker capabilities. @@ -336,7 +336,7 @@ pub mod pallet { /// Defines the block when next unsigned transaction will be accepted. /// - /// To prevent spam of unsigned (and unpayed!) transactions on the network, + /// To prevent spam of unsigned (and unpaid!) transactions on the network, /// we only allow one transaction every `T::UnsignedInterval` blocks. /// This storage entry defines when new transaction is going to be accepted. #[pallet::storage] @@ -570,12 +570,12 @@ impl Pallet { fn fetch_price() -> Result { // We want to keep the offchain worker execution time reasonable, so we set a hard-coded // deadline to 2s to complete the external call. - // You can also wait idefinitely for the response, however you may still get a timeout + // You can also wait indefinitely for the response, however you may still get a timeout // coming from the host machine. let deadline = sp_io::offchain::timestamp().add(Duration::from_millis(2_000)); // Initiate an external HTTP GET request. // This is using high-level wrappers from `sp_runtime`, for the low-level calls that - // you can find in `sp_io`. The API is trying to be similar to `reqwest`, but + // you can find in `sp_io`. The API is trying to be similar to `request`, but // since we are running in a custom WASM execution environment we can't simply // import the library here. let request = From b0700a6d3e9a9dfa3897971ee62a06134bda17d3 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Thu, 16 Mar 2023 11:02:39 +0200 Subject: [PATCH 23/80] sc-consensus-beefy: improve beefy gossip validator (#13606) * sc-consensus-beefy: improve beefy gossip validator Old gossip validator was pretty dumb, being very permissive with incoming votes - only condition it had was to be newer than best finalized. New filter conditions: - voter rounds are initialized (discarding votes until voter is actually active), - only votes for current active set id are accepted, - only votes for rounds in the current voting session are accepted, - only votes for GRANDPA finalized blocks are accepted, - when BEEFY voter reaches mandatory round, only votes for said mandatory round are accepted. New validator uses the VoterOracle to easily implement above conditions and only allow through votes that are immediately useful to the voter. After every GRANDPA or BEEFY finality, the gossip validator filter is updated. * sc-consensus-beefy: remove votes enqueueing Since gossip validator will simply disallow votes for future rounds, and only allow votes that the voter can immediately process, there is no need for the voter to enqueue votes. It will see these "future" votes later in rebroadcasts, when voter will also be able to process them. Only at that point does gossip accept and consume them. * sc-consensus-beefy: refactor persistent state Move best-beefy and best-grandpa into VoterOracle instead of passing them around as params. VoterOracle ultimately needs to know best-beefy and/or best-grandpa for most of its functions. * sc-consensus-beefy: further restrict gossip validator Assuming mandatory done in current session: Instead of allowing votes for any round in the current session, only accept votes for rounds equal or better than best BEEFY finalized. * sc-consensus-beefy: add a couple of comments * sc-consensus-beefy: fix tests involving multiple tasks Finalize blocks one a time in tests where we want gossip to happen in a certain round. Otherwise, some tasks may be left behind in terms of gossip round numbers because once "scheduled" a task will greedily process as much as possible. This change should be in line with the real-world scenario where voters run "in parallel" across nodes, the only points of synchronization being the finality notifications. * sc-consensus-beefy: address review comments --------- Signed-off-by: acatangiu --- client/consensus/beefy/src/aux_schema.rs | 6 +- .../beefy/src/communication/gossip.rs | 204 +++---- client/consensus/beefy/src/lib.rs | 10 + client/consensus/beefy/src/metrics.rs | 24 - client/consensus/beefy/src/tests.rs | 183 ++---- client/consensus/beefy/src/worker.rs | 532 ++++++++---------- 6 files changed, 385 insertions(+), 574 deletions(-) diff --git a/client/consensus/beefy/src/aux_schema.rs b/client/consensus/beefy/src/aux_schema.rs index 2e99b4cc40638..84186140b6925 100644 --- a/client/consensus/beefy/src/aux_schema.rs +++ b/client/consensus/beefy/src/aux_schema.rs @@ -28,7 +28,7 @@ use sp_runtime::traits::Block as BlockT; const VERSION_KEY: &[u8] = b"beefy_auxschema_version"; const WORKER_STATE_KEY: &[u8] = b"beefy_voter_state"; -const CURRENT_VERSION: u32 = 2; +const CURRENT_VERSION: u32 = 3; pub(crate) fn write_current_version(backend: &BE) -> ClientResult<()> { info!(target: LOG_TARGET, "🥩 write aux schema version {:?}", CURRENT_VERSION); @@ -63,8 +63,8 @@ where match version { None => (), - Some(1) => (), // version 1 is totally obsolete and should be simply ignored - Some(2) => return load_decode::<_, PersistedState>(backend, WORKER_STATE_KEY), + Some(1) | Some(2) => (), // versions 1 & 2 are obsolete and should be simply ignored + Some(3) => return load_decode::<_, PersistedState>(backend, WORKER_STATE_KEY), other => return Err(ClientError::Backend(format!("Unsupported BEEFY DB version: {:?}", other))), } diff --git a/client/consensus/beefy/src/communication/gossip.rs b/client/consensus/beefy/src/communication/gossip.rs index 219203ee4e173..e49382251e846 100644 --- a/client/consensus/beefy/src/communication/gossip.rs +++ b/client/consensus/beefy/src/communication/gossip.rs @@ -31,11 +31,14 @@ use wasm_timer::Instant; use crate::{communication::peers::KnownPeers, keystore::BeefyKeystore, LOG_TARGET}; use sp_consensus_beefy::{ crypto::{Public, Signature}, - VoteMessage, + ValidatorSetId, VoteMessage, }; // Timeout for rebroadcasting messages. -const REBROADCAST_AFTER: Duration = Duration::from_secs(60 * 5); +#[cfg(not(test))] +const REBROADCAST_AFTER: Duration = Duration::from_secs(60); +#[cfg(test)] +const REBROADCAST_AFTER: Duration = Duration::from_secs(5); /// Gossip engine messages topic pub(crate) fn topic() -> B::Hash @@ -45,45 +48,51 @@ where <::Hashing as Hash>::hash(b"beefy") } +#[derive(Debug)] +pub(crate) struct GossipVoteFilter { + pub start: NumberFor, + pub end: NumberFor, + pub validator_set_id: ValidatorSetId, +} + /// A type that represents hash of the message. pub type MessageHash = [u8; 8]; -struct KnownVotes { - last_done: Option>, +struct VotesFilter { + filter: Option>, live: BTreeMap, fnv::FnvHashSet>, } -impl KnownVotes { +impl VotesFilter { pub fn new() -> Self { - Self { last_done: None, live: BTreeMap::new() } - } - - /// Create new round votes set if not already present. - fn insert(&mut self, round: NumberFor) { - self.live.entry(round).or_default(); + Self { filter: None, live: BTreeMap::new() } } - /// Remove `round` and older from live set, update `last_done` accordingly. - fn conclude(&mut self, round: NumberFor) { - self.live.retain(|&number, _| number > round); - self.last_done = self.last_done.max(Some(round)); + /// Update filter to new `start` and `set_id`. + fn update(&mut self, filter: GossipVoteFilter) { + self.live.retain(|&round, _| round >= filter.start && round <= filter.end); + self.filter = Some(filter); } - /// Return true if `round` is newer than previously concluded rounds. + /// Return true if `round` is >= than `max(session_start, best_beefy)`, + /// and vote set id matches session set id. /// /// Latest concluded round is still considered alive to allow proper gossiping for it. - fn is_live(&self, round: &NumberFor) -> bool { - Some(*round) >= self.last_done + fn is_live(&self, round: NumberFor, set_id: ValidatorSetId) -> bool { + self.filter + .as_ref() + .map(|f| set_id == f.validator_set_id && round >= f.start && round <= f.end) + .unwrap_or(false) } /// Add new _known_ `hash` to the round's known votes. - fn add_known(&mut self, round: &NumberFor, hash: MessageHash) { - self.live.get_mut(round).map(|known| known.insert(hash)); + fn add_known(&mut self, round: NumberFor, hash: MessageHash) { + self.live.entry(round).or_default().insert(hash); } /// Check if `hash` is already part of round's known votes. - fn is_known(&self, round: &NumberFor, hash: &MessageHash) -> bool { - self.live.get(round).map(|known| known.contains(hash)).unwrap_or(false) + fn is_known(&self, round: NumberFor, hash: &MessageHash) -> bool { + self.live.get(&round).map(|known| known.contains(hash)).unwrap_or(false) } } @@ -100,7 +109,7 @@ where B: Block, { topic: B::Hash, - known_votes: RwLock>, + votes_filter: RwLock>, next_rebroadcast: Mutex, known_peers: Arc>>, } @@ -112,26 +121,18 @@ where pub fn new(known_peers: Arc>>) -> GossipValidator { GossipValidator { topic: topic::(), - known_votes: RwLock::new(KnownVotes::new()), + votes_filter: RwLock::new(VotesFilter::new()), next_rebroadcast: Mutex::new(Instant::now() + REBROADCAST_AFTER), known_peers, } } - /// Note a voting round. - /// - /// Noting round will track gossiped votes for `round`. - pub(crate) fn note_round(&self, round: NumberFor) { - debug!(target: LOG_TARGET, "🥩 About to note gossip round #{}", round); - self.known_votes.write().insert(round); - } - - /// Conclude a voting round. + /// Update gossip validator filter. /// - /// This can be called once round is complete so we stop gossiping for it. - pub(crate) fn conclude_round(&self, round: NumberFor) { - debug!(target: LOG_TARGET, "🥩 About to drop gossip round #{}", round); - self.known_votes.write().conclude(round); + /// Only votes for `set_id` and rounds `start <= round <= end` will be accepted. + pub(crate) fn update_filter(&self, filter: GossipVoteFilter) { + debug!(target: LOG_TARGET, "🥩 New gossip filter {:?}", filter); + self.votes_filter.write().update(filter); } } @@ -152,25 +153,26 @@ where if let Ok(msg) = VoteMessage::, Public, Signature>::decode(&mut data) { let msg_hash = twox_64(data); let round = msg.commitment.block_number; + let set_id = msg.commitment.validator_set_id; + self.known_peers.lock().note_vote_for(*sender, round); // Verify general usefulness of the message. // We are going to discard old votes right away (without verification) // Also we keep track of already received votes to avoid verifying duplicates. { - let known_votes = self.known_votes.read(); + let filter = self.votes_filter.read(); - if !known_votes.is_live(&round) { + if !filter.is_live(round, set_id) { return ValidationResult::Discard } - if known_votes.is_known(&round, &msg_hash) { + if filter.is_known(round, &msg_hash) { return ValidationResult::ProcessAndKeep(self.topic) } } if BeefyKeystore::verify(&msg.id, &msg.signature, &msg.commitment.encode()) { - self.known_votes.write().add_known(&round, msg_hash); - self.known_peers.lock().note_vote_for(*sender, round); + self.votes_filter.write().add_known(round, msg_hash); return ValidationResult::ProcessAndKeep(self.topic) } else { // TODO: report peer @@ -185,7 +187,7 @@ where } fn message_expired<'a>(&'a self) -> Box bool + 'a> { - let known_votes = self.known_votes.read(); + let filter = self.votes_filter.read(); Box::new(move |_topic, mut data| { let msg = match VoteMessage::, Public, Signature>::decode(&mut data) { Ok(vote) => vote, @@ -193,7 +195,8 @@ where }; let round = msg.commitment.block_number; - let expired = !known_votes.is_live(&round); + let set_id = msg.commitment.validator_set_id; + let expired = !filter.is_live(round, set_id); trace!(target: LOG_TARGET, "🥩 Message for round #{} expired: {}", round, expired); @@ -208,6 +211,7 @@ where let now = Instant::now(); let mut next_rebroadcast = self.next_rebroadcast.lock(); if now >= *next_rebroadcast { + trace!(target: LOG_TARGET, "🥩 Gossip rebroadcast"); *next_rebroadcast = now + REBROADCAST_AFTER; true } else { @@ -215,7 +219,7 @@ where } }; - let known_votes = self.known_votes.read(); + let filter = self.votes_filter.read(); Box::new(move |_who, intent, _topic, mut data| { if let MessageIntent::PeriodicRebroadcast = intent { return do_rebroadcast @@ -227,7 +231,8 @@ where }; let round = msg.commitment.block_number; - let allowed = known_votes.is_live(&round); + let set_id = msg.commitment.validator_set_id; + let allowed = filter.is_live(round, set_id); trace!(target: LOG_TARGET, "🥩 Message for round #{} allowed: {}", round, allowed); @@ -252,81 +257,35 @@ mod tests { #[test] fn known_votes_insert_remove() { - let mut kv = KnownVotes::::new(); + let mut kv = VotesFilter::::new(); + let msg_hash = twox_64(b"data"); - kv.insert(1); - kv.insert(1); - kv.insert(2); + kv.add_known(1, msg_hash); + kv.add_known(1, msg_hash); + kv.add_known(2, msg_hash); assert_eq!(kv.live.len(), 2); - let mut kv = KnownVotes::::new(); - kv.insert(1); - kv.insert(2); - kv.insert(3); + kv.add_known(3, msg_hash); + assert!(kv.is_known(3, &msg_hash)); + assert!(!kv.is_known(3, &twox_64(b"other"))); + assert!(!kv.is_known(4, &msg_hash)); + assert_eq!(kv.live.len(), 3); - assert!(kv.last_done.is_none()); - kv.conclude(2); - assert_eq!(kv.live.len(), 1); - assert!(!kv.live.contains_key(&2)); - assert_eq!(kv.last_done, Some(2)); + assert!(kv.filter.is_none()); + assert!(!kv.is_live(1, 1)); - kv.conclude(1); - assert_eq!(kv.last_done, Some(2)); + kv.update(GossipVoteFilter { start: 3, end: 10, validator_set_id: 1 }); + assert_eq!(kv.live.len(), 1); + assert!(kv.live.contains_key(&3)); + assert!(!kv.is_live(2, 1)); + assert!(kv.is_live(3, 1)); + assert!(kv.is_live(4, 1)); + assert!(!kv.is_live(4, 2)); - kv.conclude(3); - assert_eq!(kv.last_done, Some(3)); + kv.update(GossipVoteFilter { start: 5, end: 10, validator_set_id: 2 }); assert!(kv.live.is_empty()); } - #[test] - fn note_and_drop_round_works() { - let gv = GossipValidator::::new(Arc::new(Mutex::new(KnownPeers::new()))); - - gv.note_round(1u64); - - assert!(gv.known_votes.read().is_live(&1u64)); - - gv.note_round(3u64); - gv.note_round(7u64); - gv.note_round(10u64); - - assert_eq!(gv.known_votes.read().live.len(), 4); - - gv.conclude_round(7u64); - - let votes = gv.known_votes.read(); - - // rounds 1 and 3 are outdated, don't gossip anymore - assert!(!votes.is_live(&1u64)); - assert!(!votes.is_live(&3u64)); - // latest concluded round is still gossiped - assert!(votes.is_live(&7u64)); - // round 10 is alive and in-progress - assert!(votes.is_live(&10u64)); - } - - #[test] - fn note_same_round_twice() { - let gv = GossipValidator::::new(Arc::new(Mutex::new(KnownPeers::new()))); - - gv.note_round(3u64); - gv.note_round(7u64); - gv.note_round(10u64); - - assert_eq!(gv.known_votes.read().live.len(), 3); - - // note round #7 again -> should not change anything - gv.note_round(7u64); - - let votes = gv.known_votes.read(); - - assert_eq!(votes.live.len(), 3); - - assert!(votes.is_live(&3u64)); - assert!(votes.is_live(&7u64)); - assert!(votes.is_live(&10u64)); - } - struct TestContext; impl ValidatorContext for TestContext { fn broadcast_topic(&mut self, _topic: B::Hash, _force: bool) { @@ -368,21 +327,18 @@ mod tests { #[test] fn should_avoid_verifying_signatures_twice() { let gv = GossipValidator::::new(Arc::new(Mutex::new(KnownPeers::new()))); + gv.update_filter(GossipVoteFilter { start: 0, end: 10, validator_set_id: 0 }); let sender = sc_network::PeerId::random(); let mut context = TestContext; let vote = dummy_vote(3); - gv.note_round(3u64); - gv.note_round(7u64); - gv.note_round(10u64); - // first time the cache should be populated let res = gv.validate(&mut context, &sender, &vote.encode()); assert!(matches!(res, ValidationResult::ProcessAndKeep(_))); assert_eq!( - gv.known_votes.read().live.get(&vote.commitment.block_number).map(|x| x.len()), + gv.votes_filter.read().live.get(&vote.commitment.block_number).map(|x| x.len()), Some(1) ); @@ -392,9 +348,11 @@ mod tests { assert!(matches!(res, ValidationResult::ProcessAndKeep(_))); // next we should quickly reject if the round is not live - gv.conclude_round(7_u64); + gv.update_filter(GossipVoteFilter { start: 7, end: 10, validator_set_id: 0 }); - assert!(!gv.known_votes.read().is_live(&vote.commitment.block_number)); + let number = vote.commitment.block_number; + let set_id = vote.commitment.validator_set_id; + assert!(!gv.votes_filter.read().is_live(number, set_id)); let res = gv.validate(&mut context, &sender, &vote.encode()); @@ -404,14 +362,13 @@ mod tests { #[test] fn messages_allowed_and_expired() { let gv = GossipValidator::::new(Arc::new(Mutex::new(KnownPeers::new()))); + gv.update_filter(GossipVoteFilter { start: 0, end: 10, validator_set_id: 0 }); let sender = sc_network::PeerId::random(); let topic = Default::default(); let intent = MessageIntent::Broadcast; - // note round 2 and 3, then conclude 2 - gv.note_round(2u64); - gv.note_round(3u64); - gv.conclude_round(2u64); + // conclude 2 + gv.update_filter(GossipVoteFilter { start: 2, end: 10, validator_set_id: 0 }); let mut allowed = gv.message_allowed(); let mut expired = gv.message_expired(); @@ -447,6 +404,7 @@ mod tests { #[test] fn messages_rebroadcast() { let gv = GossipValidator::::new(Arc::new(Mutex::new(KnownPeers::new()))); + gv.update_filter(GossipVoteFilter { start: 0, end: 10, validator_set_id: 0 }); let sender = sc_network::PeerId::random(); let topic = Default::default(); diff --git a/client/consensus/beefy/src/lib.rs b/client/consensus/beefy/src/lib.rs index eb56a97de1dd9..d632f58332a77 100644 --- a/client/consensus/beefy/src/lib.rs +++ b/client/consensus/beefy/src/lib.rs @@ -247,6 +247,8 @@ pub async fn start_beefy_gadget( } = network_params; let known_peers = Arc::new(Mutex::new(KnownPeers::new())); + // Default votes filter is to discard everything. + // Validator is updated later with correct starting round and set id. let gossip_validator = Arc::new(communication::gossip::GossipValidator::new(known_peers.clone())); let mut gossip_engine = sc_network_gossip::GossipEngine::new( @@ -284,6 +286,14 @@ pub async fn start_beefy_gadget( return }, }; + // Update the gossip validator with the right starting round and set id. + if let Err(e) = persisted_state + .current_gossip_filter() + .map(|f| gossip_validator.update_filter(f)) + { + error!(target: LOG_TARGET, "Error: {:?}. Terminating.", e); + return + } let worker_params = worker::WorkerParams { backend, diff --git a/client/consensus/beefy/src/metrics.rs b/client/consensus/beefy/src/metrics.rs index 0ce48e60ebc84..6653763fc6754 100644 --- a/client/consensus/beefy/src/metrics.rs +++ b/client/consensus/beefy/src/metrics.rs @@ -45,10 +45,6 @@ pub struct VoterMetrics { pub beefy_lagging_sessions: Counter, /// Number of times no Authority public key found in store pub beefy_no_authority_found_in_store: Counter, - /// Number of currently buffered votes - pub beefy_buffered_votes: Gauge, - /// Number of votes dropped due to full buffers - pub beefy_buffered_votes_dropped: Counter, /// Number of good votes successfully handled pub beefy_good_votes_processed: Counter, /// Number of equivocation votes received @@ -65,8 +61,6 @@ pub struct VoterMetrics { pub beefy_imported_justifications: Counter, /// Number of justifications dropped due to full buffers pub beefy_buffered_justifications_dropped: Counter, - /// Trying to set Best Beefy block to old block - pub beefy_best_block_set_last_failure: Gauge, } impl PrometheusRegister for VoterMetrics { @@ -110,17 +104,6 @@ impl PrometheusRegister for VoterMetrics { )?, registry, )?, - beefy_buffered_votes: register( - Gauge::new("substrate_beefy_buffered_votes", "Number of currently buffered votes")?, - registry, - )?, - beefy_buffered_votes_dropped: register( - Counter::new( - "substrate_beefy_buffered_votes_dropped", - "Number of votes dropped due to full buffers", - )?, - registry, - )?, beefy_good_votes_processed: register( Counter::new( "substrate_beefy_successful_handled_votes", @@ -174,13 +157,6 @@ impl PrometheusRegister for VoterMetrics { )?, registry, )?, - beefy_best_block_set_last_failure: register( - Gauge::new( - "substrate_beefy_best_block_to_old_block", - "Trying to set Best Beefy block to old block", - )?, - registry, - )?, }) } } diff --git a/client/consensus/beefy/src/tests.rs b/client/consensus/beefy/src/tests.rs index 27dc8d81915aa..629f144246d7f 100644 --- a/client/consensus/beefy/src/tests.rs +++ b/client/consensus/beefy/src/tests.rs @@ -526,17 +526,15 @@ async fn finalize_block_and_wait_for_beefy( net: &Arc>, // peer index and key peers: impl Iterator + Clone, - finalize_targets: &[H256], + finalize_target: &H256, expected_beefy: &[u64], ) { let (best_blocks, versioned_finality_proof) = get_beefy_streams(&mut net.lock(), peers.clone()); - for block in finalize_targets { - peers.clone().for_each(|(index, _)| { - let client = net.lock().peer(index).client().as_client(); - client.finalize_block(*block, None).unwrap(); - }) - } + peers.clone().for_each(|(index, _)| { + let client = net.lock().peer(index).client().as_client(); + client.finalize_block(*finalize_target, None).unwrap(); + }); if expected_beefy.is_empty() { // run for quarter second then verify no new best beefy block available @@ -574,31 +572,32 @@ async fn beefy_finalizing_blocks() { let peers = peers.into_iter().enumerate(); // finalize block #5 -> BEEFY should finalize #1 (mandatory) and #5 from diff-power-of-two rule. - finalize_block_and_wait_for_beefy(&net, peers.clone(), &[hashes[1], hashes[5]], &[1, 5]).await; + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[1], &[1]).await; + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[5], &[5]).await; // GRANDPA finalize #10 -> BEEFY finalize #10 (mandatory) - finalize_block_and_wait_for_beefy(&net, peers.clone(), &[hashes[10]], &[10]).await; + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[10], &[10]).await; // GRANDPA finalize #18 -> BEEFY finalize #14, then #18 (diff-power-of-two rule) - finalize_block_and_wait_for_beefy(&net, peers.clone(), &[hashes[18]], &[14, 18]).await; + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[18], &[14, 18]).await; // GRANDPA finalize #20 -> BEEFY finalize #20 (mandatory) - finalize_block_and_wait_for_beefy(&net, peers.clone(), &[hashes[20]], &[20]).await; + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[20], &[20]).await; // GRANDPA finalize #21 -> BEEFY finalize nothing (yet) because min delta is 4 - finalize_block_and_wait_for_beefy(&net, peers, &[hashes[21]], &[]).await; + finalize_block_and_wait_for_beefy(&net, peers, &hashes[21], &[]).await; } #[tokio::test] async fn lagging_validators() { sp_tracing::try_init_simple(); - let peers = [BeefyKeyring::Alice, BeefyKeyring::Bob]; + let peers = [BeefyKeyring::Alice, BeefyKeyring::Bob, BeefyKeyring::Charlie]; let validator_set = ValidatorSet::new(make_beefy_ids(&peers), 0).unwrap(); let session_len = 30; let min_block_delta = 1; - let mut net = BeefyTestNet::new(2); + let mut net = BeefyTestNet::new(3); let api = Arc::new(TestApi::with_validator_set(&validator_set)); let beefy_peers = peers.iter().enumerate().map(|(id, key)| (id, key, api.clone())).collect(); tokio::spawn(initialize_beefy(&mut net, beefy_peers, min_block_delta)); @@ -611,55 +610,47 @@ async fn lagging_validators() { let peers = peers.into_iter().enumerate(); // finalize block #15 -> BEEFY should finalize #1 (mandatory) and #9, #13, #14, #15 from // diff-power-of-two rule. - finalize_block_and_wait_for_beefy( - &net, - peers.clone(), - &[hashes[1], hashes[15]], - &[1, 9, 13, 14, 15], - ) - .await; - - // Alice finalizes #25, Bob lags behind + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[1], &[1]).await; + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[15], &[9, 13, 14, 15]).await; + + // Alice and Bob finalize #25, Charlie lags behind let finalize = hashes[25]; let (best_blocks, versioned_finality_proof) = get_beefy_streams(&mut net.lock(), peers.clone()); net.lock().peer(0).client().as_client().finalize_block(finalize, None).unwrap(); + net.lock().peer(1).client().as_client().finalize_block(finalize, None).unwrap(); // verify nothing gets finalized by BEEFY - let timeout = Some(Duration::from_millis(250)); + let timeout = Some(Duration::from_millis(100)); streams_empty_after_timeout(best_blocks, &net, timeout).await; streams_empty_after_timeout(versioned_finality_proof, &net, None).await; - // Bob catches up and also finalizes #25 + // Charlie catches up and also finalizes #25 let (best_blocks, versioned_finality_proof) = get_beefy_streams(&mut net.lock(), peers.clone()); - net.lock().peer(1).client().as_client().finalize_block(finalize, None).unwrap(); - // expected beefy finalizes block #17 from diff-power-of-two + net.lock().peer(2).client().as_client().finalize_block(finalize, None).unwrap(); + // expected beefy finalizes blocks 23, 24, 25 from diff-power-of-two wait_for_best_beefy_blocks(best_blocks, &net, &[23, 24, 25]).await; wait_for_beefy_signed_commitments(versioned_finality_proof, &net, &[23, 24, 25]).await; // Both finalize #30 (mandatory session) and #32 -> BEEFY finalize #30 (mandatory), #31, #32 - finalize_block_and_wait_for_beefy( - &net, - peers.clone(), - &[hashes[30], hashes[32]], - &[30, 31, 32], - ) - .await; + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[30], &[30]).await; + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[32], &[31, 32]).await; // Verify that session-boundary votes get buffered by client and only processed once // session-boundary block is GRANDPA-finalized (this guarantees authenticity for the new session // validator set). - // Alice finalizes session-boundary mandatory block #60, Bob lags behind + // Alice and Bob finalize session-boundary mandatory block #60, Charlie lags behind let (best_blocks, versioned_finality_proof) = get_beefy_streams(&mut net.lock(), peers.clone()); let finalize = hashes[60]; net.lock().peer(0).client().as_client().finalize_block(finalize, None).unwrap(); + net.lock().peer(1).client().as_client().finalize_block(finalize, None).unwrap(); // verify nothing gets finalized by BEEFY - let timeout = Some(Duration::from_millis(250)); + let timeout = Some(Duration::from_millis(100)); streams_empty_after_timeout(best_blocks, &net, timeout).await; streams_empty_after_timeout(versioned_finality_proof, &net, None).await; - // Bob catches up and also finalizes #60 (and should have buffered Alice's vote on #60) + // Charlie catches up and also finalizes #60 (and should have buffered Alice's vote on #60) let (best_blocks, versioned_finality_proof) = get_beefy_streams(&mut net.lock(), peers); - net.lock().peer(1).client().as_client().finalize_block(finalize, None).unwrap(); + net.lock().peer(2).client().as_client().finalize_block(finalize, None).unwrap(); // verify beefy skips intermediary votes, and successfully finalizes mandatory block #60 wait_for_best_beefy_blocks(best_blocks, &net, &[60]).await; wait_for_beefy_signed_commitments(versioned_finality_proof, &net, &[60]).await; @@ -696,7 +687,8 @@ async fn correct_beefy_payload() { let net = Arc::new(Mutex::new(net)); let peers = peers.into_iter().enumerate(); // with 3 good voters and 1 bad one, consensus should happen and best blocks produced. - finalize_block_and_wait_for_beefy(&net, peers, &[hashes[1], hashes[10]], &[1, 9]).await; + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[1], &[1]).await; + finalize_block_and_wait_for_beefy(&net, peers, &hashes[10], &[9]).await; let (best_blocks, versioned_finality_proof) = get_beefy_streams(&mut net.lock(), [(0, BeefyKeyring::Alice)].into_iter()); @@ -708,7 +700,7 @@ async fn correct_beefy_payload() { net.lock().peer(3).client().as_client().finalize_block(hashof11, None).unwrap(); // verify consensus is _not_ reached - let timeout = Some(Duration::from_millis(250)); + let timeout = Some(Duration::from_millis(100)); streams_empty_after_timeout(best_blocks, &net, timeout).await; streams_empty_after_timeout(versioned_finality_proof, &net, None).await; @@ -874,39 +866,6 @@ async fn beefy_importing_justifications() { } } -#[tokio::test] -async fn voter_initialization() { - sp_tracing::try_init_simple(); - // Regression test for voter initialization where finality notifications were dropped - // after waiting for BEEFY pallet availability. - - let peers = [BeefyKeyring::Alice, BeefyKeyring::Bob]; - let validator_set = ValidatorSet::new(make_beefy_ids(&peers), 0).unwrap(); - let session_len = 5; - // Should vote on all mandatory blocks no matter the `min_block_delta`. - let min_block_delta = 10; - - let mut net = BeefyTestNet::new(2); - let api = Arc::new(TestApi::with_validator_set(&validator_set)); - let beefy_peers = peers.iter().enumerate().map(|(id, key)| (id, key, api.clone())).collect(); - tokio::spawn(initialize_beefy(&mut net, beefy_peers, min_block_delta)); - - // push 26 blocks - let hashes = net.generate_blocks_and_sync(26, session_len, &validator_set, false).await; - let net = Arc::new(Mutex::new(net)); - - // Finalize multiple blocks at once to get a burst of finality notifications right from start. - // Need to finalize at least one block in each session, choose randomly. - // Expect voters to pick up all of them and BEEFY-finalize the mandatory blocks of each session. - finalize_block_and_wait_for_beefy( - &net, - peers.into_iter().enumerate(), - &[hashes[1], hashes[6], hashes[10], hashes[17], hashes[24], hashes[26]], - &[1, 5, 10, 15, 20, 25], - ) - .await; -} - #[tokio::test] async fn on_demand_beefy_justification_sync() { sp_tracing::try_init_simple(); @@ -940,13 +899,11 @@ async fn on_demand_beefy_justification_sync() { let net = Arc::new(Mutex::new(net)); // With 3 active voters and one inactive, consensus should happen and blocks BEEFY-finalized. // Need to finalize at least one block in each session, choose randomly. - finalize_block_and_wait_for_beefy( - &net, - fast_peers.clone(), - &[hashes[1], hashes[6], hashes[10], hashes[17], hashes[23]], - &[1, 5, 10, 15, 20], - ) - .await; + finalize_block_and_wait_for_beefy(&net, fast_peers.clone(), &hashes[1], &[1]).await; + finalize_block_and_wait_for_beefy(&net, fast_peers.clone(), &hashes[6], &[5]).await; + finalize_block_and_wait_for_beefy(&net, fast_peers.clone(), &hashes[10], &[10]).await; + finalize_block_and_wait_for_beefy(&net, fast_peers.clone(), &hashes[17], &[15]).await; + finalize_block_and_wait_for_beefy(&net, fast_peers.clone(), &hashes[24], &[20]).await; // Spawn Dave, they are now way behind voting and can only catch up through on-demand justif // sync. @@ -971,7 +928,8 @@ async fn on_demand_beefy_justification_sync() { // freshly spun up Dave now needs to listen for gossip to figure out the state of their peers. // Have the other peers do some gossip so Dave finds out about their progress. - finalize_block_and_wait_for_beefy(&net, fast_peers, &[hashes[25], hashes[29]], &[25, 29]).await; + finalize_block_and_wait_for_beefy(&net, fast_peers.clone(), &hashes[25], &[25]).await; + finalize_block_and_wait_for_beefy(&net, fast_peers, &hashes[29], &[29]).await; // Kick Dave's async loop by finalizing another block. client.finalize_block(hashes[2], None).unwrap(); @@ -982,13 +940,14 @@ async fn on_demand_beefy_justification_sync() { // Give all tasks some cpu cycles to burn through their events queues, run_for(Duration::from_millis(100), &net).await; // then verify Dave catches up through on-demand justification requests. - finalize_block_and_wait_for_beefy( - &net, - [(dave_index, BeefyKeyring::Dave)].into_iter(), - &[hashes[6], hashes[10], hashes[17], hashes[24], hashes[26]], - &[5, 10, 15, 20, 25], - ) - .await; + let (dave_best_blocks, _) = + get_beefy_streams(&mut net.lock(), [(dave_index, BeefyKeyring::Dave)].into_iter()); + client.finalize_block(hashes[6], None).unwrap(); + client.finalize_block(hashes[10], None).unwrap(); + client.finalize_block(hashes[17], None).unwrap(); + client.finalize_block(hashes[24], None).unwrap(); + client.finalize_block(hashes[26], None).unwrap(); + wait_for_best_beefy_blocks(dave_best_blocks, &net, &[5, 10, 15, 20, 25]).await; } #[tokio::test] @@ -1022,13 +981,8 @@ async fn should_initialize_voter_at_genesis() { // verify next vote target is mandatory block 1 assert_eq!(persisted_state.best_beefy_block(), 0); - assert_eq!(persisted_state.best_grandpa_block(), 13); - assert_eq!( - persisted_state - .voting_oracle() - .voting_target(persisted_state.best_beefy_block(), 13), - Some(1) - ); + assert_eq!(persisted_state.best_grandpa_number(), 13); + assert_eq!(persisted_state.voting_oracle().voting_target(), Some(1)); // verify state also saved to db assert!(verify_persisted_version(&*backend)); @@ -1070,13 +1024,8 @@ async fn should_initialize_voter_at_custom_genesis() { // verify next vote target is mandatory block 7 assert_eq!(persisted_state.best_beefy_block(), 0); - assert_eq!(persisted_state.best_grandpa_block(), 8); - assert_eq!( - persisted_state - .voting_oracle() - .voting_target(persisted_state.best_beefy_block(), 13), - Some(custom_pallet_genesis) - ); + assert_eq!(persisted_state.best_grandpa_number(), 8); + assert_eq!(persisted_state.voting_oracle().voting_target(), Some(custom_pallet_genesis)); // verify state also saved to db assert!(verify_persisted_version(&*backend)); @@ -1128,14 +1077,9 @@ async fn should_initialize_voter_when_last_final_is_session_boundary() { // verify block 10 is correctly marked as finalized assert_eq!(persisted_state.best_beefy_block(), 10); - assert_eq!(persisted_state.best_grandpa_block(), 13); + assert_eq!(persisted_state.best_grandpa_number(), 13); // verify next vote target is diff-power-of-two block 12 - assert_eq!( - persisted_state - .voting_oracle() - .voting_target(persisted_state.best_beefy_block(), 13), - Some(12) - ); + assert_eq!(persisted_state.voting_oracle().voting_target(), Some(12)); // verify state also saved to db assert!(verify_persisted_version(&*backend)); @@ -1186,13 +1130,8 @@ async fn should_initialize_voter_at_latest_finalized() { // verify next vote target is 13 assert_eq!(persisted_state.best_beefy_block(), 12); - assert_eq!(persisted_state.best_grandpa_block(), 13); - assert_eq!( - persisted_state - .voting_oracle() - .voting_target(persisted_state.best_beefy_block(), 13), - Some(13) - ); + assert_eq!(persisted_state.best_grandpa_number(), 13); + assert_eq!(persisted_state.voting_oracle().voting_target(), Some(13)); // verify state also saved to db assert!(verify_persisted_version(&*backend)); @@ -1225,13 +1164,13 @@ async fn beefy_finalizing_after_pallet_genesis() { // Minimum BEEFY block delta is 1. // GRANDPA finalize blocks leading up to BEEFY pallet genesis -> BEEFY should finalize nothing. - finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[1..14], &[]).await; + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[14], &[]).await; // GRANDPA finalize block #16 -> BEEFY should finalize #15 (genesis mandatory) and #16. - finalize_block_and_wait_for_beefy(&net, peers.clone(), &[hashes[16]], &[15, 16]).await; + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[16], &[15, 16]).await; // GRANDPA finalize #21 -> BEEFY finalize #20 (mandatory) and #21 - finalize_block_and_wait_for_beefy(&net, peers.clone(), &[hashes[21]], &[20, 21]).await; + finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[21], &[20, 21]).await; } #[tokio::test] @@ -1249,14 +1188,14 @@ async fn beefy_reports_equivocations() { let mut api_alice = TestApi::with_validator_set(&validator_set); api_alice.allow_equivocations(); let api_alice = Arc::new(api_alice); - let alice = (0, &peers[0], api_alice.clone()); + let alice = (0, &BeefyKeyring::Alice, api_alice.clone()); tokio::spawn(initialize_beefy(&mut net, vec![alice], min_block_delta)); // Bob votes on bad MMR roots, equivocations are allowed/expected. let mut api_bob = TestApi::new(1, &validator_set, BAD_MMR_ROOT); api_bob.allow_equivocations(); let api_bob = Arc::new(api_bob); - let bob = (1, &peers[1], api_bob.clone()); + let bob = (1, &BeefyKeyring::Bob, api_bob.clone()); tokio::spawn(initialize_beefy(&mut net, vec![bob], min_block_delta)); // We spawn another node voting with Bob key, on alternate bad MMR roots (equivocating). @@ -1276,7 +1215,7 @@ async fn beefy_reports_equivocations() { let peers = peers.into_iter().enumerate(); // finalize block #1 -> BEEFY should not finalize anything (each node votes on different MMR). - finalize_block_and_wait_for_beefy(&net, peers, &[hashes[1]], &[]).await; + finalize_block_and_wait_for_beefy(&net, peers, &hashes[1], &[]).await; // Verify neither Bob or Bob_Prime report themselves as equivocating. assert!(api_bob.reported_equivocations.as_ref().unwrap().lock().is_empty()); diff --git a/client/consensus/beefy/src/worker.rs b/client/consensus/beefy/src/worker.rs index 0abb38d022ef6..0260d7693c654 100644 --- a/client/consensus/beefy/src/worker.rs +++ b/client/consensus/beefy/src/worker.rs @@ -18,13 +18,13 @@ use crate::{ communication::{ - gossip::{topic, GossipValidator}, + gossip::{topic, GossipValidator, GossipVoteFilter}, request_response::outgoing_requests_engine::OnDemandJustificationsEngine, }, error::Error, justification::BeefyVersionedFinalityProof, keystore::{BeefyKeystore, BeefySignatureHasher}, - metric_get, metric_inc, metric_set, + metric_inc, metric_set, metrics::VoterMetrics, round::{Rounds, VoteImportResult}, BeefyVoterLinks, LOG_TARGET, @@ -42,24 +42,19 @@ use sp_consensus_beefy::{ check_equivocation_proof, crypto::{AuthorityId, Signature}, BeefyApi, Commitment, ConsensusLog, EquivocationProof, PayloadProvider, ValidatorSet, - VersionedFinalityProof, VoteMessage, BEEFY_ENGINE_ID, + ValidatorSetId, VersionedFinalityProof, VoteMessage, BEEFY_ENGINE_ID, }; use sp_runtime::{ generic::OpaqueDigestItemId, - traits::{Block, ConstU32, Header, NumberFor, Zero}, - BoundedVec, SaturatedConversion, + traits::{Block, Header, NumberFor, Zero}, + SaturatedConversion, }; use std::{ collections::{BTreeMap, BTreeSet, VecDeque}, fmt::Debug, - marker::PhantomData, sync::Arc, }; -/// Bound for the number of buffered future voting rounds. -const MAX_BUFFERED_VOTE_ROUNDS: usize = 600; -/// Bound for the number of buffered votes per round number. -const MAX_BUFFERED_VOTES_PER_ROUND: u32 = 1000; /// Bound for the number of pending justifications - use 2400 - the max number /// of justifications possible in a single session. const MAX_BUFFERED_JUSTIFICATIONS: usize = 2400; @@ -87,23 +82,34 @@ pub(crate) struct VoterOracle { sessions: VecDeque>, /// Min delta in block numbers between two blocks, BEEFY should vote on. min_block_delta: u32, + /// Best block we received a GRANDPA finality for. + best_grandpa_block_header: ::Header, + /// Best block a BEEFY voting round has been concluded for. + best_beefy_block: NumberFor, } impl VoterOracle { /// Verify provided `sessions` satisfies requirements, then build `VoterOracle`. - pub fn checked_new(sessions: VecDeque>, min_block_delta: u32) -> Option { + pub fn checked_new( + sessions: VecDeque>, + min_block_delta: u32, + grandpa_header: ::Header, + best_beefy: NumberFor, + ) -> Option { let mut prev_start = Zero::zero(); let mut prev_validator_id = None; // verifies the let mut validate = || -> bool { - if sessions.is_empty() { + let best_grandpa = *grandpa_header.number(); + if sessions.is_empty() || best_beefy > best_grandpa { return false } for (idx, session) in sessions.iter().enumerate() { + let start = session.session_start(); if session.validators().is_empty() { return false } - if session.session_start() <= prev_start { + if start > best_grandpa || start <= prev_start { return false } #[cfg(not(test))] @@ -125,23 +131,35 @@ impl VoterOracle { sessions, // Always target at least one block better than current best beefy. min_block_delta: min_block_delta.max(1), + best_grandpa_block_header: grandpa_header, + best_beefy_block: best_beefy, }) } else { - error!(target: LOG_TARGET, "🥩 Invalid sessions queue: {:?}.", sessions); + error!( + target: LOG_TARGET, + "🥩 Invalid sessions queue: {:?}; best-beefy {:?} best-grandpa-header {:?}.", + sessions, + best_beefy, + grandpa_header + ); None } } // Return reference to rounds pertaining to first session in the queue. // Voting will always happen at the head of the queue. - fn active_rounds(&self) -> Option<&Rounds> { - self.sessions.front() + fn active_rounds(&self) -> Result<&Rounds, Error> { + self.sessions.front().ok_or(Error::UninitSession) } // Return mutable reference to rounds pertaining to first session in the queue. // Voting will always happen at the head of the queue. - fn active_rounds_mut(&mut self) -> Option<&mut Rounds> { - self.sessions.front_mut() + fn active_rounds_mut(&mut self) -> Result<&mut Rounds, Error> { + self.sessions.front_mut().ok_or(Error::UninitSession) + } + + fn current_validator_set_id(&self) -> Result { + self.active_rounds().map(|r| r.validator_set_id()) } // Prune the sessions queue to keep the Oracle in one of the expected three states. @@ -164,7 +182,7 @@ impl VoterOracle { /// Finalize a particular block. pub fn finalize(&mut self, block: NumberFor) -> Result<(), Error> { // Conclude voting round for this block. - self.active_rounds_mut().ok_or(Error::UninitSession)?.conclude(block); + self.active_rounds_mut()?.conclude(block); // Prune any now "finalized" sessions from queue. self.try_prune(); Ok(()) @@ -182,30 +200,26 @@ impl VoterOracle { } /// Return `(A, B)` tuple representing inclusive [A, B] interval of votes to accept. - pub fn accepted_interval( - &self, - best_grandpa: NumberFor, - ) -> Result<(NumberFor, NumberFor), Error> { + pub fn accepted_interval(&self) -> Result<(NumberFor, NumberFor), Error> { let rounds = self.sessions.front().ok_or(Error::UninitSession)?; if rounds.mandatory_done() { // There's only one session active and its mandatory is done. - // Accept any GRANDPA finalized vote. - Ok((rounds.session_start(), best_grandpa.into())) + // Accept any vote for a GRANDPA finalized block in a better round. + Ok(( + rounds.session_start().max(self.best_beefy_block), + (*self.best_grandpa_block_header.number()).into(), + )) } else { - // There's at least one session with mandatory not done. + // Current session has mandatory not done. // Only accept votes for the mandatory block in the front of queue. Ok((rounds.session_start(), rounds.session_start())) } } /// Utility function to quickly decide what to do for each round. - pub fn triage_round( - &self, - round: NumberFor, - best_grandpa: NumberFor, - ) -> Result { - let (start, end) = self.accepted_interval(best_grandpa)?; + pub fn triage_round(&self, round: NumberFor) -> Result { + let (start, end) = self.accepted_interval()?; if start <= round && round <= end { Ok(RoundAction::Process) } else if round > end { @@ -217,17 +231,15 @@ impl VoterOracle { /// Return `Some(number)` if we should be voting on block `number`, /// return `None` if there is no block we should vote on. - pub fn voting_target( - &self, - best_beefy: NumberFor, - best_grandpa: NumberFor, - ) -> Option> { + pub fn voting_target(&self) -> Option> { let rounds = if let Some(r) = self.sessions.front() { r } else { debug!(target: LOG_TARGET, "🥩 No voting round started"); return None }; + let best_grandpa = *self.best_grandpa_block_header.number(); + let best_beefy = self.best_beefy_block; // `target` is guaranteed > `best_beefy` since `min_block_delta` is at least `1`. let target = @@ -259,10 +271,6 @@ pub(crate) struct WorkerParams { #[derive(Debug, Decode, Encode, PartialEq)] pub(crate) struct PersistedState { - /// Best block we received a GRANDPA finality for. - best_grandpa_block_header: ::Header, - /// Best block a BEEFY voting round has been concluded for. - best_beefy_block: NumberFor, /// Best block we voted on. best_voted: NumberFor, /// Chooses which incoming votes to accept and which votes to generate. @@ -277,20 +285,26 @@ impl PersistedState { sessions: VecDeque>, min_block_delta: u32, ) -> Option { - VoterOracle::checked_new(sessions, min_block_delta).map(|voting_oracle| PersistedState { - best_grandpa_block_header: grandpa_header, - best_beefy_block: best_beefy, - best_voted: Zero::zero(), - voting_oracle, - }) + VoterOracle::checked_new(sessions, min_block_delta, grandpa_header, best_beefy) + .map(|voting_oracle| PersistedState { best_voted: Zero::zero(), voting_oracle }) } pub(crate) fn set_min_block_delta(&mut self, min_block_delta: u32) { self.voting_oracle.min_block_delta = min_block_delta.max(1); } + pub(crate) fn set_best_beefy(&mut self, best_beefy: NumberFor) { + self.voting_oracle.best_beefy_block = best_beefy; + } + pub(crate) fn set_best_grandpa(&mut self, best_grandpa: ::Header) { - self.best_grandpa_block_header = best_grandpa; + self.voting_oracle.best_grandpa_block_header = best_grandpa; + } + + pub(crate) fn current_gossip_filter(&self) -> Result, Error> { + let (start, end) = self.voting_oracle.accepted_interval()?; + let validator_set_id = self.voting_oracle.current_validator_set_id()?; + Ok(GossipVoteFilter { start, end, validator_set_id }) } } @@ -315,14 +329,6 @@ pub(crate) struct BeefyWorker { // voter state /// BEEFY client metrics. metrics: Option, - /// Buffer holding votes for future processing. - pending_votes: BTreeMap< - NumberFor, - BoundedVec< - VoteMessage, AuthorityId, Signature>, - ConstU32, - >, - >, /// Buffer holding justifications for future processing. pending_justifications: BTreeMap, BeefyVersionedFinalityProof>, /// Persisted voter state. @@ -370,25 +376,20 @@ where on_demand_justifications, links, metrics, - pending_votes: BTreeMap::new(), pending_justifications: BTreeMap::new(), persisted_state, } } fn best_grandpa_block(&self) -> NumberFor { - *self.persisted_state.best_grandpa_block_header.number() - } - - fn best_beefy_block(&self) -> NumberFor { - self.persisted_state.best_beefy_block + *self.persisted_state.voting_oracle.best_grandpa_block_header.number() } fn voting_oracle(&self) -> &VoterOracle { &self.persisted_state.voting_oracle } - fn active_rounds(&mut self) -> Option<&Rounds> { + fn active_rounds(&mut self) -> Result<&Rounds, Error> { self.persisted_state.voting_oracle.active_rounds() } @@ -429,7 +430,7 @@ where debug!(target: LOG_TARGET, "🥩 New active validator set: {:?}", validator_set); // BEEFY should finalize a mandatory block during each session. - if let Some(active_session) = self.active_rounds() { + if let Ok(active_session) = self.active_rounds() { if !active_session.mandatory_done() { debug!( target: LOG_TARGET, @@ -460,12 +461,17 @@ where } fn handle_finality_notification(&mut self, notification: &FinalityNotification) { - debug!(target: LOG_TARGET, "🥩 Finality notification: {:?}", notification); + debug!( + target: LOG_TARGET, + "🥩 Finality notification: header {:?} tree_route {:?}", + notification.header, + notification.tree_route, + ); let header = ¬ification.header; if *header.number() > self.best_grandpa_block() { // update best GRANDPA finalized block we have seen - self.persisted_state.best_grandpa_block_header = header.clone(); + self.persisted_state.set_best_grandpa(header.clone()); // Check all (newly) finalized blocks for new session(s). let backend = self.backend.clone(); @@ -484,38 +490,28 @@ where self.init_session_at(new_validator_set, *header.number()); } } + + // Update gossip validator votes filter. + if let Err(e) = self + .persisted_state + .current_gossip_filter() + .map(|filter| self.gossip_validator.update_filter(filter)) + { + error!(target: LOG_TARGET, "🥩 Voter error: {:?}", e); + } } } - /// Based on [VoterOracle] this vote is either processed here or enqueued for later. + /// Based on [VoterOracle] this vote is either processed here or discarded. fn triage_incoming_vote( &mut self, vote: VoteMessage, AuthorityId, Signature>, ) -> Result<(), Error> { let block_num = vote.commitment.block_number; - let best_grandpa = self.best_grandpa_block(); - self.gossip_validator.note_round(block_num); - match self.voting_oracle().triage_round(block_num, best_grandpa)? { + match self.voting_oracle().triage_round(block_num)? { RoundAction::Process => self.handle_vote(vote)?, - RoundAction::Enqueue => { - debug!(target: LOG_TARGET, "🥩 Buffer vote for round: {:?}.", block_num); - if self.pending_votes.len() < MAX_BUFFERED_VOTE_ROUNDS { - let votes_vec = self.pending_votes.entry(block_num).or_default(); - if votes_vec.try_push(vote).is_ok() { - metric_inc!(self, beefy_buffered_votes); - } else { - warn!( - target: LOG_TARGET, - "🥩 Buffer vote dropped for round: {:?}", block_num - ); - metric_inc!(self, beefy_buffered_votes_dropped); - } - } else { - warn!(target: LOG_TARGET, "🥩 Buffer vote dropped for round: {:?}.", block_num); - metric_inc!(self, beefy_buffered_votes_dropped); - } - }, RoundAction::Drop => metric_inc!(self, beefy_stale_votes), + RoundAction::Enqueue => error!(target: LOG_TARGET, "🥩 unexpected vote: {:?}.", vote), }; Ok(()) } @@ -531,8 +527,7 @@ where VersionedFinalityProof::V1(ref sc) => sc, }; let block_num = signed_commitment.commitment.block_number; - let best_grandpa = self.best_grandpa_block(); - match self.voting_oracle().triage_round(block_num, best_grandpa)? { + match self.voting_oracle().triage_round(block_num)? { RoundAction::Process => { debug!(target: LOG_TARGET, "🥩 Process justification for round: {:?}.", block_num); metric_inc!(self, beefy_imported_justifications); @@ -560,11 +555,7 @@ where &mut self, vote: VoteMessage, AuthorityId, Signature>, ) -> Result<(), Error> { - let rounds = self - .persisted_state - .voting_oracle - .active_rounds_mut() - .ok_or(Error::UninitSession)?; + let rounds = self.persisted_state.voting_oracle.active_rounds_mut()?; let block_number = vote.commitment.block_number; match rounds.add_vote(vote) { @@ -608,7 +599,7 @@ where /// 3. Persist voter state, /// 4. Send best block hash and `finality_proof` to RPC worker. /// - /// Expects `finality proof` to be valid. + /// Expects `finality proof` to be valid and for a block > current-best-beefy. fn finalize(&mut self, finality_proof: BeefyVersionedFinalityProof) -> Result<(), Error> { let block_num = match finality_proof { VersionedFinalityProof::V1(ref sc) => sc.commitment.block_number, @@ -616,74 +607,62 @@ where // Finalize inner round and update voting_oracle state. self.persisted_state.voting_oracle.finalize(block_num)?; - self.gossip_validator.conclude_round(block_num); - if block_num > self.best_beefy_block() { - // Set new best BEEFY block number. - self.persisted_state.best_beefy_block = block_num; - crate::aux_schema::write_voter_state(&*self.backend, &self.persisted_state) - .map_err(|e| Error::Backend(e.to_string()))?; + // Set new best BEEFY block number. + self.persisted_state.set_best_beefy(block_num); + crate::aux_schema::write_voter_state(&*self.backend, &self.persisted_state) + .map_err(|e| Error::Backend(e.to_string()))?; - metric_set!(self, beefy_best_block, block_num); + metric_set!(self, beefy_best_block, block_num); - self.on_demand_justifications.cancel_requests_older_than(block_num); + self.on_demand_justifications.cancel_requests_older_than(block_num); - if let Err(e) = self - .backend - .blockchain() - .expect_block_hash_from_id(&BlockId::Number(block_num)) - .and_then(|hash| { - self.links - .to_rpc_best_block_sender - .notify(|| Ok::<_, ()>(hash)) - .expect("forwards closure result; the closure always returns Ok; qed."); - - self.backend - .append_justification(hash, (BEEFY_ENGINE_ID, finality_proof.encode())) - }) { - error!( - target: LOG_TARGET, - "🥩 Error {:?} on appending justification: {:?}", e, finality_proof - ); - } - - self.links - .to_rpc_justif_sender - .notify(|| Ok::<_, ()>(finality_proof)) - .expect("forwards closure result; the closure always returns Ok; qed."); - } else { - debug!(target: LOG_TARGET, "🥩 Can't set best beefy to old: {}", block_num); - metric_set!(self, beefy_best_block_set_last_failure, block_num); + if let Err(e) = self + .backend + .blockchain() + .expect_block_hash_from_id(&BlockId::Number(block_num)) + .and_then(|hash| { + self.links + .to_rpc_best_block_sender + .notify(|| Ok::<_, ()>(hash)) + .expect("forwards closure result; the closure always returns Ok; qed."); + + self.backend + .append_justification(hash, (BEEFY_ENGINE_ID, finality_proof.encode())) + }) { + error!( + target: LOG_TARGET, + "🥩 Error {:?} on appending justification: {:?}", e, finality_proof + ); } + + self.links + .to_rpc_justif_sender + .notify(|| Ok::<_, ()>(finality_proof)) + .expect("forwards closure result; the closure always returns Ok; qed."); + + // Update gossip validator votes filter. + self.persisted_state + .current_gossip_filter() + .map(|filter| self.gossip_validator.update_filter(filter))?; Ok(()) } - /// Handle previously buffered justifications and votes that now land in the voting interval. - fn try_pending_justif_and_votes(&mut self) -> Result<(), Error> { - let best_grandpa = self.best_grandpa_block(); - let _ph = PhantomData::::default(); - - fn to_process_for( - pending: &mut BTreeMap, T>, - (start, end): (NumberFor, NumberFor), - _: PhantomData, - ) -> BTreeMap, T> { + /// Handle previously buffered justifications, that now land in the voting interval. + fn try_pending_justififactions(&mut self) -> Result<(), Error> { + // Interval of blocks for which we can process justifications and votes right now. + let (start, end) = self.voting_oracle().accepted_interval()?; + // Process pending justifications. + if !self.pending_justifications.is_empty() { // These are still pending. - let still_pending = pending.split_off(&end.saturating_add(1u32.into())); + let still_pending = + self.pending_justifications.split_off(&end.saturating_add(1u32.into())); // These can be processed. - let to_handle = pending.split_off(&start); + let justifs_to_process = self.pending_justifications.split_off(&start); // The rest can be dropped. - *pending = still_pending; - // Return ones to process. - to_handle - } - // Interval of blocks for which we can process justifications and votes right now. - let mut interval = self.voting_oracle().accepted_interval(best_grandpa)?; + self.pending_justifications = still_pending; - // Process pending justifications. - if !self.pending_justifications.is_empty() { - let justifs_to_handle = to_process_for(&mut self.pending_justifications, interval, _ph); - for (num, justification) in justifs_to_handle.into_iter() { + for (num, justification) in justifs_to_process.into_iter() { debug!(target: LOG_TARGET, "🥩 Handle buffered justification for: {:?}.", num); metric_inc!(self, beefy_imported_justifications); if let Err(err) = self.finalize(justification) { @@ -691,27 +670,6 @@ where } } metric_set!(self, beefy_buffered_justifications, self.pending_justifications.len()); - // Possibly new interval after processing justifications. - interval = self.voting_oracle().accepted_interval(best_grandpa)?; - } - - // Process pending votes. - if !self.pending_votes.is_empty() { - let mut processed = 0u64; - let votes_to_handle = to_process_for(&mut self.pending_votes, interval, _ph); - for (num, votes) in votes_to_handle.into_iter() { - debug!(target: LOG_TARGET, "🥩 Handle buffered votes for: {:?}.", num); - processed += votes.len() as u64; - for v in votes.into_iter() { - if let Err(err) = self.handle_vote(v) { - error!(target: LOG_TARGET, "🥩 Error handling buffered vote: {}", err); - }; - } - } - if let Some(previous) = metric_get!(self, beefy_buffered_votes) { - previous.sub(processed); - metric_set!(self, beefy_buffered_votes, previous.get()); - } } Ok(()) } @@ -719,10 +677,7 @@ where /// Decide if should vote, then vote.. or don't.. fn try_to_vote(&mut self) -> Result<(), Error> { // Vote if there's now a new vote target. - if let Some(target) = self - .voting_oracle() - .voting_target(self.best_beefy_block(), self.best_grandpa_block()) - { + if let Some(target) = self.voting_oracle().voting_target() { metric_set!(self, beefy_should_vote_on, target); if target > self.persisted_state.best_voted { self.do_vote(target)?; @@ -740,7 +695,7 @@ where // Most of the time we get here, `target` is actually `best_grandpa`, // avoid getting header from backend in that case. let target_header = if target_number == self.best_grandpa_block() { - self.persisted_state.best_grandpa_block_header.clone() + self.persisted_state.voting_oracle.best_grandpa_block_header.clone() } else { let hash = self .backend @@ -771,11 +726,7 @@ where return Ok(()) }; - let rounds = self - .persisted_state - .voting_oracle - .active_rounds_mut() - .ok_or(Error::UninitSession)?; + let rounds = self.persisted_state.voting_oracle.active_rounds_mut()?; let (validators, validator_set_id) = (rounds.validators(), rounds.validator_set_id()); let authority_id = if let Some(id) = self.key_store.authority_id(validators) { @@ -830,7 +781,7 @@ where fn process_new_state(&mut self) { // Handle pending justifications and/or votes for now GRANDPA finalized blocks. - if let Err(err) = self.try_pending_justif_and_votes() { + if let Err(err) = self.try_pending_justififactions() { debug!(target: LOG_TARGET, "🥩 {}", err); } @@ -867,12 +818,12 @@ where self.gossip_engine .messages_for(topic::()) .filter_map(|notification| async move { - trace!(target: LOG_TARGET, "🥩 Got vote message: {:?}", notification); - - VoteMessage::, AuthorityId, Signature>::decode( + let vote = VoteMessage::, AuthorityId, Signature>::decode( &mut ¬ification.message[..], ) - .ok() + .ok(); + trace!(target: LOG_TARGET, "🥩 Got vote message: {:?}", vote); + vote }) .fuse(), ); @@ -946,8 +897,7 @@ where &self, proof: EquivocationProof, AuthorityId, Signature>, ) -> Result<(), Error> { - let rounds = - self.persisted_state.voting_oracle.active_rounds().ok_or(Error::UninitSession)?; + let rounds = self.persisted_state.voting_oracle.active_rounds()?; let (validators, validator_set_id) = (rounds.validators(), rounds.validator_set_id()); let offender_id = proof.offender_id().clone(); @@ -1083,16 +1033,16 @@ pub(crate) mod tests { &self.voting_oracle } - pub fn active_round(&self) -> Option<&Rounds> { + pub fn active_round(&self) -> Result<&Rounds, Error> { self.voting_oracle.active_rounds() } pub fn best_beefy_block(&self) -> NumberFor { - self.best_beefy_block + self.voting_oracle.best_beefy_block } - pub fn best_grandpa_block(&self) -> NumberFor { - *self.best_grandpa_block_header.number() + pub fn best_grandpa_number(&self) -> NumberFor { + *self.voting_oracle.best_grandpa_block_header.number() } } @@ -1103,7 +1053,7 @@ pub(crate) mod tests { } fn create_beefy_worker( - peer: &BeefyPeer, + peer: &mut BeefyPeer, key: &Keyring, min_block_delta: u32, genesis_validator_set: ValidatorSet, @@ -1153,12 +1103,15 @@ pub(crate) mod tests { known_peers, None, ); - let genesis_header = backend + // Push 1 block - will start first session. + let hashes = peer.push_blocks(1, false); + backend.finalize_block(hashes[0], None).unwrap(); + let first_header = backend .blockchain() - .expect_header(backend.blockchain().info().genesis_hash) + .expect_header(backend.blockchain().info().best_hash) .unwrap(); let persisted_state = PersistedState::checked_new( - genesis_header, + first_header, Zero::zero(), vec![Rounds::new(One::one(), genesis_validator_set)].into(), min_block_delta, @@ -1275,10 +1228,30 @@ pub(crate) mod tests { #[test] fn should_vote_target() { - let mut oracle = VoterOracle:: { min_block_delta: 1, sessions: VecDeque::new() }; + let header = Header::new( + 1u32.into(), + Default::default(), + Default::default(), + Default::default(), + Digest::default(), + ); + let mut oracle = VoterOracle:: { + best_beefy_block: 0, + best_grandpa_block_header: header, + min_block_delta: 1, + sessions: VecDeque::new(), + }; + let voting_target_with = |oracle: &mut VoterOracle, + best_beefy: NumberFor, + best_grandpa: NumberFor| + -> Option> { + oracle.best_beefy_block = best_beefy; + oracle.best_grandpa_block_header.number = best_grandpa; + oracle.voting_target() + }; // rounds not initialized -> should vote: `None` - assert_eq!(oracle.voting_target(0, 1), None); + assert_eq!(voting_target_with(&mut oracle, 0, 1), None); let keys = &[Keyring::Alice]; let validator_set = ValidatorSet::new(make_beefy_ids(keys), 0).unwrap(); @@ -1287,29 +1260,29 @@ pub(crate) mod tests { // under min delta oracle.min_block_delta = 4; - assert_eq!(oracle.voting_target(1, 1), None); - assert_eq!(oracle.voting_target(2, 5), None); + assert_eq!(voting_target_with(&mut oracle, 1, 1), None); + assert_eq!(voting_target_with(&mut oracle, 2, 5), None); // vote on min delta - assert_eq!(oracle.voting_target(4, 9), Some(8)); + assert_eq!(voting_target_with(&mut oracle, 4, 9), Some(8)); oracle.min_block_delta = 8; - assert_eq!(oracle.voting_target(10, 18), Some(18)); + assert_eq!(voting_target_with(&mut oracle, 10, 18), Some(18)); // vote on power of two oracle.min_block_delta = 1; - assert_eq!(oracle.voting_target(1000, 1008), Some(1004)); - assert_eq!(oracle.voting_target(1000, 1016), Some(1008)); + assert_eq!(voting_target_with(&mut oracle, 1000, 1008), Some(1004)); + assert_eq!(voting_target_with(&mut oracle, 1000, 1016), Some(1008)); // nothing new to vote on - assert_eq!(oracle.voting_target(1000, 1000), None); + assert_eq!(voting_target_with(&mut oracle, 1000, 1000), None); // vote on mandatory oracle.sessions.clear(); oracle.add_session(Rounds::new(1000, validator_set.clone())); - assert_eq!(oracle.voting_target(0, 1008), Some(1000)); + assert_eq!(voting_target_with(&mut oracle, 0, 1008), Some(1000)); oracle.sessions.clear(); oracle.add_session(Rounds::new(1001, validator_set.clone())); - assert_eq!(oracle.voting_target(1000, 1008), Some(1001)); + assert_eq!(voting_target_with(&mut oracle, 1000, 1008), Some(1001)); } #[test] @@ -1317,16 +1290,34 @@ pub(crate) mod tests { let keys = &[Keyring::Alice]; let validator_set = ValidatorSet::new(make_beefy_ids(keys), 0).unwrap(); - let mut oracle = VoterOracle:: { min_block_delta: 1, sessions: VecDeque::new() }; + let header = Header::new( + 1u32.into(), + Default::default(), + Default::default(), + Default::default(), + Digest::default(), + ); + let mut oracle = VoterOracle:: { + best_beefy_block: 0, + best_grandpa_block_header: header, + min_block_delta: 1, + sessions: VecDeque::new(), + }; + let accepted_interval_with = |oracle: &mut VoterOracle, + best_grandpa: NumberFor| + -> Result<(NumberFor, NumberFor), Error> { + oracle.best_grandpa_block_header.number = best_grandpa; + oracle.accepted_interval() + }; // rounds not initialized -> should accept votes: `None` - assert!(oracle.accepted_interval(1).is_err()); + assert!(accepted_interval_with(&mut oracle, 1).is_err()); let session_one = 1; oracle.add_session(Rounds::new(session_one, validator_set.clone())); // mandatory not done, only accept mandatory for i in 0..15 { - assert_eq!(oracle.accepted_interval(i), Ok((session_one, session_one))); + assert_eq!(accepted_interval_with(&mut oracle, i), Ok((session_one, session_one))); } // add more sessions, nothing changes @@ -1336,7 +1327,7 @@ pub(crate) mod tests { oracle.add_session(Rounds::new(session_three, validator_set.clone())); // mandatory not done, should accept mandatory for session_one for i in session_three..session_three + 15 { - assert_eq!(oracle.accepted_interval(i), Ok((session_one, session_one))); + assert_eq!(accepted_interval_with(&mut oracle, i), Ok((session_one, session_one))); } // simulate finish mandatory for session one, prune oracle @@ -1344,7 +1335,7 @@ pub(crate) mod tests { oracle.try_prune(); // session_one pruned, should accept mandatory for session_two for i in session_three..session_three + 15 { - assert_eq!(oracle.accepted_interval(i), Ok((session_two, session_two))); + assert_eq!(accepted_interval_with(&mut oracle, i), Ok((session_two, session_two))); } // simulate finish mandatory for session two, prune oracle @@ -1352,26 +1343,29 @@ pub(crate) mod tests { oracle.try_prune(); // session_two pruned, should accept mandatory for session_three for i in session_three..session_three + 15 { - assert_eq!(oracle.accepted_interval(i), Ok((session_three, session_three))); + assert_eq!(accepted_interval_with(&mut oracle, i), Ok((session_three, session_three))); } // simulate finish mandatory for session three oracle.sessions.front_mut().unwrap().test_set_mandatory_done(true); // verify all other blocks in this session are now open to voting for i in session_three..session_three + 15 { - assert_eq!(oracle.accepted_interval(i), Ok((session_three, i))); + assert_eq!(accepted_interval_with(&mut oracle, i), Ok((session_three, i))); } // pruning does nothing in this case oracle.try_prune(); for i in session_three..session_three + 15 { - assert_eq!(oracle.accepted_interval(i), Ok((session_three, i))); + assert_eq!(accepted_interval_with(&mut oracle, i), Ok((session_three, i))); } // adding new session automatically prunes "finalized" previous session let session_four = 31; oracle.add_session(Rounds::new(session_four, validator_set.clone())); assert_eq!(oracle.sessions.front().unwrap().session_start(), session_four); - assert_eq!(oracle.accepted_interval(session_four + 10), Ok((session_four, session_four))); + assert_eq!( + accepted_interval_with(&mut oracle, session_four + 10), + Ok((session_four, session_four)) + ); } #[test] @@ -1405,7 +1399,7 @@ pub(crate) mod tests { let keys = &[Keyring::Alice]; let validator_set = ValidatorSet::new(make_beefy_ids(keys), 0).unwrap(); let mut net = BeefyTestNet::new(1); - let mut worker = create_beefy_worker(&net.peer(0), &keys[0], 1, validator_set.clone()); + let mut worker = create_beefy_worker(net.peer(0), &keys[0], 1, validator_set.clone()); // keystore doesn't contain other keys than validators' assert_eq!(worker.verify_validator_set(&1, &validator_set), Ok(())); @@ -1429,7 +1423,7 @@ pub(crate) mod tests { let validator_set = ValidatorSet::new(make_beefy_ids(&keys), 0).unwrap(); let mut net = BeefyTestNet::new(1); let backend = net.peer(0).client().as_backend(); - let mut worker = create_beefy_worker(&net.peer(0), &keys[0], 1, validator_set.clone()); + let mut worker = create_beefy_worker(net.peer(0), &keys[0], 1, validator_set.clone()); // remove default session, will manually add custom one. worker.persisted_state.voting_oracle.sessions.clear(); @@ -1449,7 +1443,7 @@ pub(crate) mod tests { }; // no 'best beefy block' or finality proofs - assert_eq!(worker.best_beefy_block(), 0); + assert_eq!(worker.persisted_state.best_beefy_block(), 0); poll_fn(move |cx| { assert_eq!(best_block_stream.poll_next_unpin(cx), Poll::Pending); assert_eq!(finality_proof.poll_next_unpin(cx), Poll::Pending); @@ -1457,6 +1451,7 @@ pub(crate) mod tests { }) .await; + let client = net.peer(0).client().as_client(); // unknown hash for block #1 let (mut best_block_streams, mut finality_proofs) = get_beefy_streams(&mut net, keys.clone()); @@ -1471,10 +1466,16 @@ pub(crate) mod tests { // try to finalize block #1 worker.finalize(justif.clone()).unwrap(); // verify block finalized - assert_eq!(worker.best_beefy_block(), 1); + assert_eq!(worker.persisted_state.best_beefy_block(), 1); poll_fn(move |cx| { - // unknown hash -> nothing streamed - assert_eq!(best_block_stream.poll_next_unpin(cx), Poll::Pending); + // expect Some(hash-of-block-1) + match best_block_stream.poll_next_unpin(cx) { + Poll::Ready(Some(hash)) => { + let block_num = client.number(hash).unwrap(); + assert_eq!(block_num, Some(1)); + }, + v => panic!("unexpected value: {:?}", v), + } // commitment streamed match finality_proof.poll_next_unpin(cx) { // expect justification @@ -1488,11 +1489,9 @@ pub(crate) mod tests { // generate 2 blocks, try again expect success let (mut best_block_streams, _) = get_beefy_streams(&mut net, keys); let mut best_block_stream = best_block_streams.drain(..).next().unwrap(); - let hashes = net.peer(0).push_blocks(2, false); + let hashes = net.peer(0).push_blocks(1, false); // finalize 1 and 2 without justifications (hashes does not contain genesis) - let hashof1 = hashes[0]; - let hashof2 = hashes[1]; - backend.finalize_block(hashof1, None).unwrap(); + let hashof2 = hashes[0]; backend.finalize_block(hashof2, None).unwrap(); let justif = create_finality_proof(2); @@ -1504,7 +1503,7 @@ pub(crate) mod tests { // new session starting at #2 is in front assert_eq!(worker.active_rounds().unwrap().session_start(), 2); // verify block finalized - assert_eq!(worker.best_beefy_block(), 2); + assert_eq!(worker.persisted_state.best_beefy_block(), 2); poll_fn(move |cx| { match best_block_stream.poll_next_unpin(cx) { // expect Some(hash-of-block-2) @@ -1528,7 +1527,7 @@ pub(crate) mod tests { let keys = &[Keyring::Alice, Keyring::Bob]; let validator_set = ValidatorSet::new(make_beefy_ids(keys), 0).unwrap(); let mut net = BeefyTestNet::new(1); - let mut worker = create_beefy_worker(&net.peer(0), &keys[0], 1, validator_set.clone()); + let mut worker = create_beefy_worker(net.peer(0), &keys[0], 1, validator_set.clone()); let worker_rounds = worker.active_rounds().unwrap(); assert_eq!(worker_rounds.session_start(), 1); @@ -1554,77 +1553,6 @@ pub(crate) mod tests { assert_eq!(rounds.validator_set_id(), new_validator_set.id()); } - #[tokio::test] - async fn should_triage_votes_and_process_later() { - let keys = &[Keyring::Alice, Keyring::Bob]; - let validator_set = ValidatorSet::new(make_beefy_ids(keys), 0).unwrap(); - let mut net = BeefyTestNet::new(1); - let mut worker = create_beefy_worker(&net.peer(0), &keys[0], 1, validator_set.clone()); - // remove default session, will manually add custom one. - worker.persisted_state.voting_oracle.sessions.clear(); - - fn new_vote( - block_number: NumberFor, - ) -> VoteMessage, AuthorityId, Signature> { - let commitment = Commitment { - payload: Payload::from_single_entry(*b"BF", vec![]), - block_number, - validator_set_id: 0, - }; - VoteMessage { - commitment, - id: Keyring::Alice.public(), - signature: Keyring::Alice.sign(b"I am committed"), - } - } - - // best grandpa is 20 - let best_grandpa_header = Header::new( - 20u32.into(), - Default::default(), - Default::default(), - Default::default(), - Digest::default(), - ); - - worker - .persisted_state - .voting_oracle - .add_session(Rounds::new(10, validator_set.clone())); - worker.persisted_state.best_grandpa_block_header = best_grandpa_header; - - // triage votes for blocks 10..13 - worker.triage_incoming_vote(new_vote(10)).unwrap(); - worker.triage_incoming_vote(new_vote(11)).unwrap(); - worker.triage_incoming_vote(new_vote(12)).unwrap(); - // triage votes for blocks 20..23 - worker.triage_incoming_vote(new_vote(20)).unwrap(); - worker.triage_incoming_vote(new_vote(21)).unwrap(); - worker.triage_incoming_vote(new_vote(22)).unwrap(); - - // vote for 10 should have been handled, while the rest buffered for later processing - let mut votes = worker.pending_votes.values(); - assert_eq!(votes.next().unwrap().first().unwrap().commitment.block_number, 11); - assert_eq!(votes.next().unwrap().first().unwrap().commitment.block_number, 12); - assert_eq!(votes.next().unwrap().first().unwrap().commitment.block_number, 20); - assert_eq!(votes.next().unwrap().first().unwrap().commitment.block_number, 21); - assert_eq!(votes.next().unwrap().first().unwrap().commitment.block_number, 22); - assert!(votes.next().is_none()); - - // simulate mandatory done, and retry buffered votes - worker - .persisted_state - .voting_oracle - .active_rounds_mut() - .unwrap() - .test_set_mandatory_done(true); - worker.try_pending_justif_and_votes().unwrap(); - // all blocks <= grandpa finalized should have been handled, rest still buffered - let mut votes = worker.pending_votes.values(); - assert_eq!(votes.next().unwrap().first().unwrap().commitment.block_number, 21); - assert_eq!(votes.next().unwrap().first().unwrap().commitment.block_number, 22); - } - #[tokio::test] async fn should_not_report_bad_old_or_self_equivocations() { let block_num = 1; @@ -1637,7 +1565,7 @@ pub(crate) mod tests { let api_alice = Arc::new(api_alice); let mut net = BeefyTestNet::new(1); - let mut worker = create_beefy_worker(&net.peer(0), &keys[0], 1, validator_set.clone()); + let mut worker = create_beefy_worker(net.peer(0), &keys[0], 1, validator_set.clone()); worker.runtime = api_alice.clone(); // let there be a block with num = 1: From 8a9f48bcf0c9f92949082535d77c12166522bb2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Thu, 16 Mar 2023 12:24:20 +0100 Subject: [PATCH 24/80] Try to fix flaky `temp-base-path-work` test (#13505) * Try to fix flaky `temp-base-path-work` test The test is most of the time failing when checking if the database path was deleted. The assumption is that it takes a little bit more time by the OS to actually clean up the temp path under high load. The pr tries to fix this by checking multiple times if the path was deleted. Besides that it also ensures that the tests that require the benchmark feature don't fail when compiled without the feature. * ".git/.scripts/commands/fmt/fmt.sh" * Capture signals earlier * Rewrite tests to let them having one big timeout * Remove unneeded dep * Update bin/node/cli/tests/common.rs Co-authored-by: Koute * Review feedback * Update bin/node/cli/tests/common.rs Co-authored-by: Anton --------- Co-authored-by: command-bot <> Co-authored-by: Koute Co-authored-by: Anton --- bin/node/cli/tests/benchmark_pallet_works.rs | 2 + bin/node/cli/tests/benchmark_storage_works.rs | 2 + bin/node/cli/tests/common.rs | 132 ++++++++-------- .../tests/running_the_node_and_interrupt.rs | 143 ++++++++---------- bin/node/cli/tests/telemetry.rs | 131 ++++++++-------- bin/node/cli/tests/temp_base_path_works.rs | 63 ++++---- client/cli/src/lib.rs | 14 +- client/cli/src/runner.rs | 97 +++++++----- 8 files changed, 296 insertions(+), 288 deletions(-) diff --git a/bin/node/cli/tests/benchmark_pallet_works.rs b/bin/node/cli/tests/benchmark_pallet_works.rs index 1a278f985da4f..053516b9521d1 100644 --- a/bin/node/cli/tests/benchmark_pallet_works.rs +++ b/bin/node/cli/tests/benchmark_pallet_works.rs @@ -16,6 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#![cfg(feature = "runtime-benchmarks")] + use assert_cmd::cargo::cargo_bin; use std::process::Command; diff --git a/bin/node/cli/tests/benchmark_storage_works.rs b/bin/node/cli/tests/benchmark_storage_works.rs index 1f1181218db03..953c07ca7f0db 100644 --- a/bin/node/cli/tests/benchmark_storage_works.rs +++ b/bin/node/cli/tests/benchmark_storage_works.rs @@ -16,6 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#![cfg(feature = "runtime-benchmarks")] + use assert_cmd::cargo::cargo_bin; use std::{ path::Path, diff --git a/bin/node/cli/tests/common.rs b/bin/node/cli/tests/common.rs index a0de7300fca90..4c4824391fdc1 100644 --- a/bin/node/cli/tests/common.rs +++ b/bin/node/cli/tests/common.rs @@ -20,54 +20,26 @@ use assert_cmd::cargo::cargo_bin; use nix::{ - sys::signal::{kill, Signal::SIGINT}, + sys::signal::{kill, Signal, Signal::SIGINT}, unistd::Pid, }; use node_primitives::{Hash, Header}; +use regex::Regex; use std::{ io::{BufRead, BufReader, Read}, ops::{Deref, DerefMut}, - path::Path, - process::{self, Child, Command, ExitStatus}, + path::{Path, PathBuf}, + process::{self, Child, Command}, time::Duration, }; -use tokio::time::timeout; -/// Wait for the given `child` the given number of `secs`. -/// -/// Returns the `Some(exit status)` or `None` if the process did not finish in the given time. -pub fn wait_for(child: &mut Child, secs: u64) -> Result { - let result = wait_timeout::ChildExt::wait_timeout(child, Duration::from_secs(5.min(secs))) - .map_err(|_| ())?; - if let Some(exit_status) = result { - Ok(exit_status) - } else { - if secs > 5 { - eprintln!("Child process taking over 5 seconds to exit gracefully"); - let result = wait_timeout::ChildExt::wait_timeout(child, Duration::from_secs(secs - 5)) - .map_err(|_| ())?; - if let Some(exit_status) = result { - return Ok(exit_status) - } - } - eprintln!("Took too long to exit (> {} seconds). Killing...", secs); - let _ = child.kill(); - child.wait().unwrap(); - Err(()) - } -} - -/// Wait for at least n blocks to be finalized within a specified time. -pub async fn wait_n_finalized_blocks( - n: usize, - timeout_secs: u64, - url: &str, -) -> Result<(), tokio::time::error::Elapsed> { - timeout(Duration::from_secs(timeout_secs), wait_n_finalized_blocks_from(n, url)).await +/// Run the given `future` and panic if the `timeout` is hit. +pub async fn run_with_timeout(timeout: Duration, future: impl futures::Future) { + tokio::time::timeout(timeout, future).await.expect("Hit timeout"); } /// Wait for at least n blocks to be finalized from a specified node -pub async fn wait_n_finalized_blocks_from(n: usize, url: &str) { +pub async fn wait_n_finalized_blocks(n: usize, url: &str) { use substrate_rpc_client::{ws_client, ChainApi}; let mut built_blocks = std::collections::HashSet::new(); @@ -87,46 +59,54 @@ pub async fn wait_n_finalized_blocks_from(n: usize, url: &str) { /// Run the node for a while (3 blocks) pub async fn run_node_for_a_while(base_path: &Path, args: &[&str]) { - let mut cmd = Command::new(cargo_bin("substrate")) - .stdout(process::Stdio::piped()) - .stderr(process::Stdio::piped()) - .args(args) - .arg("-d") - .arg(base_path) - .spawn() - .unwrap(); + run_with_timeout(Duration::from_secs(60 * 10), async move { + let mut cmd = Command::new(cargo_bin("substrate")) + .stdout(process::Stdio::piped()) + .stderr(process::Stdio::piped()) + .args(args) + .arg("-d") + .arg(base_path) + .spawn() + .unwrap(); - let stderr = cmd.stderr.take().unwrap(); + let stderr = cmd.stderr.take().unwrap(); - let mut child = KillChildOnDrop(cmd); + let mut child = KillChildOnDrop(cmd); - let (ws_url, _) = find_ws_url_from_output(stderr); + let ws_url = extract_info_from_output(stderr).0.ws_url; - // Let it produce some blocks. - let _ = wait_n_finalized_blocks(3, 30, &ws_url).await; + // Let it produce some blocks. + wait_n_finalized_blocks(3, &ws_url).await; - assert!(child.try_wait().unwrap().is_none(), "the process should still be running"); + child.assert_still_running(); - // Stop the process - kill(Pid::from_raw(child.id().try_into().unwrap()), SIGINT).unwrap(); - assert!(wait_for(&mut child, 40).map(|x| x.success()).unwrap()); + // Stop the process + child.stop(); + }) + .await } -/// Run the node asserting that it fails with an error -pub fn run_node_assert_fail(base_path: &Path, args: &[&str]) { - let mut cmd = Command::new(cargo_bin("substrate")); +pub struct KillChildOnDrop(pub Child); - let mut child = KillChildOnDrop(cmd.args(args).arg("-d").arg(base_path).spawn().unwrap()); +impl KillChildOnDrop { + /// Stop the child and wait until it is finished. + /// + /// Asserts if the exit status isn't success. + pub fn stop(&mut self) { + self.stop_with_signal(SIGINT); + } - // Let it produce some blocks, but it should die within 10 seconds. - assert_ne!( - wait_timeout::ChildExt::wait_timeout(&mut *child, Duration::from_secs(10)).unwrap(), - None, - "the process should not be running anymore" - ); -} + /// Same as [`Self::stop`] but takes the `signal` that is sent to stop the child. + pub fn stop_with_signal(&mut self, signal: Signal) { + kill(Pid::from_raw(self.id().try_into().unwrap()), signal).unwrap(); + assert!(self.wait().unwrap().success()); + } -pub struct KillChildOnDrop(pub Child); + /// Asserts that the child is still running. + pub fn assert_still_running(&mut self) { + assert!(self.try_wait().unwrap().is_none(), "the process should still be running"); + } +} impl Drop for KillChildOnDrop { fn drop(&mut self) { @@ -148,18 +128,22 @@ impl DerefMut for KillChildOnDrop { } } -/// Read the WS address from the output. +/// Information extracted from a running node. +pub struct NodeInfo { + pub ws_url: String, + pub db_path: PathBuf, +} + +/// Extract [`NodeInfo`] from a running node by parsing its output. /// -/// This is hack to get the actual binded sockaddr because -/// substrate assigns a random port if the specified port was already binded. -pub fn find_ws_url_from_output(read: impl Read + Send) -> (String, String) { +/// Returns the [`NodeInfo`] and all the read data. +pub fn extract_info_from_output(read: impl Read + Send) -> (NodeInfo, String) { let mut data = String::new(); let ws_url = BufReader::new(read) .lines() .find_map(|line| { - let line = - line.expect("failed to obtain next line from stdout for WS address discovery"); + let line = line.expect("failed to obtain next line while extracting node info"); data.push_str(&line); data.push_str("\n"); @@ -176,5 +160,9 @@ pub fn find_ws_url_from_output(read: impl Read + Send) -> (String, String) { panic!("We should get a WebSocket address") }); - (ws_url, data) + // Database path is printed before the ws url! + let re = Regex::new(r"Database: .+ at (\S+)").unwrap(); + let db_path = PathBuf::from(re.captures(data.as_str()).unwrap().get(1).unwrap().as_str()); + + (NodeInfo { ws_url, db_path }, data) } diff --git a/bin/node/cli/tests/running_the_node_and_interrupt.rs b/bin/node/cli/tests/running_the_node_and_interrupt.rs index fc0bf69a099ba..3d5598f3fbe23 100644 --- a/bin/node/cli/tests/running_the_node_and_interrupt.rs +++ b/bin/node/cli/tests/running_the_node_and_interrupt.rs @@ -18,94 +18,81 @@ #![cfg(unix)] use assert_cmd::cargo::cargo_bin; -use nix::{ - sys::signal::{ - kill, - Signal::{self, SIGINT, SIGTERM}, - }, - unistd::Pid, +use nix::sys::signal::Signal::{self, SIGINT, SIGTERM}; +use std::{ + process::{self, Child, Command}, + time::Duration, }; -use std::process::{self, Child, Command}; use tempfile::tempdir; pub mod common; #[tokio::test] async fn running_the_node_works_and_can_be_interrupted() { - async fn run_command_and_kill(signal: Signal) { - let base_path = tempdir().expect("could not create a temp dir"); - let mut cmd = common::KillChildOnDrop( + common::run_with_timeout(Duration::from_secs(60 * 10), async move { + async fn run_command_and_kill(signal: Signal) { + let base_path = tempdir().expect("could not create a temp dir"); + let mut cmd = common::KillChildOnDrop( + Command::new(cargo_bin("substrate")) + .stdout(process::Stdio::piped()) + .stderr(process::Stdio::piped()) + .args(&["--dev", "-d"]) + .arg(base_path.path()) + .arg("--db=paritydb") + .arg("--no-hardware-benchmarks") + .spawn() + .unwrap(), + ); + + let stderr = cmd.stderr.take().unwrap(); + + let ws_url = common::extract_info_from_output(stderr).0.ws_url; + + common::wait_n_finalized_blocks(3, &ws_url).await; + + cmd.assert_still_running(); + + cmd.stop_with_signal(signal); + + // Check if the database was closed gracefully. If it was not, + // there may exist a ref cycle that prevents the Client from being dropped properly. + // + // parity-db only writes the stats file on clean shutdown. + let stats_file = base_path.path().join("chains/dev/paritydb/full/stats.txt"); + assert!(std::path::Path::exists(&stats_file)); + } + + run_command_and_kill(SIGINT).await; + run_command_and_kill(SIGTERM).await; + }) + .await; +} + +#[tokio::test] +async fn running_two_nodes_with_the_same_ws_port_should_work() { + common::run_with_timeout(Duration::from_secs(60 * 10), async move { + fn start_node() -> Child { Command::new(cargo_bin("substrate")) .stdout(process::Stdio::piped()) .stderr(process::Stdio::piped()) - .args(&["--dev", "-d"]) - .arg(base_path.path()) - .arg("--db=paritydb") - .arg("--no-hardware-benchmarks") + .args(&["--dev", "--tmp", "--ws-port=45789", "--no-hardware-benchmarks"]) .spawn() - .unwrap(), - ); - - let stderr = cmd.stderr.take().unwrap(); - - let (ws_url, _) = common::find_ws_url_from_output(stderr); - - common::wait_n_finalized_blocks(3, 30, &ws_url) - .await - .expect("Blocks are produced in time"); - assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running"); - kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap(); - assert_eq!( - common::wait_for(&mut cmd, 30).map(|x| x.success()), - Ok(true), - "the process must exit gracefully after signal {}", - signal, - ); - // Check if the database was closed gracefully. If it was not, - // there may exist a ref cycle that prevents the Client from being dropped properly. - // - // parity-db only writes the stats file on clean shutdown. - let stats_file = base_path.path().join("chains/dev/paritydb/full/stats.txt"); - assert!(std::path::Path::exists(&stats_file)); - } - - run_command_and_kill(SIGINT).await; - run_command_and_kill(SIGTERM).await; -} + .unwrap() + } -#[tokio::test] -async fn running_two_nodes_with_the_same_ws_port_should_work() { - 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"]) - .spawn() - .unwrap() - } - - let mut first_node = common::KillChildOnDrop(start_node()); - let mut second_node = common::KillChildOnDrop(start_node()); - - let stderr = first_node.stderr.take().unwrap(); - let (ws_url, _) = common::find_ws_url_from_output(stderr); - - common::wait_n_finalized_blocks(3, 30, &ws_url).await.unwrap(); - - assert!(first_node.try_wait().unwrap().is_none(), "The first node should still be running"); - assert!(second_node.try_wait().unwrap().is_none(), "The second node should still be running"); - - kill(Pid::from_raw(first_node.id().try_into().unwrap()), SIGINT).unwrap(); - kill(Pid::from_raw(second_node.id().try_into().unwrap()), SIGINT).unwrap(); - - assert_eq!( - common::wait_for(&mut first_node, 30).map(|x| x.success()), - Ok(true), - "The first node must exit gracefully", - ); - assert_eq!( - common::wait_for(&mut second_node, 30).map(|x| x.success()), - Ok(true), - "The second node must exit gracefully", - ); + let mut first_node = common::KillChildOnDrop(start_node()); + let mut second_node = common::KillChildOnDrop(start_node()); + + let stderr = first_node.stderr.take().unwrap(); + let ws_url = common::extract_info_from_output(stderr).0.ws_url; + + common::wait_n_finalized_blocks(3, &ws_url).await; + + first_node.assert_still_running(); + second_node.assert_still_running(); + + first_node.stop(); + second_node.stop(); + }) + .await; } diff --git a/bin/node/cli/tests/telemetry.rs b/bin/node/cli/tests/telemetry.rs index 633cc996ca615..a68746a2c0011 100644 --- a/bin/node/cli/tests/telemetry.rs +++ b/bin/node/cli/tests/telemetry.rs @@ -17,78 +17,75 @@ // along with this program. If not, see . use assert_cmd::cargo::cargo_bin; -use nix::{ - sys::signal::{kill, Signal::SIGINT}, - unistd::Pid, -}; -use std::process; +use std::{process, time::Duration}; + +use crate::common::KillChildOnDrop; pub mod common; pub mod websocket_server; #[tokio::test] async fn telemetry_works() { - let config = websocket_server::Config { - capacity: 1, - max_frame_size: 1048 * 1024, - send_buffer_len: 32, - bind_address: "127.0.0.1:0".parse().unwrap(), - }; - let mut server = websocket_server::WsServer::new(config).await.unwrap(); - - let addr = server.local_addr().unwrap(); - - let server_task = tokio::spawn(async move { - loop { - use websocket_server::Event; - match server.next_event().await { - // New connection on the listener. - Event::ConnectionOpen { address } => { - println!("New connection from {:?}", address); - server.accept(); - }, - - // Received a message from a connection. - Event::BinaryFrame { message, .. } => { - let json: serde_json::Value = serde_json::from_slice(&message).unwrap(); - let object = - json.as_object().unwrap().get("payload").unwrap().as_object().unwrap(); - if matches!(object.get("best"), Some(serde_json::Value::String(_))) { - break - } - }, - - Event::TextFrame { .. } => panic!("Got a TextFrame over the socket, this is a bug"), - - // Connection has been closed. - Event::ConnectionError { .. } => {}, + common::run_with_timeout(Duration::from_secs(60 * 10), async move { + let config = websocket_server::Config { + capacity: 1, + max_frame_size: 1048 * 1024, + send_buffer_len: 32, + bind_address: "127.0.0.1:0".parse().unwrap(), + }; + let mut server = websocket_server::WsServer::new(config).await.unwrap(); + + let addr = server.local_addr().unwrap(); + + let server_task = tokio::spawn(async move { + loop { + use websocket_server::Event; + match server.next_event().await { + // New connection on the listener. + Event::ConnectionOpen { address } => { + println!("New connection from {:?}", address); + server.accept(); + }, + + // Received a message from a connection. + Event::BinaryFrame { message, .. } => { + let json: serde_json::Value = serde_json::from_slice(&message).unwrap(); + let object = + json.as_object().unwrap().get("payload").unwrap().as_object().unwrap(); + if matches!(object.get("best"), Some(serde_json::Value::String(_))) { + break + } + }, + + Event::TextFrame { .. } => + panic!("Got a TextFrame over the socket, this is a bug"), + + // Connection has been closed. + Event::ConnectionError { .. } => {}, + } } - } - }); - - let mut substrate = process::Command::new(cargo_bin("substrate")); - - let mut substrate = substrate - .args(&["--dev", "--tmp", "--telemetry-url"]) - .arg(format!("ws://{} 10", addr)) - .arg("--no-hardware-benchmarks") - .stdout(process::Stdio::piped()) - .stderr(process::Stdio::piped()) - .stdin(process::Stdio::null()) - .spawn() - .unwrap(); - - server_task.await.expect("server task panicked"); - - assert!(substrate.try_wait().unwrap().is_none(), "the process should still be running"); - - // Stop the process - kill(Pid::from_raw(substrate.id().try_into().unwrap()), SIGINT).unwrap(); - assert!(common::wait_for(&mut substrate, 40).map(|x| x.success()).unwrap_or_default()); - - let output = substrate.wait_with_output().unwrap(); - - println!("{}", String::from_utf8(output.stdout).unwrap()); - eprintln!("{}", String::from_utf8(output.stderr).unwrap()); - assert!(output.status.success()); + }); + + let mut substrate = process::Command::new(cargo_bin("substrate")); + + let mut substrate = KillChildOnDrop( + substrate + .args(&["--dev", "--tmp", "--telemetry-url"]) + .arg(format!("ws://{} 10", addr)) + .arg("--no-hardware-benchmarks") + .stdout(process::Stdio::piped()) + .stderr(process::Stdio::piped()) + .stdin(process::Stdio::null()) + .spawn() + .unwrap(), + ); + + server_task.await.expect("server task panicked"); + + substrate.assert_still_running(); + + // Stop the process + substrate.stop(); + }) + .await; } diff --git a/bin/node/cli/tests/temp_base_path_works.rs b/bin/node/cli/tests/temp_base_path_works.rs index 4e743f2d3abd4..89e901c00e118 100644 --- a/bin/node/cli/tests/temp_base_path_works.rs +++ b/bin/node/cli/tests/temp_base_path_works.rs @@ -19,45 +19,42 @@ #![cfg(unix)] use assert_cmd::cargo::cargo_bin; -use nix::{ - sys::signal::{kill, Signal::SIGINT}, - unistd::Pid, -}; -use regex::Regex; use std::{ - io::Read, - path::PathBuf, process::{Command, Stdio}, + time::Duration, }; pub mod common; #[tokio::test] async fn temp_base_path_works() { - let mut cmd = Command::new(cargo_bin("substrate")); - let mut child = common::KillChildOnDrop( - cmd.args(&["--dev", "--tmp", "--no-hardware-benchmarks"]) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .unwrap(), - ); - - let mut stderr = child.stderr.take().unwrap(); - let (ws_url, mut data) = common::find_ws_url_from_output(&mut stderr); - - // Let it produce some blocks. - common::wait_n_finalized_blocks(3, 30, &ws_url).await.unwrap(); - assert!(child.try_wait().unwrap().is_none(), "the process should still be running"); - - // Stop the process - kill(Pid::from_raw(child.id().try_into().unwrap()), SIGINT).unwrap(); - assert!(common::wait_for(&mut child, 40).map(|x| x.success()).unwrap_or_default()); - - // Ensure the database has been deleted - stderr.read_to_string(&mut data).unwrap(); - let re = Regex::new(r"Database: .+ at (\S+)").unwrap(); - let db_path = PathBuf::from(re.captures(data.as_str()).unwrap().get(1).unwrap().as_str()); - - assert!(!db_path.exists()); + common::run_with_timeout(Duration::from_secs(60 * 10), async move { + let mut cmd = Command::new(cargo_bin("substrate")); + let mut child = common::KillChildOnDrop( + cmd.args(&["--dev", "--tmp", "--no-hardware-benchmarks"]) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .unwrap(), + ); + + let mut stderr = child.stderr.take().unwrap(); + let node_info = common::extract_info_from_output(&mut stderr).0; + + // Let it produce some blocks. + common::wait_n_finalized_blocks(3, &node_info.ws_url).await; + + // Ensure the db path exists while the node is running + assert!(node_info.db_path.exists()); + + child.assert_still_running(); + + // Stop the process + child.stop(); + + if node_info.db_path.exists() { + panic!("Database path `{}` wasn't deleted!", node_info.db_path.display()); + } + }) + .await; } diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index adbb299317ac9..e73321ecce5b3 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -197,10 +197,15 @@ pub trait SubstrateCli: Sized { command: &T, ) -> error::Result> { let tokio_runtime = build_runtime()?; + + // `capture` needs to be called in a tokio context. + // Also capture them as early as possible. + let signals = tokio_runtime.block_on(async { Signals::capture() })?; + let config = command.create_configuration(self, tokio_runtime.handle().clone())?; command.init(&Self::support_url(), &Self::impl_version(), |_, _| {}, &config)?; - Runner::new(config, tokio_runtime) + Runner::new(config, tokio_runtime, signals) } /// Create a runner for the command provided in argument. The `logger_hook` can be used to setup @@ -231,10 +236,15 @@ pub trait SubstrateCli: Sized { F: FnOnce(&mut LoggerBuilder, &Configuration), { let tokio_runtime = build_runtime()?; + + // `capture` needs to be called in a tokio context. + // Also capture them as early as possible. + let signals = tokio_runtime.block_on(async { Signals::capture() })?; + let config = command.create_configuration(self, tokio_runtime.handle().clone())?; command.init(&Self::support_url(), &Self::impl_version(), logger_hook, &config)?; - Runner::new(config, tokio_runtime) + Runner::new(config, tokio_runtime, signals) } /// Native runtime version. fn native_runtime_version(chain_spec: &Box) -> &'static RuntimeVersion; diff --git a/client/cli/src/runner.rs b/client/cli/src/runner.rs index 8917a37c499c0..47adfcf89fe99 100644 --- a/client/cli/src/runner.rs +++ b/client/cli/src/runner.rs @@ -18,54 +18,72 @@ use crate::{error::Error as CliError, Result, SubstrateCli}; use chrono::prelude::*; -use futures::{future, future::FutureExt, pin_mut, select, Future}; +use futures::{ + future::{self, BoxFuture, FutureExt}, + pin_mut, select, Future, +}; use log::info; use sc_service::{Configuration, Error as ServiceError, TaskManager}; use sc_utils::metrics::{TOKIO_THREADS_ALIVE, TOKIO_THREADS_TOTAL}; use std::{marker::PhantomData, time::Duration}; -#[cfg(target_family = "unix")] -async fn main(func: F) -> std::result::Result<(), E> -where - F: Future> + future::FusedFuture, - E: std::error::Error + Send + Sync + 'static + From, -{ - use tokio::signal::unix::{signal, SignalKind}; +/// Abstraction over OS signals to handle the shutdown of the node smoothly. +/// +/// On `unix` this represents `SigInt` and `SigTerm`. +pub struct Signals(BoxFuture<'static, ()>); - let mut stream_int = signal(SignalKind::interrupt()).map_err(ServiceError::Io)?; - let mut stream_term = signal(SignalKind::terminate()).map_err(ServiceError::Io)?; - - let t1 = stream_int.recv().fuse(); - let t2 = stream_term.recv().fuse(); - let t3 = func; - - pin_mut!(t1, t2, t3); +impl Signals { + /// Capture the relevant signals to handle shutdown of the node smoothly. + /// + /// Needs to be called in a Tokio context to have access to the tokio reactor. + #[cfg(target_family = "unix")] + pub fn capture() -> std::result::Result { + use tokio::signal::unix::{signal, SignalKind}; + + let mut stream_int = signal(SignalKind::interrupt()).map_err(ServiceError::Io)?; + let mut stream_term = signal(SignalKind::terminate()).map_err(ServiceError::Io)?; + + Ok(Signals( + async move { + future::select(stream_int.recv().boxed(), stream_term.recv().boxed()).await; + } + .boxed(), + )) + } - select! { - _ = t1 => {}, - _ = t2 => {}, - res = t3 => res?, + /// Capture the relevant signals to handle shutdown of the node smoothly. + /// + /// Needs to be called in a Tokio context to have access to the tokio reactor. + #[cfg(not(unix))] + pub fn capture() -> std::result::Result { + use tokio::signal::ctrl_c; + + Ok(Signals( + async move { + let _ = ctrl_c().await; + } + .boxed(), + )) } - Ok(()) + /// A dummy signal that never returns. + pub fn dummy() -> Self { + Self(future::pending().boxed()) + } } -#[cfg(not(unix))] -async fn main(func: F) -> std::result::Result<(), E> +async fn main(func: F, signals: impl Future) -> std::result::Result<(), E> where F: Future> + future::FusedFuture, - E: std::error::Error + Send + Sync + 'static + From, + E: std::error::Error + Send + Sync + 'static, { - use tokio::signal::ctrl_c; - - let t1 = ctrl_c().fuse(); - let t2 = func; + let signals = signals.fuse(); - pin_mut!(t1, t2); + pin_mut!(func, signals); select! { - _ = t1 => {}, - res = t2 => res?, + _ = signals => {}, + res = func => res?, } Ok(()) @@ -89,6 +107,7 @@ fn run_until_exit( tokio_runtime: tokio::runtime::Runtime, future: F, task_manager: TaskManager, + signals: impl Future, ) -> std::result::Result<(), E> where F: Future> + future::Future, @@ -97,7 +116,7 @@ where let f = future.fuse(); pin_mut!(f); - tokio_runtime.block_on(main(f))?; + tokio_runtime.block_on(main(f, signals))?; drop(task_manager); Ok(()) @@ -107,13 +126,18 @@ where pub struct Runner { config: Configuration, tokio_runtime: tokio::runtime::Runtime, + signals: Signals, phantom: PhantomData, } impl Runner { /// Create a new runtime with the command provided in argument - pub fn new(config: Configuration, tokio_runtime: tokio::runtime::Runtime) -> Result> { - Ok(Runner { config, tokio_runtime, phantom: PhantomData }) + pub fn new( + config: Configuration, + tokio_runtime: tokio::runtime::Runtime, + signals: Signals, + ) -> Result> { + Ok(Runner { config, tokio_runtime, signals, phantom: PhantomData }) } /// Log information about the node itself. @@ -147,7 +171,7 @@ impl Runner { self.print_node_infos(); let mut task_manager = self.tokio_runtime.block_on(initialize(self.config))?; - let res = self.tokio_runtime.block_on(main(task_manager.future().fuse())); + let res = self.tokio_runtime.block_on(main(task_manager.future().fuse(), self.signals.0)); // We need to drop the task manager here to inform all tasks that they should shut down. // // This is important to be done before we instruct the tokio runtime to shutdown. Otherwise @@ -210,7 +234,7 @@ impl Runner { E: std::error::Error + Send + Sync + 'static + From + From, { let (future, task_manager) = runner(self.config)?; - run_until_exit::<_, E>(self.tokio_runtime, future, task_manager) + run_until_exit::<_, E>(self.tokio_runtime, future, task_manager, self.signals.0) } /// Get an immutable reference to the node Configuration @@ -369,6 +393,7 @@ mod tests { runtime_cache_size: 2, }, runtime, + Signals::dummy(), ) .unwrap(); From 22cca143a2c8e4a03ae770d71e94329eb518cca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Thu, 16 Mar 2023 12:09:50 +0000 Subject: [PATCH 25/80] Integration tests for staking + election-provider-multi-phase (#12972) * EPM and staking pallets: Adds new crate for integration tests a * Adds ExtBuilder and helpers with initial conditions assertions * removes account helpers; adds staking, session, etc genesis * Adds kusama incident test case * Prepare for slashing test * Adds solution submission * slash_through_offending_threshold * Renames e2e integration tests dir and crate * consistently slash 10% of validator set * finishes continous_slashes_below_offending_threshold test * Update frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> * Update frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> * Update frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * mock fixes * Additional checks to delayed solution eras and mock fixes * nits and addresses review comments; splits ext_builder into one per pallet * helper to set balances ext builder * bring up mock.rs to master * integration test fixes and additions --------- Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- .../test-staking-e2e/Cargo.lock | 3609 +++++++++++++++++ .../test-staking-e2e/Cargo.toml | 40 + .../test-staking-e2e/src/lib.rs | 206 + .../test-staking-e2e/src/mock.rs | 779 ++++ 4 files changed, 4634 insertions(+) create mode 100644 frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock create mode 100644 frame/election-provider-multi-phase/test-staking-e2e/Cargo.toml create mode 100644 frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs create mode 100644 frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs diff --git a/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock new file mode 100644 index 0000000000000..b179ab7059a48 --- /dev/null +++ b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock @@ -0,0 +1,3609 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom 0.2.8", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "getrandom 0.2.8", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" + +[[package]] +name = "approx" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +dependencies = [ + "num-traits", +] + +[[package]] +name = "array-bytes" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "async-trait" +version = "0.1.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base58" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64ct" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b12e5fd123190ce1c2e559308a94c9bacad77907d4c6005d9e58fe1a0689e55e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "blake2b_simd" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" +dependencies = [ + "arrayref", + "arrayvec 0.7.2", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.6", +] + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array 0.14.6", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "bounded-collections" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a071c348a5ef6da1d3a87166b408170b46002382b1dda83992b5c2208cefb370" +dependencies = [ + "log", + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "bytemuck" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" + +[[package]] +name = "cc" +version = "1.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" + +[[package]] +name = "cfg-expr" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +dependencies = [ + "smallvec", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +dependencies = [ + "iana-time-zone", + "num-integer", + "num-traits", + "winapi", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "const-oid" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" + +[[package]] +name = "constant_time_eq" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpp_demangle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "cranelift-entity" +version = "0.93.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cf583f7b093f291005f9fb1323e2c37f6ee4c7909e39ce016b2e8360d461705" +dependencies = [ + "serde", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array 0.14.6", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array 0.14.6", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array 0.14.6", + "subtle", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array 0.14.6", + "subtle", +] + +[[package]] +name = "curve25519-dalek" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b85542f99a2dfa2a1b8e192662741c9859a846b296bef1c92ef9b58b5a216" +dependencies = [ + "byteorder", + "digest 0.8.1", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "cxx" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "derive-syn-parse" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.6", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer 0.10.3", + "crypto-common", + "subtle", +] + +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + +[[package]] +name = "dyn-clonable" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" +dependencies = [ + "dyn-clonable-impl", + "dyn-clone", +] + +[[package]] +name = "dyn-clonable-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dyn-clone" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "ed25519" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek 3.2.0", + "ed25519", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "ed25519-zebra" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +dependencies = [ + "curve25519-dalek 3.2.0", + "hashbrown 0.12.3", + "hex", + "rand_core 0.6.4", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest 0.10.6", + "ff", + "generic-array 0.14.6", + "group", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "environmental" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "expander" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f360349150728553f92e4c997a16af8915f418d3a0f21b440d34c5632f16ed84" +dependencies = [ + "blake2", + "fs-err", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand 0.8.5", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "frame-benchmarking" +version = "4.0.0-dev" +dependencies = [ + "frame-support", + "frame-support-procedural", + "frame-system", + "linregress", + "log", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-io", + "sp-runtime", + "sp-runtime-interface", + "sp-std", + "sp-storage", + "static_assertions", +] + +[[package]] +name = "frame-election-provider-solution-type" +version = "4.0.0-dev" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-election-provider-support" +version = "4.0.0-dev" +dependencies = [ + "frame-election-provider-solution-type", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-npos-elections", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "frame-metadata" +version = "15.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df6bb8542ef006ef0de09a5c4420787d79823c0ed7924225822362fd2bf2ff2d" +dependencies = [ + "cfg-if", + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "frame-support" +version = "4.0.0-dev" +dependencies = [ + "bitflags", + "environmental", + "frame-metadata", + "frame-support-procedural", + "impl-trait-for-tuples", + "k256", + "log", + "once_cell", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "smallvec", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-core-hashing-proc-macro", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-weights", + "tt-call", +] + +[[package]] +name = "frame-support-procedural" +version = "4.0.0-dev" +dependencies = [ + "Inflector", + "cfg-expr", + "derive-syn-parse", + "frame-support-procedural-tools", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-support-procedural-tools" +version = "4.0.0-dev" +dependencies = [ + "frame-support-procedural-tools-derive", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-support-procedural-tools-derive" +version = "3.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-system" +version = "4.0.0-dev" +dependencies = [ + "frame-support", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-version", + "sp-weights", +] + +[[package]] +name = "fs-err" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" + +[[package]] +name = "futures-executor" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", + "num_cpus", +] + +[[package]] +name = "futures-io" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" + +[[package]] +name = "futures-macro" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" + +[[package]] +name = "futures-task" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + +[[package]] +name = "futures-util" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +dependencies = [ + "fallible-iterator", + "stable_deref_trait", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "hash-db" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e7d7786361d7425ae2fe4f9e407eb0efaa0840f5212d109cc018c40c35c6ab4" + +[[package]] +name = "hash256-std-hasher" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" +dependencies = [ + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.6", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac 0.11.1", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.6", + "hmac 0.8.1", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +dependencies = [ + "libc", + "windows-sys 0.45.0", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", +] + +[[package]] +name = "keccak" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" + +[[package]] +name = "libm" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" + +[[package]] +name = "libsecp256k1" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" +dependencies = [ + "arrayref", + "base64", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.8.5", + "serde", + "sha2 0.9.9", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +dependencies = [ + "cc", +] + +[[package]] +name = "linregress" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "475015a7f8f017edb28d2e69813be23500ad4b32cfe3421c4148efc97324ee52" +dependencies = [ + "nalgebra", +] + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matrixmultiply" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" +dependencies = [ + "rawpointer", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memfd" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" +dependencies = [ + "rustix", +] + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memory-db" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" +dependencies = [ + "hash-db", +] + +[[package]] +name = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" + +[[package]] +name = "merlin" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "miniz_oxide" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +dependencies = [ + "adler", +] + +[[package]] +name = "nalgebra" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d68d47bba83f9e2006d117a9a33af1524e655516b8919caac694427a6fb1e511" +dependencies = [ + "approx", + "matrixmultiply", + "nalgebra-macros", + "num-complex", + "num-rational", + "num-traits", + "simba", + "typenum", +] + +[[package]] +name = "nalgebra-macros" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-format" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" +dependencies = [ + "arrayvec 0.7.2", + "itoa", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +dependencies = [ + "crc32fast", + "hashbrown 0.12.3", + "indexmap", + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "pallet-authorship" +version = "4.0.0-dev" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-bags-list" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-tracing", +] + +[[package]] +name = "pallet-balances" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-election-provider-e2e-test" +version = "1.0.0" +dependencies = [ + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-bags-list", + "pallet-balances", + "pallet-election-provider-multi-phase", + "pallet-session", + "pallet-staking", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "sp-staking", + "sp-std", + "sp-tracing", +] + +[[package]] +name = "pallet-election-provider-multi-phase" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-election-provider-support-benchmarking", + "parity-scale-codec", + "rand 0.8.5", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "sp-std", + "strum", +] + +[[package]] +name = "pallet-election-provider-support-benchmarking" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-system", + "parity-scale-codec", + "sp-npos-elections", + "sp-runtime", +] + +[[package]] +name = "pallet-session" +version = "4.0.0-dev" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-trie", +] + +[[package]] +name = "pallet-staking" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "scale-info", + "serde", + "sp-application-crypto", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-timestamp" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-std", + "sp-timestamp", +] + +[[package]] +name = "parity-scale-codec" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" +dependencies = [ + "arrayvec 0.7.2", + "bitvec", + "byte-slice-cast", + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "parity-wasm" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.42.0", +] + +[[package]] +name = "paste" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1c2c742266c2f1041c914ba65355a83ae8747b05f208319784083583494b4b" + +[[package]] +name = "pbkdf2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +dependencies = [ + "crypto-mac 0.11.1", +] + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "primitive-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-serde", + "scale-info", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +dependencies = [ + "once_cell", + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.8", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "ref-cast" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b15debb4f9d60d767cd8ca9ef7abb2452922f3214671ff052defc7f3502c44" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abfa8511e9e94fd3de6585a3d3cd00e01ed556dc9814829280af0e8dc72a8f36" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "regex" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac 0.12.1", + "zeroize", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustix" +version = "0.36.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.45.0", +] + +[[package]] +name = "rustversion" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "safe_arch" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "scale-info" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "schnellru" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" +dependencies = [ + "ahash 0.8.3", + "cfg-if", + "hashbrown 0.13.2", +] + +[[package]] +name = "schnorrkel" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "curve25519-dalek 2.1.3", + "getrandom 0.1.16", + "merlin", + "rand 0.7.3", + "rand_core 0.5.1", + "sha2 0.8.2", + "subtle", + "zeroize", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array 0.14.6", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9512ffd81e3a3503ed401f79c33168b9148c75038956039166cd750eaa037c3" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +dependencies = [ + "cc", +] + +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + +[[package]] +name = "serde" +version = "1.0.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e326c9ec8042f1b5da33252c8a37e9ffbd2c9bef0155215b6e6c80c790e05f91" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42a3df25b0713732468deadad63ab9da1f1fd75a48a15024b50363f128db627e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "sha3" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +dependencies = [ + "digest 0.10.6", + "keccak", +] + +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.6", + "rand_core 0.6.4", +] + +[[package]] +name = "simba" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50582927ed6f77e4ac020c057f37a268fc6aebc29225050365aacbb9deeeddc4" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", + "wide", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "sp-api" +version = "4.0.0-dev" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", + "sp-api-proc-macro", + "sp-core", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-trie", + "sp-version", + "thiserror", +] + +[[package]] +name = "sp-api-proc-macro" +version = "4.0.0-dev" +dependencies = [ + "Inflector", + "blake2", + "expander", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-application-crypto" +version = "7.0.0" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-std", +] + +[[package]] +name = "sp-arithmetic" +version = "6.0.0" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-std", + "static_assertions", +] + +[[package]] +name = "sp-core" +version = "7.0.0" +dependencies = [ + "array-bytes", + "base58", + "bitflags", + "blake2", + "bounded-collections", + "dyn-clonable", + "ed25519-zebra", + "futures", + "hash-db", + "hash256-std-hasher", + "impl-serde", + "lazy_static", + "libsecp256k1", + "log", + "merlin", + "parity-scale-codec", + "parking_lot", + "primitive-types", + "rand 0.8.5", + "regex", + "scale-info", + "schnorrkel", + "secp256k1", + "secrecy", + "serde", + "sp-core-hashing", + "sp-debug-derive", + "sp-externalities", + "sp-runtime-interface", + "sp-std", + "sp-storage", + "ss58-registry", + "substrate-bip39", + "thiserror", + "tiny-bip39", + "zeroize", +] + +[[package]] +name = "sp-core-hashing" +version = "5.0.0" +dependencies = [ + "blake2b_simd", + "byteorder", + "digest 0.10.6", + "sha2 0.10.6", + "sha3", + "sp-std", + "twox-hash", +] + +[[package]] +name = "sp-core-hashing-proc-macro" +version = "5.0.0" +dependencies = [ + "proc-macro2", + "quote", + "sp-core-hashing", + "syn", +] + +[[package]] +name = "sp-debug-derive" +version = "5.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-externalities" +version = "0.13.0" +dependencies = [ + "environmental", + "parity-scale-codec", + "sp-std", + "sp-storage", +] + +[[package]] +name = "sp-inherents" +version = "4.0.0-dev" +dependencies = [ + "async-trait", + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", + "thiserror", +] + +[[package]] +name = "sp-io" +version = "7.0.0" +dependencies = [ + "bytes", + "ed25519", + "ed25519-dalek", + "futures", + "libsecp256k1", + "log", + "parity-scale-codec", + "secp256k1", + "sp-core", + "sp-externalities", + "sp-keystore", + "sp-runtime-interface", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-trie", + "tracing", + "tracing-core", +] + +[[package]] +name = "sp-keystore" +version = "0.13.0" +dependencies = [ + "async-trait", + "futures", + "merlin", + "parity-scale-codec", + "parking_lot", + "schnorrkel", + "sp-core", + "sp-externalities", + "thiserror", +] + +[[package]] +name = "sp-npos-elections" +version = "4.0.0-dev" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-arithmetic", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-panic-handler" +version = "5.0.0" +dependencies = [ + "backtrace", + "lazy_static", + "regex", +] + +[[package]] +name = "sp-runtime" +version = "7.0.0" +dependencies = [ + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "paste", + "rand 0.8.5", + "scale-info", + "serde", + "sp-application-crypto", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", + "sp-weights", +] + +[[package]] +name = "sp-runtime-interface" +version = "7.0.0" +dependencies = [ + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec", + "primitive-types", + "sp-externalities", + "sp-runtime-interface-proc-macro", + "sp-std", + "sp-storage", + "sp-tracing", + "sp-wasm-interface", + "static_assertions", +] + +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "6.0.0" +dependencies = [ + "Inflector", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-session" +version = "4.0.0-dev" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-core", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "sp-staking" +version = "4.0.0-dev" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-state-machine" +version = "0.13.0" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", + "parking_lot", + "rand 0.8.5", + "smallvec", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-std", + "sp-trie", + "thiserror", + "tracing", +] + +[[package]] +name = "sp-std" +version = "5.0.0" + +[[package]] +name = "sp-storage" +version = "7.0.0" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "ref-cast", + "serde", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "sp-timestamp" +version = "4.0.0-dev" +dependencies = [ + "async-trait", + "futures-timer", + "log", + "parity-scale-codec", + "sp-inherents", + "sp-runtime", + "sp-std", + "thiserror", +] + +[[package]] +name = "sp-tracing" +version = "6.0.0" +dependencies = [ + "parity-scale-codec", + "sp-std", + "tracing", + "tracing-core", + "tracing-subscriber", +] + +[[package]] +name = "sp-trie" +version = "7.0.0" +dependencies = [ + "ahash 0.8.3", + "hash-db", + "hashbrown 0.12.3", + "lazy_static", + "memory-db", + "nohash-hasher", + "parity-scale-codec", + "parking_lot", + "scale-info", + "schnellru", + "sp-core", + "sp-std", + "thiserror", + "tracing", + "trie-db", + "trie-root", +] + +[[package]] +name = "sp-version" +version = "5.0.0" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "parity-wasm", + "scale-info", + "serde", + "sp-core-hashing-proc-macro", + "sp-runtime", + "sp-std", + "sp-version-proc-macro", + "thiserror", +] + +[[package]] +name = "sp-version-proc-macro" +version = "4.0.0-dev" +dependencies = [ + "parity-scale-codec", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-wasm-interface" +version = "7.0.0" +dependencies = [ + "anyhow", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "sp-std", + "wasmi", + "wasmtime", +] + +[[package]] +name = "sp-weights" +version = "4.0.0" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic", + "sp-core", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "ss58-registry" +version = "1.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d92659e7d18d82b803824a9ba5a6022cff101c3491d027c1c1d8d30e749284" +dependencies = [ + "Inflector", + "num-format", + "proc-macro2", + "quote", + "serde", + "serde_json", + "unicode-xid", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "substrate-bip39" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" +dependencies = [ + "hmac 0.11.0", + "pbkdf2 0.8.0", + "schnorrkel", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "target-lexicon" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tiny-bip39" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62cc94d358b5a1e84a5cb9109f559aa3c4d634d2b1b4de3d0fa4adc7c78e2861" +dependencies = [ + "anyhow", + "hmac 0.12.1", + "once_cell", + "pbkdf2 0.11.0", + "rand 0.8.5", + "rustc-hash", + "sha2 0.10.6", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "ansi_term", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "trie-db" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d75c77ea43f2ad8ea9d9c58de49dfc9c3995bdef32b503df7883ff054e7f1" +dependencies = [ + "hash-db", + "hashbrown 0.13.2", + "log", + "rustc-hex", + "smallvec", +] + +[[package]] +name = "trie-root" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" +dependencies = [ + "hash-db", +] + +[[package]] +name = "tt-call" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e66dcbec4290c69dd03c57e76c2469ea5c7ce109c6dd4351c13055cf71ea055" + +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "digest 0.10.6", + "rand 0.8.5", + "static_assertions", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" + +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "wasmi" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" +dependencies = [ + "parity-wasm", + "wasmi-validation", + "wasmi_core", +] + +[[package]] +name = "wasmi-validation" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" +dependencies = [ + "parity-wasm", +] + +[[package]] +name = "wasmi_core" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" +dependencies = [ + "downcast-rs", + "libm", + "memory_units", + "num-rational", + "num-traits", +] + +[[package]] +name = "wasmparser" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64b20236ab624147dfbb62cf12a19aaf66af0e41b8398838b66e997d07d269d4" +dependencies = [ + "indexmap", + "url", +] + +[[package]] +name = "wasmtime" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6e89f9819523447330ffd70367ef4a18d8c832e24e8150fe054d1d912841632" +dependencies = [ + "anyhow", + "bincode", + "cfg-if", + "indexmap", + "libc", + "log", + "object", + "once_cell", + "paste", + "psm", + "serde", + "target-lexicon", + "wasmparser", + "wasmtime-environ", + "wasmtime-jit", + "wasmtime-runtime", + "windows-sys 0.42.0", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd3a5e46c198032da934469f3a6e48649d1f9142438e4fd4617b68a35644b8a" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-environ" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a6db9fc52985ba06ca601f2ff0ff1f526c5d724c7ac267b47326304b0c97883" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli", + "indexmap", + "log", + "object", + "serde", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-jit" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b77e3a52cd84d0f7f18554afa8060cfe564ccac61e3b0802d3fd4084772fa5f6" +dependencies = [ + "addr2line", + "anyhow", + "bincode", + "cfg-if", + "cpp_demangle", + "gimli", + "log", + "object", + "rustc-demangle", + "serde", + "target-lexicon", + "wasmtime-environ", + "wasmtime-jit-icache-coherence", + "wasmtime-runtime", + "windows-sys 0.42.0", +] + +[[package]] +name = "wasmtime-jit-debug" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0245e8a9347017c7185a72e215218a802ff561545c242953c11ba00fccc930f" +dependencies = [ + "once_cell", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67d412e9340ab1c83867051d8d1d7c90aa8c9afc91da086088068e2734e25064" +dependencies = [ + "cfg-if", + "libc", + "windows-sys 0.42.0", +] + +[[package]] +name = "wasmtime-runtime" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d594e791b5fdd4dbaf8cf7ae62f2e4ff85018ce90f483ca6f42947688e48827d" +dependencies = [ + "anyhow", + "cc", + "cfg-if", + "indexmap", + "libc", + "log", + "mach", + "memfd", + "memoffset", + "paste", + "rand 0.8.5", + "rustix", + "wasmtime-asm-macros", + "wasmtime-environ", + "wasmtime-jit-debug", + "windows-sys 0.42.0", +] + +[[package]] +name = "wasmtime-types" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6688d6f96d4dbc1f89fab626c56c1778936d122b5f4ae7a57c2eb42b8d982e2" +dependencies = [ + "cranelift-entity", + "serde", + "thiserror", + "wasmparser", +] + +[[package]] +name = "wide" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b689b6c49d6549434bf944e6b0f39238cf63693cb7a147e9d887507fffa3b223" +dependencies = [ + "bytemuck", + "safe_arch", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] diff --git a/frame/election-provider-multi-phase/test-staking-e2e/Cargo.toml b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.toml new file mode 100644 index 0000000000000..432b732b48e9d --- /dev/null +++ b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "pallet-election-provider-e2e-test" +version = "1.0.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "Apache-2.0" +homepage = "https://substrate.io" +repository = "https://github.com/paritytech/substrate/" +description = "FRAME election provider multi phase pallet tests with staking pallet, bags-list and session pallets" +publish = false + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[workspace] + +[dev-dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +scale-info = { version = "2.0.1", features = ["derive"] } +log = { version = "0.4.17", default-features = false } + +sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } +sp-io = { version = "7.0.0", path = "../../../primitives/io" } +sp-std = { version = "5.0.0", path = "../../../primitives/std" } +sp-staking = { version = "4.0.0-dev", path = "../../../primitives/staking" } +sp-core = { version = "7.0.0", path = "../../../primitives/core" } +sp-npos-elections = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/npos-elections" } +sp-tracing = { version = "6.0.0", path = "../../../primitives/tracing" } + +frame-system = { version = "4.0.0-dev", path = "../../system" } +frame-support = { version = "4.0.0-dev", path = "../../support" } +frame-election-provider-support = { version = "4.0.0-dev", path = "../../election-provider-support" } + +pallet-election-provider-multi-phase = { version = "4.0.0-dev", path = "../../election-provider-multi-phase" } +pallet-staking = { version = "4.0.0-dev", path = "../../staking" } +pallet-bags-list = { version = "4.0.0-dev", path = "../../bags-list" } +pallet-balances = { version = "4.0.0-dev", path = "../../balances" } +pallet-timestamp = { version = "4.0.0-dev", path = "../../timestamp" } +pallet-session = { version = "4.0.0-dev", path = "../../session" } + diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs new file mode 100644 index 0000000000000..c8f7d48a89ecf --- /dev/null +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs @@ -0,0 +1,206 @@ +// 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)] +mod mock; + +pub(crate) const LOG_TARGET: &str = "tests::e2e-epm"; + +use mock::*; +use sp_core::Get; +use sp_npos_elections::{to_supports, StakedAssignment}; +use sp_runtime::Perbill; + +use crate::mock::RuntimeOrigin; + +// syntactic sugar for logging. +#[macro_export] +macro_rules! log { + ($level:tt, $patter:expr $(, $values:expr)* $(,)?) => { + log::$level!( + target: crate::LOG_TARGET, + concat!("🛠️ ", $patter) $(, $values)* + ) + }; +} + +fn log_current_time() { + log!( + trace, + "block: {:?}, session: {:?}, era: {:?}, EPM phase: {:?} ts: {:?}", + System::block_number(), + Session::current_index(), + Staking::current_era(), + ElectionProviderMultiPhase::current_phase(), + Timestamp::now() + ); +} + +#[test] +fn block_progression_works() { + ExtBuilder::default().build_and_execute(|| { + assert_eq!(active_era(), 0); + assert_eq!(Session::current_index(), 0); + assert!(ElectionProviderMultiPhase::current_phase().is_off()); + + assert!(start_next_active_era().is_ok()); + assert_eq!(active_era(), 1); + assert_eq!(Session::current_index(), >::get()); + + assert!(ElectionProviderMultiPhase::current_phase().is_off()); + + roll_to_epm_signed(); + assert!(ElectionProviderMultiPhase::current_phase().is_signed()); + }); + + ExtBuilder::default().build_and_execute(|| { + assert_eq!(active_era(), 0); + assert_eq!(Session::current_index(), 0); + assert!(ElectionProviderMultiPhase::current_phase().is_off()); + + assert!(start_next_active_era_delayed_solution().is_ok()); + // if the solution is delayed, EPM will end up in emergency mode.. + assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); + // .. era won't progress.. + assert_eq!(active_era(), 0); + // .. but session does. + assert_eq!(Session::current_index(), 2); + }) +} + +#[test] +/// Replicates the Kusama incident of 8th Dec 2022 and its resolution through the governance +/// fallback. +/// +/// After enough slashes exceeded the `Staking::OffendingValidatorsThreshold`, the staking pallet +/// set `Forcing::ForceNew`. When a new session starts, staking will start to force a new era and +/// calls ::elect(). If at this point EPM and the staking miners did not +/// have enough time to queue a new solution (snapshot + solution submission), the election request +/// fails. If there is no election fallback mechanism in place, EPM enters in emergency mode. +/// Recovery: Once EPM is in emergency mode, subsequent calls to `elect()` will fail until a new +/// solution is added to EPM's `QueuedSolution` queue. This can be achieved through +/// `Call::set_emergency_election_result` or `Call::governance_fallback` dispatchables. Once a new +/// solution is added to the queue, EPM phase transitions to `Phase::Off` and the election flow +/// restarts. Note that in this test case, the emergency throttling is disabled. +fn enters_emergency_phase_after_forcing_before_elect() { + let epm_builder = EpmExtBuilder::default().disable_emergency_throttling(); + + ExtBuilder::default().epm(epm_builder).build_and_execute(|| { + log!( + trace, + "current validators (staking): {:?}", + >::validators() + ); + let session_validators_before = Session::validators(); + + roll_to_epm_off(); + assert!(ElectionProviderMultiPhase::current_phase().is_off()); + + assert_eq!(pallet_staking::ForceEra::::get(), pallet_staking::Forcing::NotForcing); + // slashes so that staking goes into `Forcing::ForceNew`. + slash_through_offending_threshold(); + + assert_eq!(pallet_staking::ForceEra::::get(), pallet_staking::Forcing::ForceNew); + + advance_session_delayed_solution(); + assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); + log_current_time(); + + let era_before_delayed_next = Staking::current_era(); + // try to advance 2 eras. + assert!(start_next_active_era_delayed_solution().is_ok()); + assert_eq!(Staking::current_era(), era_before_delayed_next); + assert!(start_next_active_era().is_err()); + assert_eq!(Staking::current_era(), era_before_delayed_next); + + // EPM is still in emergency phase. + assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); + + // session validator set remains the same. + assert_eq!(Session::validators(), session_validators_before); + + // performs recovery through the set emergency result. + let supports = to_supports(&vec![ + StakedAssignment { who: 21, distribution: vec![(21, 10)] }, + StakedAssignment { who: 31, distribution: vec![(21, 10), (31, 10)] }, + StakedAssignment { who: 41, distribution: vec![(41, 10)] }, + ]); + assert!(ElectionProviderMultiPhase::set_emergency_election_result( + RuntimeOrigin::root(), + supports + ) + .is_ok()); + + // EPM can now roll to signed phase to proceed with elections. The validator set is the + // expected (ie. set through `set_emergency_election_result`). + roll_to_epm_signed(); + //assert!(ElectionProviderMultiPhase::current_phase().is_signed()); + assert_eq!(Session::validators(), vec![21, 31, 41]); + assert_eq!(Staking::current_era(), era_before_delayed_next.map(|e| e + 1)); + }); +} + +#[test] +/// Continuously slash 10% of the active validators per era. +/// +/// Since the `OffendingValidatorsThreshold` is only checked per era staking does not force a new +/// era even as the number of active validators is decreasing across eras. When processing a new +/// slash, staking calculates the offending threshold based on the length of the current list of +/// active validators. Thus, slashing a percentage of the current validators that is lower than +/// `OffendingValidatorsThreshold` will never force a new era. However, as the slashes progress, if +/// the subsequent elections do not meet the minimum election untrusted score, the election will +/// fail and enter in emenergency mode. +fn continous_slashes_below_offending_threshold() { + let staking_builder = StakingExtBuilder::default().validator_count(10); + let epm_builder = EpmExtBuilder::default().disable_emergency_throttling(); + + ExtBuilder::default() + .staking(staking_builder) + .epm(epm_builder) + .build_and_execute(|| { + assert_eq!(Session::validators().len(), 10); + let mut active_validator_set = Session::validators(); + + roll_to_epm_signed(); + + // set a minimum election score. + assert!(set_minimum_election_score(500, 1000, 500).is_ok()); + + // slash 10% of the active validators and progress era until the minimum trusted score + // is reached. + while active_validator_set.len() > 0 { + let slashed = slash_percentage(Perbill::from_percent(10)); + assert_eq!(slashed.len(), 1); + + // break loop when era does not progress; EPM is in emergency phase as election + // failed due to election minimum score. + if start_next_active_era().is_err() { + assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); + break + } + + active_validator_set = Session::validators(); + + log!( + trace, + "slashed 10% of active validators ({:?}). After slash: {:?}", + slashed, + active_validator_set + ); + } + }); +} diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs new file mode 100644 index 0000000000000..19f568737c852 --- /dev/null +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -0,0 +1,779 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 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. + +#![allow(dead_code)] + +use _feps::ExtendedBalance; +use frame_support::{ + parameter_types, traits, + traits::{GenesisBuild, Hooks}, + weights::constants, +}; +use frame_system::EnsureRoot; +use sp_core::{ConstU32, Get, H256}; +use sp_npos_elections::{ElectionScore, VoteWeight}; +use sp_runtime::{ + testing, + traits::{IdentityLookup, Zero}, + transaction_validity, PerU16, Perbill, +}; +use sp_staking::{ + offence::{DisableStrategy, OffenceDetails, OnOffenceHandler}, + EraIndex, SessionIndex, +}; +use sp_std::prelude::*; +use std::collections::BTreeMap; + +use frame_election_provider_support::{onchain, ElectionDataProvider, SequentialPhragmen, Weight}; +use pallet_election_provider_multi_phase::{ + unsigned::MinerConfig, ElectionCompute, QueuedSolution, SolutionAccuracyOf, +}; +use pallet_staking::StakerStatus; + +use crate::{log, log_current_time}; + +pub const INIT_TIMESTAMP: u64 = 30_000; +pub const BLOCK_TIME: u64 = 1000; + +type Block = frame_system::mocking::MockBlock; +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Extrinsic = testing::TestXt; + +frame_support::construct_runtime!( + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: frame_system, + ElectionProviderMultiPhase: pallet_election_provider_multi_phase, + Staking: pallet_staking, + Balances: pallet_balances, + BagsList: pallet_bags_list, + Session: pallet_session, + Historical: pallet_session::historical, + Timestamp: pallet_timestamp, + } +); + +pub(crate) type AccountId = u128; +pub(crate) type AccountIndex = u32; +pub(crate) type BlockNumber = u64; +pub(crate) type Balance = u64; +pub(crate) type VoterIndex = u32; +pub(crate) type TargetIndex = u16; +pub(crate) type Moment = u64; + +impl frame_system::Config for Runtime { + type BaseCallFilter = traits::Everything; + type BlockWeights = BlockWeights; + type BlockLength = (); + type DbWeight = (); + type RuntimeOrigin = RuntimeOrigin; + type Index = AccountIndex; + type BlockNumber = BlockNumber; + type RuntimeCall = RuntimeCall; + type Hash = H256; + type Hashing = sp_runtime::traits::BlakeTwo256; + type AccountId = AccountId; + type Lookup = IdentityLookup; + type Header = sp_runtime::testing::Header; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = (); + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = traits::ConstU32<16>; +} + +const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); +parameter_types! { + pub static ExistentialDeposit: Balance = 1; + pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights + ::with_sensible_defaults( + Weight::from_parts(2u64 * constants::WEIGHT_REF_TIME_PER_SECOND, u64::MAX), + NORMAL_DISPATCH_RATIO, + ); +} + +impl pallet_balances::Config for Runtime { + type MaxLocks = traits::ConstU32<1024>; + type MaxReserves = (); + type ReserveIdentifier = [u8; 8]; + type Balance = Balance; + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = (); +} + +impl pallet_timestamp::Config for Runtime { + type Moment = Moment; + type OnTimestampSet = (); + type MinimumPeriod = traits::ConstU64<5>; + type WeightInfo = (); +} + +parameter_types! { + pub static Period: BlockNumber = 30; + pub static Offset: BlockNumber = 0; +} + +sp_runtime::impl_opaque_keys! { + pub struct SessionKeys { + pub other: OtherSessionHandler, + } +} + +impl pallet_session::Config for Runtime { + type SessionManager = pallet_session::historical::NoteHistoricalRoot; + type Keys = SessionKeys; + type ShouldEndSession = pallet_session::PeriodicSessions; + type NextSessionRotation = pallet_session::PeriodicSessions; + type SessionHandler = (OtherSessionHandler,); + type RuntimeEvent = RuntimeEvent; + type ValidatorId = AccountId; + type ValidatorIdOf = pallet_staking::StashOf; + type WeightInfo = (); +} +impl pallet_session::historical::Config for Runtime { + type FullIdentification = pallet_staking::Exposure; + type FullIdentificationOf = pallet_staking::ExposureOf; +} + +frame_election_provider_support::generate_solution_type!( + #[compact] + pub struct MockNposSolution::< + VoterIndex = VoterIndex, + TargetIndex = TargetIndex, + Accuracy = PerU16, + MaxVoters = ConstU32::<2_000> + >(16) +); + +parameter_types! { + pub static SignedPhase: BlockNumber = 10; + pub static UnsignedPhase: BlockNumber = 10; + // we expect a minimum of 3 blocks in signed phase and unsigned phases before trying + // enetering in emergency phase after the election failed. + pub static MinBlocksBeforeEmergency: BlockNumber = 3; + pub static MaxElectingVoters: VoterIndex = 1000; + pub static MaxElectableTargets: TargetIndex = 1000; + pub static MaxActiveValidators: u32 = 1000; + pub static OffchainRepeat: u32 = 5; + pub static MinerMaxLength: u32 = 256; + pub static MinerMaxWeight: Weight = BlockWeights::get().max_block; + pub static TransactionPriority: transaction_validity::TransactionPriority = 1; + pub static MaxWinners: u32 = 100; + pub static MaxVotesPerVoter: u32 = 16; + pub static MaxNominations: u32 = 16; +} + +impl pallet_election_provider_multi_phase::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type EstimateCallFee = frame_support::traits::ConstU32<8>; + type SignedPhase = SignedPhase; + type UnsignedPhase = UnsignedPhase; + type BetterSignedThreshold = (); + type BetterUnsignedThreshold = (); + type OffchainRepeat = OffchainRepeat; + type MinerTxPriority = TransactionPriority; + type MinerConfig = Self; + type SignedMaxSubmissions = ConstU32<10>; + type SignedRewardBase = (); + type SignedDepositBase = (); + type SignedDepositByte = (); + type SignedMaxRefunds = ConstU32<3>; + type SignedDepositWeight = (); + type SignedMaxWeight = (); + type SlashHandler = (); + type RewardHandler = (); + type DataProvider = Staking; + type Fallback = + frame_election_provider_support::NoElection<(AccountId, BlockNumber, Staking, MaxWinners)>; + type GovernanceFallback = onchain::OnChainExecution; + type Solver = SequentialPhragmen, ()>; + type ForceOrigin = EnsureRoot; + type MaxElectableTargets = MaxElectableTargets; + type MaxElectingVoters = MaxElectingVoters; + type MaxWinners = MaxWinners; + type BenchmarkingConfig = NoopElectionProviderBenchmarkConfig; + type WeightInfo = (); +} + +impl MinerConfig for Runtime { + type AccountId = AccountId; + type Solution = MockNposSolution; + type MaxVotesPerVoter = + <::DataProvider as ElectionDataProvider>::MaxVotesPerVoter; + type MaxLength = MinerMaxLength; + type MaxWeight = MinerMaxWeight; + type MaxWinners = MaxWinners; + + fn solution_weight(_v: u32, _t: u32, _a: u32, _d: u32) -> Weight { + Weight::zero() + } +} + +const THRESHOLDS: [VoteWeight; 9] = [10, 20, 30, 40, 50, 60, 1_000, 2_000, 10_000]; + +parameter_types! { + pub static BagThresholds: &'static [sp_npos_elections::VoteWeight] = &THRESHOLDS; + pub const SessionsPerEra: sp_staking::SessionIndex = 2; + pub const BondingDuration: sp_staking::EraIndex = 28; + pub const SlashDeferDuration: sp_staking::EraIndex = 7; // 1/4 the bonding duration. + pub const MaxNominatorRewardedPerValidator: u32 = 256; + pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(40); + pub HistoryDepth: u32 = 84; +} + +impl pallet_bags_list::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); + type ScoreProvider = Staking; + type BagThresholds = BagThresholds; + type Score = VoteWeight; +} + +impl pallet_staking::Config for Runtime { + type MaxNominations = MaxNominations; + type Currency = Balances; + type CurrencyBalance = Balance; + type UnixTime = Timestamp; + type CurrencyToVote = traits::SaturatingCurrencyToVote; + type RewardRemainder = (); + type RuntimeEvent = RuntimeEvent; + type Slash = (); // burn slashes + type Reward = (); // rewards are minted from the void + type SessionsPerEra = SessionsPerEra; + type BondingDuration = BondingDuration; + type SlashDeferDuration = SlashDeferDuration; + type AdminOrigin = EnsureRoot; // root can cancel slashes + type SessionInterface = Self; + type EraPayout = (); + type NextNewSession = Session; + type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type OffendingValidatorsThreshold = OffendingValidatorsThreshold; + type ElectionProvider = ElectionProviderMultiPhase; + type GenesisElectionProvider = onchain::OnChainExecution; + type VoterList = BagsList; + type TargetList = pallet_staking::UseValidatorsMap; + type MaxUnlockingChunks = ConstU32<32>; + type HistoryDepth = HistoryDepth; + type OnStakerSlash = (); + type WeightInfo = pallet_staking::weights::SubstrateWeight; + type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; +} + +impl frame_system::offchain::SendTransactionTypes for Runtime +where + RuntimeCall: From, +{ + type OverarchingCall = RuntimeCall; + type Extrinsic = Extrinsic; +} + +pub struct OnChainSeqPhragmen; + +parameter_types! { + pub static VotersBound: u32 = 600; + pub static TargetsBound: u32 = 400; +} + +impl onchain::Config for OnChainSeqPhragmen { + type System = Runtime; + type Solver = SequentialPhragmen< + AccountId, + pallet_election_provider_multi_phase::SolutionAccuracyOf, + >; + type DataProvider = Staking; + type WeightInfo = (); + type MaxWinners = MaxWinners; + type VotersBound = VotersBound; + type TargetsBound = TargetsBound; +} + +pub struct NoopElectionProviderBenchmarkConfig; + +impl pallet_election_provider_multi_phase::BenchmarkingConfig + for NoopElectionProviderBenchmarkConfig +{ + const VOTERS: [u32; 2] = [0, 0]; + const TARGETS: [u32; 2] = [0, 0]; + const ACTIVE_VOTERS: [u32; 2] = [0, 0]; + const DESIRED_TARGETS: [u32; 2] = [0, 0]; + const SNAPSHOT_MAXIMUM_VOTERS: u32 = 0; + const MINER_MAXIMUM_VOTERS: u32 = 0; + const MAXIMUM_TARGETS: u32 = 0; +} + +pub struct OtherSessionHandler; +impl traits::OneSessionHandler for OtherSessionHandler { + type Key = testing::UintAuthorityId; + + fn on_genesis_session<'a, I: 'a>(_: I) + where + I: Iterator, + AccountId: 'a, + { + } + + fn on_new_session<'a, I: 'a>(_: bool, _: I, _: I) + where + I: Iterator, + AccountId: 'a, + { + } + + fn on_disabled(_validator_index: u32) {} +} + +impl sp_runtime::BoundToRuntimeAppPublic for OtherSessionHandler { + type Public = testing::UintAuthorityId; +} + +pub struct StakingExtBuilder { + validator_count: u32, + minimum_validator_count: u32, + min_nominator_bond: Balance, + min_validator_bond: Balance, + status: BTreeMap>, + stakes: BTreeMap, + stakers: Vec<(AccountId, AccountId, Balance, StakerStatus)>, +} + +impl Default for StakingExtBuilder { + fn default() -> Self { + let stakers = vec![ + // (stash, ctrl, stake, status) + // these two will be elected in the default test where we elect 2. + (11, 10, 1000, StakerStatus::::Validator), + (21, 20, 1000, StakerStatus::::Validator), + // loser validatos if validator_count() is default. + (31, 30, 500, StakerStatus::::Validator), + (41, 40, 500, StakerStatus::::Validator), + (51, 50, 500, StakerStatus::::Validator), + (61, 60, 500, StakerStatus::::Validator), + (71, 70, 500, StakerStatus::::Validator), + (81, 80, 500, StakerStatus::::Validator), + (91, 90, 500, StakerStatus::::Validator), + (101, 100, 500, StakerStatus::::Validator), + // an idle validator + (201, 200, 1000, StakerStatus::::Idle), + ]; + + Self { + validator_count: 2, + minimum_validator_count: 0, + min_nominator_bond: ExistentialDeposit::get(), + min_validator_bond: ExistentialDeposit::get(), + status: Default::default(), + stakes: Default::default(), + stakers, + } + } +} + +impl StakingExtBuilder { + pub fn validator_count(mut self, n: u32) -> Self { + self.validator_count = n; + self + } +} + +pub struct EpmExtBuilder {} + +impl Default for EpmExtBuilder { + fn default() -> Self { + EpmExtBuilder {} + } +} + +impl EpmExtBuilder { + pub fn disable_emergency_throttling(self) -> Self { + ::set(0); + self + } + + pub fn phases(self, signed: BlockNumber, unsigned: BlockNumber) -> Self { + ::set(signed); + ::set(unsigned); + self + } +} + +pub struct BalancesExtBuilder { + balances: Vec<(AccountId, Balance)>, +} + +impl Default for BalancesExtBuilder { + fn default() -> Self { + let balances = vec![ + // (account_id, balance) + (1, 10), + (2, 20), + (3, 300), + (4, 400), + // controllers + (10, 100), + (20, 100), + (30, 100), + (40, 100), + (50, 100), + (60, 100), + (70, 100), + (80, 100), + (90, 100), + (100, 100), + (200, 100), + // stashes + (11, 1000), + (21, 2000), + (31, 3000), + (41, 4000), + (51, 5000), + (61, 6000), + (71, 7000), + (81, 8000), + (91, 9000), + (101, 10000), + (201, 20000), + // This allows us to have a total_payout different from 0. + (999, 1_000_000_000_000), + ]; + Self { balances } + } +} + +pub struct ExtBuilder { + staking_builder: StakingExtBuilder, + epm_builder: EpmExtBuilder, + balances_builder: BalancesExtBuilder, +} + +impl Default for ExtBuilder { + fn default() -> Self { + Self { + staking_builder: StakingExtBuilder::default(), + epm_builder: EpmExtBuilder::default(), + balances_builder: BalancesExtBuilder::default(), + } + } +} + +impl ExtBuilder { + pub fn build(self) -> sp_io::TestExternalities { + sp_tracing::try_init_simple(); + let mut storage = + frame_system::GenesisConfig::default().build_storage::().unwrap(); + + let _ = + pallet_balances::GenesisConfig:: { balances: self.balances_builder.balances } + .assimilate_storage(&mut storage); + + let mut stakers = self.staking_builder.stakers.clone(); + self.staking_builder.status.into_iter().for_each(|(stash, status)| { + let (_, _, _, ref mut prev_status) = stakers + .iter_mut() + .find(|s| s.0 == stash) + .expect("set_status staker should exist; qed"); + *prev_status = status; + }); + // replaced any of the stakes if needed. + self.staking_builder.stakes.into_iter().for_each(|(stash, stake)| { + let (_, _, ref mut prev_stake, _) = stakers + .iter_mut() + .find(|s| s.0 == stash) + .expect("set_stake staker should exits; qed."); + *prev_stake = stake; + }); + + let _ = pallet_staking::GenesisConfig:: { + stakers: stakers.clone(), + validator_count: self.staking_builder.validator_count, + minimum_validator_count: self.staking_builder.minimum_validator_count, + slash_reward_fraction: Perbill::from_percent(10), + min_nominator_bond: self.staking_builder.min_nominator_bond, + min_validator_bond: self.staking_builder.min_validator_bond, + ..Default::default() + } + .assimilate_storage(&mut storage); + + let _ = pallet_session::GenesisConfig:: { + // set the keys for the first session. + keys: stakers + .into_iter() + .map(|(id, ..)| (id, id, SessionKeys { other: (id as u64).into() })) + .collect(), + } + .assimilate_storage(&mut storage); + + let mut ext = sp_io::TestExternalities::from(storage); + + // We consider all test to start after timestamp is initialized This must be ensured by + // having `timestamp::on_initialize` called before `staking::on_initialize`. + ext.execute_with(|| { + System::set_block_number(1); + Session::on_initialize(1); + >::on_initialize(1); + Timestamp::set_timestamp(INIT_TIMESTAMP); + }); + + ext + } + pub fn staking(mut self, builder: StakingExtBuilder) -> Self { + self.staking_builder = builder; + self + } + + pub fn epm(mut self, builder: EpmExtBuilder) -> Self { + self.epm_builder = builder; + self + } + + pub fn balances(mut self, builder: BalancesExtBuilder) -> Self { + self.balances_builder = builder; + self + } + + pub fn build_and_execute(self, test: impl FnOnce() -> ()) { + self.build().execute_with(test) + } +} + +// Progress to given block, triggering session and era changes as we progress and ensuring that +// there is a solution queued when expected. +pub fn roll_to(n: BlockNumber, delay_solution: bool) { + for b in (System::block_number()) + 1..=n { + System::set_block_number(b); + Session::on_initialize(b); + Timestamp::set_timestamp(System::block_number() * BLOCK_TIME + INIT_TIMESTAMP); + + // TODO(gpestana): implement a realistic OCW worker insted of simulating it + // https://github.com/paritytech/substrate/issues/13589 + // if there's no solution queued and the solution should not be delayed, try mining and + // queue a solution. + if ElectionProviderMultiPhase::current_phase().is_signed() && !delay_solution { + let _ = try_queue_solution(ElectionCompute::Signed).map_err(|e| { + log!(info, "failed to mine/queue solution: {:?}", e); + }); + } + ElectionProviderMultiPhase::on_initialize(b); + + Staking::on_initialize(b); + if b != n { + Staking::on_finalize(System::block_number()); + } + + log_current_time(); + } +} + +/// Progresses from the current block number (whatever that may be) to the block where the session +/// `session_index` starts. +pub(crate) fn start_session(session_index: SessionIndex, delay_solution: bool) { + let end: u64 = if Offset::get().is_zero() { + Period::get() * (session_index as u64) + } else { + Offset::get() * (session_index as u64) + Period::get() * (session_index as u64) + }; + + assert!(end >= System::block_number()); + + roll_to(end, delay_solution); + + // session must have progressed properly. + assert_eq!( + Session::current_index(), + session_index, + "current session index = {}, expected = {}", + Session::current_index(), + session_index, + ); +} + +/// Go one session forward. +pub(crate) fn advance_session() { + let current_index = Session::current_index(); + start_session(current_index + 1, false); +} + +pub(crate) fn advance_session_delayed_solution() { + let current_index = Session::current_index(); + start_session(current_index + 1, true); +} + +pub(crate) fn start_next_active_era() -> Result<(), ()> { + start_active_era(active_era() + 1, false) +} + +pub(crate) fn start_next_active_era_delayed_solution() -> Result<(), ()> { + start_active_era(active_era() + 1, true) +} + +/// Progress until the given era. +pub(crate) fn start_active_era(era_index: EraIndex, delay_solution: bool) -> Result<(), ()> { + let era_before = current_era(); + + start_session((era_index * >::get()).into(), delay_solution); + + log!( + info, + "start_active_era - era_before: {}, current era: {} -> progress to: {} -> after era: {}", + era_before, + active_era(), + era_index, + current_era(), + ); + + // if the solution was not delayed, era should have progressed. + if !delay_solution && (active_era() != era_index || current_era() != active_era()) { + Err(()) + } else { + Ok(()) + } +} + +pub(crate) fn active_era() -> EraIndex { + Staking::active_era().unwrap().index +} + +pub(crate) fn current_era() -> EraIndex { + Staking::current_era().unwrap() +} + +// Fast forward until EPM signed phase. +pub fn roll_to_epm_signed() { + while !matches!( + ElectionProviderMultiPhase::current_phase(), + pallet_election_provider_multi_phase::Phase::Signed + ) { + roll_to(System::block_number() + 1, false); + } +} + +// Fast forward until EPM unsigned phase. +pub fn roll_to_epm_unsigned() { + while !matches!( + ElectionProviderMultiPhase::current_phase(), + pallet_election_provider_multi_phase::Phase::Unsigned(_) + ) { + roll_to(System::block_number() + 1, false); + } +} + +// Fast forward until EPM off. +pub fn roll_to_epm_off() { + while !matches!( + ElectionProviderMultiPhase::current_phase(), + pallet_election_provider_multi_phase::Phase::Off + ) { + roll_to(System::block_number() + 1, false); + } +} + +// Queue a solution based on the current snapshot. +pub(crate) fn try_queue_solution(when: ElectionCompute) -> Result<(), String> { + let raw_solution = ElectionProviderMultiPhase::mine_solution() + .map_err(|e| format!("error mining solution: {:?}", e))?; + + ElectionProviderMultiPhase::feasibility_check(raw_solution.0, when) + .map(|ready| { + QueuedSolution::::put(ready); + }) + .map_err(|e| format!("error in solution feasibility: {:?}", e)) +} + +pub(crate) fn on_offence_now( + offenders: &[OffenceDetails< + AccountId, + pallet_session::historical::IdentificationTuple, + >], + slash_fraction: &[Perbill], +) { + let now = Staking::active_era().unwrap().index; + let _ = Staking::on_offence( + offenders, + slash_fraction, + Staking::eras_start_session_index(now).unwrap(), + DisableStrategy::WhenSlashed, + ); +} + +// Add offence to validator, slash it. +pub(crate) fn add_slash(who: &AccountId) { + on_offence_now( + &[OffenceDetails { + offender: (*who, Staking::eras_stakers(active_era(), *who)), + reporters: vec![], + }], + &[Perbill::from_percent(10)], + ); +} + +// Slashes enough validators to cross the `Staking::OffendingValidatorsThreshold`. +pub(crate) fn slash_through_offending_threshold() { + let validators = Session::validators(); + let mut remaining_slashes = + ::OffendingValidatorsThreshold::get() * + validators.len() as u32; + + for v in validators.into_iter() { + if remaining_slashes != 0 { + add_slash(&v); + remaining_slashes -= 1; + } + } +} + +// Slashes a percentage of the active nominators that haven't been slashed yet, with +// a minimum of 1 validator slash. +pub(crate) fn slash_percentage(percentage: Perbill) -> Vec { + let validators = Session::validators(); + let mut remaining_slashes = (percentage * validators.len() as u32).max(1); + let mut slashed = vec![]; + + for v in validators.into_iter() { + if remaining_slashes != 0 { + add_slash(&v); + slashed.push(v); + remaining_slashes -= 1; + } + } + slashed +} + +pub(crate) fn set_minimum_election_score( + minimal_stake: ExtendedBalance, + sum_stake: ExtendedBalance, + sum_stake_squared: ExtendedBalance, +) -> Result<(), ()> { + let election_score = ElectionScore { minimal_stake, sum_stake, sum_stake_squared }; + ElectionProviderMultiPhase::set_minimum_untrusted_score( + RuntimeOrigin::root(), + Some(election_score), + ) + .map(|_| ()) + .map_err(|_| ()) +} From e359d8b3d14ae3c5b012704dd406ed593fcfcca2 Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Thu, 16 Mar 2023 13:41:43 +0100 Subject: [PATCH 26/80] fix BASE lookup in cargo-check-benches --- scripts/ci/gitlab/pipeline/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index fd031d9aa56c3..c13f2f3611ba0 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -91,7 +91,7 @@ cargo-check-benches: - !reference [.pipeline-stopper-vars, script] # merges in the master branch on PRs - | - export BASE=$(curl -s -H "Authorization: Bearer ${GITHUB_PR_TOKEN}" https://api.github.com/repos/paritytech/substrate/pulls/${$CI_COMMIT_REF_NAME} | jq .base.ref) + export BASE=$(curl -s -H "Authorization: Bearer ${GITHUB_PR_TOKEN}" https://api.github.com/repos/paritytech/substrate/pulls/${CI_COMMIT_REF_NAME} | jq .base.ref) - if [ $CI_COMMIT_REF_NAME != "master" ]; then git fetch origin +${BASE}:${BASE}; git fetch origin +$CI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME; From 283106b19b85bc8deb232cfa624eed195f143541 Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Thu, 16 Mar 2023 14:47:28 +0100 Subject: [PATCH 27/80] refactor cargo-check-benches logic * fix fetch refspec * assume base is master if the api call fails * merge master into pr branch rather than the other way around; same effect but imo cleaner and more readable * don't re-fetch pr branch, we want to test the version our pipeline is running on --- scripts/ci/gitlab/pipeline/test.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index c13f2f3611ba0..7c5f43c291ea7 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -90,15 +90,13 @@ cargo-check-benches: - !reference [.rusty-cachier, before_script] - !reference [.pipeline-stopper-vars, script] # merges in the master branch on PRs - - | - export BASE=$(curl -s -H "Authorization: Bearer ${GITHUB_PR_TOKEN}" https://api.github.com/repos/paritytech/substrate/pulls/${CI_COMMIT_REF_NAME} | jq .base.ref) - - if [ $CI_COMMIT_REF_NAME != "master" ]; then - git fetch origin +${BASE}:${BASE}; - git fetch origin +$CI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME; - git checkout ${BASE}; + - 'if [ $CI_COMMIT_REF_NAME != "master" ]; then + BASE=$(curl -s -H "Authorization: Bearer ${GITHUB_PR_TOKEN}" https://api.github.com/repos/paritytech/substrate/pulls/${CI_COMMIT_REF_NAME} | jq -r .base.ref); + printf "Merging base branch %s\n" "${BASE:=master}"; git config user.email "ci@gitlab.parity.io"; - git merge $CI_COMMIT_REF_NAME --verbose --no-edit; - fi + git fetch origin "refs/heads/${BASE}"; + git merge --verbose --no-edit FETCH_HEAD; + fi' parallel: 2 script: - rusty-cachier snapshot create From be9e305d2476fa68b4278fdd7eb00decb5b80331 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 16 Mar 2023 17:57:45 +0100 Subject: [PATCH 28/80] Update all weights (#13614) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Empty commit * ".git/.scripts/commands/bench/bench.sh" all --------- Co-authored-by: Alexander Theißen Co-authored-by: command-bot <> --- frame/alliance/src/weights.rs | 523 ++-- frame/assets/src/weights.rs | 354 +-- frame/bags-list/src/weights.rs | 55 +- frame/balances/src/weights.rs | 100 +- frame/benchmarking/src/weights.rs | 70 +- frame/bounties/src/weights.rs | 199 +- frame/child-bounties/src/weights.rs | 143 +- frame/collective/src/weights.rs | 343 ++- frame/contracts/src/weights.rs | 2736 ++++++++--------- frame/conviction-voting/src/weights.rs | 143 +- frame/core-fellowship/src/weights.rs | 122 +- frame/democracy/src/weights.rs | 480 +-- .../src/weights.rs | 227 +- frame/elections-phragmen/src/weights.rs | 268 +- frame/fast-unstake/src/weights.rs | 399 ++- frame/glutton/src/weights.rs | 148 +- frame/identity/src/weights.rs | 455 ++- frame/im-online/src/weights.rs | 43 +- frame/indices/src/weights.rs | 83 +- frame/lottery/src/weights.rs | 95 +- frame/membership/src/weights.rs | 167 +- frame/message-queue/src/weights.rs | 118 +- frame/multisig/src/weights.rs | 183 +- frame/nfts/src/weights.rs | 526 ++-- frame/nis/src/weights.rs | 187 +- frame/nomination-pools/src/weights.rs | 290 +- frame/preimage/src/weights.rs | 175 +- frame/proxy/src/weights.rs | 275 +- frame/ranked-collective/src/weights.rs | 127 +- frame/recovery/src/weights.rs | 167 +- frame/referenda/src/weights.rs | 492 +-- frame/remark/src/weights.rs | 23 +- frame/salary/src/weights.rs | 97 +- frame/scheduler/src/weights.rs | 207 +- frame/session/src/weights.rs | 39 +- frame/staking/src/weights.rs | 555 ++-- frame/state-trie-migration/src/weights.rs | 99 +- frame/support/src/weights/block_weights.rs | 20 +- .../support/src/weights/extrinsic_weights.rs | 20 +- frame/system/src/weights.rs | 93 +- frame/timestamp/src/weights.rs | 27 +- frame/tips/src/weights.rs | 147 +- frame/transaction-storage/src/weights.rs | 55 +- frame/treasury/src/weights.rs | 111 +- frame/uniques/src/weights.rs | 471 +-- frame/utility/src/weights.rs | 71 +- frame/vesting/src/weights.rs | 263 +- frame/whitelist/src/weights.rs | 71 +- 48 files changed, 6019 insertions(+), 6043 deletions(-) diff --git a/frame/alliance/src/weights.rs b/frame/alliance/src/weights.rs index 8ff4bad31313c..a9756c2d27127 100644 --- a/frame/alliance/src/weights.rs +++ b/frame/alliance/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_alliance //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_alliance +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -88,20 +91,20 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `692 + m * (32 ±0) + p * (36 ±0)` - // Estimated: `11659 + m * (132 ±0) + p * (144 ±0)` - // Minimum execution time: 28_849 nanoseconds. - Weight::from_parts(29_823_933, 11659) - // Standard Error: 74 - .saturating_add(Weight::from_parts(830, 0).saturating_mul(b.into())) - // Standard Error: 775 - .saturating_add(Weight::from_parts(22_980, 0).saturating_mul(m.into())) - // Standard Error: 765 - .saturating_add(Weight::from_parts(90_520, 0).saturating_mul(p.into())) + // Measured: `618 + m * (32 ±0) + p * (36 ±0)` + // Estimated: `15463 + m * (124 ±0) + p * (148 ±0)` + // Minimum execution time: 32_788_000 picoseconds. + Weight::from_parts(36_725_375, 15463) + // Standard Error: 138 + .saturating_add(Weight::from_parts(1_252, 0).saturating_mul(b.into())) + // Standard Error: 1_445 + .saturating_add(Weight::from_parts(9_861, 0).saturating_mul(m.into())) + // Standard Error: 1_427 + .saturating_add(Weight::from_parts(127_304, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) - .saturating_add(Weight::from_parts(0, 132).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 144).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 124).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 148).saturating_mul(p.into())) } /// Storage: Alliance Members (r:1 w:0) /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) @@ -110,12 +113,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1177 + m * (64 ±0)` - // Estimated: `9337 + m * (64 ±0)` - // Minimum execution time: 23_570 nanoseconds. - Weight::from_parts(25_473_196, 9337) - // Standard Error: 824 - .saturating_add(Weight::from_parts(54_603, 0).saturating_mul(m.into())) + // Measured: `1042 + m * (64 ±0)` + // Estimated: `11182 + m * (64 ±0)` + // Minimum execution time: 26_632_000 picoseconds. + Weight::from_parts(28_918_089, 11182) + // Standard Error: 947 + .saturating_add(Weight::from_parts(56_565, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) @@ -134,17 +137,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `730 + m * (96 ±0) + p * (36 ±0)` - // Estimated: `11979 + m * (388 ±0) + p * (148 ±0)` - // Minimum execution time: 35_373 nanoseconds. - Weight::from_parts(32_763_656, 11979) - // Standard Error: 2_041 - .saturating_add(Weight::from_parts(52_915, 0).saturating_mul(m.into())) - // Standard Error: 1_991 - .saturating_add(Weight::from_parts(78_594, 0).saturating_mul(p.into())) + // Measured: `622 + m * (96 ±0) + p * (37 ±0)` + // Estimated: `15551 + m * (384 ±0) + p * (148 ±0)` + // Minimum execution time: 40_937_000 picoseconds. + Weight::from_parts(39_361_123, 15551) + // Standard Error: 1_609 + .saturating_add(Weight::from_parts(43_225, 0).saturating_mul(m.into())) + // Standard Error: 1_569 + .saturating_add(Weight::from_parts(112_935, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 388).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 384).saturating_mul(m.into())) .saturating_add(Weight::from_parts(0, 148).saturating_mul(p.into())) } /// Storage: Alliance Members (r:1 w:0) @@ -162,20 +165,20 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1139 + m * (96 ±0) + p * (41 ±0)` - // Estimated: `15730 + m * (388 ±0) + p * (164 ±0)` - // Minimum execution time: 44_590 nanoseconds. - Weight::from_parts(43_367_913, 15730) - // Standard Error: 71 - .saturating_add(Weight::from_parts(819, 0).saturating_mul(b.into())) - // Standard Error: 751 - .saturating_add(Weight::from_parts(39_124, 0).saturating_mul(m.into())) - // Standard Error: 732 - .saturating_add(Weight::from_parts(90_469, 0).saturating_mul(p.into())) + // Measured: `903 + m * (96 ±0) + p * (41 ±0)` + // Estimated: `20072 + m * (392 ±0) + p * (160 ±0)` + // Minimum execution time: 51_569_000 picoseconds. + Weight::from_parts(50_722_448, 20072) + // Standard Error: 120 + .saturating_add(Weight::from_parts(474, 0).saturating_mul(b.into())) + // Standard Error: 1_271 + .saturating_add(Weight::from_parts(48_855, 0).saturating_mul(m.into())) + // Standard Error: 1_239 + .saturating_add(Weight::from_parts(139_022, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 388).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 164).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 392).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 160).saturating_mul(p.into())) } /// Storage: Alliance Members (r:1 w:0) /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) @@ -193,17 +196,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `730 + m * (96 ±0) + p * (36 ±0)` - // Estimated: `13201 + m * (485 ±0) + p * (185 ±0)` - // Minimum execution time: 36_796 nanoseconds. - Weight::from_parts(34_578_765, 13201) - // Standard Error: 1_037 - .saturating_add(Weight::from_parts(43_508, 0).saturating_mul(m.into())) - // Standard Error: 1_024 - .saturating_add(Weight::from_parts(77_084, 0).saturating_mul(p.into())) + // Measured: `622 + m * (96 ±0) + p * (37 ±0)` + // Estimated: `17666 + m * (480 ±0) + p * (185 ±0)` + // Minimum execution time: 42_084_000 picoseconds. + Weight::from_parts(39_907_823, 17666) + // Standard Error: 899 + .saturating_add(Weight::from_parts(46_642, 0).saturating_mul(m.into())) + // Standard Error: 888 + .saturating_add(Weight::from_parts(114_161, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 485).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 480).saturating_mul(m.into())) .saturating_add(Weight::from_parts(0, 185).saturating_mul(p.into())) } /// Storage: Alliance Members (r:1 w:0) @@ -223,20 +226,20 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `757 + m * (96 ±0) + p * (36 ±0)` - // Estimated: `13146 + m * (480 ±0) + p * (185 ±0)` - // Minimum execution time: 36_897 nanoseconds. - Weight::from_parts(34_169_666, 13146) - // Standard Error: 47 - .saturating_add(Weight::from_parts(972, 0).saturating_mul(b.into())) - // Standard Error: 510 - .saturating_add(Weight::from_parts(38_084, 0).saturating_mul(m.into())) - // Standard Error: 492 - .saturating_add(Weight::from_parts(78_576, 0).saturating_mul(p.into())) + // Measured: `591 + m * (96 ±0) + p * (36 ±0)` + // Estimated: `17471 + m * (485 ±0) + p * (180 ±0)` + // Minimum execution time: 42_322_000 picoseconds. + Weight::from_parts(38_753_429, 17471) + // Standard Error: 78 + .saturating_add(Weight::from_parts(1_053, 0).saturating_mul(b.into())) + // Standard Error: 841 + .saturating_add(Weight::from_parts(51_720, 0).saturating_mul(m.into())) + // Standard Error: 811 + .saturating_add(Weight::from_parts(113_343, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 480).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 185).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 485).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 180).saturating_mul(p.into())) } /// Storage: Alliance Members (r:2 w:2) /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) @@ -247,13 +250,13 @@ impl WeightInfo for SubstrateWeight { fn init_members(m: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `217` - // Estimated: `12084` - // Minimum execution time: 29_313 nanoseconds. - Weight::from_parts(20_502_244, 12084) - // Standard Error: 304 - .saturating_add(Weight::from_parts(107_994, 0).saturating_mul(m.into())) - // Standard Error: 300 - .saturating_add(Weight::from_parts(92_645, 0).saturating_mul(z.into())) + // Estimated: `14064` + // Minimum execution time: 33_217_000 picoseconds. + Weight::from_parts(24_495_505, 14064) + // Standard Error: 412 + .saturating_add(Weight::from_parts(108_405, 0).saturating_mul(m.into())) + // Standard Error: 407 + .saturating_add(Weight::from_parts(95_707, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -274,16 +277,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `z` is `[0, 50]`. fn disband(x: u32, y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + x * (50 ±0) + y * (51 ±0) + z * (283 ±0)` - // Estimated: `32201 + x * (2587 ±0) + y * (2590 ±0) + z * (3209 ±1)` - // Minimum execution time: 232_895 nanoseconds. - Weight::from_parts(233_860_000, 32201) - // Standard Error: 19_092 - .saturating_add(Weight::from_parts(445_664, 0).saturating_mul(x.into())) - // Standard Error: 19_000 - .saturating_add(Weight::from_parts(432_571, 0).saturating_mul(y.into())) - // Standard Error: 37_965 - .saturating_add(Weight::from_parts(9_386_151, 0).saturating_mul(z.into())) + // Measured: `0 + x * (50 ±0) + y * (51 ±0) + z * (251 ±0)` + // Estimated: `35975 + x * (2587 ±0) + y * (2590 ±0) + z * (3113 ±1)` + // Minimum execution time: 278_029_000 picoseconds. + Weight::from_parts(279_353_000, 35975) + // Standard Error: 23_655 + .saturating_add(Weight::from_parts(519_330, 0).saturating_mul(x.into())) + // Standard Error: 23_541 + .saturating_add(Weight::from_parts(547_382, 0).saturating_mul(y.into())) + // Standard Error: 47_040 + .saturating_add(Weight::from_parts(10_939_685, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) @@ -292,7 +295,7 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(z.into()))) .saturating_add(Weight::from_parts(0, 2587).saturating_mul(x.into())) .saturating_add(Weight::from_parts(0, 2590).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 3209).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(0, 3113).saturating_mul(z.into())) } /// Storage: Alliance Rule (r:0 w:1) /// Proof: Alliance Rule (max_values: Some(1), max_size: Some(87), added: 582, mode: MaxEncodedLen) @@ -300,8 +303,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_156 nanoseconds. - Weight::from_parts(9_376_000, 0) + // Minimum execution time: 10_129_000 picoseconds. + Weight::from_parts(10_370_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Alliance Announcements (r:1 w:1) @@ -309,9 +312,9 @@ impl WeightInfo for SubstrateWeight { fn announce() -> Weight { // Proof Size summary in bytes: // Measured: `246` - // Estimated: `9197` - // Minimum execution time: 12_163 nanoseconds. - Weight::from_parts(12_397_000, 9197) + // Estimated: `10187` + // Minimum execution time: 13_601_000 picoseconds. + Weight::from_parts(13_823_000, 10187) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -319,10 +322,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Alliance Announcements (max_values: Some(1), max_size: Some(8702), added: 9197, mode: MaxEncodedLen) fn remove_announcement() -> Weight { // Proof Size summary in bytes: - // Measured: `351` - // Estimated: `9197` - // Minimum execution time: 12_778 nanoseconds. - Weight::from_parts(12_991_000, 9197) + // Measured: `319` + // Estimated: `10187` + // Minimum execution time: 14_953_000 picoseconds. + Weight::from_parts(15_239_000, 10187) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -336,10 +339,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Alliance DepositOf (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) fn join_alliance() -> Weight { // Proof Size summary in bytes: - // Measured: `562` - // Estimated: `23358` - // Minimum execution time: 40_216 nanoseconds. - Weight::from_parts(40_535_000, 23358) + // Measured: `468` + // Estimated: `26328` + // Minimum execution time: 42_947_000 picoseconds. + Weight::from_parts(43_602_000, 26328) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -349,10 +352,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Alliance UnscrupulousAccounts (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) fn nominate_ally() -> Weight { // Proof Size summary in bytes: - // Measured: `429` - // Estimated: `20755` - // Minimum execution time: 28_027 nanoseconds. - Weight::from_parts(28_392_000, 20755) + // Measured: `367` + // Estimated: `22735` + // Minimum execution time: 28_787_000 picoseconds. + Weight::from_parts(29_286_000, 22735) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -366,10 +369,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn elevate_ally() -> Weight { // Proof Size summary in bytes: - // Measured: `505` - // Estimated: `13382` - // Minimum execution time: 24_427 nanoseconds. - Weight::from_parts(24_952_000, 13382) + // Measured: `443` + // Estimated: `15176` + // Minimum execution time: 28_476_000 picoseconds. + Weight::from_parts(28_972_000, 15176) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -385,10 +388,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Alliance RetiringMembers (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn give_retirement_notice() -> Weight { // Proof Size summary in bytes: - // Measured: `505` - // Estimated: `24754` - // Minimum execution time: 33_163 nanoseconds. - Weight::from_parts(33_556_000, 24754) + // Measured: `443` + // Estimated: `26548` + // Minimum execution time: 36_773_000 picoseconds. + Weight::from_parts(38_123_000, 26548) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -402,10 +405,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn retire() -> Weight { // Proof Size summary in bytes: - // Measured: `750` - // Estimated: `13355` - // Minimum execution time: 32_980 nanoseconds. - Weight::from_parts(33_452_000, 13355) + // Measured: `687` + // Estimated: `17315` + // Minimum execution time: 37_814_000 picoseconds. + Weight::from_parts(38_353_000, 17315) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -423,10 +426,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn kick_member() -> Weight { // Proof Size summary in bytes: - // Measured: `801` - // Estimated: `25098` - // Minimum execution time: 54_660 nanoseconds. - Weight::from_parts(55_186_000, 25098) + // Measured: `707` + // Estimated: `28776` + // Minimum execution time: 62_194_000 picoseconds. + Weight::from_parts(63_925_000, 28776) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -439,13 +442,13 @@ impl WeightInfo for SubstrateWeight { fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `246` - // Estimated: `29894` - // Minimum execution time: 7_709 nanoseconds. - Weight::from_parts(7_773_000, 29894) - // Standard Error: 2_645 - .saturating_add(Weight::from_parts(1_266_755, 0).saturating_mul(n.into())) - // Standard Error: 1_036 - .saturating_add(Weight::from_parts(67_359, 0).saturating_mul(l.into())) + // Estimated: `31874` + // Minimum execution time: 8_369_000 picoseconds. + Weight::from_parts(8_462_000, 31874) + // Standard Error: 3_347 + .saturating_add(Weight::from_parts(1_567_757, 0).saturating_mul(n.into())) + // Standard Error: 1_310 + .saturating_add(Weight::from_parts(72_697, 0).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -458,13 +461,13 @@ impl WeightInfo for SubstrateWeight { fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + n * (289 ±0) + l * (100 ±0)` - // Estimated: `29894` - // Minimum execution time: 7_438 nanoseconds. - Weight::from_parts(7_570_000, 29894) - // Standard Error: 165_072 - .saturating_add(Weight::from_parts(13_026_975, 0).saturating_mul(n.into())) - // Standard Error: 64_649 - .saturating_add(Weight::from_parts(485_565, 0).saturating_mul(l.into())) + // Estimated: `31874` + // Minimum execution time: 8_309_000 picoseconds. + Weight::from_parts(8_450_000, 31874) + // Standard Error: 185_163 + .saturating_add(Weight::from_parts(16_348_419, 0).saturating_mul(n.into())) + // Standard Error: 72_518 + .saturating_add(Weight::from_parts(337_571, 0).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -478,10 +481,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn abdicate_fellow_status() -> Weight { // Proof Size summary in bytes: - // Measured: `505` - // Estimated: `19068` - // Minimum execution time: 31_326 nanoseconds. - Weight::from_parts(31_768_000, 19068) + // Measured: `443` + // Estimated: `20862` + // Minimum execution time: 35_363_000 picoseconds. + Weight::from_parts(35_665_000, 20862) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -504,20 +507,20 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `692 + m * (32 ±0) + p * (36 ±0)` - // Estimated: `11659 + m * (132 ±0) + p * (144 ±0)` - // Minimum execution time: 28_849 nanoseconds. - Weight::from_parts(29_823_933, 11659) - // Standard Error: 74 - .saturating_add(Weight::from_parts(830, 0).saturating_mul(b.into())) - // Standard Error: 775 - .saturating_add(Weight::from_parts(22_980, 0).saturating_mul(m.into())) - // Standard Error: 765 - .saturating_add(Weight::from_parts(90_520, 0).saturating_mul(p.into())) + // Measured: `618 + m * (32 ±0) + p * (36 ±0)` + // Estimated: `15463 + m * (124 ±0) + p * (148 ±0)` + // Minimum execution time: 32_788_000 picoseconds. + Weight::from_parts(36_725_375, 15463) + // Standard Error: 138 + .saturating_add(Weight::from_parts(1_252, 0).saturating_mul(b.into())) + // Standard Error: 1_445 + .saturating_add(Weight::from_parts(9_861, 0).saturating_mul(m.into())) + // Standard Error: 1_427 + .saturating_add(Weight::from_parts(127_304, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) - .saturating_add(Weight::from_parts(0, 132).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 144).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 124).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 148).saturating_mul(p.into())) } /// Storage: Alliance Members (r:1 w:0) /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) @@ -526,12 +529,12 @@ impl WeightInfo for () { /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1177 + m * (64 ±0)` - // Estimated: `9337 + m * (64 ±0)` - // Minimum execution time: 23_570 nanoseconds. - Weight::from_parts(25_473_196, 9337) - // Standard Error: 824 - .saturating_add(Weight::from_parts(54_603, 0).saturating_mul(m.into())) + // Measured: `1042 + m * (64 ±0)` + // Estimated: `11182 + m * (64 ±0)` + // Minimum execution time: 26_632_000 picoseconds. + Weight::from_parts(28_918_089, 11182) + // Standard Error: 947 + .saturating_add(Weight::from_parts(56_565, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) @@ -550,17 +553,17 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `730 + m * (96 ±0) + p * (36 ±0)` - // Estimated: `11979 + m * (388 ±0) + p * (148 ±0)` - // Minimum execution time: 35_373 nanoseconds. - Weight::from_parts(32_763_656, 11979) - // Standard Error: 2_041 - .saturating_add(Weight::from_parts(52_915, 0).saturating_mul(m.into())) - // Standard Error: 1_991 - .saturating_add(Weight::from_parts(78_594, 0).saturating_mul(p.into())) + // Measured: `622 + m * (96 ±0) + p * (37 ±0)` + // Estimated: `15551 + m * (384 ±0) + p * (148 ±0)` + // Minimum execution time: 40_937_000 picoseconds. + Weight::from_parts(39_361_123, 15551) + // Standard Error: 1_609 + .saturating_add(Weight::from_parts(43_225, 0).saturating_mul(m.into())) + // Standard Error: 1_569 + .saturating_add(Weight::from_parts(112_935, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 388).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 384).saturating_mul(m.into())) .saturating_add(Weight::from_parts(0, 148).saturating_mul(p.into())) } /// Storage: Alliance Members (r:1 w:0) @@ -578,20 +581,20 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1139 + m * (96 ±0) + p * (41 ±0)` - // Estimated: `15730 + m * (388 ±0) + p * (164 ±0)` - // Minimum execution time: 44_590 nanoseconds. - Weight::from_parts(43_367_913, 15730) - // Standard Error: 71 - .saturating_add(Weight::from_parts(819, 0).saturating_mul(b.into())) - // Standard Error: 751 - .saturating_add(Weight::from_parts(39_124, 0).saturating_mul(m.into())) - // Standard Error: 732 - .saturating_add(Weight::from_parts(90_469, 0).saturating_mul(p.into())) + // Measured: `903 + m * (96 ±0) + p * (41 ±0)` + // Estimated: `20072 + m * (392 ±0) + p * (160 ±0)` + // Minimum execution time: 51_569_000 picoseconds. + Weight::from_parts(50_722_448, 20072) + // Standard Error: 120 + .saturating_add(Weight::from_parts(474, 0).saturating_mul(b.into())) + // Standard Error: 1_271 + .saturating_add(Weight::from_parts(48_855, 0).saturating_mul(m.into())) + // Standard Error: 1_239 + .saturating_add(Weight::from_parts(139_022, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 388).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 164).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 392).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 160).saturating_mul(p.into())) } /// Storage: Alliance Members (r:1 w:0) /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) @@ -609,17 +612,17 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `730 + m * (96 ±0) + p * (36 ±0)` - // Estimated: `13201 + m * (485 ±0) + p * (185 ±0)` - // Minimum execution time: 36_796 nanoseconds. - Weight::from_parts(34_578_765, 13201) - // Standard Error: 1_037 - .saturating_add(Weight::from_parts(43_508, 0).saturating_mul(m.into())) - // Standard Error: 1_024 - .saturating_add(Weight::from_parts(77_084, 0).saturating_mul(p.into())) + // Measured: `622 + m * (96 ±0) + p * (37 ±0)` + // Estimated: `17666 + m * (480 ±0) + p * (185 ±0)` + // Minimum execution time: 42_084_000 picoseconds. + Weight::from_parts(39_907_823, 17666) + // Standard Error: 899 + .saturating_add(Weight::from_parts(46_642, 0).saturating_mul(m.into())) + // Standard Error: 888 + .saturating_add(Weight::from_parts(114_161, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 485).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 480).saturating_mul(m.into())) .saturating_add(Weight::from_parts(0, 185).saturating_mul(p.into())) } /// Storage: Alliance Members (r:1 w:0) @@ -639,20 +642,20 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `757 + m * (96 ±0) + p * (36 ±0)` - // Estimated: `13146 + m * (480 ±0) + p * (185 ±0)` - // Minimum execution time: 36_897 nanoseconds. - Weight::from_parts(34_169_666, 13146) - // Standard Error: 47 - .saturating_add(Weight::from_parts(972, 0).saturating_mul(b.into())) - // Standard Error: 510 - .saturating_add(Weight::from_parts(38_084, 0).saturating_mul(m.into())) - // Standard Error: 492 - .saturating_add(Weight::from_parts(78_576, 0).saturating_mul(p.into())) + // Measured: `591 + m * (96 ±0) + p * (36 ±0)` + // Estimated: `17471 + m * (485 ±0) + p * (180 ±0)` + // Minimum execution time: 42_322_000 picoseconds. + Weight::from_parts(38_753_429, 17471) + // Standard Error: 78 + .saturating_add(Weight::from_parts(1_053, 0).saturating_mul(b.into())) + // Standard Error: 841 + .saturating_add(Weight::from_parts(51_720, 0).saturating_mul(m.into())) + // Standard Error: 811 + .saturating_add(Weight::from_parts(113_343, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 480).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 185).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 485).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 180).saturating_mul(p.into())) } /// Storage: Alliance Members (r:2 w:2) /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) @@ -663,13 +666,13 @@ impl WeightInfo for () { fn init_members(m: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `217` - // Estimated: `12084` - // Minimum execution time: 29_313 nanoseconds. - Weight::from_parts(20_502_244, 12084) - // Standard Error: 304 - .saturating_add(Weight::from_parts(107_994, 0).saturating_mul(m.into())) - // Standard Error: 300 - .saturating_add(Weight::from_parts(92_645, 0).saturating_mul(z.into())) + // Estimated: `14064` + // Minimum execution time: 33_217_000 picoseconds. + Weight::from_parts(24_495_505, 14064) + // Standard Error: 412 + .saturating_add(Weight::from_parts(108_405, 0).saturating_mul(m.into())) + // Standard Error: 407 + .saturating_add(Weight::from_parts(95_707, 0).saturating_mul(z.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -690,16 +693,16 @@ impl WeightInfo for () { /// The range of component `z` is `[0, 50]`. fn disband(x: u32, y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + x * (50 ±0) + y * (51 ±0) + z * (283 ±0)` - // Estimated: `32201 + x * (2587 ±0) + y * (2590 ±0) + z * (3209 ±1)` - // Minimum execution time: 232_895 nanoseconds. - Weight::from_parts(233_860_000, 32201) - // Standard Error: 19_092 - .saturating_add(Weight::from_parts(445_664, 0).saturating_mul(x.into())) - // Standard Error: 19_000 - .saturating_add(Weight::from_parts(432_571, 0).saturating_mul(y.into())) - // Standard Error: 37_965 - .saturating_add(Weight::from_parts(9_386_151, 0).saturating_mul(z.into())) + // Measured: `0 + x * (50 ±0) + y * (51 ±0) + z * (251 ±0)` + // Estimated: `35975 + x * (2587 ±0) + y * (2590 ±0) + z * (3113 ±1)` + // Minimum execution time: 278_029_000 picoseconds. + Weight::from_parts(279_353_000, 35975) + // Standard Error: 23_655 + .saturating_add(Weight::from_parts(519_330, 0).saturating_mul(x.into())) + // Standard Error: 23_541 + .saturating_add(Weight::from_parts(547_382, 0).saturating_mul(y.into())) + // Standard Error: 47_040 + .saturating_add(Weight::from_parts(10_939_685, 0).saturating_mul(z.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into()))) @@ -708,7 +711,7 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(z.into()))) .saturating_add(Weight::from_parts(0, 2587).saturating_mul(x.into())) .saturating_add(Weight::from_parts(0, 2590).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 3209).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(0, 3113).saturating_mul(z.into())) } /// Storage: Alliance Rule (r:0 w:1) /// Proof: Alliance Rule (max_values: Some(1), max_size: Some(87), added: 582, mode: MaxEncodedLen) @@ -716,8 +719,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_156 nanoseconds. - Weight::from_parts(9_376_000, 0) + // Minimum execution time: 10_129_000 picoseconds. + Weight::from_parts(10_370_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Alliance Announcements (r:1 w:1) @@ -725,9 +728,9 @@ impl WeightInfo for () { fn announce() -> Weight { // Proof Size summary in bytes: // Measured: `246` - // Estimated: `9197` - // Minimum execution time: 12_163 nanoseconds. - Weight::from_parts(12_397_000, 9197) + // Estimated: `10187` + // Minimum execution time: 13_601_000 picoseconds. + Weight::from_parts(13_823_000, 10187) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -735,10 +738,10 @@ impl WeightInfo for () { /// Proof: Alliance Announcements (max_values: Some(1), max_size: Some(8702), added: 9197, mode: MaxEncodedLen) fn remove_announcement() -> Weight { // Proof Size summary in bytes: - // Measured: `351` - // Estimated: `9197` - // Minimum execution time: 12_778 nanoseconds. - Weight::from_parts(12_991_000, 9197) + // Measured: `319` + // Estimated: `10187` + // Minimum execution time: 14_953_000 picoseconds. + Weight::from_parts(15_239_000, 10187) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -752,10 +755,10 @@ impl WeightInfo for () { /// Proof: Alliance DepositOf (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) fn join_alliance() -> Weight { // Proof Size summary in bytes: - // Measured: `562` - // Estimated: `23358` - // Minimum execution time: 40_216 nanoseconds. - Weight::from_parts(40_535_000, 23358) + // Measured: `468` + // Estimated: `26328` + // Minimum execution time: 42_947_000 picoseconds. + Weight::from_parts(43_602_000, 26328) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -765,10 +768,10 @@ impl WeightInfo for () { /// Proof: Alliance UnscrupulousAccounts (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) fn nominate_ally() -> Weight { // Proof Size summary in bytes: - // Measured: `429` - // Estimated: `20755` - // Minimum execution time: 28_027 nanoseconds. - Weight::from_parts(28_392_000, 20755) + // Measured: `367` + // Estimated: `22735` + // Minimum execution time: 28_787_000 picoseconds. + Weight::from_parts(29_286_000, 22735) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -782,10 +785,10 @@ impl WeightInfo for () { /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn elevate_ally() -> Weight { // Proof Size summary in bytes: - // Measured: `505` - // Estimated: `13382` - // Minimum execution time: 24_427 nanoseconds. - Weight::from_parts(24_952_000, 13382) + // Measured: `443` + // Estimated: `15176` + // Minimum execution time: 28_476_000 picoseconds. + Weight::from_parts(28_972_000, 15176) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -801,10 +804,10 @@ impl WeightInfo for () { /// Proof: Alliance RetiringMembers (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn give_retirement_notice() -> Weight { // Proof Size summary in bytes: - // Measured: `505` - // Estimated: `24754` - // Minimum execution time: 33_163 nanoseconds. - Weight::from_parts(33_556_000, 24754) + // Measured: `443` + // Estimated: `26548` + // Minimum execution time: 36_773_000 picoseconds. + Weight::from_parts(38_123_000, 26548) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -818,10 +821,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn retire() -> Weight { // Proof Size summary in bytes: - // Measured: `750` - // Estimated: `13355` - // Minimum execution time: 32_980 nanoseconds. - Weight::from_parts(33_452_000, 13355) + // Measured: `687` + // Estimated: `17315` + // Minimum execution time: 37_814_000 picoseconds. + Weight::from_parts(38_353_000, 17315) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -839,10 +842,10 @@ impl WeightInfo for () { /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn kick_member() -> Weight { // Proof Size summary in bytes: - // Measured: `801` - // Estimated: `25098` - // Minimum execution time: 54_660 nanoseconds. - Weight::from_parts(55_186_000, 25098) + // Measured: `707` + // Estimated: `28776` + // Minimum execution time: 62_194_000 picoseconds. + Weight::from_parts(63_925_000, 28776) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -855,13 +858,13 @@ impl WeightInfo for () { fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `246` - // Estimated: `29894` - // Minimum execution time: 7_709 nanoseconds. - Weight::from_parts(7_773_000, 29894) - // Standard Error: 2_645 - .saturating_add(Weight::from_parts(1_266_755, 0).saturating_mul(n.into())) - // Standard Error: 1_036 - .saturating_add(Weight::from_parts(67_359, 0).saturating_mul(l.into())) + // Estimated: `31874` + // Minimum execution time: 8_369_000 picoseconds. + Weight::from_parts(8_462_000, 31874) + // Standard Error: 3_347 + .saturating_add(Weight::from_parts(1_567_757, 0).saturating_mul(n.into())) + // Standard Error: 1_310 + .saturating_add(Weight::from_parts(72_697, 0).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -874,13 +877,13 @@ impl WeightInfo for () { fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + n * (289 ±0) + l * (100 ±0)` - // Estimated: `29894` - // Minimum execution time: 7_438 nanoseconds. - Weight::from_parts(7_570_000, 29894) - // Standard Error: 165_072 - .saturating_add(Weight::from_parts(13_026_975, 0).saturating_mul(n.into())) - // Standard Error: 64_649 - .saturating_add(Weight::from_parts(485_565, 0).saturating_mul(l.into())) + // Estimated: `31874` + // Minimum execution time: 8_309_000 picoseconds. + Weight::from_parts(8_450_000, 31874) + // Standard Error: 185_163 + .saturating_add(Weight::from_parts(16_348_419, 0).saturating_mul(n.into())) + // Standard Error: 72_518 + .saturating_add(Weight::from_parts(337_571, 0).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -894,10 +897,10 @@ impl WeightInfo for () { /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn abdicate_fellow_status() -> Weight { // Proof Size summary in bytes: - // Measured: `505` - // Estimated: `19068` - // Minimum execution time: 31_326 nanoseconds. - Weight::from_parts(31_768_000, 19068) + // Measured: `443` + // Estimated: `20862` + // Minimum execution time: 35_363_000 picoseconds. + Weight::from_parts(35_665_000, 20862) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } diff --git a/frame/assets/src/weights.rs b/frame/assets/src/weights.rs index b9c3ab21d8a33..0d6c41b458db0 100644 --- a/frame/assets/src/weights.rs +++ b/frame/assets/src/weights.rs @@ -18,26 +18,28 @@ //! Autogenerated weights for pallet_assets //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_assets +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_assets -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/assets/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -87,10 +89,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn create() -> Weight { // Proof Size summary in bytes: - // Measured: `325` + // Measured: `293` // Estimated: `7268` - // Minimum execution time: 28_265_000 picoseconds. - Weight::from_parts(28_764_000, 7268) + // Minimum execution time: 27_756_000 picoseconds. + Weight::from_parts(28_637_000, 7268) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -100,8 +102,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `153` // Estimated: `3675` - // Minimum execution time: 15_125_000 picoseconds. - Weight::from_parts(15_468_000, 3675) + // Minimum execution time: 15_402_000 picoseconds. + Weight::from_parts(15_803_000, 3675) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -109,10 +111,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn start_destroy() -> Weight { // Proof Size summary in bytes: - // Measured: `417` + // Measured: `385` // Estimated: `3675` - // Minimum execution time: 15_368_000 picoseconds. - Weight::from_parts(15_625_000, 3675) + // Minimum execution time: 16_027_000 picoseconds. + Weight::from_parts(16_372_000, 3675) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -125,12 +127,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 1000]`. fn destroy_accounts(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `25 + c * (240 ±0)` + // Measured: `0 + c * (208 ±0)` // Estimated: `8232 + c * (5180 ±0)` - // Minimum execution time: 20_816_000 picoseconds. - Weight::from_parts(21_045_000, 8232) - // Standard Error: 7_118 - .saturating_add(Weight::from_parts(12_723_454, 0).saturating_mul(c.into())) + // Minimum execution time: 20_667_000 picoseconds. + Weight::from_parts(20_930_000, 8232) + // Standard Error: 7_226 + .saturating_add(Weight::from_parts(12_759_091, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -144,12 +146,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `a` is `[0, 1000]`. fn destroy_approvals(a: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `554 + a * (86 ±0)` + // Measured: `522 + a * (86 ±0)` // Estimated: `7288 + a * (2623 ±0)` - // Minimum execution time: 20_923_000 picoseconds. - Weight::from_parts(21_229_000, 7288) - // Standard Error: 7_215 - .saturating_add(Weight::from_parts(12_915_292, 0).saturating_mul(a.into())) + // Minimum execution time: 20_798_000 picoseconds. + Weight::from_parts(21_129_000, 7288) + // Standard Error: 7_484 + .saturating_add(Weight::from_parts(12_761_996, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -162,10 +164,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn finish_destroy() -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `7280` - // Minimum execution time: 15_764_000 picoseconds. - Weight::from_parts(16_245_000, 7280) + // Minimum execution time: 15_870_000 picoseconds. + Weight::from_parts(16_280_000, 7280) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -175,10 +177,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `7242` - // Minimum execution time: 28_814_000 picoseconds. - Weight::from_parts(29_407_000, 7242) + // Minimum execution time: 28_556_000 picoseconds. + Weight::from_parts(28_972_000, 7242) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -188,10 +190,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn burn() -> Weight { // Proof Size summary in bytes: - // Measured: `491` + // Measured: `459` // Estimated: `7242` - // Minimum execution time: 34_784_000 picoseconds. - Weight::from_parts(35_402_000, 7242) + // Minimum execution time: 35_379_000 picoseconds. + Weight::from_parts(35_826_000, 7242) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -203,10 +205,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `530` + // Measured: `498` // Estimated: `13412` - // Minimum execution time: 49_110_000 picoseconds. - Weight::from_parts(50_483_000, 13412) + // Minimum execution time: 48_837_000 picoseconds. + Weight::from_parts(49_305_000, 13412) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -218,10 +220,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_keep_alive() -> Weight { // Proof Size summary in bytes: - // Measured: `530` + // Measured: `498` // Estimated: `13412` - // Minimum execution time: 43_585_000 picoseconds. - Weight::from_parts(44_207_000, 13412) + // Minimum execution time: 43_603_000 picoseconds. + Weight::from_parts(44_142_000, 13412) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -233,10 +235,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `530` + // Measured: `498` // Estimated: `13412` - // Minimum execution time: 49_238_000 picoseconds. - Weight::from_parts(77_664_000, 13412) + // Minimum execution time: 49_691_000 picoseconds. + Weight::from_parts(50_402_000, 13412) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -246,10 +248,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn freeze() -> Weight { // Proof Size summary in bytes: - // Measured: `491` + // Measured: `459` // Estimated: `7242` - // Minimum execution time: 19_198_000 picoseconds. - Weight::from_parts(19_585_000, 7242) + // Minimum execution time: 19_600_000 picoseconds. + Weight::from_parts(20_435_000, 7242) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -259,10 +261,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn thaw() -> Weight { // Proof Size summary in bytes: - // Measured: `491` + // Measured: `459` // Estimated: `7242` - // Minimum execution time: 19_659_000 picoseconds. - Weight::from_parts(20_079_000, 7242) + // Minimum execution time: 19_396_000 picoseconds. + Weight::from_parts(19_745_000, 7242) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -270,10 +272,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn freeze_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `417` + // Measured: `385` // Estimated: `3675` - // Minimum execution time: 15_035_000 picoseconds. - Weight::from_parts(15_594_000, 3675) + // Minimum execution time: 15_503_000 picoseconds. + Weight::from_parts(15_788_000, 3675) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -281,10 +283,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn thaw_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `417` + // Measured: `385` // Estimated: `3675` - // Minimum execution time: 15_073_000 picoseconds. - Weight::from_parts(15_862_000, 3675) + // Minimum execution time: 15_874_000 picoseconds. + Weight::from_parts(16_190_000, 3675) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -294,10 +296,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `7280` - // Minimum execution time: 17_343_000 picoseconds. - Weight::from_parts(17_656_000, 7280) + // Minimum execution time: 17_067_000 picoseconds. + Weight::from_parts(17_355_000, 7280) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -305,10 +307,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn set_team() -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `3675` - // Minimum execution time: 15_902_000 picoseconds. - Weight::from_parts(16_439_000, 3675) + // Minimum execution time: 16_155_000 picoseconds. + Weight::from_parts(16_442_000, 3675) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -320,10 +322,10 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 50]`. fn set_metadata(_n: u32, _s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `7280` - // Minimum execution time: 27_222_000 picoseconds. - Weight::from_parts(29_151_657, 7280) + // Minimum execution time: 27_270_000 picoseconds. + Weight::from_parts(28_634_060, 7280) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -333,10 +335,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `579` + // Measured: `515` // Estimated: `7280` - // Minimum execution time: 27_976_000 picoseconds. - Weight::from_parts(28_289_000, 7280) + // Minimum execution time: 27_469_000 picoseconds. + Weight::from_parts(27_911_000, 7280) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -350,10 +352,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `190` // Estimated: `7280` - // Minimum execution time: 16_162_000 picoseconds. - Weight::from_parts(17_137_043, 7280) - // Standard Error: 982 - .saturating_add(Weight::from_parts(4_180, 0).saturating_mul(s.into())) + // Minimum execution time: 16_008_000 picoseconds. + Weight::from_parts(17_007_654, 7280) + // Standard Error: 527 + .saturating_add(Weight::from_parts(4_158, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -363,10 +365,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn force_clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `579` + // Measured: `515` // Estimated: `7280` - // Minimum execution time: 27_219_000 picoseconds. - Weight::from_parts(27_931_000, 7280) + // Minimum execution time: 27_118_000 picoseconds. + Weight::from_parts(27_776_000, 7280) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -374,10 +376,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn force_asset_status() -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `3675` - // Minimum execution time: 15_313_000 picoseconds. - Weight::from_parts(15_775_000, 3675) + // Minimum execution time: 14_776_000 picoseconds. + Weight::from_parts(15_281_000, 3675) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -387,10 +389,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) fn approve_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `417` + // Measured: `385` // Estimated: `7288` - // Minimum execution time: 31_865_000 picoseconds. - Weight::from_parts(32_316_000, 7288) + // Minimum execution time: 31_324_000 picoseconds. + Weight::from_parts(32_161_000, 7288) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -404,10 +406,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_approved() -> Weight { // Proof Size summary in bytes: - // Measured: `700` + // Measured: `668` // Estimated: `17025` - // Minimum execution time: 67_203_000 picoseconds. - Weight::from_parts(109_742_000, 17025) + // Minimum execution time: 63_750_000 picoseconds. + Weight::from_parts(64_828_000, 17025) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -417,10 +419,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) fn cancel_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `587` + // Measured: `555` // Estimated: `7288` - // Minimum execution time: 33_430_000 picoseconds. - Weight::from_parts(33_824_000, 7288) + // Minimum execution time: 32_698_000 picoseconds. + Weight::from_parts(33_309_000, 7288) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -430,10 +432,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) fn force_cancel_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `587` + // Measured: `555` // Estimated: `7288` - // Minimum execution time: 33_596_000 picoseconds. - Weight::from_parts(34_226_000, 7288) + // Minimum execution time: 33_147_000 picoseconds. + Weight::from_parts(33_620_000, 7288) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -441,10 +443,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn set_min_balance() -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `3675` - // Minimum execution time: 16_367_000 picoseconds. - Weight::from_parts(16_703_000, 3675) + // Minimum execution time: 15_910_000 picoseconds. + Weight::from_parts(16_315_000, 3675) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -458,10 +460,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn create() -> Weight { // Proof Size summary in bytes: - // Measured: `325` + // Measured: `293` // Estimated: `7268` - // Minimum execution time: 28_265_000 picoseconds. - Weight::from_parts(28_764_000, 7268) + // Minimum execution time: 27_756_000 picoseconds. + Weight::from_parts(28_637_000, 7268) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -471,8 +473,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `153` // Estimated: `3675` - // Minimum execution time: 15_125_000 picoseconds. - Weight::from_parts(15_468_000, 3675) + // Minimum execution time: 15_402_000 picoseconds. + Weight::from_parts(15_803_000, 3675) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -480,10 +482,10 @@ impl WeightInfo for () { /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn start_destroy() -> Weight { // Proof Size summary in bytes: - // Measured: `417` + // Measured: `385` // Estimated: `3675` - // Minimum execution time: 15_368_000 picoseconds. - Weight::from_parts(15_625_000, 3675) + // Minimum execution time: 16_027_000 picoseconds. + Weight::from_parts(16_372_000, 3675) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -496,12 +498,12 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 1000]`. fn destroy_accounts(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `25 + c * (240 ±0)` + // Measured: `0 + c * (208 ±0)` // Estimated: `8232 + c * (5180 ±0)` - // Minimum execution time: 20_816_000 picoseconds. - Weight::from_parts(21_045_000, 8232) - // Standard Error: 7_118 - .saturating_add(Weight::from_parts(12_723_454, 0).saturating_mul(c.into())) + // Minimum execution time: 20_667_000 picoseconds. + Weight::from_parts(20_930_000, 8232) + // Standard Error: 7_226 + .saturating_add(Weight::from_parts(12_759_091, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(c.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -515,12 +517,12 @@ impl WeightInfo for () { /// The range of component `a` is `[0, 1000]`. fn destroy_approvals(a: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `554 + a * (86 ±0)` + // Measured: `522 + a * (86 ±0)` // Estimated: `7288 + a * (2623 ±0)` - // Minimum execution time: 20_923_000 picoseconds. - Weight::from_parts(21_229_000, 7288) - // Standard Error: 7_215 - .saturating_add(Weight::from_parts(12_915_292, 0).saturating_mul(a.into())) + // Minimum execution time: 20_798_000 picoseconds. + Weight::from_parts(21_129_000, 7288) + // Standard Error: 7_484 + .saturating_add(Weight::from_parts(12_761_996, 0).saturating_mul(a.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -533,10 +535,10 @@ impl WeightInfo for () { /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn finish_destroy() -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `7280` - // Minimum execution time: 15_764_000 picoseconds. - Weight::from_parts(16_245_000, 7280) + // Minimum execution time: 15_870_000 picoseconds. + Weight::from_parts(16_280_000, 7280) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -546,10 +548,10 @@ impl WeightInfo for () { /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `7242` - // Minimum execution time: 28_814_000 picoseconds. - Weight::from_parts(29_407_000, 7242) + // Minimum execution time: 28_556_000 picoseconds. + Weight::from_parts(28_972_000, 7242) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -559,10 +561,10 @@ impl WeightInfo for () { /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn burn() -> Weight { // Proof Size summary in bytes: - // Measured: `491` + // Measured: `459` // Estimated: `7242` - // Minimum execution time: 34_784_000 picoseconds. - Weight::from_parts(35_402_000, 7242) + // Minimum execution time: 35_379_000 picoseconds. + Weight::from_parts(35_826_000, 7242) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -574,10 +576,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `530` + // Measured: `498` // Estimated: `13412` - // Minimum execution time: 49_110_000 picoseconds. - Weight::from_parts(50_483_000, 13412) + // Minimum execution time: 48_837_000 picoseconds. + Weight::from_parts(49_305_000, 13412) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -589,10 +591,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_keep_alive() -> Weight { // Proof Size summary in bytes: - // Measured: `530` + // Measured: `498` // Estimated: `13412` - // Minimum execution time: 43_585_000 picoseconds. - Weight::from_parts(44_207_000, 13412) + // Minimum execution time: 43_603_000 picoseconds. + Weight::from_parts(44_142_000, 13412) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -604,10 +606,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `530` + // Measured: `498` // Estimated: `13412` - // Minimum execution time: 49_238_000 picoseconds. - Weight::from_parts(77_664_000, 13412) + // Minimum execution time: 49_691_000 picoseconds. + Weight::from_parts(50_402_000, 13412) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -617,10 +619,10 @@ impl WeightInfo for () { /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn freeze() -> Weight { // Proof Size summary in bytes: - // Measured: `491` + // Measured: `459` // Estimated: `7242` - // Minimum execution time: 19_198_000 picoseconds. - Weight::from_parts(19_585_000, 7242) + // Minimum execution time: 19_600_000 picoseconds. + Weight::from_parts(20_435_000, 7242) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -630,10 +632,10 @@ impl WeightInfo for () { /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn thaw() -> Weight { // Proof Size summary in bytes: - // Measured: `491` + // Measured: `459` // Estimated: `7242` - // Minimum execution time: 19_659_000 picoseconds. - Weight::from_parts(20_079_000, 7242) + // Minimum execution time: 19_396_000 picoseconds. + Weight::from_parts(19_745_000, 7242) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -641,10 +643,10 @@ impl WeightInfo for () { /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn freeze_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `417` + // Measured: `385` // Estimated: `3675` - // Minimum execution time: 15_035_000 picoseconds. - Weight::from_parts(15_594_000, 3675) + // Minimum execution time: 15_503_000 picoseconds. + Weight::from_parts(15_788_000, 3675) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -652,10 +654,10 @@ impl WeightInfo for () { /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn thaw_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `417` + // Measured: `385` // Estimated: `3675` - // Minimum execution time: 15_073_000 picoseconds. - Weight::from_parts(15_862_000, 3675) + // Minimum execution time: 15_874_000 picoseconds. + Weight::from_parts(16_190_000, 3675) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -665,10 +667,10 @@ impl WeightInfo for () { /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `7280` - // Minimum execution time: 17_343_000 picoseconds. - Weight::from_parts(17_656_000, 7280) + // Minimum execution time: 17_067_000 picoseconds. + Weight::from_parts(17_355_000, 7280) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -676,10 +678,10 @@ impl WeightInfo for () { /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn set_team() -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `3675` - // Minimum execution time: 15_902_000 picoseconds. - Weight::from_parts(16_439_000, 3675) + // Minimum execution time: 16_155_000 picoseconds. + Weight::from_parts(16_442_000, 3675) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -691,10 +693,10 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 50]`. fn set_metadata(_n: u32, _s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `7280` - // Minimum execution time: 27_222_000 picoseconds. - Weight::from_parts(29_151_657, 7280) + // Minimum execution time: 27_270_000 picoseconds. + Weight::from_parts(28_634_060, 7280) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -704,10 +706,10 @@ impl WeightInfo for () { /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `579` + // Measured: `515` // Estimated: `7280` - // Minimum execution time: 27_976_000 picoseconds. - Weight::from_parts(28_289_000, 7280) + // Minimum execution time: 27_469_000 picoseconds. + Weight::from_parts(27_911_000, 7280) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -721,10 +723,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `190` // Estimated: `7280` - // Minimum execution time: 16_162_000 picoseconds. - Weight::from_parts(17_137_043, 7280) - // Standard Error: 982 - .saturating_add(Weight::from_parts(4_180, 0).saturating_mul(s.into())) + // Minimum execution time: 16_008_000 picoseconds. + Weight::from_parts(17_007_654, 7280) + // Standard Error: 527 + .saturating_add(Weight::from_parts(4_158, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -734,10 +736,10 @@ impl WeightInfo for () { /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn force_clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `579` + // Measured: `515` // Estimated: `7280` - // Minimum execution time: 27_219_000 picoseconds. - Weight::from_parts(27_931_000, 7280) + // Minimum execution time: 27_118_000 picoseconds. + Weight::from_parts(27_776_000, 7280) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -745,10 +747,10 @@ impl WeightInfo for () { /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn force_asset_status() -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `3675` - // Minimum execution time: 15_313_000 picoseconds. - Weight::from_parts(15_775_000, 3675) + // Minimum execution time: 14_776_000 picoseconds. + Weight::from_parts(15_281_000, 3675) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -758,10 +760,10 @@ impl WeightInfo for () { /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) fn approve_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `417` + // Measured: `385` // Estimated: `7288` - // Minimum execution time: 31_865_000 picoseconds. - Weight::from_parts(32_316_000, 7288) + // Minimum execution time: 31_324_000 picoseconds. + Weight::from_parts(32_161_000, 7288) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -775,10 +777,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_approved() -> Weight { // Proof Size summary in bytes: - // Measured: `700` + // Measured: `668` // Estimated: `17025` - // Minimum execution time: 67_203_000 picoseconds. - Weight::from_parts(109_742_000, 17025) + // Minimum execution time: 63_750_000 picoseconds. + Weight::from_parts(64_828_000, 17025) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -788,10 +790,10 @@ impl WeightInfo for () { /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) fn cancel_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `587` + // Measured: `555` // Estimated: `7288` - // Minimum execution time: 33_430_000 picoseconds. - Weight::from_parts(33_824_000, 7288) + // Minimum execution time: 32_698_000 picoseconds. + Weight::from_parts(33_309_000, 7288) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -801,10 +803,10 @@ impl WeightInfo for () { /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) fn force_cancel_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `587` + // Measured: `555` // Estimated: `7288` - // Minimum execution time: 33_596_000 picoseconds. - Weight::from_parts(34_226_000, 7288) + // Minimum execution time: 33_147_000 picoseconds. + Weight::from_parts(33_620_000, 7288) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -812,10 +814,10 @@ impl WeightInfo for () { /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn set_min_balance() -> Weight { // Proof Size summary in bytes: - // Measured: `383` + // Measured: `351` // Estimated: `3675` - // Minimum execution time: 16_367_000 picoseconds. - Weight::from_parts(16_703_000, 3675) + // Minimum execution time: 15_910_000 picoseconds. + Weight::from_parts(16_315_000, 3675) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/bags-list/src/weights.rs b/frame/bags-list/src/weights.rs index 65d27c5aea4bb..30efe1ef0cb38 100644 --- a/frame/bags-list/src/weights.rs +++ b/frame/bags-list/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_bags_list //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_bags_list +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -66,10 +69,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn rebag_non_terminal() -> Weight { // Proof Size summary in bytes: - // Measured: `1916` - // Estimated: `19186` - // Minimum execution time: 54_348 nanoseconds. - Weight::from_parts(55_024_000, 19186) + // Measured: `1724` + // Estimated: `23146` + // Minimum execution time: 63_526_000 picoseconds. + Weight::from_parts(64_125_000, 23146) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -83,10 +86,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn rebag_terminal() -> Weight { // Proof Size summary in bytes: - // Measured: `1810` - // Estimated: `19114` - // Minimum execution time: 53_306 nanoseconds. - Weight::from_parts(54_263_000, 19114) + // Measured: `1618` + // Estimated: `23074` + // Minimum execution time: 62_404_000 picoseconds. + Weight::from_parts(63_178_000, 23074) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -102,10 +105,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn put_in_front_of() -> Weight { // Proof Size summary in bytes: - // Measured: `2154` - // Estimated: `25798` - // Minimum execution time: 59_513 nanoseconds. - Weight::from_parts(60_717_000, 25798) + // Measured: `1930` + // Estimated: `30748` + // Minimum execution time: 69_938_000 picoseconds. + Weight::from_parts(70_723_000, 30748) .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -123,10 +126,10 @@ impl WeightInfo for () { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn rebag_non_terminal() -> Weight { // Proof Size summary in bytes: - // Measured: `1916` - // Estimated: `19186` - // Minimum execution time: 54_348 nanoseconds. - Weight::from_parts(55_024_000, 19186) + // Measured: `1724` + // Estimated: `23146` + // Minimum execution time: 63_526_000 picoseconds. + Weight::from_parts(64_125_000, 23146) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -140,10 +143,10 @@ impl WeightInfo for () { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn rebag_terminal() -> Weight { // Proof Size summary in bytes: - // Measured: `1810` - // Estimated: `19114` - // Minimum execution time: 53_306 nanoseconds. - Weight::from_parts(54_263_000, 19114) + // Measured: `1618` + // Estimated: `23074` + // Minimum execution time: 62_404_000 picoseconds. + Weight::from_parts(63_178_000, 23074) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -159,10 +162,10 @@ impl WeightInfo for () { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn put_in_front_of() -> Weight { // Proof Size summary in bytes: - // Measured: `2154` - // Estimated: `25798` - // Minimum execution time: 59_513 nanoseconds. - Weight::from_parts(60_717_000, 25798) + // Measured: `1930` + // Estimated: `30748` + // Minimum execution time: 69_938_000 picoseconds. + Weight::from_parts(70_723_000, 30748) .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index cdc657ce1656c..500eb3371d635 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -18,26 +18,28 @@ //! Autogenerated weights for pallet_balances //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-02-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_balances +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_balances -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/balances/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -67,9 +69,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 37_815 nanoseconds. - Weight::from_parts(38_109_000, 0) - .saturating_add(Weight::from_parts(0, 3593)) + // Minimum execution time: 37_266_000 picoseconds. + Weight::from_parts(37_757_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -79,9 +80,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 28_184 nanoseconds. - Weight::from_parts(49_250_000, 0) - .saturating_add(Weight::from_parts(0, 3593)) + // Minimum execution time: 28_782_000 picoseconds. + Weight::from_parts(29_185_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -89,11 +89,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_balance_creating() -> Weight { // Proof Size summary in bytes: - // Measured: `206` + // Measured: `174` // Estimated: `3593` - // Minimum execution time: 17_474 nanoseconds. - Weight::from_parts(17_777_000, 0) - .saturating_add(Weight::from_parts(0, 3593)) + // Minimum execution time: 17_406_000 picoseconds. + Weight::from_parts(17_781_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -101,11 +100,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_balance_killing() -> Weight { // Proof Size summary in bytes: - // Measured: `206` + // Measured: `174` // Estimated: `3593` - // Minimum execution time: 20_962 nanoseconds. - Weight::from_parts(21_419_000, 0) - .saturating_add(Weight::from_parts(0, 3593)) + // Minimum execution time: 20_942_000 picoseconds. + Weight::from_parts(21_270_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -113,11 +111,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `135` + // Measured: `103` // Estimated: `6196` - // Minimum execution time: 39_713 nanoseconds. - Weight::from_parts(40_360_000, 0) - .saturating_add(Weight::from_parts(0, 6196)) + // Minimum execution time: 41_706_000 picoseconds. + Weight::from_parts(42_176_000, 6196) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -127,9 +124,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 34_878 nanoseconds. - Weight::from_parts(35_121_000, 0) - .saturating_add(Weight::from_parts(0, 3593)) + // Minimum execution time: 35_622_000 picoseconds. + Weight::from_parts(35_943_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -137,11 +133,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_unreserve() -> Weight { // Proof Size summary in bytes: - // Measured: `206` + // Measured: `174` // Estimated: `3593` - // Minimum execution time: 16_790 nanoseconds. - Weight::from_parts(17_029_000, 0) - .saturating_add(Weight::from_parts(0, 3593)) + // Minimum execution time: 16_586_000 picoseconds. + Weight::from_parts(17_352_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -155,9 +150,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 37_815 nanoseconds. - Weight::from_parts(38_109_000, 0) - .saturating_add(Weight::from_parts(0, 3593)) + // Minimum execution time: 37_266_000 picoseconds. + Weight::from_parts(37_757_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -167,9 +161,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 28_184 nanoseconds. - Weight::from_parts(49_250_000, 0) - .saturating_add(Weight::from_parts(0, 3593)) + // Minimum execution time: 28_782_000 picoseconds. + Weight::from_parts(29_185_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -177,11 +170,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_balance_creating() -> Weight { // Proof Size summary in bytes: - // Measured: `206` + // Measured: `174` // Estimated: `3593` - // Minimum execution time: 17_474 nanoseconds. - Weight::from_parts(17_777_000, 0) - .saturating_add(Weight::from_parts(0, 3593)) + // Minimum execution time: 17_406_000 picoseconds. + Weight::from_parts(17_781_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -189,11 +181,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_balance_killing() -> Weight { // Proof Size summary in bytes: - // Measured: `206` + // Measured: `174` // Estimated: `3593` - // Minimum execution time: 20_962 nanoseconds. - Weight::from_parts(21_419_000, 0) - .saturating_add(Weight::from_parts(0, 3593)) + // Minimum execution time: 20_942_000 picoseconds. + Weight::from_parts(21_270_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -201,11 +192,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `135` + // Measured: `103` // Estimated: `6196` - // Minimum execution time: 39_713 nanoseconds. - Weight::from_parts(40_360_000, 0) - .saturating_add(Weight::from_parts(0, 6196)) + // Minimum execution time: 41_706_000 picoseconds. + Weight::from_parts(42_176_000, 6196) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -215,9 +205,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 34_878 nanoseconds. - Weight::from_parts(35_121_000, 0) - .saturating_add(Weight::from_parts(0, 3593)) + // Minimum execution time: 35_622_000 picoseconds. + Weight::from_parts(35_943_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -225,11 +214,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_unreserve() -> Weight { // Proof Size summary in bytes: - // Measured: `206` + // Measured: `174` // Estimated: `3593` - // Minimum execution time: 16_790 nanoseconds. - Weight::from_parts(17_029_000, 0) - .saturating_add(Weight::from_parts(0, 3593)) + // Minimum execution time: 16_586_000 picoseconds. + Weight::from_parts(17_352_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/benchmarking/src/weights.rs b/frame/benchmarking/src/weights.rs index b05feb5900a65..aa24b99ace2a7 100644 --- a/frame/benchmarking/src/weights.rs +++ b/frame/benchmarking/src/weights.rs @@ -18,26 +18,28 @@ //! Autogenerated weights for frame_benchmarking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=frame_benchmarking +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=frame_benchmarking -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/benchmarking/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -65,49 +67,49 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 168_000 picoseconds. - Weight::from_parts(237_577, 0) + // Minimum execution time: 205_000 picoseconds. + Weight::from_parts(263_483, 0) } /// The range of component `i` is `[0, 1000000]`. fn subtraction(_i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 169_000 picoseconds. - Weight::from_parts(224_111, 0) + // Minimum execution time: 186_000 picoseconds. + Weight::from_parts(257_588, 0) } /// The range of component `i` is `[0, 1000000]`. fn multiplication(_i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 175_000 picoseconds. - Weight::from_parts(229_708, 0) + // Minimum execution time: 192_000 picoseconds. + Weight::from_parts(264_271, 0) } /// The range of component `i` is `[0, 1000000]`. fn division(_i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 173_000 picoseconds. - Weight::from_parts(229_855, 0) + // Minimum execution time: 191_000 picoseconds. + Weight::from_parts(250_785, 0) } fn hashing() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 21_286_627_000 picoseconds. - Weight::from_parts(21_405_011_000, 0) + // Minimum execution time: 21_405_207_000 picoseconds. + Weight::from_parts(21_534_243_000, 0) } /// The range of component `i` is `[0, 100]`. fn sr25519_verification(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 239_000 picoseconds. - Weight::from_parts(661_987, 0) - // Standard Error: 24_324 - .saturating_add(Weight::from_parts(47_322_399, 0).saturating_mul(i.into())) + // Minimum execution time: 255_000 picoseconds. + Weight::from_parts(271_000, 0) + // Standard Error: 12_788 + .saturating_add(Weight::from_parts(47_469_387, 0).saturating_mul(i.into())) } } @@ -118,48 +120,48 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 168_000 picoseconds. - Weight::from_parts(237_577, 0) + // Minimum execution time: 205_000 picoseconds. + Weight::from_parts(263_483, 0) } /// The range of component `i` is `[0, 1000000]`. fn subtraction(_i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 169_000 picoseconds. - Weight::from_parts(224_111, 0) + // Minimum execution time: 186_000 picoseconds. + Weight::from_parts(257_588, 0) } /// The range of component `i` is `[0, 1000000]`. fn multiplication(_i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 175_000 picoseconds. - Weight::from_parts(229_708, 0) + // Minimum execution time: 192_000 picoseconds. + Weight::from_parts(264_271, 0) } /// The range of component `i` is `[0, 1000000]`. fn division(_i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 173_000 picoseconds. - Weight::from_parts(229_855, 0) + // Minimum execution time: 191_000 picoseconds. + Weight::from_parts(250_785, 0) } fn hashing() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 21_286_627_000 picoseconds. - Weight::from_parts(21_405_011_000, 0) + // Minimum execution time: 21_405_207_000 picoseconds. + Weight::from_parts(21_534_243_000, 0) } /// The range of component `i` is `[0, 100]`. fn sr25519_verification(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 239_000 picoseconds. - Weight::from_parts(661_987, 0) - // Standard Error: 24_324 - .saturating_add(Weight::from_parts(47_322_399, 0).saturating_mul(i.into())) + // Minimum execution time: 255_000 picoseconds. + Weight::from_parts(271_000, 0) + // Standard Error: 12_788 + .saturating_add(Weight::from_parts(47_469_387, 0).saturating_mul(i.into())) } } diff --git a/frame/bounties/src/weights.rs b/frame/bounties/src/weights.rs index f0ea78b5f1e8d..b0459fee62eb1 100644 --- a/frame/bounties/src/weights.rs +++ b/frame/bounties/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_bounties //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_bounties +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -73,14 +76,12 @@ impl WeightInfo for SubstrateWeight { /// Storage: Bounties Bounties (r:0 w:1) /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) /// The range of component `d` is `[0, 300]`. - fn propose_bounty(d: u32, ) -> Weight { + fn propose_bounty(_d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `308` - // Estimated: `3102` - // Minimum execution time: 22_787 nanoseconds. - Weight::from_parts(23_898_632, 3102) - // Standard Error: 141 - .saturating_add(Weight::from_parts(568, 0).saturating_mul(d.into())) + // Measured: `276` + // Estimated: `5082` + // Minimum execution time: 26_271_000 picoseconds. + Weight::from_parts(28_048_901, 5082) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -90,10 +91,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn approve_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `400` - // Estimated: `3549` - // Minimum execution time: 10_526 nanoseconds. - Weight::from_parts(10_729_000, 3549) + // Measured: `368` + // Estimated: `5529` + // Minimum execution time: 12_573_000 picoseconds. + Weight::from_parts(12_827_000, 5529) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -101,10 +102,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) fn propose_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `420` - // Estimated: `2652` - // Minimum execution time: 9_193 nanoseconds. - Weight::from_parts(9_455_000, 2652) + // Measured: `388` + // Estimated: `3642` + // Minimum execution time: 10_555_000 picoseconds. + Weight::from_parts(10_857_000, 3642) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -114,10 +115,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn unassign_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `628` - // Estimated: `5255` - // Minimum execution time: 22_592 nanoseconds. - Weight::from_parts(22_952_000, 5255) + // Measured: `564` + // Estimated: `7235` + // Minimum execution time: 26_003_000 picoseconds. + Weight::from_parts(26_291_000, 7235) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -127,10 +128,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn accept_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `624` - // Estimated: `5255` - // Minimum execution time: 20_920 nanoseconds. - Weight::from_parts(21_369_000, 5255) + // Measured: `560` + // Estimated: `7235` + // Minimum execution time: 24_371_000 picoseconds. + Weight::from_parts(24_781_000, 7235) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -140,10 +141,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) fn award_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `570` - // Estimated: `5143` - // Minimum execution time: 17_853 nanoseconds. - Weight::from_parts(18_280_000, 5143) + // Measured: `538` + // Estimated: `7123` + // Minimum execution time: 20_688_000 picoseconds. + Weight::from_parts(20_909_000, 7123) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -157,10 +158,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn claim_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `998` - // Estimated: `12964` - // Minimum execution time: 67_538 nanoseconds. - Weight::from_parts(67_974_000, 12964) + // Measured: `902` + // Estimated: `15934` + // Minimum execution time: 78_933_000 picoseconds. + Weight::from_parts(79_884_000, 15934) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -174,10 +175,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_bounty_proposed() -> Weight { // Proof Size summary in bytes: - // Measured: `646` - // Estimated: `7746` - // Minimum execution time: 28_380 nanoseconds. - Weight::from_parts(28_859_000, 7746) + // Measured: `582` + // Estimated: `10716` + // Minimum execution time: 32_332_000 picoseconds. + Weight::from_parts(32_833_000, 10716) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -191,10 +192,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_bounty_active() -> Weight { // Proof Size summary in bytes: - // Measured: `914` - // Estimated: `10349` - // Minimum execution time: 47_739 nanoseconds. - Weight::from_parts(48_388_000, 10349) + // Measured: `818` + // Estimated: `13319` + // Minimum execution time: 55_686_000 picoseconds. + Weight::from_parts(56_271_000, 13319) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -202,10 +203,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) fn extend_bounty_expiry() -> Weight { // Proof Size summary in bytes: - // Measured: `456` - // Estimated: `2652` - // Minimum execution time: 14_188 nanoseconds. - Weight::from_parts(14_801_000, 2652) + // Measured: `424` + // Estimated: `3642` + // Minimum execution time: 16_414_000 picoseconds. + Weight::from_parts(16_681_000, 3642) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -218,12 +219,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `b` is `[0, 100]`. fn spend_funds(b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `31 + b * (360 ±0)` - // Estimated: `897 + b * (7858 ±0)` - // Minimum execution time: 4_685 nanoseconds. - Weight::from_parts(9_932_840, 897) - // Standard Error: 14_301 - .saturating_add(Weight::from_parts(27_178_347, 0).saturating_mul(b.into())) + // Measured: `4 + b * (297 ±0)` + // Estimated: `3867 + b * (7858 ±0)` + // Minimum execution time: 5_398_000 picoseconds. + Weight::from_parts(4_478_947, 3867) + // Standard Error: 41_860 + .saturating_add(Weight::from_parts(33_082_606, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -243,14 +244,12 @@ impl WeightInfo for () { /// Storage: Bounties Bounties (r:0 w:1) /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) /// The range of component `d` is `[0, 300]`. - fn propose_bounty(d: u32, ) -> Weight { + fn propose_bounty(_d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `308` - // Estimated: `3102` - // Minimum execution time: 22_787 nanoseconds. - Weight::from_parts(23_898_632, 3102) - // Standard Error: 141 - .saturating_add(Weight::from_parts(568, 0).saturating_mul(d.into())) + // Measured: `276` + // Estimated: `5082` + // Minimum execution time: 26_271_000 picoseconds. + Weight::from_parts(28_048_901, 5082) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -260,10 +259,10 @@ impl WeightInfo for () { /// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn approve_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `400` - // Estimated: `3549` - // Minimum execution time: 10_526 nanoseconds. - Weight::from_parts(10_729_000, 3549) + // Measured: `368` + // Estimated: `5529` + // Minimum execution time: 12_573_000 picoseconds. + Weight::from_parts(12_827_000, 5529) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -271,10 +270,10 @@ impl WeightInfo for () { /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) fn propose_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `420` - // Estimated: `2652` - // Minimum execution time: 9_193 nanoseconds. - Weight::from_parts(9_455_000, 2652) + // Measured: `388` + // Estimated: `3642` + // Minimum execution time: 10_555_000 picoseconds. + Weight::from_parts(10_857_000, 3642) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -284,10 +283,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn unassign_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `628` - // Estimated: `5255` - // Minimum execution time: 22_592 nanoseconds. - Weight::from_parts(22_952_000, 5255) + // Measured: `564` + // Estimated: `7235` + // Minimum execution time: 26_003_000 picoseconds. + Weight::from_parts(26_291_000, 7235) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -297,10 +296,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn accept_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `624` - // Estimated: `5255` - // Minimum execution time: 20_920 nanoseconds. - Weight::from_parts(21_369_000, 5255) + // Measured: `560` + // Estimated: `7235` + // Minimum execution time: 24_371_000 picoseconds. + Weight::from_parts(24_781_000, 7235) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -310,10 +309,10 @@ impl WeightInfo for () { /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) fn award_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `570` - // Estimated: `5143` - // Minimum execution time: 17_853 nanoseconds. - Weight::from_parts(18_280_000, 5143) + // Measured: `538` + // Estimated: `7123` + // Minimum execution time: 20_688_000 picoseconds. + Weight::from_parts(20_909_000, 7123) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -327,10 +326,10 @@ impl WeightInfo for () { /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn claim_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `998` - // Estimated: `12964` - // Minimum execution time: 67_538 nanoseconds. - Weight::from_parts(67_974_000, 12964) + // Measured: `902` + // Estimated: `15934` + // Minimum execution time: 78_933_000 picoseconds. + Weight::from_parts(79_884_000, 15934) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -344,10 +343,10 @@ impl WeightInfo for () { /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_bounty_proposed() -> Weight { // Proof Size summary in bytes: - // Measured: `646` - // Estimated: `7746` - // Minimum execution time: 28_380 nanoseconds. - Weight::from_parts(28_859_000, 7746) + // Measured: `582` + // Estimated: `10716` + // Minimum execution time: 32_332_000 picoseconds. + Weight::from_parts(32_833_000, 10716) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -361,10 +360,10 @@ impl WeightInfo for () { /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_bounty_active() -> Weight { // Proof Size summary in bytes: - // Measured: `914` - // Estimated: `10349` - // Minimum execution time: 47_739 nanoseconds. - Weight::from_parts(48_388_000, 10349) + // Measured: `818` + // Estimated: `13319` + // Minimum execution time: 55_686_000 picoseconds. + Weight::from_parts(56_271_000, 13319) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -372,10 +371,10 @@ impl WeightInfo for () { /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) fn extend_bounty_expiry() -> Weight { // Proof Size summary in bytes: - // Measured: `456` - // Estimated: `2652` - // Minimum execution time: 14_188 nanoseconds. - Weight::from_parts(14_801_000, 2652) + // Measured: `424` + // Estimated: `3642` + // Minimum execution time: 16_414_000 picoseconds. + Weight::from_parts(16_681_000, 3642) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -388,12 +387,12 @@ impl WeightInfo for () { /// The range of component `b` is `[0, 100]`. fn spend_funds(b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `31 + b * (360 ±0)` - // Estimated: `897 + b * (7858 ±0)` - // Minimum execution time: 4_685 nanoseconds. - Weight::from_parts(9_932_840, 897) - // Standard Error: 14_301 - .saturating_add(Weight::from_parts(27_178_347, 0).saturating_mul(b.into())) + // Measured: `4 + b * (297 ±0)` + // Estimated: `3867 + b * (7858 ±0)` + // Minimum execution time: 5_398_000 picoseconds. + Weight::from_parts(4_478_947, 3867) + // Standard Error: 41_860 + .saturating_add(Weight::from_parts(33_082_606, 0).saturating_mul(b.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(b.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) diff --git a/frame/child-bounties/src/weights.rs b/frame/child-bounties/src/weights.rs index eeb14419678d7..92be77c49dc9c 100644 --- a/frame/child-bounties/src/weights.rs +++ b/frame/child-bounties/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_child_bounties //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_child_bounties +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -76,12 +79,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `d` is `[0, 300]`. fn add_child_bounty(d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `742` - // Estimated: `10848` - // Minimum execution time: 46_743 nanoseconds. - Weight::from_parts(47_762_924, 10848) - // Standard Error: 135 - .saturating_add(Weight::from_parts(599, 0).saturating_mul(d.into())) + // Measured: `678` + // Estimated: `14808` + // Minimum execution time: 54_017_000 picoseconds. + Weight::from_parts(55_142_443, 14808) + // Standard Error: 310 + .saturating_add(Weight::from_parts(1_199, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -93,10 +96,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: ChildBounties ChildrenCuratorFees (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn propose_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `796` - // Estimated: `7775` - // Minimum execution time: 16_417 nanoseconds. - Weight::from_parts(16_712_000, 7775) + // Measured: `732` + // Estimated: `10745` + // Minimum execution time: 19_222_000 picoseconds. + Weight::from_parts(19_446_000, 10745) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -108,10 +111,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn accept_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `974` - // Estimated: `7875` - // Minimum execution time: 25_548 nanoseconds. - Weight::from_parts(25_919_000, 7875) + // Measured: `878` + // Estimated: `10845` + // Minimum execution time: 31_049_000 picoseconds. + Weight::from_parts(31_546_000, 10845) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -123,10 +126,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn unassign_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `974` - // Estimated: `7875` - // Minimum execution time: 27_645 nanoseconds. - Weight::from_parts(27_947_000, 7875) + // Measured: `878` + // Estimated: `10845` + // Minimum execution time: 33_860_000 picoseconds. + Weight::from_parts(34_897_000, 10845) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -136,10 +139,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) fn award_child_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `839` - // Estimated: `5272` - // Minimum execution time: 20_002 nanoseconds. - Weight::from_parts(20_512_000, 5272) + // Measured: `775` + // Estimated: `7252` + // Minimum execution time: 23_178_000 picoseconds. + Weight::from_parts(23_412_000, 7252) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -153,10 +156,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn claim_child_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `744` - // Estimated: `12920` - // Minimum execution time: 63_752 nanoseconds. - Weight::from_parts(64_179_000, 12920) + // Measured: `648` + // Estimated: `15890` + // Minimum execution time: 76_189_000 picoseconds. + Weight::from_parts(76_770_000, 15890) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -174,10 +177,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_child_bounty_added() -> Weight { // Proof Size summary in bytes: - // Measured: `1106` - // Estimated: `15472` - // Minimum execution time: 47_388 nanoseconds. - Weight::from_parts(47_946_000, 15472) + // Measured: `978` + // Estimated: `20422` + // Minimum execution time: 55_161_000 picoseconds. + Weight::from_parts(55_578_000, 20422) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -195,10 +198,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_child_bounty_active() -> Weight { // Proof Size summary in bytes: - // Measured: `1325` - // Estimated: `18075` - // Minimum execution time: 58_008 nanoseconds. - Weight::from_parts(58_586_000, 18075) + // Measured: `1165` + // Estimated: `23025` + // Minimum execution time: 67_815_000 picoseconds. + Weight::from_parts(68_620_000, 23025) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -221,12 +224,12 @@ impl WeightInfo for () { /// The range of component `d` is `[0, 300]`. fn add_child_bounty(d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `742` - // Estimated: `10848` - // Minimum execution time: 46_743 nanoseconds. - Weight::from_parts(47_762_924, 10848) - // Standard Error: 135 - .saturating_add(Weight::from_parts(599, 0).saturating_mul(d.into())) + // Measured: `678` + // Estimated: `14808` + // Minimum execution time: 54_017_000 picoseconds. + Weight::from_parts(55_142_443, 14808) + // Standard Error: 310 + .saturating_add(Weight::from_parts(1_199, 0).saturating_mul(d.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -238,10 +241,10 @@ impl WeightInfo for () { /// Proof: ChildBounties ChildrenCuratorFees (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn propose_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `796` - // Estimated: `7775` - // Minimum execution time: 16_417 nanoseconds. - Weight::from_parts(16_712_000, 7775) + // Measured: `732` + // Estimated: `10745` + // Minimum execution time: 19_222_000 picoseconds. + Weight::from_parts(19_446_000, 10745) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -253,10 +256,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn accept_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `974` - // Estimated: `7875` - // Minimum execution time: 25_548 nanoseconds. - Weight::from_parts(25_919_000, 7875) + // Measured: `878` + // Estimated: `10845` + // Minimum execution time: 31_049_000 picoseconds. + Weight::from_parts(31_546_000, 10845) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -268,10 +271,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn unassign_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `974` - // Estimated: `7875` - // Minimum execution time: 27_645 nanoseconds. - Weight::from_parts(27_947_000, 7875) + // Measured: `878` + // Estimated: `10845` + // Minimum execution time: 33_860_000 picoseconds. + Weight::from_parts(34_897_000, 10845) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -281,10 +284,10 @@ impl WeightInfo for () { /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) fn award_child_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `839` - // Estimated: `5272` - // Minimum execution time: 20_002 nanoseconds. - Weight::from_parts(20_512_000, 5272) + // Measured: `775` + // Estimated: `7252` + // Minimum execution time: 23_178_000 picoseconds. + Weight::from_parts(23_412_000, 7252) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -298,10 +301,10 @@ impl WeightInfo for () { /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn claim_child_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `744` - // Estimated: `12920` - // Minimum execution time: 63_752 nanoseconds. - Weight::from_parts(64_179_000, 12920) + // Measured: `648` + // Estimated: `15890` + // Minimum execution time: 76_189_000 picoseconds. + Weight::from_parts(76_770_000, 15890) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -319,10 +322,10 @@ impl WeightInfo for () { /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_child_bounty_added() -> Weight { // Proof Size summary in bytes: - // Measured: `1106` - // Estimated: `15472` - // Minimum execution time: 47_388 nanoseconds. - Weight::from_parts(47_946_000, 15472) + // Measured: `978` + // Estimated: `20422` + // Minimum execution time: 55_161_000 picoseconds. + Weight::from_parts(55_578_000, 20422) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -340,10 +343,10 @@ impl WeightInfo for () { /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_child_bounty_active() -> Weight { // Proof Size summary in bytes: - // Measured: `1325` - // Estimated: `18075` - // Minimum execution time: 58_008 nanoseconds. - Weight::from_parts(58_586_000, 18075) + // Measured: `1165` + // Estimated: `23025` + // Minimum execution time: 67_815_000 picoseconds. + Weight::from_parts(68_620_000, 23025) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } diff --git a/frame/collective/src/weights.rs b/frame/collective/src/weights.rs index df233fc248e3d..2199c02052009 100644 --- a/frame/collective/src/weights.rs +++ b/frame/collective/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_collective //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_collective +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -76,20 +79,20 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[0, 100]`. fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + m * (3233 ±0) + p * (3223 ±0)` - // Estimated: `16586 + m * (7809 ±24) + p * (10238 ±24)` - // Minimum execution time: 17_093 nanoseconds. - Weight::from_parts(17_284_000, 16586) - // Standard Error: 64_700 - .saturating_add(Weight::from_parts(5_143_145, 0).saturating_mul(m.into())) - // Standard Error: 64_700 - .saturating_add(Weight::from_parts(7_480_941, 0).saturating_mul(p.into())) + // Measured: `0 + m * (3232 ±0) + p * (3190 ±0)` + // Estimated: `19428 + m * (7799 ±24) + p * (10110 ±24)` + // Minimum execution time: 18_772_000 picoseconds. + Weight::from_parts(18_931_000, 19428) + // Standard Error: 65_247 + .saturating_add(Weight::from_parts(5_050_136, 0).saturating_mul(m.into())) + // Standard Error: 65_247 + .saturating_add(Weight::from_parts(8_235_069, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) - .saturating_add(Weight::from_parts(0, 7809).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 10238).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 7799).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 10110).saturating_mul(p.into())) } /// Storage: Council Members (r:1 w:0) /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) @@ -97,14 +100,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `234 + m * (32 ±0)` - // Estimated: `730 + m * (32 ±0)` - // Minimum execution time: 15_972 nanoseconds. - Weight::from_parts(14_971_445, 730) - // Standard Error: 32 - .saturating_add(Weight::from_parts(1_775, 0).saturating_mul(b.into())) - // Standard Error: 334 - .saturating_add(Weight::from_parts(17_052, 0).saturating_mul(m.into())) + // Measured: `202 + m * (32 ±0)` + // Estimated: `1688 + m * (32 ±0)` + // Minimum execution time: 17_741_000 picoseconds. + Weight::from_parts(17_580_031, 1688) + // Standard Error: 113 + .saturating_add(Weight::from_parts(941, 0).saturating_mul(b.into())) + // Standard Error: 1_170 + .saturating_add(Weight::from_parts(17_329, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } @@ -116,14 +119,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `234 + m * (32 ±0)` - // Estimated: `3440 + m * (64 ±0)` - // Minimum execution time: 17_950 nanoseconds. - Weight::from_parts(17_019_558, 3440) - // Standard Error: 41 - .saturating_add(Weight::from_parts(1_807, 0).saturating_mul(b.into())) - // Standard Error: 432 - .saturating_add(Weight::from_parts(27_986, 0).saturating_mul(m.into())) + // Measured: `202 + m * (32 ±0)` + // Estimated: `5356 + m * (64 ±0)` + // Minimum execution time: 20_214_000 picoseconds. + Weight::from_parts(19_508_816, 5356) + // Standard Error: 46 + .saturating_add(Weight::from_parts(1_646, 0).saturating_mul(b.into())) + // Standard Error: 475 + .saturating_add(Weight::from_parts(27_145, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) } @@ -142,16 +145,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `556 + m * (32 ±0) + p * (36 ±0)` - // Estimated: `6355 + m * (165 ±0) + p * (180 ±0)` - // Minimum execution time: 24_817 nanoseconds. - Weight::from_parts(24_778_955, 6355) - // Standard Error: 73 - .saturating_add(Weight::from_parts(2_355, 0).saturating_mul(b.into())) - // Standard Error: 765 - .saturating_add(Weight::from_parts(20_518, 0).saturating_mul(m.into())) - // Standard Error: 755 - .saturating_add(Weight::from_parts(85_670, 0).saturating_mul(p.into())) + // Measured: `492 + m * (32 ±0) + p * (36 ±0)` + // Estimated: `10015 + m * (165 ±0) + p * (180 ±0)` + // Minimum execution time: 27_872_000 picoseconds. + Weight::from_parts(28_010_227, 10015) + // Standard Error: 90 + .saturating_add(Weight::from_parts(2_643, 0).saturating_mul(b.into())) + // Standard Error: 944 + .saturating_add(Weight::from_parts(17_897, 0).saturating_mul(m.into())) + // Standard Error: 932 + .saturating_add(Weight::from_parts(122_368, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 165).saturating_mul(m.into())) @@ -164,12 +167,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1006 + m * (64 ±0)` - // Estimated: `4980 + m * (128 ±0)` - // Minimum execution time: 19_790 nanoseconds. - Weight::from_parts(20_528_275, 4980) - // Standard Error: 651 - .saturating_add(Weight::from_parts(48_856, 0).saturating_mul(m.into())) + // Measured: `941 + m * (64 ±0)` + // Estimated: `6830 + m * (128 ±0)` + // Minimum execution time: 22_518_000 picoseconds. + Weight::from_parts(23_281_512, 6830) + // Standard Error: 647 + .saturating_add(Weight::from_parts(53_974, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 128).saturating_mul(m.into())) @@ -186,14 +189,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `626 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `5893 + m * (260 ±0) + p * (144 ±0)` - // Minimum execution time: 25_564 nanoseconds. - Weight::from_parts(25_535_497, 5893) - // Standard Error: 610 - .saturating_add(Weight::from_parts(27_956, 0).saturating_mul(m.into())) - // Standard Error: 595 - .saturating_add(Weight::from_parts(84_835, 0).saturating_mul(p.into())) + // Measured: `530 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `8475 + m * (260 ±0) + p * (144 ±0)` + // Minimum execution time: 29_020_000 picoseconds. + Weight::from_parts(29_009_937, 8475) + // Standard Error: 809 + .saturating_add(Weight::from_parts(31_952, 0).saturating_mul(m.into())) + // Standard Error: 789 + .saturating_add(Weight::from_parts(124_282, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 260).saturating_mul(m.into())) @@ -212,16 +215,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `962 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `9164 + b * (4 ±0) + m * (264 ±0) + p * (160 ±0)` - // Minimum execution time: 36_515 nanoseconds. - Weight::from_parts(36_626_648, 9164) - // Standard Error: 98 - .saturating_add(Weight::from_parts(2_295, 0).saturating_mul(b.into())) - // Standard Error: 1_036 - .saturating_add(Weight::from_parts(22_182, 0).saturating_mul(m.into())) - // Standard Error: 1_010 - .saturating_add(Weight::from_parts(100_034, 0).saturating_mul(p.into())) + // Measured: `832 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `12636 + b * (4 ±0) + m * (264 ±0) + p * (160 ±0)` + // Minimum execution time: 41_541_000 picoseconds. + Weight::from_parts(43_640_322, 12636) + // Standard Error: 104 + .saturating_add(Weight::from_parts(2_178, 0).saturating_mul(b.into())) + // Standard Error: 1_101 + .saturating_add(Weight::from_parts(20_512, 0).saturating_mul(m.into())) + // Standard Error: 1_073 + .saturating_add(Weight::from_parts(133_112, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 4).saturating_mul(b.into())) @@ -242,14 +245,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `646 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `7095 + m * (325 ±0) + p * (180 ±0)` - // Minimum execution time: 28_858 nanoseconds. - Weight::from_parts(28_050_047, 7095) - // Standard Error: 614 - .saturating_add(Weight::from_parts(34_031, 0).saturating_mul(m.into())) - // Standard Error: 599 - .saturating_add(Weight::from_parts(85_744, 0).saturating_mul(p.into())) + // Measured: `550 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `10570 + m * (325 ±0) + p * (180 ±0)` + // Minimum execution time: 32_773_000 picoseconds. + Weight::from_parts(33_031_550, 10570) + // Standard Error: 1_205 + .saturating_add(Weight::from_parts(26_143, 0).saturating_mul(m.into())) + // Standard Error: 1_175 + .saturating_add(Weight::from_parts(137_503, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 325).saturating_mul(m.into())) @@ -270,16 +273,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `982 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `10565 + b * (5 ±0) + m * (330 ±0) + p * (200 ±0)` - // Minimum execution time: 38_608 nanoseconds. - Weight::from_parts(39_948_329, 10565) - // Standard Error: 84 - .saturating_add(Weight::from_parts(2_045, 0).saturating_mul(b.into())) - // Standard Error: 895 - .saturating_add(Weight::from_parts(22_669, 0).saturating_mul(m.into())) - // Standard Error: 872 - .saturating_add(Weight::from_parts(95_525, 0).saturating_mul(p.into())) + // Measured: `852 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `14905 + b * (5 ±0) + m * (330 ±0) + p * (200 ±0)` + // Minimum execution time: 44_855_000 picoseconds. + Weight::from_parts(47_307_460, 14905) + // Standard Error: 100 + .saturating_add(Weight::from_parts(1_536, 0).saturating_mul(b.into())) + // Standard Error: 1_065 + .saturating_add(Weight::from_parts(20_549, 0).saturating_mul(m.into())) + // Standard Error: 1_038 + .saturating_add(Weight::from_parts(133_143, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(b.into())) @@ -295,12 +298,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn disapprove_proposal(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `391 + p * (32 ±0)` - // Estimated: `1668 + p * (96 ±0)` - // Minimum execution time: 14_785 nanoseconds. - Weight::from_parts(16_393_818, 1668) - // Standard Error: 612 - .saturating_add(Weight::from_parts(76_786, 0).saturating_mul(p.into())) + // Measured: `359 + p * (32 ±0)` + // Estimated: `2562 + p * (96 ±0)` + // Minimum execution time: 16_420_000 picoseconds. + Weight::from_parts(18_236_525, 2562) + // Standard Error: 894 + .saturating_add(Weight::from_parts(115_590, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 96).saturating_mul(p.into())) @@ -322,20 +325,20 @@ impl WeightInfo for () { /// The range of component `p` is `[0, 100]`. fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + m * (3233 ±0) + p * (3223 ±0)` - // Estimated: `16586 + m * (7809 ±24) + p * (10238 ±24)` - // Minimum execution time: 17_093 nanoseconds. - Weight::from_parts(17_284_000, 16586) - // Standard Error: 64_700 - .saturating_add(Weight::from_parts(5_143_145, 0).saturating_mul(m.into())) - // Standard Error: 64_700 - .saturating_add(Weight::from_parts(7_480_941, 0).saturating_mul(p.into())) + // Measured: `0 + m * (3232 ±0) + p * (3190 ±0)` + // Estimated: `19428 + m * (7799 ±24) + p * (10110 ±24)` + // Minimum execution time: 18_772_000 picoseconds. + Weight::from_parts(18_931_000, 19428) + // Standard Error: 65_247 + .saturating_add(Weight::from_parts(5_050_136, 0).saturating_mul(m.into())) + // Standard Error: 65_247 + .saturating_add(Weight::from_parts(8_235_069, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(p.into()))) - .saturating_add(Weight::from_parts(0, 7809).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 10238).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 7799).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 10110).saturating_mul(p.into())) } /// Storage: Council Members (r:1 w:0) /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) @@ -343,14 +346,14 @@ impl WeightInfo for () { /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `234 + m * (32 ±0)` - // Estimated: `730 + m * (32 ±0)` - // Minimum execution time: 15_972 nanoseconds. - Weight::from_parts(14_971_445, 730) - // Standard Error: 32 - .saturating_add(Weight::from_parts(1_775, 0).saturating_mul(b.into())) - // Standard Error: 334 - .saturating_add(Weight::from_parts(17_052, 0).saturating_mul(m.into())) + // Measured: `202 + m * (32 ±0)` + // Estimated: `1688 + m * (32 ±0)` + // Minimum execution time: 17_741_000 picoseconds. + Weight::from_parts(17_580_031, 1688) + // Standard Error: 113 + .saturating_add(Weight::from_parts(941, 0).saturating_mul(b.into())) + // Standard Error: 1_170 + .saturating_add(Weight::from_parts(17_329, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } @@ -362,14 +365,14 @@ impl WeightInfo for () { /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `234 + m * (32 ±0)` - // Estimated: `3440 + m * (64 ±0)` - // Minimum execution time: 17_950 nanoseconds. - Weight::from_parts(17_019_558, 3440) - // Standard Error: 41 - .saturating_add(Weight::from_parts(1_807, 0).saturating_mul(b.into())) - // Standard Error: 432 - .saturating_add(Weight::from_parts(27_986, 0).saturating_mul(m.into())) + // Measured: `202 + m * (32 ±0)` + // Estimated: `5356 + m * (64 ±0)` + // Minimum execution time: 20_214_000 picoseconds. + Weight::from_parts(19_508_816, 5356) + // Standard Error: 46 + .saturating_add(Weight::from_parts(1_646, 0).saturating_mul(b.into())) + // Standard Error: 475 + .saturating_add(Weight::from_parts(27_145, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) } @@ -388,16 +391,16 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `556 + m * (32 ±0) + p * (36 ±0)` - // Estimated: `6355 + m * (165 ±0) + p * (180 ±0)` - // Minimum execution time: 24_817 nanoseconds. - Weight::from_parts(24_778_955, 6355) - // Standard Error: 73 - .saturating_add(Weight::from_parts(2_355, 0).saturating_mul(b.into())) - // Standard Error: 765 - .saturating_add(Weight::from_parts(20_518, 0).saturating_mul(m.into())) - // Standard Error: 755 - .saturating_add(Weight::from_parts(85_670, 0).saturating_mul(p.into())) + // Measured: `492 + m * (32 ±0) + p * (36 ±0)` + // Estimated: `10015 + m * (165 ±0) + p * (180 ±0)` + // Minimum execution time: 27_872_000 picoseconds. + Weight::from_parts(28_010_227, 10015) + // Standard Error: 90 + .saturating_add(Weight::from_parts(2_643, 0).saturating_mul(b.into())) + // Standard Error: 944 + .saturating_add(Weight::from_parts(17_897, 0).saturating_mul(m.into())) + // Standard Error: 932 + .saturating_add(Weight::from_parts(122_368, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 165).saturating_mul(m.into())) @@ -410,12 +413,12 @@ impl WeightInfo for () { /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1006 + m * (64 ±0)` - // Estimated: `4980 + m * (128 ±0)` - // Minimum execution time: 19_790 nanoseconds. - Weight::from_parts(20_528_275, 4980) - // Standard Error: 651 - .saturating_add(Weight::from_parts(48_856, 0).saturating_mul(m.into())) + // Measured: `941 + m * (64 ±0)` + // Estimated: `6830 + m * (128 ±0)` + // Minimum execution time: 22_518_000 picoseconds. + Weight::from_parts(23_281_512, 6830) + // Standard Error: 647 + .saturating_add(Weight::from_parts(53_974, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 128).saturating_mul(m.into())) @@ -432,14 +435,14 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `626 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `5893 + m * (260 ±0) + p * (144 ±0)` - // Minimum execution time: 25_564 nanoseconds. - Weight::from_parts(25_535_497, 5893) - // Standard Error: 610 - .saturating_add(Weight::from_parts(27_956, 0).saturating_mul(m.into())) - // Standard Error: 595 - .saturating_add(Weight::from_parts(84_835, 0).saturating_mul(p.into())) + // Measured: `530 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `8475 + m * (260 ±0) + p * (144 ±0)` + // Minimum execution time: 29_020_000 picoseconds. + Weight::from_parts(29_009_937, 8475) + // Standard Error: 809 + .saturating_add(Weight::from_parts(31_952, 0).saturating_mul(m.into())) + // Standard Error: 789 + .saturating_add(Weight::from_parts(124_282, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 260).saturating_mul(m.into())) @@ -458,16 +461,16 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `962 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `9164 + b * (4 ±0) + m * (264 ±0) + p * (160 ±0)` - // Minimum execution time: 36_515 nanoseconds. - Weight::from_parts(36_626_648, 9164) - // Standard Error: 98 - .saturating_add(Weight::from_parts(2_295, 0).saturating_mul(b.into())) - // Standard Error: 1_036 - .saturating_add(Weight::from_parts(22_182, 0).saturating_mul(m.into())) - // Standard Error: 1_010 - .saturating_add(Weight::from_parts(100_034, 0).saturating_mul(p.into())) + // Measured: `832 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `12636 + b * (4 ±0) + m * (264 ±0) + p * (160 ±0)` + // Minimum execution time: 41_541_000 picoseconds. + Weight::from_parts(43_640_322, 12636) + // Standard Error: 104 + .saturating_add(Weight::from_parts(2_178, 0).saturating_mul(b.into())) + // Standard Error: 1_101 + .saturating_add(Weight::from_parts(20_512, 0).saturating_mul(m.into())) + // Standard Error: 1_073 + .saturating_add(Weight::from_parts(133_112, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 4).saturating_mul(b.into())) @@ -488,14 +491,14 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `646 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `7095 + m * (325 ±0) + p * (180 ±0)` - // Minimum execution time: 28_858 nanoseconds. - Weight::from_parts(28_050_047, 7095) - // Standard Error: 614 - .saturating_add(Weight::from_parts(34_031, 0).saturating_mul(m.into())) - // Standard Error: 599 - .saturating_add(Weight::from_parts(85_744, 0).saturating_mul(p.into())) + // Measured: `550 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `10570 + m * (325 ±0) + p * (180 ±0)` + // Minimum execution time: 32_773_000 picoseconds. + Weight::from_parts(33_031_550, 10570) + // Standard Error: 1_205 + .saturating_add(Weight::from_parts(26_143, 0).saturating_mul(m.into())) + // Standard Error: 1_175 + .saturating_add(Weight::from_parts(137_503, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 325).saturating_mul(m.into())) @@ -516,16 +519,16 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `982 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `10565 + b * (5 ±0) + m * (330 ±0) + p * (200 ±0)` - // Minimum execution time: 38_608 nanoseconds. - Weight::from_parts(39_948_329, 10565) - // Standard Error: 84 - .saturating_add(Weight::from_parts(2_045, 0).saturating_mul(b.into())) - // Standard Error: 895 - .saturating_add(Weight::from_parts(22_669, 0).saturating_mul(m.into())) - // Standard Error: 872 - .saturating_add(Weight::from_parts(95_525, 0).saturating_mul(p.into())) + // Measured: `852 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `14905 + b * (5 ±0) + m * (330 ±0) + p * (200 ±0)` + // Minimum execution time: 44_855_000 picoseconds. + Weight::from_parts(47_307_460, 14905) + // Standard Error: 100 + .saturating_add(Weight::from_parts(1_536, 0).saturating_mul(b.into())) + // Standard Error: 1_065 + .saturating_add(Weight::from_parts(20_549, 0).saturating_mul(m.into())) + // Standard Error: 1_038 + .saturating_add(Weight::from_parts(133_143, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(b.into())) @@ -541,12 +544,12 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn disapprove_proposal(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `391 + p * (32 ±0)` - // Estimated: `1668 + p * (96 ±0)` - // Minimum execution time: 14_785 nanoseconds. - Weight::from_parts(16_393_818, 1668) - // Standard Error: 612 - .saturating_add(Weight::from_parts(76_786, 0).saturating_mul(p.into())) + // Measured: `359 + p * (32 ±0)` + // Estimated: `2562 + p * (96 ±0)` + // Minimum execution time: 16_420_000 picoseconds. + Weight::from_parts(18_236_525, 2562) + // Standard Error: 894 + .saturating_add(Weight::from_parts(115_590, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 96).saturating_mul(p.into())) diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index 14e680fb6a0ed..ae8638eb73431 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -18,26 +18,28 @@ //! Autogenerated weights for pallet_contracts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-02-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/benchbot/cargo_target_dir/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_contracts +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_contracts -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/contracts/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -177,10 +179,9 @@ impl WeightInfo for SubstrateWeight { fn on_process_deletion_queue_batch() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `604` - // Minimum execution time: 2_591 nanoseconds. - Weight::from_parts(2_817_000, 0) - .saturating_add(Weight::from_parts(0, 604)) + // Estimated: `1594` + // Minimum execution time: 2_679_000 picoseconds. + Weight::from_parts(2_907_000, 1594) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Skipped Metadata (r:0 w:0) @@ -188,14 +189,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `481 + k * (69 ±0)` - // Estimated: `471 + k * (70 ±0)` - // Minimum execution time: 10_190 nanoseconds. - Weight::from_parts(6_642_117, 0) - .saturating_add(Weight::from_parts(0, 471)) - // Standard Error: 992 - .saturating_add(Weight::from_parts(919_828, 0).saturating_mul(k.into())) + // Measured: `450 + k * (69 ±0)` + // Estimated: `440 + k * (70 ±0)` + // Minimum execution time: 11_162_000 picoseconds. + Weight::from_parts(5_734_923, 440) + // Standard Error: 1_097 + .saturating_add(Weight::from_parts(976_647, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(k.into())) @@ -205,13 +206,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `q` is `[0, 128]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `281 + q * (33 ±0)` - // Estimated: `763 + q * (33 ±0)` - // Minimum execution time: 2_598 nanoseconds. - Weight::from_parts(10_288_252, 0) - .saturating_add(Weight::from_parts(0, 763)) - // Standard Error: 2_886 - .saturating_add(Weight::from_parts(1_092_420, 0).saturating_mul(q.into())) + // Measured: `250 + q * (33 ±0)` + // Estimated: `1725 + q * (33 ±0)` + // Minimum execution time: 2_626_000 picoseconds. + Weight::from_parts(10_626_314, 1725) + // Standard Error: 4_006 + .saturating_add(Weight::from_parts(1_298_864, 0).saturating_mul(q.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 33).saturating_mul(q.into())) @@ -223,13 +223,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 61717]`. fn reinstrument(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `270 + c * (1 ±0)` - // Estimated: `3025 + c * (2 ±0)` - // Minimum execution time: 34_338 nanoseconds. - Weight::from_parts(32_159_677, 0) - .saturating_add(Weight::from_parts(0, 3025)) - // Standard Error: 53 - .saturating_add(Weight::from_parts(51_034, 0).saturating_mul(c.into())) + // Measured: `238 + c * (1 ±0)` + // Estimated: `3951 + c * (2 ±0)` + // Minimum execution time: 31_434_000 picoseconds. + Weight::from_parts(29_558_961, 3951) + // Standard Error: 55 + .saturating_add(Weight::from_parts(50_774, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 2).saturating_mul(c.into())) @@ -247,13 +246,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `803` - // Estimated: `16930 + c * (5 ±0)` - // Minimum execution time: 385_587 nanoseconds. - Weight::from_parts(395_545_811, 0) - .saturating_add(Weight::from_parts(0, 16930)) - // Standard Error: 27 - .saturating_add(Weight::from_parts(31_342, 0).saturating_mul(c.into())) + // Measured: `707` + // Estimated: `21400 + c * (5 ±0)` + // Minimum execution time: 309_015_000 picoseconds. + Weight::from_parts(318_740_885, 21400) + // Standard Error: 29 + .saturating_add(Weight::from_parts(30_993, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(c.into())) @@ -280,16 +278,15 @@ impl WeightInfo for SubstrateWeight { fn instantiate_with_code(c: u32, i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `270` - // Estimated: `20267` - // Minimum execution time: 3_799_742 nanoseconds. - Weight::from_parts(670_115_588, 0) - .saturating_add(Weight::from_parts(0, 20267)) - // Standard Error: 287 - .saturating_add(Weight::from_parts(93_885, 0).saturating_mul(c.into())) - // Standard Error: 16 - .saturating_add(Weight::from_parts(1_367, 0).saturating_mul(i.into())) - // Standard Error: 16 - .saturating_add(Weight::from_parts(1_781, 0).saturating_mul(s.into())) + // Estimated: `26207` + // Minimum execution time: 3_126_495_000 picoseconds. + Weight::from_parts(636_857_878, 26207) + // Standard Error: 294 + .saturating_add(Weight::from_parts(92_930, 0).saturating_mul(c.into())) + // Standard Error: 17 + .saturating_add(Weight::from_parts(1_128, 0).saturating_mul(i.into())) + // Standard Error: 17 + .saturating_add(Weight::from_parts(1_415, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } @@ -311,15 +308,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `546` - // Estimated: `22039` - // Minimum execution time: 1_949_008 nanoseconds. - Weight::from_parts(214_033_418, 0) - .saturating_add(Weight::from_parts(0, 22039)) + // Measured: `482` + // Estimated: `28521` + // Minimum execution time: 1_591_415_000 picoseconds. + Weight::from_parts(228_633_516, 28521) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_666, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_449, 0).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_801, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_444, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -335,11 +331,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) fn call() -> Weight { // Proof Size summary in bytes: - // Measured: `855` - // Estimated: `17145` - // Minimum execution time: 146_654 nanoseconds. - Weight::from_parts(147_528_000, 0) - .saturating_add(Weight::from_parts(0, 17145)) + // Measured: `759` + // Estimated: `21615` + // Minimum execution time: 167_905_000 picoseconds. + Weight::from_parts(169_247_000, 21615) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -355,12 +350,11 @@ impl WeightInfo for SubstrateWeight { fn upload_code(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `5386` - // Minimum execution time: 387_889 nanoseconds. - Weight::from_parts(391_379_335, 0) - .saturating_add(Weight::from_parts(0, 5386)) - // Standard Error: 89 - .saturating_add(Weight::from_parts(94_810, 0).saturating_mul(c.into())) + // Estimated: `7366` + // Minimum execution time: 305_128_000 picoseconds. + Weight::from_parts(310_911_395, 7366) + // Standard Error: 70 + .saturating_add(Weight::from_parts(94_067, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -374,11 +368,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `287` - // Estimated: `6098` - // Minimum execution time: 26_014 nanoseconds. - Weight::from_parts(26_510_000, 0) - .saturating_add(Weight::from_parts(0, 6098)) + // Measured: `255` + // Estimated: `7950` + // Minimum execution time: 29_605_000 picoseconds. + Weight::from_parts(29_986_000, 7950) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -390,11 +383,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `666` - // Estimated: `16848` - // Minimum execution time: 30_177 nanoseconds. - Weight::from_parts(30_639_000, 0) - .saturating_add(Weight::from_parts(0, 16848)) + // Measured: `570` + // Estimated: `19530` + // Minimum execution time: 33_824_000 picoseconds. + Weight::from_parts(34_388_000, 19530) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -411,13 +403,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_caller(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `877 + r * (480 ±0)` - // Estimated: `17295 + r * (2400 ±0)` - // Minimum execution time: 373_786 nanoseconds. - Weight::from_parts(377_332_691, 0) - .saturating_add(Weight::from_parts(0, 17295)) - // Standard Error: 51_211 - .saturating_add(Weight::from_parts(17_715_615, 0).saturating_mul(r.into())) + // Measured: `781 + r * (480 ±0)` + // Estimated: `21765 + r * (2400 ±0)` + // Minimum execution time: 295_283_000 picoseconds. + Weight::from_parts(295_895_211, 21765) + // Standard Error: 44_860 + .saturating_add(Weight::from_parts(22_913_078, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -435,17 +426,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_is_contract(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `917 + r * (21778 ±0)` - // Estimated: `17295 + r * (306895 ±0)` - // Minimum execution time: 374_009 nanoseconds. - Weight::from_parts(238_991_986, 0) - .saturating_add(Weight::from_parts(0, 17295)) - // Standard Error: 464_711 - .saturating_add(Weight::from_parts(249_099_538, 0).saturating_mul(r.into())) + // Measured: `821 + r * (19218 ±0)` + // Estimated: `21765 + r * (294095 ±0)` + // Minimum execution time: 295_760_000 picoseconds. + Weight::from_parts(151_512_811, 21765) + // Standard Error: 522_974 + .saturating_add(Weight::from_parts(263_028_353, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 306895).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 294095).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -460,17 +450,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `921 + r * (22099 ±0)` - // Estimated: `17340 + r * (308500 ±0)` - // Minimum execution time: 375_058 nanoseconds. - Weight::from_parts(238_765_068, 0) - .saturating_add(Weight::from_parts(0, 17340)) - // Standard Error: 662_617 - .saturating_add(Weight::from_parts(302_175_089, 0).saturating_mul(r.into())) + // Measured: `825 + r * (19539 ±0)` + // Estimated: `21810 + r * (295700 ±0)` + // Minimum execution time: 295_950_000 picoseconds. + Weight::from_parts(164_516_076, 21810) + // Standard Error: 469_540 + .saturating_add(Weight::from_parts(321_138_601, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 308500).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 295700).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -485,13 +474,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_own_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `884 + r * (480 ±0)` - // Estimated: `17330 + r * (2400 ±0)` - // Minimum execution time: 374_747 nanoseconds. - Weight::from_parts(376_482_380, 0) - .saturating_add(Weight::from_parts(0, 17330)) - // Standard Error: 61_919 - .saturating_add(Weight::from_parts(22_376_795, 0).saturating_mul(r.into())) + // Measured: `788 + r * (480 ±0)` + // Estimated: `21800 + r * (2400 ±0)` + // Minimum execution time: 295_916_000 picoseconds. + Weight::from_parts(299_964_913, 21800) + // Standard Error: 78_211 + .saturating_add(Weight::from_parts(28_933_603, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -509,13 +497,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_caller_is_origin(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874 + r * (240 ±0)` - // Estimated: `17265 + r * (1200 ±0)` - // Minimum execution time: 372_287 nanoseconds. - Weight::from_parts(376_250_858, 0) - .saturating_add(Weight::from_parts(0, 17265)) - // Standard Error: 40_119 - .saturating_add(Weight::from_parts(11_359_647, 0).saturating_mul(r.into())) + // Measured: `778 + r * (240 ±0)` + // Estimated: `21735 + r * (1200 ±0)` + // Minimum execution time: 293_588_000 picoseconds. + Weight::from_parts(297_568_984, 21735) + // Standard Error: 35_513 + .saturating_add(Weight::from_parts(11_074_880, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1200).saturating_mul(r.into())) @@ -533,13 +520,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `878 + r * (480 ±0)` - // Estimated: `17260 + r * (2400 ±0)` - // Minimum execution time: 374_445 nanoseconds. - Weight::from_parts(377_243_521, 0) - .saturating_add(Weight::from_parts(0, 17260)) - // Standard Error: 53_032 - .saturating_add(Weight::from_parts(17_684_246, 0).saturating_mul(r.into())) + // Measured: `782 + r * (480 ±0)` + // Estimated: `21730 + r * (2400 ±0)` + // Minimum execution time: 294_929_000 picoseconds. + Weight::from_parts(295_916_817, 21730) + // Standard Error: 64_902 + .saturating_add(Weight::from_parts(22_944_018, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -557,13 +543,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_gas_left(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `879 + r * (480 ±0)` - // Estimated: `17250 + r * (2405 ±0)` - // Minimum execution time: 374_029 nanoseconds. - Weight::from_parts(380_415_186, 0) - .saturating_add(Weight::from_parts(0, 17250)) - // Standard Error: 60_562 - .saturating_add(Weight::from_parts(17_152_599, 0).saturating_mul(r.into())) + // Measured: `783 + r * (480 ±0)` + // Estimated: `21720 + r * (2405 ±0)` + // Minimum execution time: 296_783_000 picoseconds. + Weight::from_parts(299_399_332, 21720) + // Standard Error: 50_982 + .saturating_add(Weight::from_parts(22_173_249, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2405).saturating_mul(r.into())) @@ -581,16 +566,15 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1049 + r * (480 ±0)` - // Estimated: `19849 + r * (2456 ±0)` - // Minimum execution time: 373_999 nanoseconds. - Weight::from_parts(381_757_033, 0) - .saturating_add(Weight::from_parts(0, 19849)) - // Standard Error: 97_983 - .saturating_add(Weight::from_parts(98_290_984, 0).saturating_mul(r.into())) + // Measured: `921 + r * (480 ±0)` + // Estimated: `24193 + r * (2451 ±0)` + // Minimum execution time: 294_120_000 picoseconds. + Weight::from_parts(305_889_989, 24193) + // Standard Error: 116_244 + .saturating_add(Weight::from_parts(114_781_094, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2456).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2451).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -605,13 +589,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_value_transferred(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `888 + r * (480 ±0)` - // Estimated: `17360 + r * (2400 ±0)` - // Minimum execution time: 374_197 nanoseconds. - Weight::from_parts(377_755_896, 0) - .saturating_add(Weight::from_parts(0, 17360)) - // Standard Error: 60_542 - .saturating_add(Weight::from_parts(17_442_065, 0).saturating_mul(r.into())) + // Measured: `792 + r * (480 ±0)` + // Estimated: `21830 + r * (2400 ±0)` + // Minimum execution time: 295_569_000 picoseconds. + Weight::from_parts(299_774_774, 21830) + // Standard Error: 46_252 + .saturating_add(Weight::from_parts(21_753_842, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -629,13 +612,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_minimum_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `886 + r * (480 ±0)` - // Estimated: `17290 + r * (2400 ±0)` - // Minimum execution time: 373_888 nanoseconds. - Weight::from_parts(377_825_771, 0) - .saturating_add(Weight::from_parts(0, 17290)) - // Standard Error: 38_026 - .saturating_add(Weight::from_parts(17_147_903, 0).saturating_mul(r.into())) + // Measured: `790 + r * (480 ±0)` + // Estimated: `21760 + r * (2400 ±0)` + // Minimum execution time: 295_400_000 picoseconds. + Weight::from_parts(300_637_266, 21760) + // Standard Error: 41_263 + .saturating_add(Weight::from_parts(21_565_466, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -653,13 +635,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_block_number(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `883 + r * (480 ±0)` - // Estimated: `17315 + r * (2400 ±0)` - // Minimum execution time: 373_904 nanoseconds. - Weight::from_parts(378_652_372, 0) - .saturating_add(Weight::from_parts(0, 17315)) - // Standard Error: 43_833 - .saturating_add(Weight::from_parts(16_936_781, 0).saturating_mul(r.into())) + // Measured: `787 + r * (480 ±0)` + // Estimated: `21785 + r * (2400 ±0)` + // Minimum execution time: 294_696_000 picoseconds. + Weight::from_parts(297_196_796, 21785) + // Standard Error: 61_173 + .saturating_add(Weight::from_parts(21_903_191, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -677,13 +658,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_now(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874 + r * (480 ±0)` - // Estimated: `17245 + r * (2400 ±0)` - // Minimum execution time: 373_473 nanoseconds. - Weight::from_parts(376_386_312, 0) - .saturating_add(Weight::from_parts(0, 17245)) - // Standard Error: 46_945 - .saturating_add(Weight::from_parts(17_336_462, 0).saturating_mul(r.into())) + // Measured: `778 + r * (480 ±0)` + // Estimated: `21715 + r * (2400 ±0)` + // Minimum execution time: 297_714_000 picoseconds. + Weight::from_parts(306_030_237, 21715) + // Standard Error: 69_984 + .saturating_add(Weight::from_parts(21_744_413, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -703,13 +683,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_weight_to_fee(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `951 + r * (800 ±0)` - // Estimated: `19046 + r * (4805 ±0)` - // Minimum execution time: 373_661 nanoseconds. - Weight::from_parts(385_824_015, 0) - .saturating_add(Weight::from_parts(0, 19046)) - // Standard Error: 75_964 - .saturating_add(Weight::from_parts(88_530_074, 0).saturating_mul(r.into())) + // Measured: `856 + r * (800 ±0)` + // Estimated: `24416 + r * (4805 ±0)` + // Minimum execution time: 295_180_000 picoseconds. + Weight::from_parts(308_851_025, 24416) + // Standard Error: 115_126 + .saturating_add(Weight::from_parts(98_678_404, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 4805).saturating_mul(r.into())) @@ -727,13 +706,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_gas(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `841 + r * (320 ±0)` - // Estimated: `17120 + r * (1600 ±0)` - // Minimum execution time: 133_849 nanoseconds. - Weight::from_parts(137_283_391, 0) - .saturating_add(Weight::from_parts(0, 17120)) - // Standard Error: 13_312 - .saturating_add(Weight::from_parts(8_055_328, 0).saturating_mul(r.into())) + // Measured: `745 + r * (320 ±0)` + // Estimated: `21590 + r * (1600 ±0)` + // Minimum execution time: 151_587_000 picoseconds. + Weight::from_parts(155_713_096, 21590) + // Standard Error: 32_464 + .saturating_add(Weight::from_parts(8_332_778, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1600).saturating_mul(r.into())) @@ -751,13 +729,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_input(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `876 + r * (480 ±0)` - // Estimated: `17245 + r * (2400 ±0)` - // Minimum execution time: 373_468 nanoseconds. - Weight::from_parts(376_121_093, 0) - .saturating_add(Weight::from_parts(0, 17245)) - // Standard Error: 61_857 - .saturating_add(Weight::from_parts(15_868_414, 0).saturating_mul(r.into())) + // Measured: `780 + r * (480 ±0)` + // Estimated: `21715 + r * (2400 ±0)` + // Minimum execution time: 295_008_000 picoseconds. + Weight::from_parts(297_982_800, 21715) + // Standard Error: 37_480 + .saturating_add(Weight::from_parts(17_970_520, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -775,13 +752,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1024]`. fn seal_input_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1356` - // Estimated: `19650` - // Minimum execution time: 390_668 nanoseconds. - Weight::from_parts(419_608_449, 0) - .saturating_add(Weight::from_parts(0, 19650)) - // Standard Error: 4_890 - .saturating_add(Weight::from_parts(9_672_288, 0).saturating_mul(n.into())) + // Measured: `1260` + // Estimated: `24120` + // Minimum execution time: 314_970_000 picoseconds. + Weight::from_parts(345_339_508, 24120) + // Standard Error: 4_112 + .saturating_add(Weight::from_parts(9_746_966, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -798,13 +774,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `864 + r * (45 ±0)` - // Estimated: `17190 + r * (225 ±0)` - // Minimum execution time: 371_309 nanoseconds. - Weight::from_parts(373_625_402, 0) - .saturating_add(Weight::from_parts(0, 17190)) - // Standard Error: 419_605 - .saturating_add(Weight::from_parts(1_737_397, 0).saturating_mul(r.into())) + // Measured: `768 + r * (45 ±0)` + // Estimated: `21660 + r * (225 ±0)` + // Minimum execution time: 293_072_000 picoseconds. + Weight::from_parts(295_694_824, 21660) + // Standard Error: 219_523 + .saturating_add(Weight::from_parts(783_975, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 225).saturating_mul(r.into())) @@ -822,13 +797,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1024]`. fn seal_return_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874` - // Estimated: `17285` - // Minimum execution time: 374_094 nanoseconds. - Weight::from_parts(375_965_200, 0) - .saturating_add(Weight::from_parts(0, 17285)) - // Standard Error: 1_127 - .saturating_add(Weight::from_parts(232_645, 0).saturating_mul(n.into())) + // Measured: `778` + // Estimated: `21755` + // Minimum execution time: 295_959_000 picoseconds. + Weight::from_parts(299_004_761, 21755) + // Standard Error: 3_988 + .saturating_add(Weight::from_parts(194_268, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -849,18 +823,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `906 + r * (452 ±0)` - // Estimated: `20242 + r * (15004 ±0)` - // Minimum execution time: 373_123 nanoseconds. - Weight::from_parts(374_924_634, 0) - .saturating_add(Weight::from_parts(0, 20242)) - // Standard Error: 378_010 - .saturating_add(Weight::from_parts(70_441_665, 0).saturating_mul(r.into())) + // Measured: `810 + r * (356 ±0)` + // Estimated: `25511 + r * (15321 ±0)` + // Minimum execution time: 294_626_000 picoseconds. + Weight::from_parts(297_839_179, 25511) + // Standard Error: 707_428 + .saturating_add(Weight::from_parts(81_507_620, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 15004).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 15321).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -877,13 +850,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_random(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `921 + r * (800 ±0)` - // Estimated: `18835 + r * (4805 ±0)` - // Minimum execution time: 373_291 nanoseconds. - Weight::from_parts(385_684_344, 0) - .saturating_add(Weight::from_parts(0, 18835)) - // Standard Error: 99_025 - .saturating_add(Weight::from_parts(111_308_793, 0).saturating_mul(r.into())) + // Measured: `825 + r * (800 ±0)` + // Estimated: `24199 + r * (4805 ±0)` + // Minimum execution time: 295_431_000 picoseconds. + Weight::from_parts(310_428_531, 24199) + // Standard Error: 143_501 + .saturating_add(Weight::from_parts(136_529_376, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 4805).saturating_mul(r.into())) @@ -901,13 +873,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_deposit_event(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874 + r * (800 ±0)` - // Estimated: `17250 + r * (4000 ±0)` - // Minimum execution time: 371_900 nanoseconds. - Weight::from_parts(384_166_626, 0) - .saturating_add(Weight::from_parts(0, 17250)) - // Standard Error: 205_255 - .saturating_add(Weight::from_parts(229_214_157, 0).saturating_mul(r.into())) + // Measured: `778 + r * (800 ±0)` + // Estimated: `21720 + r * (4000 ±0)` + // Minimum execution time: 293_778_000 picoseconds. + Weight::from_parts(323_404_081, 21720) + // Standard Error: 243_095 + .saturating_add(Weight::from_parts(269_012_482, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 4000).saturating_mul(r.into())) @@ -926,15 +897,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16]`. fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1821 + t * (2608 ±0) + n * (7 ±0)` - // Estimated: `21870 + t * (211030 ±0) + n * (50 ±0)` - // Minimum execution time: 1_289_873 nanoseconds. - Weight::from_parts(581_702_206, 0) - .saturating_add(Weight::from_parts(0, 21870)) - // Standard Error: 665_638 - .saturating_add(Weight::from_parts(181_470_553, 0).saturating_mul(t.into())) - // Standard Error: 182_816 - .saturating_add(Weight::from_parts(71_635_250, 0).saturating_mul(n.into())) + // Measured: `1725 + t * (2608 ±0) + n * (7 ±0)` + // Estimated: `26340 + t * (211030 ±0) + n * (50 ±0)` + // Minimum execution time: 1_317_129_000 picoseconds. + Weight::from_parts(566_722_295, 26340) + // Standard Error: 619_390 + .saturating_add(Weight::from_parts(194_334_643, 0).saturating_mul(t.into())) + // Standard Error: 170_114 + .saturating_add(Weight::from_parts(67_458_751, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -955,13 +925,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_debug_message(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (560 ±0)` - // Estimated: `17240 + r * (2800 ±0)` - // Minimum execution time: 148_635 nanoseconds. - Weight::from_parts(154_095_712, 0) - .saturating_add(Weight::from_parts(0, 17240)) - // Standard Error: 77_790 - .saturating_add(Weight::from_parts(14_837_085, 0).saturating_mul(r.into())) + // Measured: `777 + r * (560 ±0)` + // Estimated: `21710 + r * (2800 ±0)` + // Minimum execution time: 159_087_000 picoseconds. + Weight::from_parts(163_703_981, 21710) + // Standard Error: 26_067 + .saturating_add(Weight::from_parts(14_810_256, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2800).saturating_mul(r.into())) @@ -979,13 +948,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 1024]`. fn seal_debug_message_per_kb(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `125824` - // Estimated: `265128` - // Minimum execution time: 501_014 nanoseconds. - Weight::from_parts(505_634_218, 0) - .saturating_add(Weight::from_parts(0, 265128)) - // Standard Error: 2_441 - .saturating_add(Weight::from_parts(819_257, 0).saturating_mul(i.into())) + // Measured: `125728` + // Estimated: `269982` + // Minimum execution time: 413_391_000 picoseconds. + Weight::from_parts(414_927_640, 269982) + // Standard Error: 1_740 + .saturating_add(Weight::from_parts(763_359, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -994,13 +962,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 10]`. fn seal_set_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `911 + r * (23420 ±0)` - // Estimated: `911 + r * (23418 ±0)` - // Minimum execution time: 375_301 nanoseconds. - Weight::from_parts(291_498_841, 0) - .saturating_add(Weight::from_parts(0, 911)) - // Standard Error: 809_989 - .saturating_add(Weight::from_parts(464_550_291, 0).saturating_mul(r.into())) + // Measured: `815 + r * (23420 ±0)` + // Estimated: `815 + r * (23418 ±0)` + // Minimum execution time: 296_108_000 picoseconds. + Weight::from_parts(208_214_040, 815) + // Standard Error: 860_573 + .saturating_add(Weight::from_parts(480_342_550, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1012,13 +979,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_new_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `12672 + n * (11945 ±0)` - // Estimated: `8529 + n * (12814 ±61)` - // Minimum execution time: 506_318 nanoseconds. - Weight::from_parts(676_935_313, 0) - .saturating_add(Weight::from_parts(0, 8529)) - // Standard Error: 1_589_291 - .saturating_add(Weight::from_parts(97_839_399, 0).saturating_mul(n.into())) + // Measured: `12544 + n * (11945 ±0)` + // Estimated: `8401 + n * (12814 ±61)` + // Minimum execution time: 442_286_000 picoseconds. + Weight::from_parts(620_395_299, 8401) + // Standard Error: 1_661_554 + .saturating_add(Weight::from_parts(89_393_169, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(52_u64)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(50_u64)) @@ -1030,31 +996,29 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_old_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `15170 + n * (175775 ±0)` - // Estimated: `9914 + n * (176858 ±74)` - // Minimum execution time: 506_148 nanoseconds. - Weight::from_parts(648_278_778, 0) - .saturating_add(Weight::from_parts(0, 9914)) - // Standard Error: 1_343_586 - .saturating_add(Weight::from_parts(65_789_595, 0).saturating_mul(n.into())) + // Measured: `12532 + n * (175784 ±0)` + // Estimated: `8396 + n * (176649 ±61)` + // Minimum execution time: 440_882_000 picoseconds. + Weight::from_parts(587_317_981, 8396) + // Standard Error: 1_374_991 + .saturating_add(Weight::from_parts(66_271_084, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(51_u64)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(49_u64)) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 176858).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 176649).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 10]`. fn seal_clear_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `903 + r * (23099 ±0)` - // Estimated: `908 + r * (23099 ±0)` - // Minimum execution time: 374_344 nanoseconds. - Weight::from_parts(293_272_061, 0) - .saturating_add(Weight::from_parts(0, 908)) - // Standard Error: 810_412 - .saturating_add(Weight::from_parts(453_315_956, 0).saturating_mul(r.into())) + // Measured: `807 + r * (23099 ±0)` + // Estimated: `812 + r * (23099 ±0)` + // Minimum execution time: 296_023_000 picoseconds. + Weight::from_parts(221_471_559, 812) + // Standard Error: 814_503 + .saturating_add(Weight::from_parts(465_928_089, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1066,31 +1030,29 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 8]`. fn seal_clear_storage_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `14895 + n * (175768 ±0)` - // Estimated: `9551 + n * (176867 ±75)` - // Minimum execution time: 478_564 nanoseconds. - Weight::from_parts(630_839_142, 0) - .saturating_add(Weight::from_parts(0, 9551)) - // Standard Error: 1_427_520 - .saturating_add(Weight::from_parts(66_813_592, 0).saturating_mul(n.into())) + // Measured: `12256 + n * (175776 ±0)` + // Estimated: `8047 + n * (176655 ±62)` + // Minimum execution time: 412_212_000 picoseconds. + Weight::from_parts(569_213_147, 8047) + // Standard Error: 1_463_771 + .saturating_add(Weight::from_parts(67_932_081, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(51_u64)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(48_u64)) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 176867).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 176655).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 10]`. fn seal_get_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `896 + r * (23744 ±0)` - // Estimated: `909 + r * (23740 ±0)` - // Minimum execution time: 374_479 nanoseconds. - Weight::from_parts(311_839_315, 0) - .saturating_add(Weight::from_parts(0, 909)) - // Standard Error: 666_553 - .saturating_add(Weight::from_parts(371_213_042, 0).saturating_mul(r.into())) + // Measured: `800 + r * (23744 ±0)` + // Estimated: `813 + r * (23740 ±0)` + // Minimum execution time: 296_007_000 picoseconds. + Weight::from_parts(229_100_700, 813) + // Standard Error: 684_970 + .saturating_add(Weight::from_parts(394_982_991, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1101,30 +1063,28 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 8]`. fn seal_get_storage_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `15501 + n * (175775 ±0)` - // Estimated: `10042 + n * (176900 ±76)` - // Minimum execution time: 460_639 nanoseconds. - Weight::from_parts(591_187_094, 0) - .saturating_add(Weight::from_parts(0, 10042)) - // Standard Error: 1_233_792 - .saturating_add(Weight::from_parts(160_874_477, 0).saturating_mul(n.into())) + // Measured: `12863 + n * (175784 ±0)` + // Estimated: `8538 + n * (176688 ±63)` + // Minimum execution time: 392_306_000 picoseconds. + Weight::from_parts(539_188_004, 8538) + // Standard Error: 1_371_839 + .saturating_add(Weight::from_parts(155_130_373, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(51_u64)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 176900).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 176688).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 10]`. fn seal_contains_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `914 + r * (23098 ±0)` - // Estimated: `920 + r * (23098 ±0)` - // Minimum execution time: 374_272 nanoseconds. - Weight::from_parts(311_446_269, 0) - .saturating_add(Weight::from_parts(0, 920)) - // Standard Error: 630_307 - .saturating_add(Weight::from_parts(357_134_931, 0).saturating_mul(r.into())) + // Measured: `818 + r * (23098 ±0)` + // Estimated: `824 + r * (23098 ±0)` + // Minimum execution time: 296_038_000 picoseconds. + Weight::from_parts(229_462_798, 824) + // Standard Error: 655_463 + .saturating_add(Weight::from_parts(372_593_685, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1135,30 +1095,28 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 8]`. fn seal_contains_storage_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `14839 + n * (175789 ±0)` - // Estimated: `9532 + n * (176874 ±75)` - // Minimum execution time: 456_013 nanoseconds. - Weight::from_parts(575_116_352, 0) - .saturating_add(Weight::from_parts(0, 9532)) - // Standard Error: 1_122_298 - .saturating_add(Weight::from_parts(61_786_107, 0).saturating_mul(n.into())) + // Measured: `12200 + n * (175798 ±0)` + // Estimated: `8028 + n * (176661 ±62)` + // Minimum execution time: 386_782_000 picoseconds. + Weight::from_parts(512_965_975, 8028) + // Standard Error: 1_168_132 + .saturating_add(Weight::from_parts(63_307_325, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(51_u64)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 176874).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 176661).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 10]`. fn seal_take_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `911 + r * (23740 ±0)` - // Estimated: `913 + r * (23739 ±0)` - // Minimum execution time: 374_621 nanoseconds. - Weight::from_parts(299_689_489, 0) - .saturating_add(Weight::from_parts(0, 913)) - // Standard Error: 757_735 - .saturating_add(Weight::from_parts(465_213_246, 0).saturating_mul(r.into())) + // Measured: `815 + r * (23740 ±0)` + // Estimated: `817 + r * (23739 ±0)` + // Minimum execution time: 296_352_000 picoseconds. + Weight::from_parts(212_661_296, 817) + // Standard Error: 879_297 + .saturating_add(Weight::from_parts(494_182_672, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1170,18 +1128,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 8]`. fn seal_take_storage_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `15502 + n * (175775 ±0)` - // Estimated: `10042 + n * (176898 ±76)` - // Minimum execution time: 481_980 nanoseconds. - Weight::from_parts(647_289_053, 0) - .saturating_add(Weight::from_parts(0, 10042)) - // Standard Error: 1_556_155 - .saturating_add(Weight::from_parts(166_592_657, 0).saturating_mul(n.into())) + // Measured: `12864 + n * (175784 ±0)` + // Estimated: `8539 + n * (176686 ±63)` + // Minimum execution time: 414_693_000 picoseconds. + Weight::from_parts(595_693_859, 8539) + // Standard Error: 1_673_819 + .saturating_add(Weight::from_parts(163_090_316, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(51_u64)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(48_u64)) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 176898).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 176686).saturating_mul(n.into())) } /// Storage: System Account (r:1602 w:1601) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1196,18 +1153,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_transfer(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1457 + r * (3604 ±0)` - // Estimated: `21583 + r * (216101 ±0)` - // Minimum execution time: 374_962 nanoseconds. - Weight::from_parts(313_416_386, 0) - .saturating_add(Weight::from_parts(0, 21583)) - // Standard Error: 710_675 - .saturating_add(Weight::from_parts(1_396_551_156, 0).saturating_mul(r.into())) + // Measured: `1329 + r * (3604 ±0)` + // Estimated: `25928 + r * (216096 ±4)` + // Minimum execution time: 299_205_000 picoseconds. + Weight::from_parts(221_142_217, 25928) + // Standard Error: 1_369_909 + .saturating_add(Weight::from_parts(1_665_917_241, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 216101).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 216096).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1222,18 +1178,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1609 + r * (23073 ±0)` - // Estimated: `22098 + r * (511456 ±1)` - // Minimum execution time: 375_916 nanoseconds. - Weight::from_parts(376_468_000, 0) - .saturating_add(Weight::from_parts(0, 22098)) - // Standard Error: 7_246_855 - .saturating_add(Weight::from_parts(28_982_425_139, 0).saturating_mul(r.into())) + // Measured: `1479 + r * (20514 ±0)` + // Estimated: `26429 + r * (498656 ±1)` + // Minimum execution time: 297_501_000 picoseconds. + Weight::from_parts(298_400_000, 26429) + // Standard Error: 9_372_890 + .saturating_add(Weight::from_parts(22_507_984_433, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((160_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((160_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 511456).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 498656).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1248,18 +1203,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (71670 ±0)` - // Estimated: `17285 + r * (659930 ±563)` - // Minimum execution time: 375_412 nanoseconds. - Weight::from_parts(376_493_000, 0) - .saturating_add(Weight::from_parts(0, 17285)) - // Standard Error: 8_239_575 - .saturating_add(Weight::from_parts(28_716_347_183, 0).saturating_mul(r.into())) + // Measured: `0 + r * (69030 ±0)` + // Estimated: `21755 + r * (647542 ±560)` + // Minimum execution time: 297_432_000 picoseconds. + Weight::from_parts(298_220_000, 21755) + // Standard Error: 9_420_834 + .saturating_add(Weight::from_parts(22_261_152_353, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((150_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((75_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 659930).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 647542).saturating_mul(r.into())) } /// Storage: System Account (r:82 w:81) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1275,20 +1229,19 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 1024]`. fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `24269 + t * (16910 ±0)` - // Estimated: `532690 + t * (285025 ±0)` - // Minimum execution time: 10_443_315 nanoseconds. - Weight::from_parts(9_342_574_069, 0) - .saturating_add(Weight::from_parts(0, 532690)) - // Standard Error: 7_237_279 - .saturating_add(Weight::from_parts(1_390_221_936, 0).saturating_mul(t.into())) - // Standard Error: 10_851 - .saturating_add(Weight::from_parts(9_842_151, 0).saturating_mul(c.into())) + // Measured: `21581 + t * (14318 ±0)` + // Estimated: `524200 + t * (272065 ±0)` + // Minimum execution time: 11_799_802_000 picoseconds. + Weight::from_parts(10_575_328_547, 524200) + // Standard Error: 11_952_810 + .saturating_add(Weight::from_parts(1_603_077_083, 0).saturating_mul(t.into())) + // Standard Error: 17_922 + .saturating_add(Weight::from_parts(9_876_752, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(167_u64)) .saturating_add(T::DbWeight::get().reads((81_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(163_u64)) .saturating_add(T::DbWeight::get().writes((81_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 285025).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 272065).saturating_mul(t.into())) } /// Storage: System Account (r:3202 w:3202) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1307,18 +1260,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_instantiate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1775 + r * (25568 ±0)` - // Estimated: `26563 + r * (1367114 ±2)` - // Minimum execution time: 376_418 nanoseconds. - Weight::from_parts(377_292_000, 0) - .saturating_add(Weight::from_parts(0, 26563)) - // Standard Error: 32_312_545 - .saturating_add(Weight::from_parts(35_904_826_312, 0).saturating_mul(r.into())) + // Measured: `1646 + r * (20288 ±0)` + // Estimated: `32625 + r * (1330150 ±2)` + // Minimum execution time: 298_155_000 picoseconds. + Weight::from_parts(299_212_000, 32625) + // Standard Error: 32_410_313 + .saturating_add(Weight::from_parts(30_417_025_178, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((480_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(5_u64)) .saturating_add(T::DbWeight::get().writes((400_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 1367114).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 1330150).saturating_mul(r.into())) } /// Storage: System Account (r:162 w:162) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1339,22 +1291,21 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 960]`. fn seal_instantiate_per_transfer_input_salt_kb(t: u32, i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `5785 + t * (33 ±0)` - // Estimated: `850985 + t * (2671 ±3)` - // Minimum execution time: 132_157_340 nanoseconds. - Weight::from_parts(11_329_968_948, 0) - .saturating_add(Weight::from_parts(0, 850985)) - // Standard Error: 99_102_968 - .saturating_add(Weight::from_parts(84_719_458, 0).saturating_mul(t.into())) - // Standard Error: 161_609 - .saturating_add(Weight::from_parts(126_156_627, 0).saturating_mul(i.into())) - // Standard Error: 161_609 - .saturating_add(Weight::from_parts(126_628_313, 0).saturating_mul(s.into())) + // Measured: `5625 + t * (1 ±0)` + // Estimated: `856795 + t * (2471 ±3)` + // Minimum execution time: 105_914_928_000 picoseconds. + Weight::from_parts(13_229_760_432, 856795) + // Standard Error: 96_394_437 + .saturating_add(Weight::from_parts(398_413_888, 0).saturating_mul(t.into())) + // Standard Error: 157_192 + .saturating_add(Weight::from_parts(97_104_978, 0).saturating_mul(i.into())) + // Standard Error: 157_192 + .saturating_add(Weight::from_parts(97_146_130, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(329_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(326_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 2671).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 2471).saturating_mul(t.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1369,13 +1320,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `871 + r * (642 ±0)` - // Estimated: `17225 + r * (3210 ±0)` - // Minimum execution time: 373_559 nanoseconds. - Weight::from_parts(375_166_904, 0) - .saturating_add(Weight::from_parts(0, 17225)) - // Standard Error: 125_024 - .saturating_add(Weight::from_parts(42_291_595, 0).saturating_mul(r.into())) + // Measured: `775 + r * (642 ±0)` + // Estimated: `21695 + r * (3210 ±0)` + // Minimum execution time: 294_309_000 picoseconds. + Weight::from_parts(296_241_318, 21695) + // Standard Error: 127_872 + .saturating_add(Weight::from_parts(45_806_281, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3210).saturating_mul(r.into())) @@ -1393,13 +1343,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1024]`. fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1673` - // Estimated: `21160` - // Minimum execution time: 416_233 nanoseconds. - Weight::from_parts(416_785_000, 0) - .saturating_add(Weight::from_parts(0, 21160)) - // Standard Error: 56_223 - .saturating_add(Weight::from_parts(324_513_835, 0).saturating_mul(n.into())) + // Measured: `1577` + // Estimated: `25630` + // Minimum execution time: 341_248_000 picoseconds. + Weight::from_parts(341_607_000, 25630) + // Standard Error: 66_687 + .saturating_add(Weight::from_parts(322_250_398, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1416,13 +1365,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (642 ±0)` - // Estimated: `17235 + r * (3210 ±0)` - // Minimum execution time: 371_735 nanoseconds. - Weight::from_parts(375_979_430, 0) - .saturating_add(Weight::from_parts(0, 17235)) - // Standard Error: 968_037 - .saturating_add(Weight::from_parts(57_780_769, 0).saturating_mul(r.into())) + // Measured: `777 + r * (642 ±0)` + // Estimated: `21705 + r * (3210 ±0)` + // Minimum execution time: 293_810_000 picoseconds. + Weight::from_parts(296_719_171, 21705) + // Standard Error: 450_807 + .saturating_add(Weight::from_parts(61_627_228, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3210).saturating_mul(r.into())) @@ -1440,13 +1388,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1024]`. fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1675` - // Estimated: `21205` - // Minimum execution time: 428_196 nanoseconds. - Weight::from_parts(429_438_000, 0) - .saturating_add(Weight::from_parts(0, 21205)) - // Standard Error: 57_860 - .saturating_add(Weight::from_parts(260_917_896, 0).saturating_mul(n.into())) + // Measured: `1579` + // Estimated: `25675` + // Minimum execution time: 354_550_000 picoseconds. + Weight::from_parts(355_136_000, 25675) + // Standard Error: 61_761 + .saturating_add(Weight::from_parts(257_021_566, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1463,13 +1410,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (642 ±0)` - // Estimated: `17235 + r * (3210 ±0)` - // Minimum execution time: 371_412 nanoseconds. - Weight::from_parts(373_635_818, 0) - .saturating_add(Weight::from_parts(0, 17235)) - // Standard Error: 222_973 - .saturating_add(Weight::from_parts(33_347_181, 0).saturating_mul(r.into())) + // Measured: `777 + r * (642 ±0)` + // Estimated: `21705 + r * (3210 ±0)` + // Minimum execution time: 293_369_000 picoseconds. + Weight::from_parts(295_990_893, 21705) + // Standard Error: 431_269 + .saturating_add(Weight::from_parts(32_213_406, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3210).saturating_mul(r.into())) @@ -1487,13 +1433,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1675` - // Estimated: `21180` - // Minimum execution time: 405_858 nanoseconds. - Weight::from_parts(406_498_000, 0) - .saturating_add(Weight::from_parts(0, 21180)) - // Standard Error: 48_388 - .saturating_add(Weight::from_parts(103_283_157, 0).saturating_mul(n.into())) + // Measured: `1579` + // Estimated: `25650` + // Minimum execution time: 326_595_000 picoseconds. + Weight::from_parts(327_188_000, 25650) + // Standard Error: 53_385 + .saturating_add(Weight::from_parts(74_046_074, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1510,13 +1455,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (679 ±0)` - // Estimated: `17235 + r * (3395 ±0)` - // Minimum execution time: 371_746 nanoseconds. - Weight::from_parts(373_538_171, 0) - .saturating_add(Weight::from_parts(0, 17235)) - // Standard Error: 387_332 - .saturating_add(Weight::from_parts(35_933_528, 0).saturating_mul(r.into())) + // Measured: `777 + r * (679 ±0)` + // Estimated: `21705 + r * (3395 ±0)` + // Minimum execution time: 292_388_000 picoseconds. + Weight::from_parts(295_090_179, 21705) + // Standard Error: 170_487 + .saturating_add(Weight::from_parts(32_577_820, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3395).saturating_mul(r.into())) @@ -1534,13 +1478,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1675` - // Estimated: `21225` - // Minimum execution time: 405_752 nanoseconds. - Weight::from_parts(406_417_000, 0) - .saturating_add(Weight::from_parts(0, 21225)) - // Standard Error: 47_051 - .saturating_add(Weight::from_parts(103_325_027, 0).saturating_mul(n.into())) + // Measured: `1579` + // Estimated: `25695` + // Minimum execution time: 326_862_000 picoseconds. + Weight::from_parts(327_449_000, 25695) + // Standard Error: 54_539 + .saturating_add(Weight::from_parts(74_042_337, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1557,13 +1500,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `917 + r * (6083 ±0)` - // Estimated: `17455 + r * (30415 ±0)` - // Minimum execution time: 373_882 nanoseconds. - Weight::from_parts(376_553_787, 0) - .saturating_add(Weight::from_parts(0, 17455)) - // Standard Error: 912_833 - .saturating_add(Weight::from_parts(3_021_100_412, 0).saturating_mul(r.into())) + // Measured: `821 + r * (6083 ±0)` + // Estimated: `21925 + r * (30415 ±0)` + // Minimum execution time: 295_597_000 picoseconds. + Weight::from_parts(298_267_200, 21925) + // Standard Error: 699_824 + .saturating_add(Weight::from_parts(3_021_734_700, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30415).saturating_mul(r.into())) @@ -1581,13 +1523,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `886 + r * (3362 ±0)` - // Estimated: `17300 + r * (16810 ±0)` - // Minimum execution time: 373_673 nanoseconds. - Weight::from_parts(375_712_961, 0) - .saturating_add(Weight::from_parts(0, 17300)) - // Standard Error: 596_297 - .saturating_add(Weight::from_parts(738_257_638, 0).saturating_mul(r.into())) + // Measured: `790 + r * (3362 ±0)` + // Estimated: `21770 + r * (16810 ±0)` + // Minimum execution time: 295_539_000 picoseconds. + Weight::from_parts(297_844_822, 21770) + // Standard Error: 490_532 + .saturating_add(Weight::from_parts(747_592_977, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 16810).saturating_mul(r.into())) @@ -1607,18 +1548,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (79300 ±0)` - // Estimated: `64844 + r * (942952 ±833)` - // Minimum execution time: 374_097 nanoseconds. - Weight::from_parts(374_985_000, 0) - .saturating_add(Weight::from_parts(0, 64844)) - // Standard Error: 3_772_336 - .saturating_add(Weight::from_parts(1_546_402_854, 0).saturating_mul(r.into())) + // Measured: `0 + r * (74020 ±0)` + // Estimated: `69192 + r * (913289 ±821)` + // Minimum execution time: 295_164_000 picoseconds. + Weight::from_parts(296_597_000, 69192) + // Standard Error: 3_646_577 + .saturating_add(Weight::from_parts(1_725_796_807, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((225_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((150_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 942952).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 913289).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1633,13 +1573,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `869 + r * (240 ±0)` - // Estimated: `17215 + r * (1200 ±0)` - // Minimum execution time: 374_249 nanoseconds. - Weight::from_parts(377_990_998, 0) - .saturating_add(Weight::from_parts(0, 17215)) - // Standard Error: 38_133 - .saturating_add(Weight::from_parts(11_483_273, 0).saturating_mul(r.into())) + // Measured: `773 + r * (240 ±0)` + // Estimated: `21685 + r * (1200 ±0)` + // Minimum execution time: 296_287_000 picoseconds. + Weight::from_parts(300_696_694, 21685) + // Standard Error: 27_891 + .saturating_add(Weight::from_parts(10_943_994, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1200).saturating_mul(r.into())) @@ -1657,13 +1596,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2102 + r * (3154 ±0)` - // Estimated: `21980 + r * (15875 ±2)` - // Minimum execution time: 375_552 nanoseconds. - Weight::from_parts(400_624_032, 0) - .saturating_add(Weight::from_parts(0, 21980)) - // Standard Error: 82_523 - .saturating_add(Weight::from_parts(18_057_327, 0).saturating_mul(r.into())) + // Measured: `2006 + r * (3154 ±0)` + // Estimated: `26435 + r * (15875 ±2)` + // Minimum execution time: 298_000_000 picoseconds. + Weight::from_parts(328_282_119, 26435) + // Standard Error: 104_874 + .saturating_add(Weight::from_parts(18_428_267, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15875).saturating_mul(r.into())) @@ -1683,13 +1621,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `872 + r * (240 ±0)` - // Estimated: `18598 + r * (1440 ±0)` - // Minimum execution time: 373_899 nanoseconds. - Weight::from_parts(379_733_943, 0) - .saturating_add(Weight::from_parts(0, 18598)) - // Standard Error: 32_022 - .saturating_add(Weight::from_parts(9_381_180, 0).saturating_mul(r.into())) + // Measured: `776 + r * (240 ±0)` + // Estimated: `23962 + r * (1440 ±0)` + // Minimum execution time: 295_104_000 picoseconds. + Weight::from_parts(299_334_585, 23962) + // Standard Error: 25_840 + .saturating_add(Weight::from_parts(9_744_866, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1440).saturating_mul(r.into())) @@ -1699,572 +1636,520 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 834 nanoseconds. - Weight::from_parts(1_009_646, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 388 - .saturating_add(Weight::from_parts(411_979, 0).saturating_mul(r.into())) + // Minimum execution time: 1_132_000 picoseconds. + Weight::from_parts(1_100_159, 0) + // Standard Error: 10_131 + .saturating_add(Weight::from_parts(436_462, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64load(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 882 nanoseconds. - Weight::from_parts(1_416_377, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_133 - .saturating_add(Weight::from_parts(1_075_838, 0).saturating_mul(r.into())) + // Minimum execution time: 1_368_000 picoseconds. + Weight::from_parts(1_974_308, 0) + // Standard Error: 811 + .saturating_add(Weight::from_parts(1_079_620, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64store(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 878 nanoseconds. - Weight::from_parts(1_343_056, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 426 - .saturating_add(Weight::from_parts(1_001_214, 0).saturating_mul(r.into())) + // Minimum execution time: 1_354_000 picoseconds. + Weight::from_parts(2_057_834, 0) + // Standard Error: 4_277 + .saturating_add(Weight::from_parts(1_008_797, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_select(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 796 nanoseconds. - Weight::from_parts(1_079_086, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 409 - .saturating_add(Weight::from_parts(1_149_188, 0).saturating_mul(r.into())) + // Minimum execution time: 1_218_000 picoseconds. + Weight::from_parts(1_594_528, 0) + // Standard Error: 723 + .saturating_add(Weight::from_parts(1_147_486, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 800 nanoseconds. - Weight::from_parts(1_044_184, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 707 - .saturating_add(Weight::from_parts(1_315_686, 0).saturating_mul(r.into())) + // Minimum execution time: 1_156_000 picoseconds. + Weight::from_parts(1_460_611, 0) + // Standard Error: 419 + .saturating_add(Weight::from_parts(1_314_741, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 807 nanoseconds. - Weight::from_parts(1_049_633, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 361 - .saturating_add(Weight::from_parts(640_530, 0).saturating_mul(r.into())) + // Minimum execution time: 1_166_000 picoseconds. + Weight::from_parts(1_454_460, 0) + // Standard Error: 493 + .saturating_add(Weight::from_parts(642_481, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 774 nanoseconds. - Weight::from_parts(1_124_053, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 784 - .saturating_add(Weight::from_parts(949_398, 0).saturating_mul(r.into())) + // Minimum execution time: 1_144_000 picoseconds. + Weight::from_parts(1_410_515, 0) + // Standard Error: 894 + .saturating_add(Weight::from_parts(958_765, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br_table(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 810 nanoseconds. - Weight::from_parts(676_581, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_356 - .saturating_add(Weight::from_parts(1_163_465, 0).saturating_mul(r.into())) + // Minimum execution time: 1_190_000 picoseconds. + Weight::from_parts(1_143_236, 0) + // Standard Error: 2_773 + .saturating_add(Weight::from_parts(1_164_764, 0).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. fn instr_br_table_per_entry(e: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_580 nanoseconds. - Weight::from_parts(2_835_656, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 71 - .saturating_add(Weight::from_parts(4_686, 0).saturating_mul(e.into())) + // Minimum execution time: 2_993_000 picoseconds. + Weight::from_parts(3_270_525, 0) + // Standard Error: 65 + .saturating_add(Weight::from_parts(4_418, 0).saturating_mul(e.into())) } /// The range of component `r` is `[0, 50]`. fn instr_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 826 nanoseconds. - Weight::from_parts(1_625_698, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_740 - .saturating_add(Weight::from_parts(2_332_187, 0).saturating_mul(r.into())) + // Minimum execution time: 1_163_000 picoseconds. + Weight::from_parts(1_999_458, 0) + // Standard Error: 1_418 + .saturating_add(Weight::from_parts(2_371_979, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_call_indirect(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 901 nanoseconds. - Weight::from_parts(2_338_620, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_642 - .saturating_add(Weight::from_parts(2_924_090, 0).saturating_mul(r.into())) + // Minimum execution time: 1_288_000 picoseconds. + Weight::from_parts(2_340_227, 0) + // Standard Error: 3_234 + .saturating_add(Weight::from_parts(3_038_523, 0).saturating_mul(r.into())) } /// The range of component `p` is `[0, 128]`. fn instr_call_indirect_per_param(p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_670 nanoseconds. - Weight::from_parts(5_556_246, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_491 - .saturating_add(Weight::from_parts(228_965, 0).saturating_mul(p.into())) + // Minimum execution time: 5_270_000 picoseconds. + Weight::from_parts(6_360_011, 0) + // Standard Error: 2_585 + .saturating_add(Weight::from_parts(226_149, 0).saturating_mul(p.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_099 nanoseconds. - Weight::from_parts(3_896_177, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 99 - .saturating_add(Weight::from_parts(91_304, 0).saturating_mul(l.into())) + // Minimum execution time: 3_580_000 picoseconds. + Weight::from_parts(5_183_658, 0) + // Standard Error: 80 + .saturating_add(Weight::from_parts(46_038, 0).saturating_mul(l.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_042 nanoseconds. - Weight::from_parts(3_334_621, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 793 - .saturating_add(Weight::from_parts(459_346, 0).saturating_mul(r.into())) + // Minimum execution time: 2_559_000 picoseconds. + Weight::from_parts(2_846_350, 0) + // Standard Error: 2_809 + .saturating_add(Weight::from_parts(462_084, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_968 nanoseconds. - Weight::from_parts(3_235_286, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 427 - .saturating_add(Weight::from_parts(485_454, 0).saturating_mul(r.into())) + // Minimum execution time: 2_530_000 picoseconds. + Weight::from_parts(2_835_072, 0) + // Standard Error: 479 + .saturating_add(Weight::from_parts(483_451, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_tee(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_012 nanoseconds. - Weight::from_parts(3_303_555, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 371 - .saturating_add(Weight::from_parts(657_811, 0).saturating_mul(r.into())) + // Minimum execution time: 2_510_000 picoseconds. + Weight::from_parts(2_740_081, 0) + // Standard Error: 901 + .saturating_add(Weight::from_parts(664_354, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_global_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 865 nanoseconds. - Weight::from_parts(1_249_987, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 417 - .saturating_add(Weight::from_parts(896_704, 0).saturating_mul(r.into())) + // Minimum execution time: 1_295_000 picoseconds. + Weight::from_parts(1_798_174, 0) + // Standard Error: 464 + .saturating_add(Weight::from_parts(896_289, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_global_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 866 nanoseconds. - Weight::from_parts(1_216_218, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 503 - .saturating_add(Weight::from_parts(919_719, 0).saturating_mul(r.into())) + // Minimum execution time: 1_287_000 picoseconds. + Weight::from_parts(1_636_548, 0) + // Standard Error: 658 + .saturating_add(Weight::from_parts(923_295, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_memory_current(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 921 nanoseconds. - Weight::from_parts(1_228_408, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 309 - .saturating_add(Weight::from_parts(813_007, 0).saturating_mul(r.into())) + // Minimum execution time: 1_353_000 picoseconds. + Weight::from_parts(1_672_309, 0) + // Standard Error: 403 + .saturating_add(Weight::from_parts(818_273, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 1]`. fn instr_memory_grow(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 820 nanoseconds. - Weight::from_parts(914_830, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 6_018 - .saturating_add(Weight::from_parts(237_062_769, 0).saturating_mul(r.into())) + // Minimum execution time: 1_180_000 picoseconds. + Weight::from_parts(1_304_714, 0) + // Standard Error: 88_180 + .saturating_add(Weight::from_parts(183_952_985, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64clz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 812 nanoseconds. - Weight::from_parts(1_554_406, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 9_979 - .saturating_add(Weight::from_parts(625_434, 0).saturating_mul(r.into())) + // Minimum execution time: 1_158_000 picoseconds. + Weight::from_parts(1_800_065, 0) + // Standard Error: 2_104 + .saturating_add(Weight::from_parts(625_410, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ctz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 798 nanoseconds. - Weight::from_parts(1_095_113, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 243 - .saturating_add(Weight::from_parts(634_204, 0).saturating_mul(r.into())) + // Minimum execution time: 1_208_000 picoseconds. + Weight::from_parts(1_483_908, 0) + // Standard Error: 319 + .saturating_add(Weight::from_parts(635_095, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64popcnt(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 792 nanoseconds. - Weight::from_parts(1_109_845, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 14_944 - .saturating_add(Weight::from_parts(658_834, 0).saturating_mul(r.into())) + // Minimum execution time: 1_164_000 picoseconds. + Weight::from_parts(1_506_871, 0) + // Standard Error: 264 + .saturating_add(Weight::from_parts(633_660, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64eqz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 815 nanoseconds. - Weight::from_parts(1_068_916, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 327 - .saturating_add(Weight::from_parts(652_897, 0).saturating_mul(r.into())) + // Minimum execution time: 1_141_000 picoseconds. + Weight::from_parts(1_467_219, 0) + // Standard Error: 191 + .saturating_add(Weight::from_parts(651_156, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendsi32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 798 nanoseconds. - Weight::from_parts(1_069_745, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 306 - .saturating_add(Weight::from_parts(618_481, 0).saturating_mul(r.into())) + // Minimum execution time: 1_170_000 picoseconds. + Weight::from_parts(1_474_718, 0) + // Standard Error: 224 + .saturating_add(Weight::from_parts(617_317, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendui32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 799 nanoseconds. - Weight::from_parts(1_398_001, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 6_234 - .saturating_add(Weight::from_parts(611_399, 0).saturating_mul(r.into())) + // Minimum execution time: 1_195_000 picoseconds. + Weight::from_parts(1_501_421, 0) + // Standard Error: 221 + .saturating_add(Weight::from_parts(616_559, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i32wrapi64(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 811 nanoseconds. - Weight::from_parts(1_098_083, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 297 - .saturating_add(Weight::from_parts(617_692, 0).saturating_mul(r.into())) + // Minimum execution time: 1_172_000 picoseconds. + Weight::from_parts(1_482_402, 0) + // Standard Error: 2_163 + .saturating_add(Weight::from_parts(619_230, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64eq(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 815 nanoseconds. - Weight::from_parts(1_046_922, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 335 - .saturating_add(Weight::from_parts(909_196, 0).saturating_mul(r.into())) + // Minimum execution time: 1_149_000 picoseconds. + Weight::from_parts(2_021_801, 0) + // Standard Error: 20_804 + .saturating_add(Weight::from_parts(913_888, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ne(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 805 nanoseconds. - Weight::from_parts(1_093_667, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 233 - .saturating_add(Weight::from_parts(907_378, 0).saturating_mul(r.into())) + // Minimum execution time: 1_187_000 picoseconds. + Weight::from_parts(1_358_437, 0) + // Standard Error: 1_946 + .saturating_add(Weight::from_parts(916_378, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64lts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 805 nanoseconds. - Weight::from_parts(1_290_591, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_201 - .saturating_add(Weight::from_parts(902_006, 0).saturating_mul(r.into())) + // Minimum execution time: 1_175_000 picoseconds. + Weight::from_parts(1_527_336, 0) + // Standard Error: 243 + .saturating_add(Weight::from_parts(907_580, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ltu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 783 nanoseconds. - Weight::from_parts(1_159_977, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_310 - .saturating_add(Weight::from_parts(906_489, 0).saturating_mul(r.into())) + // Minimum execution time: 1_220_000 picoseconds. + Weight::from_parts(1_530_715, 0) + // Standard Error: 224 + .saturating_add(Weight::from_parts(906_096, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64gts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 790 nanoseconds. - Weight::from_parts(1_109_719, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 261 - .saturating_add(Weight::from_parts(906_614, 0).saturating_mul(r.into())) + // Minimum execution time: 1_107_000 picoseconds. + Weight::from_parts(1_496_553, 0) + // Standard Error: 299 + .saturating_add(Weight::from_parts(907_963, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64gtu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 776 nanoseconds. - Weight::from_parts(1_076_567, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 348 - .saturating_add(Weight::from_parts(919_374, 0).saturating_mul(r.into())) + // Minimum execution time: 1_153_000 picoseconds. + Weight::from_parts(1_482_710, 0) + // Standard Error: 182 + .saturating_add(Weight::from_parts(918_439, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64les(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 780 nanoseconds. - Weight::from_parts(1_069_663, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 265 - .saturating_add(Weight::from_parts(908_037, 0).saturating_mul(r.into())) + // Minimum execution time: 1_142_000 picoseconds. + Weight::from_parts(1_522_114, 0) + // Standard Error: 297 + .saturating_add(Weight::from_parts(906_633, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64leu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 832 nanoseconds. - Weight::from_parts(930_920, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_170 - .saturating_add(Weight::from_parts(929_811, 0).saturating_mul(r.into())) + // Minimum execution time: 1_119_000 picoseconds. + Weight::from_parts(2_199_831, 0) + // Standard Error: 4_234 + .saturating_add(Weight::from_parts(898_161, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ges(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 787 nanoseconds. - Weight::from_parts(1_087_325, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 315 - .saturating_add(Weight::from_parts(908_321, 0).saturating_mul(r.into())) + // Minimum execution time: 1_163_000 picoseconds. + Weight::from_parts(1_489_404, 0) + // Standard Error: 416 + .saturating_add(Weight::from_parts(908_450, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64geu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 798 nanoseconds. - Weight::from_parts(1_029_132, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_095 - .saturating_add(Weight::from_parts(913_553, 0).saturating_mul(r.into())) + // Minimum execution time: 1_204_000 picoseconds. + Weight::from_parts(2_266_296, 0) + // Standard Error: 13_013 + .saturating_add(Weight::from_parts(899_225, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64add(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 791 nanoseconds. - Weight::from_parts(1_086_314, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 197 - .saturating_add(Weight::from_parts(896_392, 0).saturating_mul(r.into())) + // Minimum execution time: 1_160_000 picoseconds. + Weight::from_parts(1_470_799, 0) + // Standard Error: 422 + .saturating_add(Weight::from_parts(897_325, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64sub(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 793 nanoseconds. - Weight::from_parts(1_078_172, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 404 - .saturating_add(Weight::from_parts(886_329, 0).saturating_mul(r.into())) + // Minimum execution time: 1_125_000 picoseconds. + Weight::from_parts(1_521_508, 0) + // Standard Error: 594 + .saturating_add(Weight::from_parts(886_145, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64mul(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 799 nanoseconds. - Weight::from_parts(1_095_010, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 431 - .saturating_add(Weight::from_parts(886_513, 0).saturating_mul(r.into())) + // Minimum execution time: 1_139_000 picoseconds. + Weight::from_parts(1_490_535, 0) + // Standard Error: 211 + .saturating_add(Weight::from_parts(884_929, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64divs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 810 nanoseconds. - Weight::from_parts(1_114_325, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 452 - .saturating_add(Weight::from_parts(1_521_849, 0).saturating_mul(r.into())) + // Minimum execution time: 1_180_000 picoseconds. + Weight::from_parts(2_221_481, 0) + // Standard Error: 9_884 + .saturating_add(Weight::from_parts(1_507_511, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64divu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 784 nanoseconds. - Weight::from_parts(1_123_153, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 475 - .saturating_add(Weight::from_parts(1_457_746, 0).saturating_mul(r.into())) + // Minimum execution time: 1_131_000 picoseconds. + Weight::from_parts(1_498_652, 0) + // Standard Error: 531 + .saturating_add(Weight::from_parts(1_451_498, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rems(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 809 nanoseconds. - Weight::from_parts(1_145_906, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 718 - .saturating_add(Weight::from_parts(1_549_964, 0).saturating_mul(r.into())) + // Minimum execution time: 1_145_000 picoseconds. + Weight::from_parts(1_504_118, 0) + // Standard Error: 439 + .saturating_add(Weight::from_parts(1_521_895, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64remu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 803 nanoseconds. - Weight::from_parts(1_110_328, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 627 - .saturating_add(Weight::from_parts(1_453_013, 0).saturating_mul(r.into())) + // Minimum execution time: 1_124_000 picoseconds. + Weight::from_parts(1_497_209, 0) + // Standard Error: 198 + .saturating_add(Weight::from_parts(1_449_843, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64and(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 786 nanoseconds. - Weight::from_parts(1_108_792, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 286 - .saturating_add(Weight::from_parts(897_035, 0).saturating_mul(r.into())) + // Minimum execution time: 1_169_000 picoseconds. + Weight::from_parts(1_534_491, 0) + // Standard Error: 283 + .saturating_add(Weight::from_parts(894_703, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64or(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 787 nanoseconds. - Weight::from_parts(830_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 15_995 - .saturating_add(Weight::from_parts(963_344, 0).saturating_mul(r.into())) + // Minimum execution time: 1_178_000 picoseconds. + Weight::from_parts(1_485_473, 0) + // Standard Error: 552 + .saturating_add(Weight::from_parts(897_878, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64xor(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 773 nanoseconds. - Weight::from_parts(1_082_459, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 330 - .saturating_add(Weight::from_parts(897_077, 0).saturating_mul(r.into())) + // Minimum execution time: 1_214_000 picoseconds. + Weight::from_parts(1_580_999, 0) + // Standard Error: 358 + .saturating_add(Weight::from_parts(894_207, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 810 nanoseconds. - Weight::from_parts(1_325_815, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_352 - .saturating_add(Weight::from_parts(899_555, 0).saturating_mul(r.into())) + // Minimum execution time: 1_176_000 picoseconds. + Weight::from_parts(1_490_470, 0) + // Standard Error: 738 + .saturating_add(Weight::from_parts(904_900, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shrs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 808 nanoseconds. - Weight::from_parts(1_085_903, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 430 - .saturating_add(Weight::from_parts(903_249, 0).saturating_mul(r.into())) + // Minimum execution time: 1_197_000 picoseconds. + Weight::from_parts(1_519_703, 0) + // Standard Error: 336 + .saturating_add(Weight::from_parts(901_277, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shru(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 792 nanoseconds. - Weight::from_parts(1_091_261, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 312 - .saturating_add(Weight::from_parts(902_245, 0).saturating_mul(r.into())) + // Minimum execution time: 1_166_000 picoseconds. + Weight::from_parts(1_507_499, 0) + // Standard Error: 298 + .saturating_add(Weight::from_parts(901_153, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 807 nanoseconds. - Weight::from_parts(1_121_052, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 506 - .saturating_add(Weight::from_parts(902_772, 0).saturating_mul(r.into())) + // Minimum execution time: 1_158_000 picoseconds. + Weight::from_parts(1_491_176, 0) + // Standard Error: 341 + .saturating_add(Weight::from_parts(901_880, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotr(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 823 nanoseconds. - Weight::from_parts(1_317_597, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 6_219 - .saturating_add(Weight::from_parts(896_692, 0).saturating_mul(r.into())) + // Minimum execution time: 1_207_000 picoseconds. + Weight::from_parts(1_477_261, 0) + // Standard Error: 287 + .saturating_add(Weight::from_parts(902_622, 0).saturating_mul(r.into())) } } @@ -2275,10 +2160,9 @@ impl WeightInfo for () { fn on_process_deletion_queue_batch() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `604` - // Minimum execution time: 2_591 nanoseconds. - Weight::from_parts(2_817_000, 0) - .saturating_add(Weight::from_parts(0, 604)) + // Estimated: `1594` + // Minimum execution time: 2_679_000 picoseconds. + Weight::from_parts(2_907_000, 1594) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Skipped Metadata (r:0 w:0) @@ -2286,14 +2170,14 @@ impl WeightInfo for () { /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `481 + k * (69 ±0)` - // Estimated: `471 + k * (70 ±0)` - // Minimum execution time: 10_190 nanoseconds. - Weight::from_parts(6_642_117, 0) - .saturating_add(Weight::from_parts(0, 471)) - // Standard Error: 992 - .saturating_add(Weight::from_parts(919_828, 0).saturating_mul(k.into())) + // Measured: `450 + k * (69 ±0)` + // Estimated: `440 + k * (70 ±0)` + // Minimum execution time: 11_162_000 picoseconds. + Weight::from_parts(5_734_923, 440) + // Standard Error: 1_097 + .saturating_add(Weight::from_parts(976_647, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(k.into())) @@ -2303,13 +2187,12 @@ impl WeightInfo for () { /// The range of component `q` is `[0, 128]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `281 + q * (33 ±0)` - // Estimated: `763 + q * (33 ±0)` - // Minimum execution time: 2_598 nanoseconds. - Weight::from_parts(10_288_252, 0) - .saturating_add(Weight::from_parts(0, 763)) - // Standard Error: 2_886 - .saturating_add(Weight::from_parts(1_092_420, 0).saturating_mul(q.into())) + // Measured: `250 + q * (33 ±0)` + // Estimated: `1725 + q * (33 ±0)` + // Minimum execution time: 2_626_000 picoseconds. + Weight::from_parts(10_626_314, 1725) + // Standard Error: 4_006 + .saturating_add(Weight::from_parts(1_298_864, 0).saturating_mul(q.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 33).saturating_mul(q.into())) @@ -2321,13 +2204,12 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 61717]`. fn reinstrument(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `270 + c * (1 ±0)` - // Estimated: `3025 + c * (2 ±0)` - // Minimum execution time: 34_338 nanoseconds. - Weight::from_parts(32_159_677, 0) - .saturating_add(Weight::from_parts(0, 3025)) - // Standard Error: 53 - .saturating_add(Weight::from_parts(51_034, 0).saturating_mul(c.into())) + // Measured: `238 + c * (1 ±0)` + // Estimated: `3951 + c * (2 ±0)` + // Minimum execution time: 31_434_000 picoseconds. + Weight::from_parts(29_558_961, 3951) + // Standard Error: 55 + .saturating_add(Weight::from_parts(50_774, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 2).saturating_mul(c.into())) @@ -2345,13 +2227,12 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `803` - // Estimated: `16930 + c * (5 ±0)` - // Minimum execution time: 385_587 nanoseconds. - Weight::from_parts(395_545_811, 0) - .saturating_add(Weight::from_parts(0, 16930)) - // Standard Error: 27 - .saturating_add(Weight::from_parts(31_342, 0).saturating_mul(c.into())) + // Measured: `707` + // Estimated: `21400 + c * (5 ±0)` + // Minimum execution time: 309_015_000 picoseconds. + Weight::from_parts(318_740_885, 21400) + // Standard Error: 29 + .saturating_add(Weight::from_parts(30_993, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(c.into())) @@ -2378,16 +2259,15 @@ impl WeightInfo for () { fn instantiate_with_code(c: u32, i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `270` - // Estimated: `20267` - // Minimum execution time: 3_799_742 nanoseconds. - Weight::from_parts(670_115_588, 0) - .saturating_add(Weight::from_parts(0, 20267)) - // Standard Error: 287 - .saturating_add(Weight::from_parts(93_885, 0).saturating_mul(c.into())) - // Standard Error: 16 - .saturating_add(Weight::from_parts(1_367, 0).saturating_mul(i.into())) - // Standard Error: 16 - .saturating_add(Weight::from_parts(1_781, 0).saturating_mul(s.into())) + // Estimated: `26207` + // Minimum execution time: 3_126_495_000 picoseconds. + Weight::from_parts(636_857_878, 26207) + // Standard Error: 294 + .saturating_add(Weight::from_parts(92_930, 0).saturating_mul(c.into())) + // Standard Error: 17 + .saturating_add(Weight::from_parts(1_128, 0).saturating_mul(i.into())) + // Standard Error: 17 + .saturating_add(Weight::from_parts(1_415, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(10_u64)) } @@ -2409,15 +2289,14 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `546` - // Estimated: `22039` - // Minimum execution time: 1_949_008 nanoseconds. - Weight::from_parts(214_033_418, 0) - .saturating_add(Weight::from_parts(0, 22039)) + // Measured: `482` + // Estimated: `28521` + // Minimum execution time: 1_591_415_000 picoseconds. + Weight::from_parts(228_633_516, 28521) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_666, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_449, 0).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_801, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_444, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -2433,11 +2312,10 @@ impl WeightInfo for () { /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) fn call() -> Weight { // Proof Size summary in bytes: - // Measured: `855` - // Estimated: `17145` - // Minimum execution time: 146_654 nanoseconds. - Weight::from_parts(147_528_000, 0) - .saturating_add(Weight::from_parts(0, 17145)) + // Measured: `759` + // Estimated: `21615` + // Minimum execution time: 167_905_000 picoseconds. + Weight::from_parts(169_247_000, 21615) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2453,12 +2331,11 @@ impl WeightInfo for () { fn upload_code(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `5386` - // Minimum execution time: 387_889 nanoseconds. - Weight::from_parts(391_379_335, 0) - .saturating_add(Weight::from_parts(0, 5386)) - // Standard Error: 89 - .saturating_add(Weight::from_parts(94_810, 0).saturating_mul(c.into())) + // Estimated: `7366` + // Minimum execution time: 305_128_000 picoseconds. + Weight::from_parts(310_911_395, 7366) + // Standard Error: 70 + .saturating_add(Weight::from_parts(94_067, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2472,11 +2349,10 @@ impl WeightInfo for () { /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `287` - // Estimated: `6098` - // Minimum execution time: 26_014 nanoseconds. - Weight::from_parts(26_510_000, 0) - .saturating_add(Weight::from_parts(0, 6098)) + // Measured: `255` + // Estimated: `7950` + // Minimum execution time: 29_605_000 picoseconds. + Weight::from_parts(29_986_000, 7950) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2488,11 +2364,10 @@ impl WeightInfo for () { /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `666` - // Estimated: `16848` - // Minimum execution time: 30_177 nanoseconds. - Weight::from_parts(30_639_000, 0) - .saturating_add(Weight::from_parts(0, 16848)) + // Measured: `570` + // Estimated: `19530` + // Minimum execution time: 33_824_000 picoseconds. + Weight::from_parts(34_388_000, 19530) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -2509,13 +2384,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_caller(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `877 + r * (480 ±0)` - // Estimated: `17295 + r * (2400 ±0)` - // Minimum execution time: 373_786 nanoseconds. - Weight::from_parts(377_332_691, 0) - .saturating_add(Weight::from_parts(0, 17295)) - // Standard Error: 51_211 - .saturating_add(Weight::from_parts(17_715_615, 0).saturating_mul(r.into())) + // Measured: `781 + r * (480 ±0)` + // Estimated: `21765 + r * (2400 ±0)` + // Minimum execution time: 295_283_000 picoseconds. + Weight::from_parts(295_895_211, 21765) + // Standard Error: 44_860 + .saturating_add(Weight::from_parts(22_913_078, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -2533,17 +2407,16 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_is_contract(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `917 + r * (21778 ±0)` - // Estimated: `17295 + r * (306895 ±0)` - // Minimum execution time: 374_009 nanoseconds. - Weight::from_parts(238_991_986, 0) - .saturating_add(Weight::from_parts(0, 17295)) - // Standard Error: 464_711 - .saturating_add(Weight::from_parts(249_099_538, 0).saturating_mul(r.into())) + // Measured: `821 + r * (19218 ±0)` + // Estimated: `21765 + r * (294095 ±0)` + // Minimum execution time: 295_760_000 picoseconds. + Weight::from_parts(151_512_811, 21765) + // Standard Error: 522_974 + .saturating_add(Weight::from_parts(263_028_353, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 306895).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 294095).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2558,17 +2431,16 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `921 + r * (22099 ±0)` - // Estimated: `17340 + r * (308500 ±0)` - // Minimum execution time: 375_058 nanoseconds. - Weight::from_parts(238_765_068, 0) - .saturating_add(Weight::from_parts(0, 17340)) - // Standard Error: 662_617 - .saturating_add(Weight::from_parts(302_175_089, 0).saturating_mul(r.into())) + // Measured: `825 + r * (19539 ±0)` + // Estimated: `21810 + r * (295700 ±0)` + // Minimum execution time: 295_950_000 picoseconds. + Weight::from_parts(164_516_076, 21810) + // Standard Error: 469_540 + .saturating_add(Weight::from_parts(321_138_601, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 308500).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 295700).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2583,13 +2455,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_own_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `884 + r * (480 ±0)` - // Estimated: `17330 + r * (2400 ±0)` - // Minimum execution time: 374_747 nanoseconds. - Weight::from_parts(376_482_380, 0) - .saturating_add(Weight::from_parts(0, 17330)) - // Standard Error: 61_919 - .saturating_add(Weight::from_parts(22_376_795, 0).saturating_mul(r.into())) + // Measured: `788 + r * (480 ±0)` + // Estimated: `21800 + r * (2400 ±0)` + // Minimum execution time: 295_916_000 picoseconds. + Weight::from_parts(299_964_913, 21800) + // Standard Error: 78_211 + .saturating_add(Weight::from_parts(28_933_603, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -2607,13 +2478,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_caller_is_origin(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874 + r * (240 ±0)` - // Estimated: `17265 + r * (1200 ±0)` - // Minimum execution time: 372_287 nanoseconds. - Weight::from_parts(376_250_858, 0) - .saturating_add(Weight::from_parts(0, 17265)) - // Standard Error: 40_119 - .saturating_add(Weight::from_parts(11_359_647, 0).saturating_mul(r.into())) + // Measured: `778 + r * (240 ±0)` + // Estimated: `21735 + r * (1200 ±0)` + // Minimum execution time: 293_588_000 picoseconds. + Weight::from_parts(297_568_984, 21735) + // Standard Error: 35_513 + .saturating_add(Weight::from_parts(11_074_880, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1200).saturating_mul(r.into())) @@ -2631,13 +2501,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `878 + r * (480 ±0)` - // Estimated: `17260 + r * (2400 ±0)` - // Minimum execution time: 374_445 nanoseconds. - Weight::from_parts(377_243_521, 0) - .saturating_add(Weight::from_parts(0, 17260)) - // Standard Error: 53_032 - .saturating_add(Weight::from_parts(17_684_246, 0).saturating_mul(r.into())) + // Measured: `782 + r * (480 ±0)` + // Estimated: `21730 + r * (2400 ±0)` + // Minimum execution time: 294_929_000 picoseconds. + Weight::from_parts(295_916_817, 21730) + // Standard Error: 64_902 + .saturating_add(Weight::from_parts(22_944_018, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -2655,13 +2524,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_gas_left(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `879 + r * (480 ±0)` - // Estimated: `17250 + r * (2405 ±0)` - // Minimum execution time: 374_029 nanoseconds. - Weight::from_parts(380_415_186, 0) - .saturating_add(Weight::from_parts(0, 17250)) - // Standard Error: 60_562 - .saturating_add(Weight::from_parts(17_152_599, 0).saturating_mul(r.into())) + // Measured: `783 + r * (480 ±0)` + // Estimated: `21720 + r * (2405 ±0)` + // Minimum execution time: 296_783_000 picoseconds. + Weight::from_parts(299_399_332, 21720) + // Standard Error: 50_982 + .saturating_add(Weight::from_parts(22_173_249, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2405).saturating_mul(r.into())) @@ -2679,16 +2547,15 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1049 + r * (480 ±0)` - // Estimated: `19849 + r * (2456 ±0)` - // Minimum execution time: 373_999 nanoseconds. - Weight::from_parts(381_757_033, 0) - .saturating_add(Weight::from_parts(0, 19849)) - // Standard Error: 97_983 - .saturating_add(Weight::from_parts(98_290_984, 0).saturating_mul(r.into())) + // Measured: `921 + r * (480 ±0)` + // Estimated: `24193 + r * (2451 ±0)` + // Minimum execution time: 294_120_000 picoseconds. + Weight::from_parts(305_889_989, 24193) + // Standard Error: 116_244 + .saturating_add(Weight::from_parts(114_781_094, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2456).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2451).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2703,13 +2570,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_value_transferred(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `888 + r * (480 ±0)` - // Estimated: `17360 + r * (2400 ±0)` - // Minimum execution time: 374_197 nanoseconds. - Weight::from_parts(377_755_896, 0) - .saturating_add(Weight::from_parts(0, 17360)) - // Standard Error: 60_542 - .saturating_add(Weight::from_parts(17_442_065, 0).saturating_mul(r.into())) + // Measured: `792 + r * (480 ±0)` + // Estimated: `21830 + r * (2400 ±0)` + // Minimum execution time: 295_569_000 picoseconds. + Weight::from_parts(299_774_774, 21830) + // Standard Error: 46_252 + .saturating_add(Weight::from_parts(21_753_842, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -2727,13 +2593,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_minimum_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `886 + r * (480 ±0)` - // Estimated: `17290 + r * (2400 ±0)` - // Minimum execution time: 373_888 nanoseconds. - Weight::from_parts(377_825_771, 0) - .saturating_add(Weight::from_parts(0, 17290)) - // Standard Error: 38_026 - .saturating_add(Weight::from_parts(17_147_903, 0).saturating_mul(r.into())) + // Measured: `790 + r * (480 ±0)` + // Estimated: `21760 + r * (2400 ±0)` + // Minimum execution time: 295_400_000 picoseconds. + Weight::from_parts(300_637_266, 21760) + // Standard Error: 41_263 + .saturating_add(Weight::from_parts(21_565_466, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -2751,13 +2616,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_block_number(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `883 + r * (480 ±0)` - // Estimated: `17315 + r * (2400 ±0)` - // Minimum execution time: 373_904 nanoseconds. - Weight::from_parts(378_652_372, 0) - .saturating_add(Weight::from_parts(0, 17315)) - // Standard Error: 43_833 - .saturating_add(Weight::from_parts(16_936_781, 0).saturating_mul(r.into())) + // Measured: `787 + r * (480 ±0)` + // Estimated: `21785 + r * (2400 ±0)` + // Minimum execution time: 294_696_000 picoseconds. + Weight::from_parts(297_196_796, 21785) + // Standard Error: 61_173 + .saturating_add(Weight::from_parts(21_903_191, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -2775,13 +2639,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_now(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874 + r * (480 ±0)` - // Estimated: `17245 + r * (2400 ±0)` - // Minimum execution time: 373_473 nanoseconds. - Weight::from_parts(376_386_312, 0) - .saturating_add(Weight::from_parts(0, 17245)) - // Standard Error: 46_945 - .saturating_add(Weight::from_parts(17_336_462, 0).saturating_mul(r.into())) + // Measured: `778 + r * (480 ±0)` + // Estimated: `21715 + r * (2400 ±0)` + // Minimum execution time: 297_714_000 picoseconds. + Weight::from_parts(306_030_237, 21715) + // Standard Error: 69_984 + .saturating_add(Weight::from_parts(21_744_413, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -2801,13 +2664,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_weight_to_fee(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `951 + r * (800 ±0)` - // Estimated: `19046 + r * (4805 ±0)` - // Minimum execution time: 373_661 nanoseconds. - Weight::from_parts(385_824_015, 0) - .saturating_add(Weight::from_parts(0, 19046)) - // Standard Error: 75_964 - .saturating_add(Weight::from_parts(88_530_074, 0).saturating_mul(r.into())) + // Measured: `856 + r * (800 ±0)` + // Estimated: `24416 + r * (4805 ±0)` + // Minimum execution time: 295_180_000 picoseconds. + Weight::from_parts(308_851_025, 24416) + // Standard Error: 115_126 + .saturating_add(Weight::from_parts(98_678_404, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 4805).saturating_mul(r.into())) @@ -2825,13 +2687,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_gas(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `841 + r * (320 ±0)` - // Estimated: `17120 + r * (1600 ±0)` - // Minimum execution time: 133_849 nanoseconds. - Weight::from_parts(137_283_391, 0) - .saturating_add(Weight::from_parts(0, 17120)) - // Standard Error: 13_312 - .saturating_add(Weight::from_parts(8_055_328, 0).saturating_mul(r.into())) + // Measured: `745 + r * (320 ±0)` + // Estimated: `21590 + r * (1600 ±0)` + // Minimum execution time: 151_587_000 picoseconds. + Weight::from_parts(155_713_096, 21590) + // Standard Error: 32_464 + .saturating_add(Weight::from_parts(8_332_778, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1600).saturating_mul(r.into())) @@ -2849,13 +2710,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_input(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `876 + r * (480 ±0)` - // Estimated: `17245 + r * (2400 ±0)` - // Minimum execution time: 373_468 nanoseconds. - Weight::from_parts(376_121_093, 0) - .saturating_add(Weight::from_parts(0, 17245)) - // Standard Error: 61_857 - .saturating_add(Weight::from_parts(15_868_414, 0).saturating_mul(r.into())) + // Measured: `780 + r * (480 ±0)` + // Estimated: `21715 + r * (2400 ±0)` + // Minimum execution time: 295_008_000 picoseconds. + Weight::from_parts(297_982_800, 21715) + // Standard Error: 37_480 + .saturating_add(Weight::from_parts(17_970_520, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) @@ -2873,13 +2733,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1024]`. fn seal_input_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1356` - // Estimated: `19650` - // Minimum execution time: 390_668 nanoseconds. - Weight::from_parts(419_608_449, 0) - .saturating_add(Weight::from_parts(0, 19650)) - // Standard Error: 4_890 - .saturating_add(Weight::from_parts(9_672_288, 0).saturating_mul(n.into())) + // Measured: `1260` + // Estimated: `24120` + // Minimum execution time: 314_970_000 picoseconds. + Weight::from_parts(345_339_508, 24120) + // Standard Error: 4_112 + .saturating_add(Weight::from_parts(9_746_966, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2896,13 +2755,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `864 + r * (45 ±0)` - // Estimated: `17190 + r * (225 ±0)` - // Minimum execution time: 371_309 nanoseconds. - Weight::from_parts(373_625_402, 0) - .saturating_add(Weight::from_parts(0, 17190)) - // Standard Error: 419_605 - .saturating_add(Weight::from_parts(1_737_397, 0).saturating_mul(r.into())) + // Measured: `768 + r * (45 ±0)` + // Estimated: `21660 + r * (225 ±0)` + // Minimum execution time: 293_072_000 picoseconds. + Weight::from_parts(295_694_824, 21660) + // Standard Error: 219_523 + .saturating_add(Weight::from_parts(783_975, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 225).saturating_mul(r.into())) @@ -2920,13 +2778,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1024]`. fn seal_return_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874` - // Estimated: `17285` - // Minimum execution time: 374_094 nanoseconds. - Weight::from_parts(375_965_200, 0) - .saturating_add(Weight::from_parts(0, 17285)) - // Standard Error: 1_127 - .saturating_add(Weight::from_parts(232_645, 0).saturating_mul(n.into())) + // Measured: `778` + // Estimated: `21755` + // Minimum execution time: 295_959_000 picoseconds. + Weight::from_parts(299_004_761, 21755) + // Standard Error: 3_988 + .saturating_add(Weight::from_parts(194_268, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2947,18 +2804,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `906 + r * (452 ±0)` - // Estimated: `20242 + r * (15004 ±0)` - // Minimum execution time: 373_123 nanoseconds. - Weight::from_parts(374_924_634, 0) - .saturating_add(Weight::from_parts(0, 20242)) - // Standard Error: 378_010 - .saturating_add(Weight::from_parts(70_441_665, 0).saturating_mul(r.into())) + // Measured: `810 + r * (356 ±0)` + // Estimated: `25511 + r * (15321 ±0)` + // Minimum execution time: 294_626_000 picoseconds. + Weight::from_parts(297_839_179, 25511) + // Standard Error: 707_428 + .saturating_add(Weight::from_parts(81_507_620, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 15004).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 15321).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2975,13 +2831,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_random(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `921 + r * (800 ±0)` - // Estimated: `18835 + r * (4805 ±0)` - // Minimum execution time: 373_291 nanoseconds. - Weight::from_parts(385_684_344, 0) - .saturating_add(Weight::from_parts(0, 18835)) - // Standard Error: 99_025 - .saturating_add(Weight::from_parts(111_308_793, 0).saturating_mul(r.into())) + // Measured: `825 + r * (800 ±0)` + // Estimated: `24199 + r * (4805 ±0)` + // Minimum execution time: 295_431_000 picoseconds. + Weight::from_parts(310_428_531, 24199) + // Standard Error: 143_501 + .saturating_add(Weight::from_parts(136_529_376, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 4805).saturating_mul(r.into())) @@ -2999,13 +2854,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_deposit_event(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874 + r * (800 ±0)` - // Estimated: `17250 + r * (4000 ±0)` - // Minimum execution time: 371_900 nanoseconds. - Weight::from_parts(384_166_626, 0) - .saturating_add(Weight::from_parts(0, 17250)) - // Standard Error: 205_255 - .saturating_add(Weight::from_parts(229_214_157, 0).saturating_mul(r.into())) + // Measured: `778 + r * (800 ±0)` + // Estimated: `21720 + r * (4000 ±0)` + // Minimum execution time: 293_778_000 picoseconds. + Weight::from_parts(323_404_081, 21720) + // Standard Error: 243_095 + .saturating_add(Weight::from_parts(269_012_482, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 4000).saturating_mul(r.into())) @@ -3024,15 +2878,14 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16]`. fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1821 + t * (2608 ±0) + n * (7 ±0)` - // Estimated: `21870 + t * (211030 ±0) + n * (50 ±0)` - // Minimum execution time: 1_289_873 nanoseconds. - Weight::from_parts(581_702_206, 0) - .saturating_add(Weight::from_parts(0, 21870)) - // Standard Error: 665_638 - .saturating_add(Weight::from_parts(181_470_553, 0).saturating_mul(t.into())) - // Standard Error: 182_816 - .saturating_add(Weight::from_parts(71_635_250, 0).saturating_mul(n.into())) + // Measured: `1725 + t * (2608 ±0) + n * (7 ±0)` + // Estimated: `26340 + t * (211030 ±0) + n * (50 ±0)` + // Minimum execution time: 1_317_129_000 picoseconds. + Weight::from_parts(566_722_295, 26340) + // Standard Error: 619_390 + .saturating_add(Weight::from_parts(194_334_643, 0).saturating_mul(t.into())) + // Standard Error: 170_114 + .saturating_add(Weight::from_parts(67_458_751, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3053,13 +2906,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_debug_message(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (560 ±0)` - // Estimated: `17240 + r * (2800 ±0)` - // Minimum execution time: 148_635 nanoseconds. - Weight::from_parts(154_095_712, 0) - .saturating_add(Weight::from_parts(0, 17240)) - // Standard Error: 77_790 - .saturating_add(Weight::from_parts(14_837_085, 0).saturating_mul(r.into())) + // Measured: `777 + r * (560 ±0)` + // Estimated: `21710 + r * (2800 ±0)` + // Minimum execution time: 159_087_000 picoseconds. + Weight::from_parts(163_703_981, 21710) + // Standard Error: 26_067 + .saturating_add(Weight::from_parts(14_810_256, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2800).saturating_mul(r.into())) @@ -3077,13 +2929,12 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 1024]`. fn seal_debug_message_per_kb(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `125824` - // Estimated: `265128` - // Minimum execution time: 501_014 nanoseconds. - Weight::from_parts(505_634_218, 0) - .saturating_add(Weight::from_parts(0, 265128)) - // Standard Error: 2_441 - .saturating_add(Weight::from_parts(819_257, 0).saturating_mul(i.into())) + // Measured: `125728` + // Estimated: `269982` + // Minimum execution time: 413_391_000 picoseconds. + Weight::from_parts(414_927_640, 269982) + // Standard Error: 1_740 + .saturating_add(Weight::from_parts(763_359, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3092,13 +2943,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 10]`. fn seal_set_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `911 + r * (23420 ±0)` - // Estimated: `911 + r * (23418 ±0)` - // Minimum execution time: 375_301 nanoseconds. - Weight::from_parts(291_498_841, 0) - .saturating_add(Weight::from_parts(0, 911)) - // Standard Error: 809_989 - .saturating_add(Weight::from_parts(464_550_291, 0).saturating_mul(r.into())) + // Measured: `815 + r * (23420 ±0)` + // Estimated: `815 + r * (23418 ±0)` + // Minimum execution time: 296_108_000 picoseconds. + Weight::from_parts(208_214_040, 815) + // Standard Error: 860_573 + .saturating_add(Weight::from_parts(480_342_550, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3110,13 +2960,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_new_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `12672 + n * (11945 ±0)` - // Estimated: `8529 + n * (12814 ±61)` - // Minimum execution time: 506_318 nanoseconds. - Weight::from_parts(676_935_313, 0) - .saturating_add(Weight::from_parts(0, 8529)) - // Standard Error: 1_589_291 - .saturating_add(Weight::from_parts(97_839_399, 0).saturating_mul(n.into())) + // Measured: `12544 + n * (11945 ±0)` + // Estimated: `8401 + n * (12814 ±61)` + // Minimum execution time: 442_286_000 picoseconds. + Weight::from_parts(620_395_299, 8401) + // Standard Error: 1_661_554 + .saturating_add(Weight::from_parts(89_393_169, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(52_u64)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(50_u64)) @@ -3128,31 +2977,29 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_old_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `15170 + n * (175775 ±0)` - // Estimated: `9914 + n * (176858 ±74)` - // Minimum execution time: 506_148 nanoseconds. - Weight::from_parts(648_278_778, 0) - .saturating_add(Weight::from_parts(0, 9914)) - // Standard Error: 1_343_586 - .saturating_add(Weight::from_parts(65_789_595, 0).saturating_mul(n.into())) + // Measured: `12532 + n * (175784 ±0)` + // Estimated: `8396 + n * (176649 ±61)` + // Minimum execution time: 440_882_000 picoseconds. + Weight::from_parts(587_317_981, 8396) + // Standard Error: 1_374_991 + .saturating_add(Weight::from_parts(66_271_084, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(51_u64)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(49_u64)) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 176858).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 176649).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 10]`. fn seal_clear_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `903 + r * (23099 ±0)` - // Estimated: `908 + r * (23099 ±0)` - // Minimum execution time: 374_344 nanoseconds. - Weight::from_parts(293_272_061, 0) - .saturating_add(Weight::from_parts(0, 908)) - // Standard Error: 810_412 - .saturating_add(Weight::from_parts(453_315_956, 0).saturating_mul(r.into())) + // Measured: `807 + r * (23099 ±0)` + // Estimated: `812 + r * (23099 ±0)` + // Minimum execution time: 296_023_000 picoseconds. + Weight::from_parts(221_471_559, 812) + // Standard Error: 814_503 + .saturating_add(Weight::from_parts(465_928_089, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3164,31 +3011,29 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 8]`. fn seal_clear_storage_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `14895 + n * (175768 ±0)` - // Estimated: `9551 + n * (176867 ±75)` - // Minimum execution time: 478_564 nanoseconds. - Weight::from_parts(630_839_142, 0) - .saturating_add(Weight::from_parts(0, 9551)) - // Standard Error: 1_427_520 - .saturating_add(Weight::from_parts(66_813_592, 0).saturating_mul(n.into())) + // Measured: `12256 + n * (175776 ±0)` + // Estimated: `8047 + n * (176655 ±62)` + // Minimum execution time: 412_212_000 picoseconds. + Weight::from_parts(569_213_147, 8047) + // Standard Error: 1_463_771 + .saturating_add(Weight::from_parts(67_932_081, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(51_u64)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(48_u64)) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 176867).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 176655).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 10]`. fn seal_get_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `896 + r * (23744 ±0)` - // Estimated: `909 + r * (23740 ±0)` - // Minimum execution time: 374_479 nanoseconds. - Weight::from_parts(311_839_315, 0) - .saturating_add(Weight::from_parts(0, 909)) - // Standard Error: 666_553 - .saturating_add(Weight::from_parts(371_213_042, 0).saturating_mul(r.into())) + // Measured: `800 + r * (23744 ±0)` + // Estimated: `813 + r * (23740 ±0)` + // Minimum execution time: 296_007_000 picoseconds. + Weight::from_parts(229_100_700, 813) + // Standard Error: 684_970 + .saturating_add(Weight::from_parts(394_982_991, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3199,30 +3044,28 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 8]`. fn seal_get_storage_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `15501 + n * (175775 ±0)` - // Estimated: `10042 + n * (176900 ±76)` - // Minimum execution time: 460_639 nanoseconds. - Weight::from_parts(591_187_094, 0) - .saturating_add(Weight::from_parts(0, 10042)) - // Standard Error: 1_233_792 - .saturating_add(Weight::from_parts(160_874_477, 0).saturating_mul(n.into())) + // Measured: `12863 + n * (175784 ±0)` + // Estimated: `8538 + n * (176688 ±63)` + // Minimum execution time: 392_306_000 picoseconds. + Weight::from_parts(539_188_004, 8538) + // Standard Error: 1_371_839 + .saturating_add(Weight::from_parts(155_130_373, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(51_u64)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 176900).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 176688).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 10]`. fn seal_contains_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `914 + r * (23098 ±0)` - // Estimated: `920 + r * (23098 ±0)` - // Minimum execution time: 374_272 nanoseconds. - Weight::from_parts(311_446_269, 0) - .saturating_add(Weight::from_parts(0, 920)) - // Standard Error: 630_307 - .saturating_add(Weight::from_parts(357_134_931, 0).saturating_mul(r.into())) + // Measured: `818 + r * (23098 ±0)` + // Estimated: `824 + r * (23098 ±0)` + // Minimum execution time: 296_038_000 picoseconds. + Weight::from_parts(229_462_798, 824) + // Standard Error: 655_463 + .saturating_add(Weight::from_parts(372_593_685, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3233,30 +3076,28 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 8]`. fn seal_contains_storage_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `14839 + n * (175789 ±0)` - // Estimated: `9532 + n * (176874 ±75)` - // Minimum execution time: 456_013 nanoseconds. - Weight::from_parts(575_116_352, 0) - .saturating_add(Weight::from_parts(0, 9532)) - // Standard Error: 1_122_298 - .saturating_add(Weight::from_parts(61_786_107, 0).saturating_mul(n.into())) + // Measured: `12200 + n * (175798 ±0)` + // Estimated: `8028 + n * (176661 ±62)` + // Minimum execution time: 386_782_000 picoseconds. + Weight::from_parts(512_965_975, 8028) + // Standard Error: 1_168_132 + .saturating_add(Weight::from_parts(63_307_325, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(51_u64)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 176874).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 176661).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 10]`. fn seal_take_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `911 + r * (23740 ±0)` - // Estimated: `913 + r * (23739 ±0)` - // Minimum execution time: 374_621 nanoseconds. - Weight::from_parts(299_689_489, 0) - .saturating_add(Weight::from_parts(0, 913)) - // Standard Error: 757_735 - .saturating_add(Weight::from_parts(465_213_246, 0).saturating_mul(r.into())) + // Measured: `815 + r * (23740 ±0)` + // Estimated: `817 + r * (23739 ±0)` + // Minimum execution time: 296_352_000 picoseconds. + Weight::from_parts(212_661_296, 817) + // Standard Error: 879_297 + .saturating_add(Weight::from_parts(494_182_672, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3268,18 +3109,17 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 8]`. fn seal_take_storage_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `15502 + n * (175775 ±0)` - // Estimated: `10042 + n * (176898 ±76)` - // Minimum execution time: 481_980 nanoseconds. - Weight::from_parts(647_289_053, 0) - .saturating_add(Weight::from_parts(0, 10042)) - // Standard Error: 1_556_155 - .saturating_add(Weight::from_parts(166_592_657, 0).saturating_mul(n.into())) + // Measured: `12864 + n * (175784 ±0)` + // Estimated: `8539 + n * (176686 ±63)` + // Minimum execution time: 414_693_000 picoseconds. + Weight::from_parts(595_693_859, 8539) + // Standard Error: 1_673_819 + .saturating_add(Weight::from_parts(163_090_316, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(51_u64)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(48_u64)) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 176898).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 176686).saturating_mul(n.into())) } /// Storage: System Account (r:1602 w:1601) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3294,18 +3134,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_transfer(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1457 + r * (3604 ±0)` - // Estimated: `21583 + r * (216101 ±0)` - // Minimum execution time: 374_962 nanoseconds. - Weight::from_parts(313_416_386, 0) - .saturating_add(Weight::from_parts(0, 21583)) - // Standard Error: 710_675 - .saturating_add(Weight::from_parts(1_396_551_156, 0).saturating_mul(r.into())) + // Measured: `1329 + r * (3604 ±0)` + // Estimated: `25928 + r * (216096 ±4)` + // Minimum execution time: 299_205_000 picoseconds. + Weight::from_parts(221_142_217, 25928) + // Standard Error: 1_369_909 + .saturating_add(Weight::from_parts(1_665_917_241, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(RocksDbWeight::get().writes((80_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 216101).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 216096).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3320,18 +3159,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1609 + r * (23073 ±0)` - // Estimated: `22098 + r * (511456 ±1)` - // Minimum execution time: 375_916 nanoseconds. - Weight::from_parts(376_468_000, 0) - .saturating_add(Weight::from_parts(0, 22098)) - // Standard Error: 7_246_855 - .saturating_add(Weight::from_parts(28_982_425_139, 0).saturating_mul(r.into())) + // Measured: `1479 + r * (20514 ±0)` + // Estimated: `26429 + r * (498656 ±1)` + // Minimum execution time: 297_501_000 picoseconds. + Weight::from_parts(298_400_000, 26429) + // Standard Error: 9_372_890 + .saturating_add(Weight::from_parts(22_507_984_433, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((160_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((160_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 511456).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 498656).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3346,18 +3184,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (71670 ±0)` - // Estimated: `17285 + r * (659930 ±563)` - // Minimum execution time: 375_412 nanoseconds. - Weight::from_parts(376_493_000, 0) - .saturating_add(Weight::from_parts(0, 17285)) - // Standard Error: 8_239_575 - .saturating_add(Weight::from_parts(28_716_347_183, 0).saturating_mul(r.into())) + // Measured: `0 + r * (69030 ±0)` + // Estimated: `21755 + r * (647542 ±560)` + // Minimum execution time: 297_432_000 picoseconds. + Weight::from_parts(298_220_000, 21755) + // Standard Error: 9_420_834 + .saturating_add(Weight::from_parts(22_261_152_353, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((150_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((75_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 659930).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 647542).saturating_mul(r.into())) } /// Storage: System Account (r:82 w:81) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3373,20 +3210,19 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 1024]`. fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `24269 + t * (16910 ±0)` - // Estimated: `532690 + t * (285025 ±0)` - // Minimum execution time: 10_443_315 nanoseconds. - Weight::from_parts(9_342_574_069, 0) - .saturating_add(Weight::from_parts(0, 532690)) - // Standard Error: 7_237_279 - .saturating_add(Weight::from_parts(1_390_221_936, 0).saturating_mul(t.into())) - // Standard Error: 10_851 - .saturating_add(Weight::from_parts(9_842_151, 0).saturating_mul(c.into())) + // Measured: `21581 + t * (14318 ±0)` + // Estimated: `524200 + t * (272065 ±0)` + // Minimum execution time: 11_799_802_000 picoseconds. + Weight::from_parts(10_575_328_547, 524200) + // Standard Error: 11_952_810 + .saturating_add(Weight::from_parts(1_603_077_083, 0).saturating_mul(t.into())) + // Standard Error: 17_922 + .saturating_add(Weight::from_parts(9_876_752, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(167_u64)) .saturating_add(RocksDbWeight::get().reads((81_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(163_u64)) .saturating_add(RocksDbWeight::get().writes((81_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 285025).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 272065).saturating_mul(t.into())) } /// Storage: System Account (r:3202 w:3202) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3405,18 +3241,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_instantiate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1775 + r * (25568 ±0)` - // Estimated: `26563 + r * (1367114 ±2)` - // Minimum execution time: 376_418 nanoseconds. - Weight::from_parts(377_292_000, 0) - .saturating_add(Weight::from_parts(0, 26563)) - // Standard Error: 32_312_545 - .saturating_add(Weight::from_parts(35_904_826_312, 0).saturating_mul(r.into())) + // Measured: `1646 + r * (20288 ±0)` + // Estimated: `32625 + r * (1330150 ±2)` + // Minimum execution time: 298_155_000 picoseconds. + Weight::from_parts(299_212_000, 32625) + // Standard Error: 32_410_313 + .saturating_add(Weight::from_parts(30_417_025_178, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((480_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(5_u64)) .saturating_add(RocksDbWeight::get().writes((400_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 1367114).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 1330150).saturating_mul(r.into())) } /// Storage: System Account (r:162 w:162) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3437,22 +3272,21 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 960]`. fn seal_instantiate_per_transfer_input_salt_kb(t: u32, i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `5785 + t * (33 ±0)` - // Estimated: `850985 + t * (2671 ±3)` - // Minimum execution time: 132_157_340 nanoseconds. - Weight::from_parts(11_329_968_948, 0) - .saturating_add(Weight::from_parts(0, 850985)) - // Standard Error: 99_102_968 - .saturating_add(Weight::from_parts(84_719_458, 0).saturating_mul(t.into())) - // Standard Error: 161_609 - .saturating_add(Weight::from_parts(126_156_627, 0).saturating_mul(i.into())) - // Standard Error: 161_609 - .saturating_add(Weight::from_parts(126_628_313, 0).saturating_mul(s.into())) + // Measured: `5625 + t * (1 ±0)` + // Estimated: `856795 + t * (2471 ±3)` + // Minimum execution time: 105_914_928_000 picoseconds. + Weight::from_parts(13_229_760_432, 856795) + // Standard Error: 96_394_437 + .saturating_add(Weight::from_parts(398_413_888, 0).saturating_mul(t.into())) + // Standard Error: 157_192 + .saturating_add(Weight::from_parts(97_104_978, 0).saturating_mul(i.into())) + // Standard Error: 157_192 + .saturating_add(Weight::from_parts(97_146_130, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(329_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(326_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 2671).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 2471).saturating_mul(t.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3467,13 +3301,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `871 + r * (642 ±0)` - // Estimated: `17225 + r * (3210 ±0)` - // Minimum execution time: 373_559 nanoseconds. - Weight::from_parts(375_166_904, 0) - .saturating_add(Weight::from_parts(0, 17225)) - // Standard Error: 125_024 - .saturating_add(Weight::from_parts(42_291_595, 0).saturating_mul(r.into())) + // Measured: `775 + r * (642 ±0)` + // Estimated: `21695 + r * (3210 ±0)` + // Minimum execution time: 294_309_000 picoseconds. + Weight::from_parts(296_241_318, 21695) + // Standard Error: 127_872 + .saturating_add(Weight::from_parts(45_806_281, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3210).saturating_mul(r.into())) @@ -3491,13 +3324,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1024]`. fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1673` - // Estimated: `21160` - // Minimum execution time: 416_233 nanoseconds. - Weight::from_parts(416_785_000, 0) - .saturating_add(Weight::from_parts(0, 21160)) - // Standard Error: 56_223 - .saturating_add(Weight::from_parts(324_513_835, 0).saturating_mul(n.into())) + // Measured: `1577` + // Estimated: `25630` + // Minimum execution time: 341_248_000 picoseconds. + Weight::from_parts(341_607_000, 25630) + // Standard Error: 66_687 + .saturating_add(Weight::from_parts(322_250_398, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3514,13 +3346,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (642 ±0)` - // Estimated: `17235 + r * (3210 ±0)` - // Minimum execution time: 371_735 nanoseconds. - Weight::from_parts(375_979_430, 0) - .saturating_add(Weight::from_parts(0, 17235)) - // Standard Error: 968_037 - .saturating_add(Weight::from_parts(57_780_769, 0).saturating_mul(r.into())) + // Measured: `777 + r * (642 ±0)` + // Estimated: `21705 + r * (3210 ±0)` + // Minimum execution time: 293_810_000 picoseconds. + Weight::from_parts(296_719_171, 21705) + // Standard Error: 450_807 + .saturating_add(Weight::from_parts(61_627_228, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3210).saturating_mul(r.into())) @@ -3538,13 +3369,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1024]`. fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1675` - // Estimated: `21205` - // Minimum execution time: 428_196 nanoseconds. - Weight::from_parts(429_438_000, 0) - .saturating_add(Weight::from_parts(0, 21205)) - // Standard Error: 57_860 - .saturating_add(Weight::from_parts(260_917_896, 0).saturating_mul(n.into())) + // Measured: `1579` + // Estimated: `25675` + // Minimum execution time: 354_550_000 picoseconds. + Weight::from_parts(355_136_000, 25675) + // Standard Error: 61_761 + .saturating_add(Weight::from_parts(257_021_566, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3561,13 +3391,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (642 ±0)` - // Estimated: `17235 + r * (3210 ±0)` - // Minimum execution time: 371_412 nanoseconds. - Weight::from_parts(373_635_818, 0) - .saturating_add(Weight::from_parts(0, 17235)) - // Standard Error: 222_973 - .saturating_add(Weight::from_parts(33_347_181, 0).saturating_mul(r.into())) + // Measured: `777 + r * (642 ±0)` + // Estimated: `21705 + r * (3210 ±0)` + // Minimum execution time: 293_369_000 picoseconds. + Weight::from_parts(295_990_893, 21705) + // Standard Error: 431_269 + .saturating_add(Weight::from_parts(32_213_406, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3210).saturating_mul(r.into())) @@ -3585,13 +3414,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1675` - // Estimated: `21180` - // Minimum execution time: 405_858 nanoseconds. - Weight::from_parts(406_498_000, 0) - .saturating_add(Weight::from_parts(0, 21180)) - // Standard Error: 48_388 - .saturating_add(Weight::from_parts(103_283_157, 0).saturating_mul(n.into())) + // Measured: `1579` + // Estimated: `25650` + // Minimum execution time: 326_595_000 picoseconds. + Weight::from_parts(327_188_000, 25650) + // Standard Error: 53_385 + .saturating_add(Weight::from_parts(74_046_074, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3608,13 +3436,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (679 ±0)` - // Estimated: `17235 + r * (3395 ±0)` - // Minimum execution time: 371_746 nanoseconds. - Weight::from_parts(373_538_171, 0) - .saturating_add(Weight::from_parts(0, 17235)) - // Standard Error: 387_332 - .saturating_add(Weight::from_parts(35_933_528, 0).saturating_mul(r.into())) + // Measured: `777 + r * (679 ±0)` + // Estimated: `21705 + r * (3395 ±0)` + // Minimum execution time: 292_388_000 picoseconds. + Weight::from_parts(295_090_179, 21705) + // Standard Error: 170_487 + .saturating_add(Weight::from_parts(32_577_820, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3395).saturating_mul(r.into())) @@ -3632,13 +3459,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1675` - // Estimated: `21225` - // Minimum execution time: 405_752 nanoseconds. - Weight::from_parts(406_417_000, 0) - .saturating_add(Weight::from_parts(0, 21225)) - // Standard Error: 47_051 - .saturating_add(Weight::from_parts(103_325_027, 0).saturating_mul(n.into())) + // Measured: `1579` + // Estimated: `25695` + // Minimum execution time: 326_862_000 picoseconds. + Weight::from_parts(327_449_000, 25695) + // Standard Error: 54_539 + .saturating_add(Weight::from_parts(74_042_337, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3655,13 +3481,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `917 + r * (6083 ±0)` - // Estimated: `17455 + r * (30415 ±0)` - // Minimum execution time: 373_882 nanoseconds. - Weight::from_parts(376_553_787, 0) - .saturating_add(Weight::from_parts(0, 17455)) - // Standard Error: 912_833 - .saturating_add(Weight::from_parts(3_021_100_412, 0).saturating_mul(r.into())) + // Measured: `821 + r * (6083 ±0)` + // Estimated: `21925 + r * (30415 ±0)` + // Minimum execution time: 295_597_000 picoseconds. + Weight::from_parts(298_267_200, 21925) + // Standard Error: 699_824 + .saturating_add(Weight::from_parts(3_021_734_700, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30415).saturating_mul(r.into())) @@ -3679,13 +3504,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `886 + r * (3362 ±0)` - // Estimated: `17300 + r * (16810 ±0)` - // Minimum execution time: 373_673 nanoseconds. - Weight::from_parts(375_712_961, 0) - .saturating_add(Weight::from_parts(0, 17300)) - // Standard Error: 596_297 - .saturating_add(Weight::from_parts(738_257_638, 0).saturating_mul(r.into())) + // Measured: `790 + r * (3362 ±0)` + // Estimated: `21770 + r * (16810 ±0)` + // Minimum execution time: 295_539_000 picoseconds. + Weight::from_parts(297_844_822, 21770) + // Standard Error: 490_532 + .saturating_add(Weight::from_parts(747_592_977, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 16810).saturating_mul(r.into())) @@ -3705,18 +3529,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (79300 ±0)` - // Estimated: `64844 + r * (942952 ±833)` - // Minimum execution time: 374_097 nanoseconds. - Weight::from_parts(374_985_000, 0) - .saturating_add(Weight::from_parts(0, 64844)) - // Standard Error: 3_772_336 - .saturating_add(Weight::from_parts(1_546_402_854, 0).saturating_mul(r.into())) + // Measured: `0 + r * (74020 ±0)` + // Estimated: `69192 + r * (913289 ±821)` + // Minimum execution time: 295_164_000 picoseconds. + Weight::from_parts(296_597_000, 69192) + // Standard Error: 3_646_577 + .saturating_add(Weight::from_parts(1_725_796_807, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((225_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((150_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 942952).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 913289).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3731,13 +3554,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `869 + r * (240 ±0)` - // Estimated: `17215 + r * (1200 ±0)` - // Minimum execution time: 374_249 nanoseconds. - Weight::from_parts(377_990_998, 0) - .saturating_add(Weight::from_parts(0, 17215)) - // Standard Error: 38_133 - .saturating_add(Weight::from_parts(11_483_273, 0).saturating_mul(r.into())) + // Measured: `773 + r * (240 ±0)` + // Estimated: `21685 + r * (1200 ±0)` + // Minimum execution time: 296_287_000 picoseconds. + Weight::from_parts(300_696_694, 21685) + // Standard Error: 27_891 + .saturating_add(Weight::from_parts(10_943_994, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1200).saturating_mul(r.into())) @@ -3755,13 +3577,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2102 + r * (3154 ±0)` - // Estimated: `21980 + r * (15875 ±2)` - // Minimum execution time: 375_552 nanoseconds. - Weight::from_parts(400_624_032, 0) - .saturating_add(Weight::from_parts(0, 21980)) - // Standard Error: 82_523 - .saturating_add(Weight::from_parts(18_057_327, 0).saturating_mul(r.into())) + // Measured: `2006 + r * (3154 ±0)` + // Estimated: `26435 + r * (15875 ±2)` + // Minimum execution time: 298_000_000 picoseconds. + Weight::from_parts(328_282_119, 26435) + // Standard Error: 104_874 + .saturating_add(Weight::from_parts(18_428_267, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15875).saturating_mul(r.into())) @@ -3781,13 +3602,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `872 + r * (240 ±0)` - // Estimated: `18598 + r * (1440 ±0)` - // Minimum execution time: 373_899 nanoseconds. - Weight::from_parts(379_733_943, 0) - .saturating_add(Weight::from_parts(0, 18598)) - // Standard Error: 32_022 - .saturating_add(Weight::from_parts(9_381_180, 0).saturating_mul(r.into())) + // Measured: `776 + r * (240 ±0)` + // Estimated: `23962 + r * (1440 ±0)` + // Minimum execution time: 295_104_000 picoseconds. + Weight::from_parts(299_334_585, 23962) + // Standard Error: 25_840 + .saturating_add(Weight::from_parts(9_744_866, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1440).saturating_mul(r.into())) @@ -3797,571 +3617,519 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 834 nanoseconds. - Weight::from_parts(1_009_646, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 388 - .saturating_add(Weight::from_parts(411_979, 0).saturating_mul(r.into())) + // Minimum execution time: 1_132_000 picoseconds. + Weight::from_parts(1_100_159, 0) + // Standard Error: 10_131 + .saturating_add(Weight::from_parts(436_462, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64load(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 882 nanoseconds. - Weight::from_parts(1_416_377, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_133 - .saturating_add(Weight::from_parts(1_075_838, 0).saturating_mul(r.into())) + // Minimum execution time: 1_368_000 picoseconds. + Weight::from_parts(1_974_308, 0) + // Standard Error: 811 + .saturating_add(Weight::from_parts(1_079_620, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64store(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 878 nanoseconds. - Weight::from_parts(1_343_056, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 426 - .saturating_add(Weight::from_parts(1_001_214, 0).saturating_mul(r.into())) + // Minimum execution time: 1_354_000 picoseconds. + Weight::from_parts(2_057_834, 0) + // Standard Error: 4_277 + .saturating_add(Weight::from_parts(1_008_797, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_select(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 796 nanoseconds. - Weight::from_parts(1_079_086, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 409 - .saturating_add(Weight::from_parts(1_149_188, 0).saturating_mul(r.into())) + // Minimum execution time: 1_218_000 picoseconds. + Weight::from_parts(1_594_528, 0) + // Standard Error: 723 + .saturating_add(Weight::from_parts(1_147_486, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 800 nanoseconds. - Weight::from_parts(1_044_184, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 707 - .saturating_add(Weight::from_parts(1_315_686, 0).saturating_mul(r.into())) + // Minimum execution time: 1_156_000 picoseconds. + Weight::from_parts(1_460_611, 0) + // Standard Error: 419 + .saturating_add(Weight::from_parts(1_314_741, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 807 nanoseconds. - Weight::from_parts(1_049_633, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 361 - .saturating_add(Weight::from_parts(640_530, 0).saturating_mul(r.into())) + // Minimum execution time: 1_166_000 picoseconds. + Weight::from_parts(1_454_460, 0) + // Standard Error: 493 + .saturating_add(Weight::from_parts(642_481, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 774 nanoseconds. - Weight::from_parts(1_124_053, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 784 - .saturating_add(Weight::from_parts(949_398, 0).saturating_mul(r.into())) + // Minimum execution time: 1_144_000 picoseconds. + Weight::from_parts(1_410_515, 0) + // Standard Error: 894 + .saturating_add(Weight::from_parts(958_765, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br_table(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 810 nanoseconds. - Weight::from_parts(676_581, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_356 - .saturating_add(Weight::from_parts(1_163_465, 0).saturating_mul(r.into())) + // Minimum execution time: 1_190_000 picoseconds. + Weight::from_parts(1_143_236, 0) + // Standard Error: 2_773 + .saturating_add(Weight::from_parts(1_164_764, 0).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. fn instr_br_table_per_entry(e: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_580 nanoseconds. - Weight::from_parts(2_835_656, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 71 - .saturating_add(Weight::from_parts(4_686, 0).saturating_mul(e.into())) + // Minimum execution time: 2_993_000 picoseconds. + Weight::from_parts(3_270_525, 0) + // Standard Error: 65 + .saturating_add(Weight::from_parts(4_418, 0).saturating_mul(e.into())) } /// The range of component `r` is `[0, 50]`. fn instr_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 826 nanoseconds. - Weight::from_parts(1_625_698, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_740 - .saturating_add(Weight::from_parts(2_332_187, 0).saturating_mul(r.into())) + // Minimum execution time: 1_163_000 picoseconds. + Weight::from_parts(1_999_458, 0) + // Standard Error: 1_418 + .saturating_add(Weight::from_parts(2_371_979, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_call_indirect(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 901 nanoseconds. - Weight::from_parts(2_338_620, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_642 - .saturating_add(Weight::from_parts(2_924_090, 0).saturating_mul(r.into())) + // Minimum execution time: 1_288_000 picoseconds. + Weight::from_parts(2_340_227, 0) + // Standard Error: 3_234 + .saturating_add(Weight::from_parts(3_038_523, 0).saturating_mul(r.into())) } /// The range of component `p` is `[0, 128]`. fn instr_call_indirect_per_param(p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_670 nanoseconds. - Weight::from_parts(5_556_246, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_491 - .saturating_add(Weight::from_parts(228_965, 0).saturating_mul(p.into())) + // Minimum execution time: 5_270_000 picoseconds. + Weight::from_parts(6_360_011, 0) + // Standard Error: 2_585 + .saturating_add(Weight::from_parts(226_149, 0).saturating_mul(p.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_099 nanoseconds. - Weight::from_parts(3_896_177, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 99 - .saturating_add(Weight::from_parts(91_304, 0).saturating_mul(l.into())) + // Minimum execution time: 3_580_000 picoseconds. + Weight::from_parts(5_183_658, 0) + // Standard Error: 80 + .saturating_add(Weight::from_parts(46_038, 0).saturating_mul(l.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_042 nanoseconds. - Weight::from_parts(3_334_621, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 793 - .saturating_add(Weight::from_parts(459_346, 0).saturating_mul(r.into())) + // Minimum execution time: 2_559_000 picoseconds. + Weight::from_parts(2_846_350, 0) + // Standard Error: 2_809 + .saturating_add(Weight::from_parts(462_084, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_968 nanoseconds. - Weight::from_parts(3_235_286, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 427 - .saturating_add(Weight::from_parts(485_454, 0).saturating_mul(r.into())) + // Minimum execution time: 2_530_000 picoseconds. + Weight::from_parts(2_835_072, 0) + // Standard Error: 479 + .saturating_add(Weight::from_parts(483_451, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_tee(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_012 nanoseconds. - Weight::from_parts(3_303_555, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 371 - .saturating_add(Weight::from_parts(657_811, 0).saturating_mul(r.into())) + // Minimum execution time: 2_510_000 picoseconds. + Weight::from_parts(2_740_081, 0) + // Standard Error: 901 + .saturating_add(Weight::from_parts(664_354, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_global_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 865 nanoseconds. - Weight::from_parts(1_249_987, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 417 - .saturating_add(Weight::from_parts(896_704, 0).saturating_mul(r.into())) + // Minimum execution time: 1_295_000 picoseconds. + Weight::from_parts(1_798_174, 0) + // Standard Error: 464 + .saturating_add(Weight::from_parts(896_289, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_global_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 866 nanoseconds. - Weight::from_parts(1_216_218, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 503 - .saturating_add(Weight::from_parts(919_719, 0).saturating_mul(r.into())) + // Minimum execution time: 1_287_000 picoseconds. + Weight::from_parts(1_636_548, 0) + // Standard Error: 658 + .saturating_add(Weight::from_parts(923_295, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_memory_current(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 921 nanoseconds. - Weight::from_parts(1_228_408, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 309 - .saturating_add(Weight::from_parts(813_007, 0).saturating_mul(r.into())) + // Minimum execution time: 1_353_000 picoseconds. + Weight::from_parts(1_672_309, 0) + // Standard Error: 403 + .saturating_add(Weight::from_parts(818_273, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 1]`. fn instr_memory_grow(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 820 nanoseconds. - Weight::from_parts(914_830, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 6_018 - .saturating_add(Weight::from_parts(237_062_769, 0).saturating_mul(r.into())) + // Minimum execution time: 1_180_000 picoseconds. + Weight::from_parts(1_304_714, 0) + // Standard Error: 88_180 + .saturating_add(Weight::from_parts(183_952_985, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64clz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 812 nanoseconds. - Weight::from_parts(1_554_406, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 9_979 - .saturating_add(Weight::from_parts(625_434, 0).saturating_mul(r.into())) + // Minimum execution time: 1_158_000 picoseconds. + Weight::from_parts(1_800_065, 0) + // Standard Error: 2_104 + .saturating_add(Weight::from_parts(625_410, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ctz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 798 nanoseconds. - Weight::from_parts(1_095_113, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 243 - .saturating_add(Weight::from_parts(634_204, 0).saturating_mul(r.into())) + // Minimum execution time: 1_208_000 picoseconds. + Weight::from_parts(1_483_908, 0) + // Standard Error: 319 + .saturating_add(Weight::from_parts(635_095, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64popcnt(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 792 nanoseconds. - Weight::from_parts(1_109_845, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 14_944 - .saturating_add(Weight::from_parts(658_834, 0).saturating_mul(r.into())) + // Minimum execution time: 1_164_000 picoseconds. + Weight::from_parts(1_506_871, 0) + // Standard Error: 264 + .saturating_add(Weight::from_parts(633_660, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64eqz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 815 nanoseconds. - Weight::from_parts(1_068_916, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 327 - .saturating_add(Weight::from_parts(652_897, 0).saturating_mul(r.into())) + // Minimum execution time: 1_141_000 picoseconds. + Weight::from_parts(1_467_219, 0) + // Standard Error: 191 + .saturating_add(Weight::from_parts(651_156, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendsi32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 798 nanoseconds. - Weight::from_parts(1_069_745, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 306 - .saturating_add(Weight::from_parts(618_481, 0).saturating_mul(r.into())) + // Minimum execution time: 1_170_000 picoseconds. + Weight::from_parts(1_474_718, 0) + // Standard Error: 224 + .saturating_add(Weight::from_parts(617_317, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendui32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 799 nanoseconds. - Weight::from_parts(1_398_001, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 6_234 - .saturating_add(Weight::from_parts(611_399, 0).saturating_mul(r.into())) + // Minimum execution time: 1_195_000 picoseconds. + Weight::from_parts(1_501_421, 0) + // Standard Error: 221 + .saturating_add(Weight::from_parts(616_559, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i32wrapi64(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 811 nanoseconds. - Weight::from_parts(1_098_083, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 297 - .saturating_add(Weight::from_parts(617_692, 0).saturating_mul(r.into())) + // Minimum execution time: 1_172_000 picoseconds. + Weight::from_parts(1_482_402, 0) + // Standard Error: 2_163 + .saturating_add(Weight::from_parts(619_230, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64eq(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 815 nanoseconds. - Weight::from_parts(1_046_922, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 335 - .saturating_add(Weight::from_parts(909_196, 0).saturating_mul(r.into())) + // Minimum execution time: 1_149_000 picoseconds. + Weight::from_parts(2_021_801, 0) + // Standard Error: 20_804 + .saturating_add(Weight::from_parts(913_888, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ne(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 805 nanoseconds. - Weight::from_parts(1_093_667, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 233 - .saturating_add(Weight::from_parts(907_378, 0).saturating_mul(r.into())) + // Minimum execution time: 1_187_000 picoseconds. + Weight::from_parts(1_358_437, 0) + // Standard Error: 1_946 + .saturating_add(Weight::from_parts(916_378, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64lts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 805 nanoseconds. - Weight::from_parts(1_290_591, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_201 - .saturating_add(Weight::from_parts(902_006, 0).saturating_mul(r.into())) + // Minimum execution time: 1_175_000 picoseconds. + Weight::from_parts(1_527_336, 0) + // Standard Error: 243 + .saturating_add(Weight::from_parts(907_580, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ltu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 783 nanoseconds. - Weight::from_parts(1_159_977, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_310 - .saturating_add(Weight::from_parts(906_489, 0).saturating_mul(r.into())) + // Minimum execution time: 1_220_000 picoseconds. + Weight::from_parts(1_530_715, 0) + // Standard Error: 224 + .saturating_add(Weight::from_parts(906_096, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64gts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 790 nanoseconds. - Weight::from_parts(1_109_719, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 261 - .saturating_add(Weight::from_parts(906_614, 0).saturating_mul(r.into())) + // Minimum execution time: 1_107_000 picoseconds. + Weight::from_parts(1_496_553, 0) + // Standard Error: 299 + .saturating_add(Weight::from_parts(907_963, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64gtu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 776 nanoseconds. - Weight::from_parts(1_076_567, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 348 - .saturating_add(Weight::from_parts(919_374, 0).saturating_mul(r.into())) + // Minimum execution time: 1_153_000 picoseconds. + Weight::from_parts(1_482_710, 0) + // Standard Error: 182 + .saturating_add(Weight::from_parts(918_439, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64les(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 780 nanoseconds. - Weight::from_parts(1_069_663, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 265 - .saturating_add(Weight::from_parts(908_037, 0).saturating_mul(r.into())) + // Minimum execution time: 1_142_000 picoseconds. + Weight::from_parts(1_522_114, 0) + // Standard Error: 297 + .saturating_add(Weight::from_parts(906_633, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64leu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 832 nanoseconds. - Weight::from_parts(930_920, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_170 - .saturating_add(Weight::from_parts(929_811, 0).saturating_mul(r.into())) + // Minimum execution time: 1_119_000 picoseconds. + Weight::from_parts(2_199_831, 0) + // Standard Error: 4_234 + .saturating_add(Weight::from_parts(898_161, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ges(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 787 nanoseconds. - Weight::from_parts(1_087_325, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 315 - .saturating_add(Weight::from_parts(908_321, 0).saturating_mul(r.into())) + // Minimum execution time: 1_163_000 picoseconds. + Weight::from_parts(1_489_404, 0) + // Standard Error: 416 + .saturating_add(Weight::from_parts(908_450, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64geu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 798 nanoseconds. - Weight::from_parts(1_029_132, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_095 - .saturating_add(Weight::from_parts(913_553, 0).saturating_mul(r.into())) + // Minimum execution time: 1_204_000 picoseconds. + Weight::from_parts(2_266_296, 0) + // Standard Error: 13_013 + .saturating_add(Weight::from_parts(899_225, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64add(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 791 nanoseconds. - Weight::from_parts(1_086_314, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 197 - .saturating_add(Weight::from_parts(896_392, 0).saturating_mul(r.into())) + // Minimum execution time: 1_160_000 picoseconds. + Weight::from_parts(1_470_799, 0) + // Standard Error: 422 + .saturating_add(Weight::from_parts(897_325, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64sub(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 793 nanoseconds. - Weight::from_parts(1_078_172, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 404 - .saturating_add(Weight::from_parts(886_329, 0).saturating_mul(r.into())) + // Minimum execution time: 1_125_000 picoseconds. + Weight::from_parts(1_521_508, 0) + // Standard Error: 594 + .saturating_add(Weight::from_parts(886_145, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64mul(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 799 nanoseconds. - Weight::from_parts(1_095_010, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 431 - .saturating_add(Weight::from_parts(886_513, 0).saturating_mul(r.into())) + // Minimum execution time: 1_139_000 picoseconds. + Weight::from_parts(1_490_535, 0) + // Standard Error: 211 + .saturating_add(Weight::from_parts(884_929, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64divs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 810 nanoseconds. - Weight::from_parts(1_114_325, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 452 - .saturating_add(Weight::from_parts(1_521_849, 0).saturating_mul(r.into())) + // Minimum execution time: 1_180_000 picoseconds. + Weight::from_parts(2_221_481, 0) + // Standard Error: 9_884 + .saturating_add(Weight::from_parts(1_507_511, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64divu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 784 nanoseconds. - Weight::from_parts(1_123_153, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 475 - .saturating_add(Weight::from_parts(1_457_746, 0).saturating_mul(r.into())) + // Minimum execution time: 1_131_000 picoseconds. + Weight::from_parts(1_498_652, 0) + // Standard Error: 531 + .saturating_add(Weight::from_parts(1_451_498, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rems(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 809 nanoseconds. - Weight::from_parts(1_145_906, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 718 - .saturating_add(Weight::from_parts(1_549_964, 0).saturating_mul(r.into())) + // Minimum execution time: 1_145_000 picoseconds. + Weight::from_parts(1_504_118, 0) + // Standard Error: 439 + .saturating_add(Weight::from_parts(1_521_895, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64remu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 803 nanoseconds. - Weight::from_parts(1_110_328, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 627 - .saturating_add(Weight::from_parts(1_453_013, 0).saturating_mul(r.into())) + // Minimum execution time: 1_124_000 picoseconds. + Weight::from_parts(1_497_209, 0) + // Standard Error: 198 + .saturating_add(Weight::from_parts(1_449_843, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64and(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 786 nanoseconds. - Weight::from_parts(1_108_792, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 286 - .saturating_add(Weight::from_parts(897_035, 0).saturating_mul(r.into())) + // Minimum execution time: 1_169_000 picoseconds. + Weight::from_parts(1_534_491, 0) + // Standard Error: 283 + .saturating_add(Weight::from_parts(894_703, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64or(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 787 nanoseconds. - Weight::from_parts(830_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 15_995 - .saturating_add(Weight::from_parts(963_344, 0).saturating_mul(r.into())) + // Minimum execution time: 1_178_000 picoseconds. + Weight::from_parts(1_485_473, 0) + // Standard Error: 552 + .saturating_add(Weight::from_parts(897_878, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64xor(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 773 nanoseconds. - Weight::from_parts(1_082_459, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 330 - .saturating_add(Weight::from_parts(897_077, 0).saturating_mul(r.into())) + // Minimum execution time: 1_214_000 picoseconds. + Weight::from_parts(1_580_999, 0) + // Standard Error: 358 + .saturating_add(Weight::from_parts(894_207, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 810 nanoseconds. - Weight::from_parts(1_325_815, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_352 - .saturating_add(Weight::from_parts(899_555, 0).saturating_mul(r.into())) + // Minimum execution time: 1_176_000 picoseconds. + Weight::from_parts(1_490_470, 0) + // Standard Error: 738 + .saturating_add(Weight::from_parts(904_900, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shrs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 808 nanoseconds. - Weight::from_parts(1_085_903, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 430 - .saturating_add(Weight::from_parts(903_249, 0).saturating_mul(r.into())) + // Minimum execution time: 1_197_000 picoseconds. + Weight::from_parts(1_519_703, 0) + // Standard Error: 336 + .saturating_add(Weight::from_parts(901_277, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shru(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 792 nanoseconds. - Weight::from_parts(1_091_261, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 312 - .saturating_add(Weight::from_parts(902_245, 0).saturating_mul(r.into())) + // Minimum execution time: 1_166_000 picoseconds. + Weight::from_parts(1_507_499, 0) + // Standard Error: 298 + .saturating_add(Weight::from_parts(901_153, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 807 nanoseconds. - Weight::from_parts(1_121_052, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 506 - .saturating_add(Weight::from_parts(902_772, 0).saturating_mul(r.into())) + // Minimum execution time: 1_158_000 picoseconds. + Weight::from_parts(1_491_176, 0) + // Standard Error: 341 + .saturating_add(Weight::from_parts(901_880, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotr(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 823 nanoseconds. - Weight::from_parts(1_317_597, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 6_219 - .saturating_add(Weight::from_parts(896_692, 0).saturating_mul(r.into())) + // Minimum execution time: 1_207_000 picoseconds. + Weight::from_parts(1_477_261, 0) + // Standard Error: 287 + .saturating_add(Weight::from_parts(902_622, 0).saturating_mul(r.into())) } } diff --git a/frame/conviction-voting/src/weights.rs b/frame/conviction-voting/src/weights.rs index 91c4c013051db..765a4276aea59 100644 --- a/frame/conviction-voting/src/weights.rs +++ b/frame/conviction-voting/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_conviction_voting //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_conviction_voting +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -72,10 +75,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn vote_new() -> Weight { // Proof Size summary in bytes: - // Measured: `13168` - // Estimated: `257859` - // Minimum execution time: 85_569 nanoseconds. - Weight::from_parts(86_492_000, 257859) + // Measured: `13074` + // Estimated: `262809` + // Minimum execution time: 94_493_000 picoseconds. + Weight::from_parts(96_510_000, 262809) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -91,10 +94,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn vote_existing() -> Weight { // Proof Size summary in bytes: - // Measured: `20342` - // Estimated: `257859` - // Minimum execution time: 212_727 nanoseconds. - Weight::from_parts(213_741_000, 257859) + // Measured: `20216` + // Estimated: `262809` + // Minimum execution time: 252_717_000 picoseconds. + Weight::from_parts(255_200_000, 262809) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -106,10 +109,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn remove_vote() -> Weight { // Proof Size summary in bytes: - // Measured: `20062` - // Estimated: `251551` - // Minimum execution time: 200_513 nanoseconds. - Weight::from_parts(201_589_000, 251551) + // Measured: `19968` + // Estimated: `254521` + // Minimum execution time: 244_844_000 picoseconds. + Weight::from_parts(247_433_000, 254521) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -119,10 +122,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn remove_other_vote() -> Weight { // Proof Size summary in bytes: - // Measured: `12738` - // Estimated: `32557` - // Minimum execution time: 43_083 nanoseconds. - Weight::from_parts(43_763_000, 32557) + // Measured: `12675` + // Estimated: `34537` + // Minimum execution time: 46_271_000 picoseconds. + Weight::from_parts(47_639_000, 34537) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -139,17 +142,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn delegate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `272 + r * (1689 ±0)` - // Estimated: `176657 + r * (110917 ±0)` - // Minimum execution time: 33_246 nanoseconds. - Weight::from_parts(34_560_391, 176657) - // Standard Error: 63_925 - .saturating_add(Weight::from_parts(34_500_408, 0).saturating_mul(r.into())) + // Measured: `240 + r * (1627 ±0)` + // Estimated: `180617 + r * (111908 ±0)` + // Minimum execution time: 37_578_000 picoseconds. + Weight::from_parts(39_035_446, 180617) + // Standard Error: 160_560 + .saturating_add(Weight::from_parts(39_642_553, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 110917).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 111908).saturating_mul(r.into())) } /// Storage: ConvictionVoting VotingFor (r:2 w:2) /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) @@ -160,17 +163,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn undelegate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `470 + r * (1407 ±0)` - // Estimated: `170349 + r * (110917 ±0)` - // Minimum execution time: 20_508 nanoseconds. - Weight::from_parts(21_240_024, 170349) - // Standard Error: 37_314 - .saturating_add(Weight::from_parts(30_890_875, 0).saturating_mul(r.into())) + // Measured: `406 + r * (1376 ±0)` + // Estimated: `172329 + r * (111908 ±0)` + // Minimum execution time: 22_997_000 picoseconds. + Weight::from_parts(24_180_222, 172329) + // Standard Error: 87_723 + .saturating_add(Weight::from_parts(36_189_677, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 110917).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 111908).saturating_mul(r.into())) } /// Storage: ConvictionVoting VotingFor (r:1 w:1) /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) @@ -180,10 +183,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn unlock() -> Weight { // Proof Size summary in bytes: - // Measured: `11797` - // Estimated: `36024` - // Minimum execution time: 50_305 nanoseconds. - Weight::from_parts(51_226_000, 36024) + // Measured: `11734` + // Estimated: `38994` + // Minimum execution time: 55_906_000 picoseconds. + Weight::from_parts(56_819_000, 38994) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -203,10 +206,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn vote_new() -> Weight { // Proof Size summary in bytes: - // Measured: `13168` - // Estimated: `257859` - // Minimum execution time: 85_569 nanoseconds. - Weight::from_parts(86_492_000, 257859) + // Measured: `13074` + // Estimated: `262809` + // Minimum execution time: 94_493_000 picoseconds. + Weight::from_parts(96_510_000, 262809) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -222,10 +225,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn vote_existing() -> Weight { // Proof Size summary in bytes: - // Measured: `20342` - // Estimated: `257859` - // Minimum execution time: 212_727 nanoseconds. - Weight::from_parts(213_741_000, 257859) + // Measured: `20216` + // Estimated: `262809` + // Minimum execution time: 252_717_000 picoseconds. + Weight::from_parts(255_200_000, 262809) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -237,10 +240,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn remove_vote() -> Weight { // Proof Size summary in bytes: - // Measured: `20062` - // Estimated: `251551` - // Minimum execution time: 200_513 nanoseconds. - Weight::from_parts(201_589_000, 251551) + // Measured: `19968` + // Estimated: `254521` + // Minimum execution time: 244_844_000 picoseconds. + Weight::from_parts(247_433_000, 254521) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -250,10 +253,10 @@ impl WeightInfo for () { /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn remove_other_vote() -> Weight { // Proof Size summary in bytes: - // Measured: `12738` - // Estimated: `32557` - // Minimum execution time: 43_083 nanoseconds. - Weight::from_parts(43_763_000, 32557) + // Measured: `12675` + // Estimated: `34537` + // Minimum execution time: 46_271_000 picoseconds. + Weight::from_parts(47_639_000, 34537) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -270,17 +273,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn delegate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `272 + r * (1689 ±0)` - // Estimated: `176657 + r * (110917 ±0)` - // Minimum execution time: 33_246 nanoseconds. - Weight::from_parts(34_560_391, 176657) - // Standard Error: 63_925 - .saturating_add(Weight::from_parts(34_500_408, 0).saturating_mul(r.into())) + // Measured: `240 + r * (1627 ±0)` + // Estimated: `180617 + r * (111908 ±0)` + // Minimum execution time: 37_578_000 picoseconds. + Weight::from_parts(39_035_446, 180617) + // Standard Error: 160_560 + .saturating_add(Weight::from_parts(39_642_553, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 110917).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 111908).saturating_mul(r.into())) } /// Storage: ConvictionVoting VotingFor (r:2 w:2) /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) @@ -291,17 +294,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn undelegate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `470 + r * (1407 ±0)` - // Estimated: `170349 + r * (110917 ±0)` - // Minimum execution time: 20_508 nanoseconds. - Weight::from_parts(21_240_024, 170349) - // Standard Error: 37_314 - .saturating_add(Weight::from_parts(30_890_875, 0).saturating_mul(r.into())) + // Measured: `406 + r * (1376 ±0)` + // Estimated: `172329 + r * (111908 ±0)` + // Minimum execution time: 22_997_000 picoseconds. + Weight::from_parts(24_180_222, 172329) + // Standard Error: 87_723 + .saturating_add(Weight::from_parts(36_189_677, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 110917).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 111908).saturating_mul(r.into())) } /// Storage: ConvictionVoting VotingFor (r:1 w:1) /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) @@ -311,10 +314,10 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn unlock() -> Weight { // Proof Size summary in bytes: - // Measured: `11797` - // Estimated: `36024` - // Minimum execution time: 50_305 nanoseconds. - Weight::from_parts(51_226_000, 36024) + // Measured: `11734` + // Estimated: `38994` + // Minimum execution time: 55_906_000 picoseconds. + Weight::from_parts(56_819_000, 38994) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } diff --git a/frame/core-fellowship/src/weights.rs b/frame/core-fellowship/src/weights.rs index 9f290635ec1cf..d436826665069 100644 --- a/frame/core-fellowship/src/weights.rs +++ b/frame/core-fellowship/src/weights.rs @@ -18,26 +18,28 @@ //! Autogenerated weights for pallet_core_fellowship //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_core_fellowship +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_core_fellowship -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/core-fellowship/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -70,8 +72,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 10_489_000 picoseconds. - Weight::from_parts(10_873_000, 0) + // Minimum execution time: 10_384_000 picoseconds. + Weight::from_parts(10_787_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: CoreFellowship Member (r:1 w:1) @@ -88,10 +90,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) fn bump_offboard() -> Weight { // Proof Size summary in bytes: - // Measured: `16886` + // Measured: `16854` // Estimated: `35762` - // Minimum execution time: 61_794_000 picoseconds. - Weight::from_parts(62_455_000, 35762) + // Minimum execution time: 61_847_000 picoseconds. + Weight::from_parts(62_453_000, 35762) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -109,10 +111,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) fn bump_demote() -> Weight { // Proof Size summary in bytes: - // Measured: `16996` + // Measured: `16964` // Estimated: `35762` - // Minimum execution time: 63_921_000 picoseconds. - Weight::from_parts(64_871_000, 35762) + // Minimum execution time: 64_449_000 picoseconds. + Weight::from_parts(65_298_000, 35762) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -124,8 +126,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `355` // Estimated: `7021` - // Minimum execution time: 19_023_000 picoseconds. - Weight::from_parts(19_270_000, 7021) + // Minimum execution time: 19_308_000 picoseconds. + Weight::from_parts(19_520_000, 7021) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -143,8 +145,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `113` // Estimated: `10500` - // Minimum execution time: 29_089_000 picoseconds. - Weight::from_parts(29_718_000, 10500) + // Minimum execution time: 29_228_000 picoseconds. + Weight::from_parts(29_683_000, 10500) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -164,10 +166,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) fn promote() -> Weight { // Proof Size summary in bytes: - // Measured: `16864` + // Measured: `16832` // Estimated: `32243` - // Minimum execution time: 59_529_000 picoseconds. - Weight::from_parts(60_057_000, 32243) + // Minimum execution time: 59_745_000 picoseconds. + Weight::from_parts(60_290_000, 32243) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -175,14 +177,16 @@ impl WeightInfo for SubstrateWeight { /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) /// Storage: CoreFellowship Member (r:1 w:1) /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: CoreFellowship MemberEvidence (r:0 w:1) + /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) fn offboard() -> Weight { // Proof Size summary in bytes: - // Measured: `292` + // Measured: `326` // Estimated: `7021` - // Minimum execution time: 17_221_000 picoseconds. - Weight::from_parts(17_585_000, 7021) + // Minimum execution time: 18_964_000 picoseconds. + Weight::from_parts(19_603_000, 7021) .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: CoreFellowship Member (r:1 w:1) /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) @@ -192,8 +196,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `280` // Estimated: `7021` - // Minimum execution time: 18_602_000 picoseconds. - Weight::from_parts(18_813_000, 7021) + // Minimum execution time: 18_752_000 picoseconds. + Weight::from_parts(19_035_000, 7021) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -205,10 +209,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) fn approve() -> Weight { // Proof Size summary in bytes: - // Measured: `16842` + // Measured: `16810` // Estimated: `26915` - // Minimum execution time: 43_525_000 picoseconds. - Weight::from_parts(43_994_000, 26915) + // Minimum execution time: 44_972_000 picoseconds. + Weight::from_parts(45_391_000, 26915) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -220,8 +224,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `79` // Estimated: `23408` - // Minimum execution time: 27_960_000 picoseconds. - Weight::from_parts(28_331_000, 23408) + // Minimum execution time: 27_820_000 picoseconds. + Weight::from_parts(28_992_000, 23408) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -235,8 +239,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 10_489_000 picoseconds. - Weight::from_parts(10_873_000, 0) + // Minimum execution time: 10_384_000 picoseconds. + Weight::from_parts(10_787_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: CoreFellowship Member (r:1 w:1) @@ -253,10 +257,10 @@ impl WeightInfo for () { /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) fn bump_offboard() -> Weight { // Proof Size summary in bytes: - // Measured: `16886` + // Measured: `16854` // Estimated: `35762` - // Minimum execution time: 61_794_000 picoseconds. - Weight::from_parts(62_455_000, 35762) + // Minimum execution time: 61_847_000 picoseconds. + Weight::from_parts(62_453_000, 35762) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -274,10 +278,10 @@ impl WeightInfo for () { /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) fn bump_demote() -> Weight { // Proof Size summary in bytes: - // Measured: `16996` + // Measured: `16964` // Estimated: `35762` - // Minimum execution time: 63_921_000 picoseconds. - Weight::from_parts(64_871_000, 35762) + // Minimum execution time: 64_449_000 picoseconds. + Weight::from_parts(65_298_000, 35762) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -289,8 +293,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `355` // Estimated: `7021` - // Minimum execution time: 19_023_000 picoseconds. - Weight::from_parts(19_270_000, 7021) + // Minimum execution time: 19_308_000 picoseconds. + Weight::from_parts(19_520_000, 7021) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -308,8 +312,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `113` // Estimated: `10500` - // Minimum execution time: 29_089_000 picoseconds. - Weight::from_parts(29_718_000, 10500) + // Minimum execution time: 29_228_000 picoseconds. + Weight::from_parts(29_683_000, 10500) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -329,10 +333,10 @@ impl WeightInfo for () { /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) fn promote() -> Weight { // Proof Size summary in bytes: - // Measured: `16864` + // Measured: `16832` // Estimated: `32243` - // Minimum execution time: 59_529_000 picoseconds. - Weight::from_parts(60_057_000, 32243) + // Minimum execution time: 59_745_000 picoseconds. + Weight::from_parts(60_290_000, 32243) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -340,14 +344,16 @@ impl WeightInfo for () { /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) /// Storage: CoreFellowship Member (r:1 w:1) /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: CoreFellowship MemberEvidence (r:0 w:1) + /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) fn offboard() -> Weight { // Proof Size summary in bytes: - // Measured: `292` + // Measured: `326` // Estimated: `7021` - // Minimum execution time: 17_221_000 picoseconds. - Weight::from_parts(17_585_000, 7021) + // Minimum execution time: 18_964_000 picoseconds. + Weight::from_parts(19_603_000, 7021) .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: CoreFellowship Member (r:1 w:1) /// Proof: CoreFellowship Member (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) @@ -357,8 +363,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `280` // Estimated: `7021` - // Minimum execution time: 18_602_000 picoseconds. - Weight::from_parts(18_813_000, 7021) + // Minimum execution time: 18_752_000 picoseconds. + Weight::from_parts(19_035_000, 7021) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -370,10 +376,10 @@ impl WeightInfo for () { /// Proof: CoreFellowship MemberEvidence (max_values: None, max_size: Some(16429), added: 18904, mode: MaxEncodedLen) fn approve() -> Weight { // Proof Size summary in bytes: - // Measured: `16842` + // Measured: `16810` // Estimated: `26915` - // Minimum execution time: 43_525_000 picoseconds. - Weight::from_parts(43_994_000, 26915) + // Minimum execution time: 44_972_000 picoseconds. + Weight::from_parts(45_391_000, 26915) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -385,8 +391,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `79` // Estimated: `23408` - // Minimum execution time: 27_960_000 picoseconds. - Weight::from_parts(28_331_000, 23408) + // Minimum execution time: 27_820_000 picoseconds. + Weight::from_parts(28_992_000, 23408) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/democracy/src/weights.rs b/frame/democracy/src/weights.rs index 9241b27bbe1fb..e0c970a34b372 100644 --- a/frame/democracy/src/weights.rs +++ b/frame/democracy/src/weights.rs @@ -18,26 +18,28 @@ //! Autogenerated weights for pallet_democracy //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-b3zmxxc-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_democracy +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_democracy -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/democracy/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -92,10 +94,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) fn propose() -> Weight { // Proof Size summary in bytes: - // Measured: `4864` - // Estimated: `23409` - // Minimum execution time: 42_939 nanoseconds. - Weight::from_parts(43_543_000, 23409) + // Measured: `4801` + // Estimated: `26379` + // Minimum execution time: 39_171_000 picoseconds. + Weight::from_parts(39_779_000, 26379) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -103,10 +105,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) fn second() -> Weight { // Proof Size summary in bytes: - // Measured: `3620` - // Estimated: `5705` - // Minimum execution time: 36_475 nanoseconds. - Weight::from_parts(37_863_000, 5705) + // Measured: `3556` + // Estimated: `6695` + // Minimum execution time: 35_694_000 picoseconds. + Weight::from_parts(36_181_000, 6695) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -118,10 +120,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn vote_new() -> Weight { // Proof Size summary in bytes: - // Measured: `3565` - // Estimated: `12720` - // Minimum execution time: 56_372 nanoseconds. - Weight::from_parts(57_483_000, 12720) + // Measured: `3470` + // Estimated: `15690` + // Minimum execution time: 50_274_000 picoseconds. + Weight::from_parts(51_216_000, 15690) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -133,10 +135,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn vote_existing() -> Weight { // Proof Size summary in bytes: - // Measured: `3587` - // Estimated: `12720` - // Minimum execution time: 56_789 nanoseconds. - Weight::from_parts(57_737_000, 12720) + // Measured: `3492` + // Estimated: `15690` + // Minimum execution time: 50_559_000 picoseconds. + Weight::from_parts(51_030_000, 15690) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -148,10 +150,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn emergency_cancel() -> Weight { // Proof Size summary in bytes: - // Measured: `398` - // Estimated: `7712` - // Minimum execution time: 24_379 nanoseconds. - Weight::from_parts(25_302_000, 7712) + // Measured: `366` + // Estimated: `10682` + // Minimum execution time: 27_539_000 picoseconds. + Weight::from_parts(28_040_000, 10682) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -171,10 +173,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) fn blacklist() -> Weight { // Proof Size summary in bytes: - // Measured: `6036` - // Estimated: `36392` - // Minimum execution time: 100_345 nanoseconds. - Weight::from_parts(102_233_000, 36392) + // Measured: `5910` + // Estimated: `42332` + // Minimum execution time: 93_053_000 picoseconds. + Weight::from_parts(94_193_000, 42332) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -184,10 +186,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) fn external_propose() -> Weight { // Proof Size summary in bytes: - // Measured: `3448` - // Estimated: `6340` - // Minimum execution time: 13_155 nanoseconds. - Weight::from_parts(14_158_000, 6340) + // Measured: `3416` + // Estimated: `8320` + // Minimum execution time: 14_664_000 picoseconds. + Weight::from_parts(15_064_000, 8320) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -197,8 +199,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_961 nanoseconds. - Weight::from_parts(3_139_000, 0) + // Minimum execution time: 4_073_000 picoseconds. + Weight::from_parts(4_242_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Democracy NextExternal (r:0 w:1) @@ -207,8 +209,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_040 nanoseconds. - Weight::from_parts(3_261_000, 0) + // Minimum execution time: 3_779_000 picoseconds. + Weight::from_parts(4_091_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Democracy NextExternal (r:1 w:1) @@ -222,9 +224,9 @@ impl WeightInfo for SubstrateWeight { fn fast_track() -> Weight { // Proof Size summary in bytes: // Measured: `286` - // Estimated: `3654` - // Minimum execution time: 26_666 nanoseconds. - Weight::from_parts(28_014_000, 3654) + // Estimated: `6624` + // Minimum execution time: 29_596_000 picoseconds. + Weight::from_parts(30_083_000, 6624) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -236,10 +238,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn veto_external() -> Weight { // Proof Size summary in bytes: - // Measured: `3551` - // Estimated: `8868` - // Minimum execution time: 30_180 nanoseconds. - Weight::from_parts(31_593_000, 8868) + // Measured: `3519` + // Estimated: `11838` + // Minimum execution time: 34_721_000 picoseconds. + Weight::from_parts(34_989_000, 11838) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -253,10 +255,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn cancel_proposal() -> Weight { // Proof Size summary in bytes: - // Measured: `5915` - // Estimated: `28033` - // Minimum execution time: 80_780 nanoseconds. - Weight::from_parts(82_070_000, 28033) + // Measured: `5821` + // Estimated: `31993` + // Minimum execution time: 74_835_000 picoseconds. + Weight::from_parts(75_807_000, 31993) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -267,9 +269,9 @@ impl WeightInfo for SubstrateWeight { fn cancel_referendum() -> Weight { // Proof Size summary in bytes: // Measured: `271` - // Estimated: `2528` - // Minimum execution time: 18_117 nanoseconds. - Weight::from_parts(19_027_000, 2528) + // Estimated: `3518` + // Minimum execution time: 20_995_000 picoseconds. + Weight::from_parts(21_425_000, 3518) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -282,12 +284,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `244 + r * (117 ±0)` - // Estimated: `998 + r * (2676 ±0)` - // Minimum execution time: 7_093 nanoseconds. - Weight::from_parts(8_792_955, 998) - // Standard Error: 6_630 - .saturating_add(Weight::from_parts(3_091_565, 0).saturating_mul(r.into())) + // Measured: `244 + r * (86 ±0)` + // Estimated: `3968 + r * (2676 ±0)` + // Minimum execution time: 7_002_000 picoseconds. + Weight::from_parts(10_543_534, 3968) + // Standard Error: 7_286 + .saturating_add(Weight::from_parts(2_911_122, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -308,12 +310,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `244 + r * (117 ±0)` - // Estimated: `19318 + r * (2676 ±0)` - // Minimum execution time: 10_372 nanoseconds. - Weight::from_parts(10_961_165, 19318) - // Standard Error: 7_284 - .saturating_add(Weight::from_parts(3_112_573, 0).saturating_mul(r.into())) + // Measured: `244 + r * (86 ±0)` + // Estimated: `25258 + r * (2676 ±0)` + // Minimum execution time: 10_824_000 picoseconds. + Weight::from_parts(14_187_527, 25258) + // Standard Error: 7_148 + .saturating_add(Weight::from_parts(2_886_910, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -328,12 +330,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 99]`. fn delegate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `958 + r * (139 ±0)` - // Estimated: `22584 + r * (2676 ±0)` - // Minimum execution time: 36_618 nanoseconds. - Weight::from_parts(42_803_184, 22584) - // Standard Error: 7_268 - .saturating_add(Weight::from_parts(4_537_902, 0).saturating_mul(r.into())) + // Measured: `830 + r * (108 ±0)` + // Estimated: `25554 + r * (2676 ±0)` + // Minimum execution time: 42_940_000 picoseconds. + Weight::from_parts(45_288_082, 25554) + // Standard Error: 6_380 + .saturating_add(Weight::from_parts(4_219_163, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) @@ -347,12 +349,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `557 + r * (139 ±0)` - // Estimated: `12540 + r * (2676 ±0)` - // Minimum execution time: 19_758 nanoseconds. - Weight::from_parts(21_641_793, 12540) - // Standard Error: 6_889 - .saturating_add(Weight::from_parts(4_478_884, 0).saturating_mul(r.into())) + // Measured: `493 + r * (108 ±0)` + // Estimated: `14520 + r * (2676 ±0)` + // Minimum execution time: 22_203_000 picoseconds. + Weight::from_parts(22_307_372, 14520) + // Standard Error: 7_095 + .saturating_add(Weight::from_parts(4_202_995, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -365,8 +367,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_844 nanoseconds. - Weight::from_parts(3_017_000, 0) + // Minimum execution time: 4_046_000 picoseconds. + Weight::from_parts(4_191_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Democracy VotingOf (r:1 w:1) @@ -378,12 +380,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `627` - // Estimated: `12647` - // Minimum execution time: 20_380 nanoseconds. - Weight::from_parts(28_295_875, 12647) - // Standard Error: 2_331 - .saturating_add(Weight::from_parts(67_348, 0).saturating_mul(r.into())) + // Measured: `563` + // Estimated: `15617` + // Minimum execution time: 22_585_000 picoseconds. + Weight::from_parts(28_461_437, 15617) + // Standard Error: 1_636 + .saturating_add(Weight::from_parts(19_140, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -396,12 +398,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `628 + r * (22 ±0)` - // Estimated: `12647` - // Minimum execution time: 24_475 nanoseconds. - Weight::from_parts(27_102_576, 12647) - // Standard Error: 1_464 - .saturating_add(Weight::from_parts(128_921, 0).saturating_mul(r.into())) + // Measured: `564 + r * (22 ±0)` + // Estimated: `15617` + // Minimum execution time: 26_674_000 picoseconds. + Weight::from_parts(27_815_260, 15617) + // Standard Error: 490 + .saturating_add(Weight::from_parts(68_478, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -412,12 +414,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `791 + r * (26 ±0)` - // Estimated: `8946` - // Minimum execution time: 15_039 nanoseconds. - Weight::from_parts(19_252_498, 8946) - // Standard Error: 1_798 - .saturating_add(Weight::from_parts(131_855, 0).saturating_mul(r.into())) + // Measured: `728 + r * (26 ±0)` + // Estimated: `10926` + // Minimum execution time: 17_381_000 picoseconds. + Weight::from_parts(19_728_665, 10926) + // Standard Error: 1_065 + .saturating_add(Weight::from_parts(84_481, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -428,12 +430,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `791 + r * (26 ±0)` - // Estimated: `8946` - // Minimum execution time: 14_837 nanoseconds. - Weight::from_parts(19_144_929, 8946) - // Standard Error: 1_875 - .saturating_add(Weight::from_parts(136_819, 0).saturating_mul(r.into())) + // Measured: `728 + r * (26 ±0)` + // Estimated: `10926` + // Minimum execution time: 17_496_000 picoseconds. + Weight::from_parts(19_845_941, 10926) + // Standard Error: 1_169 + .saturating_add(Weight::from_parts(85_004, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -446,9 +448,9 @@ impl WeightInfo for SubstrateWeight { fn set_external_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `356` - // Estimated: `3193` - // Minimum execution time: 17_338 nanoseconds. - Weight::from_parts(17_946_000, 3193) + // Estimated: `5173` + // Minimum execution time: 19_076_000 picoseconds. + Weight::from_parts(19_650_000, 5173) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -459,9 +461,9 @@ impl WeightInfo for SubstrateWeight { fn clear_external_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `286` - // Estimated: `3155` - // Minimum execution time: 15_364 nanoseconds. - Weight::from_parts(15_990_000, 3155) + // Estimated: `5135` + // Minimum execution time: 17_588_000 picoseconds. + Weight::from_parts(17_781_000, 5135) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -473,10 +475,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn set_proposal_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `4919` - // Estimated: `19763` - // Minimum execution time: 37_147 nanoseconds. - Weight::from_parts(37_778_000, 19763) + // Measured: `4888` + // Estimated: `21743` + // Minimum execution time: 34_828_000 picoseconds. + Weight::from_parts(35_364_000, 21743) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -486,10 +488,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn clear_proposal_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `4853` - // Estimated: `19725` - // Minimum execution time: 34_118 nanoseconds. - Weight::from_parts(34_737_000, 19725) + // Measured: `4822` + // Estimated: `21705` + // Minimum execution time: 32_035_000 picoseconds. + Weight::from_parts(32_554_000, 21705) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -500,9 +502,9 @@ impl WeightInfo for SubstrateWeight { fn set_referendum_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `144` - // Estimated: `2566` - // Minimum execution time: 12_787 nanoseconds. - Weight::from_parts(13_463_000, 2566) + // Estimated: `3556` + // Minimum execution time: 15_279_000 picoseconds. + Weight::from_parts(15_556_000, 3556) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -513,9 +515,9 @@ impl WeightInfo for SubstrateWeight { fn clear_referendum_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `302` - // Estimated: `5204` - // Minimum execution time: 17_636 nanoseconds. - Weight::from_parts(18_399_000, 5204) + // Estimated: `7184` + // Minimum execution time: 19_622_000 picoseconds. + Weight::from_parts(19_978_000, 7184) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -533,10 +535,10 @@ impl WeightInfo for () { /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) fn propose() -> Weight { // Proof Size summary in bytes: - // Measured: `4864` - // Estimated: `23409` - // Minimum execution time: 42_939 nanoseconds. - Weight::from_parts(43_543_000, 23409) + // Measured: `4801` + // Estimated: `26379` + // Minimum execution time: 39_171_000 picoseconds. + Weight::from_parts(39_779_000, 26379) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -544,10 +546,10 @@ impl WeightInfo for () { /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) fn second() -> Weight { // Proof Size summary in bytes: - // Measured: `3620` - // Estimated: `5705` - // Minimum execution time: 36_475 nanoseconds. - Weight::from_parts(37_863_000, 5705) + // Measured: `3556` + // Estimated: `6695` + // Minimum execution time: 35_694_000 picoseconds. + Weight::from_parts(36_181_000, 6695) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -559,10 +561,10 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn vote_new() -> Weight { // Proof Size summary in bytes: - // Measured: `3565` - // Estimated: `12720` - // Minimum execution time: 56_372 nanoseconds. - Weight::from_parts(57_483_000, 12720) + // Measured: `3470` + // Estimated: `15690` + // Minimum execution time: 50_274_000 picoseconds. + Weight::from_parts(51_216_000, 15690) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -574,10 +576,10 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn vote_existing() -> Weight { // Proof Size summary in bytes: - // Measured: `3587` - // Estimated: `12720` - // Minimum execution time: 56_789 nanoseconds. - Weight::from_parts(57_737_000, 12720) + // Measured: `3492` + // Estimated: `15690` + // Minimum execution time: 50_559_000 picoseconds. + Weight::from_parts(51_030_000, 15690) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -589,10 +591,10 @@ impl WeightInfo for () { /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn emergency_cancel() -> Weight { // Proof Size summary in bytes: - // Measured: `398` - // Estimated: `7712` - // Minimum execution time: 24_379 nanoseconds. - Weight::from_parts(25_302_000, 7712) + // Measured: `366` + // Estimated: `10682` + // Minimum execution time: 27_539_000 picoseconds. + Weight::from_parts(28_040_000, 10682) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -612,10 +614,10 @@ impl WeightInfo for () { /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) fn blacklist() -> Weight { // Proof Size summary in bytes: - // Measured: `6036` - // Estimated: `36392` - // Minimum execution time: 100_345 nanoseconds. - Weight::from_parts(102_233_000, 36392) + // Measured: `5910` + // Estimated: `42332` + // Minimum execution time: 93_053_000 picoseconds. + Weight::from_parts(94_193_000, 42332) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -625,10 +627,10 @@ impl WeightInfo for () { /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) fn external_propose() -> Weight { // Proof Size summary in bytes: - // Measured: `3448` - // Estimated: `6340` - // Minimum execution time: 13_155 nanoseconds. - Weight::from_parts(14_158_000, 6340) + // Measured: `3416` + // Estimated: `8320` + // Minimum execution time: 14_664_000 picoseconds. + Weight::from_parts(15_064_000, 8320) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -638,8 +640,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_961 nanoseconds. - Weight::from_parts(3_139_000, 0) + // Minimum execution time: 4_073_000 picoseconds. + Weight::from_parts(4_242_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Democracy NextExternal (r:0 w:1) @@ -648,8 +650,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_040 nanoseconds. - Weight::from_parts(3_261_000, 0) + // Minimum execution time: 3_779_000 picoseconds. + Weight::from_parts(4_091_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Democracy NextExternal (r:1 w:1) @@ -663,9 +665,9 @@ impl WeightInfo for () { fn fast_track() -> Weight { // Proof Size summary in bytes: // Measured: `286` - // Estimated: `3654` - // Minimum execution time: 26_666 nanoseconds. - Weight::from_parts(28_014_000, 3654) + // Estimated: `6624` + // Minimum execution time: 29_596_000 picoseconds. + Weight::from_parts(30_083_000, 6624) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -677,10 +679,10 @@ impl WeightInfo for () { /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn veto_external() -> Weight { // Proof Size summary in bytes: - // Measured: `3551` - // Estimated: `8868` - // Minimum execution time: 30_180 nanoseconds. - Weight::from_parts(31_593_000, 8868) + // Measured: `3519` + // Estimated: `11838` + // Minimum execution time: 34_721_000 picoseconds. + Weight::from_parts(34_989_000, 11838) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -694,10 +696,10 @@ impl WeightInfo for () { /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn cancel_proposal() -> Weight { // Proof Size summary in bytes: - // Measured: `5915` - // Estimated: `28033` - // Minimum execution time: 80_780 nanoseconds. - Weight::from_parts(82_070_000, 28033) + // Measured: `5821` + // Estimated: `31993` + // Minimum execution time: 74_835_000 picoseconds. + Weight::from_parts(75_807_000, 31993) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -708,9 +710,9 @@ impl WeightInfo for () { fn cancel_referendum() -> Weight { // Proof Size summary in bytes: // Measured: `271` - // Estimated: `2528` - // Minimum execution time: 18_117 nanoseconds. - Weight::from_parts(19_027_000, 2528) + // Estimated: `3518` + // Minimum execution time: 20_995_000 picoseconds. + Weight::from_parts(21_425_000, 3518) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -723,12 +725,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `244 + r * (117 ±0)` - // Estimated: `998 + r * (2676 ±0)` - // Minimum execution time: 7_093 nanoseconds. - Weight::from_parts(8_792_955, 998) - // Standard Error: 6_630 - .saturating_add(Weight::from_parts(3_091_565, 0).saturating_mul(r.into())) + // Measured: `244 + r * (86 ±0)` + // Estimated: `3968 + r * (2676 ±0)` + // Minimum execution time: 7_002_000 picoseconds. + Weight::from_parts(10_543_534, 3968) + // Standard Error: 7_286 + .saturating_add(Weight::from_parts(2_911_122, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -749,12 +751,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `244 + r * (117 ±0)` - // Estimated: `19318 + r * (2676 ±0)` - // Minimum execution time: 10_372 nanoseconds. - Weight::from_parts(10_961_165, 19318) - // Standard Error: 7_284 - .saturating_add(Weight::from_parts(3_112_573, 0).saturating_mul(r.into())) + // Measured: `244 + r * (86 ±0)` + // Estimated: `25258 + r * (2676 ±0)` + // Minimum execution time: 10_824_000 picoseconds. + Weight::from_parts(14_187_527, 25258) + // Standard Error: 7_148 + .saturating_add(Weight::from_parts(2_886_910, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -769,12 +771,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 99]`. fn delegate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `958 + r * (139 ±0)` - // Estimated: `22584 + r * (2676 ±0)` - // Minimum execution time: 36_618 nanoseconds. - Weight::from_parts(42_803_184, 22584) - // Standard Error: 7_268 - .saturating_add(Weight::from_parts(4_537_902, 0).saturating_mul(r.into())) + // Measured: `830 + r * (108 ±0)` + // Estimated: `25554 + r * (2676 ±0)` + // Minimum execution time: 42_940_000 picoseconds. + Weight::from_parts(45_288_082, 25554) + // Standard Error: 6_380 + .saturating_add(Weight::from_parts(4_219_163, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) @@ -788,12 +790,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `557 + r * (139 ±0)` - // Estimated: `12540 + r * (2676 ±0)` - // Minimum execution time: 19_758 nanoseconds. - Weight::from_parts(21_641_793, 12540) - // Standard Error: 6_889 - .saturating_add(Weight::from_parts(4_478_884, 0).saturating_mul(r.into())) + // Measured: `493 + r * (108 ±0)` + // Estimated: `14520 + r * (2676 ±0)` + // Minimum execution time: 22_203_000 picoseconds. + Weight::from_parts(22_307_372, 14520) + // Standard Error: 7_095 + .saturating_add(Weight::from_parts(4_202_995, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -806,8 +808,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_844 nanoseconds. - Weight::from_parts(3_017_000, 0) + // Minimum execution time: 4_046_000 picoseconds. + Weight::from_parts(4_191_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Democracy VotingOf (r:1 w:1) @@ -819,12 +821,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `627` - // Estimated: `12647` - // Minimum execution time: 20_380 nanoseconds. - Weight::from_parts(28_295_875, 12647) - // Standard Error: 2_331 - .saturating_add(Weight::from_parts(67_348, 0).saturating_mul(r.into())) + // Measured: `563` + // Estimated: `15617` + // Minimum execution time: 22_585_000 picoseconds. + Weight::from_parts(28_461_437, 15617) + // Standard Error: 1_636 + .saturating_add(Weight::from_parts(19_140, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -837,12 +839,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `628 + r * (22 ±0)` - // Estimated: `12647` - // Minimum execution time: 24_475 nanoseconds. - Weight::from_parts(27_102_576, 12647) - // Standard Error: 1_464 - .saturating_add(Weight::from_parts(128_921, 0).saturating_mul(r.into())) + // Measured: `564 + r * (22 ±0)` + // Estimated: `15617` + // Minimum execution time: 26_674_000 picoseconds. + Weight::from_parts(27_815_260, 15617) + // Standard Error: 490 + .saturating_add(Weight::from_parts(68_478, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -853,12 +855,12 @@ impl WeightInfo for () { /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `791 + r * (26 ±0)` - // Estimated: `8946` - // Minimum execution time: 15_039 nanoseconds. - Weight::from_parts(19_252_498, 8946) - // Standard Error: 1_798 - .saturating_add(Weight::from_parts(131_855, 0).saturating_mul(r.into())) + // Measured: `728 + r * (26 ±0)` + // Estimated: `10926` + // Minimum execution time: 17_381_000 picoseconds. + Weight::from_parts(19_728_665, 10926) + // Standard Error: 1_065 + .saturating_add(Weight::from_parts(84_481, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -869,12 +871,12 @@ impl WeightInfo for () { /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `791 + r * (26 ±0)` - // Estimated: `8946` - // Minimum execution time: 14_837 nanoseconds. - Weight::from_parts(19_144_929, 8946) - // Standard Error: 1_875 - .saturating_add(Weight::from_parts(136_819, 0).saturating_mul(r.into())) + // Measured: `728 + r * (26 ±0)` + // Estimated: `10926` + // Minimum execution time: 17_496_000 picoseconds. + Weight::from_parts(19_845_941, 10926) + // Standard Error: 1_169 + .saturating_add(Weight::from_parts(85_004, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -887,9 +889,9 @@ impl WeightInfo for () { fn set_external_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `356` - // Estimated: `3193` - // Minimum execution time: 17_338 nanoseconds. - Weight::from_parts(17_946_000, 3193) + // Estimated: `5173` + // Minimum execution time: 19_076_000 picoseconds. + Weight::from_parts(19_650_000, 5173) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -900,9 +902,9 @@ impl WeightInfo for () { fn clear_external_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `286` - // Estimated: `3155` - // Minimum execution time: 15_364 nanoseconds. - Weight::from_parts(15_990_000, 3155) + // Estimated: `5135` + // Minimum execution time: 17_588_000 picoseconds. + Weight::from_parts(17_781_000, 5135) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -914,10 +916,10 @@ impl WeightInfo for () { /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn set_proposal_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `4919` - // Estimated: `19763` - // Minimum execution time: 37_147 nanoseconds. - Weight::from_parts(37_778_000, 19763) + // Measured: `4888` + // Estimated: `21743` + // Minimum execution time: 34_828_000 picoseconds. + Weight::from_parts(35_364_000, 21743) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -927,10 +929,10 @@ impl WeightInfo for () { /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn clear_proposal_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `4853` - // Estimated: `19725` - // Minimum execution time: 34_118 nanoseconds. - Weight::from_parts(34_737_000, 19725) + // Measured: `4822` + // Estimated: `21705` + // Minimum execution time: 32_035_000 picoseconds. + Weight::from_parts(32_554_000, 21705) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -941,9 +943,9 @@ impl WeightInfo for () { fn set_referendum_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `144` - // Estimated: `2566` - // Minimum execution time: 12_787 nanoseconds. - Weight::from_parts(13_463_000, 2566) + // Estimated: `3556` + // Minimum execution time: 15_279_000 picoseconds. + Weight::from_parts(15_556_000, 3556) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -954,9 +956,9 @@ impl WeightInfo for () { fn clear_referendum_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `302` - // Estimated: `5204` - // Minimum execution time: 17_636 nanoseconds. - Weight::from_parts(18_399_000, 5204) + // Estimated: `7184` + // Minimum execution time: 19_622_000 picoseconds. + Weight::from_parts(19_978_000, 7184) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/election-provider-multi-phase/src/weights.rs b/frame/election-provider-multi-phase/src/weights.rs index 90be98ece489a..f9dfdfc19aa3d 100644 --- a/frame/election-provider-multi-phase/src/weights.rs +++ b/frame/election-provider-multi-phase/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_election_provider_multi_phase //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_election_provider_multi_phase +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -82,9 +85,9 @@ impl WeightInfo for SubstrateWeight { fn on_initialize_nothing() -> Weight { // Proof Size summary in bytes: // Measured: `994` - // Estimated: `6983` - // Minimum execution time: 17_801 nanoseconds. - Weight::from_parts(18_364_000, 6983) + // Estimated: `14903` + // Minimum execution time: 21_538_000 picoseconds. + Weight::from_parts(22_045_000, 14903) .saturating_add(T::DbWeight::get().reads(8_u64)) } /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) @@ -94,9 +97,9 @@ impl WeightInfo for SubstrateWeight { fn on_initialize_open_signed() -> Weight { // Proof Size summary in bytes: // Measured: `114` - // Estimated: `1218` - // Minimum execution time: 12_814 nanoseconds. - Weight::from_parts(13_154_000, 1218) + // Estimated: `3198` + // Minimum execution time: 12_696_000 picoseconds. + Weight::from_parts(12_950_000, 3198) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -107,9 +110,9 @@ impl WeightInfo for SubstrateWeight { fn on_initialize_open_unsigned() -> Weight { // Proof Size summary in bytes: // Measured: `114` - // Estimated: `1218` - // Minimum execution time: 14_565 nanoseconds. - Weight::from_parts(15_097_000, 1218) + // Estimated: `3198` + // Minimum execution time: 14_029_000 picoseconds. + Weight::from_parts(14_288_000, 3198) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -119,10 +122,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: ElectionProviderMultiPhase QueuedSolution (max_values: Some(1), max_size: None, mode: Measured) fn finalize_signed_phase_accept_solution() -> Weight { // Proof Size summary in bytes: - // Measured: `206` - // Estimated: `2809` - // Minimum execution time: 23_341 nanoseconds. - Weight::from_parts(23_770_000, 2809) + // Measured: `174` + // Estimated: `3767` + // Minimum execution time: 26_468_000 picoseconds. + Weight::from_parts(26_790_000, 3767) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -130,10 +133,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn finalize_signed_phase_reject_solution() -> Weight { // Proof Size summary in bytes: - // Measured: `206` - // Estimated: `2603` - // Minimum execution time: 16_662 nanoseconds. - Weight::from_parts(16_898_000, 2603) + // Measured: `174` + // Estimated: `3593` + // Minimum execution time: 18_401_000 picoseconds. + Weight::from_parts(18_686_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -149,10 +152,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 215_168 nanoseconds. - Weight::from_parts(219_887_000, 0) - // Standard Error: 1_444 - .saturating_add(Weight::from_parts(146_388, 0).saturating_mul(v.into())) + // Minimum execution time: 266_901_000 picoseconds. + Weight::from_parts(270_251_000, 0) + // Standard Error: 1_758 + .saturating_add(Weight::from_parts(167_310, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) @@ -177,14 +180,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `d` is `[200, 400]`. fn elect_queued(a: u32, d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `368 + a * (768 ±0) + d * (48 ±0)` - // Estimated: `9540 + a * (6912 ±0) + d * (441 ±0)` - // Minimum execution time: 268_021 nanoseconds. - Weight::from_parts(72_491_937, 9540) - // Standard Error: 2_910 - .saturating_add(Weight::from_parts(303_955, 0).saturating_mul(a.into())) - // Standard Error: 4_363 - .saturating_add(Weight::from_parts(167_369, 0).saturating_mul(d.into())) + // Measured: `337 + a * (768 ±0) + d * (48 ±0)` + // Estimated: `16191 + a * (6912 ±0) + d * (441 ±0)` + // Minimum execution time: 286_523_000 picoseconds. + Weight::from_parts(19_101_753, 16191) + // Standard Error: 4_194 + .saturating_add(Weight::from_parts(398_102, 0).saturating_mul(a.into())) + // Standard Error: 6_287 + .saturating_add(Weight::from_parts(188_928, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) .saturating_add(Weight::from_parts(0, 6912).saturating_mul(a.into())) @@ -204,10 +207,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionsMap (max_values: None, max_size: None, mode: Measured) fn submit() -> Weight { // Proof Size summary in bytes: - // Measured: `924` - // Estimated: `7111` - // Minimum execution time: 44_177 nanoseconds. - Weight::from_parts(44_663_000, 7111) + // Measured: `893` + // Estimated: `11906` + // Minimum execution time: 47_876_000 picoseconds. + Weight::from_parts(48_464_000, 11906) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -221,51 +224,51 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: ElectionProviderMultiPhase QueuedSolution (max_values: Some(1), max_size: None, mode: Measured) /// Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) /// Proof Skipped: ElectionProviderMultiPhase SnapshotMetadata (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) - /// Proof Skipped: ElectionProviderMultiPhase MinimumUntrustedScore (max_values: Some(1), max_size: None, mode: Measured) /// Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) /// Proof Skipped: ElectionProviderMultiPhase Snapshot (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase MinimumUntrustedScore (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. fn submit_unsigned(v: u32, t: u32, a: u32, _d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `251 + v * (553 ±0) + t * (32 ±0)` - // Estimated: `5222 + v * (3871 ±0) + t * (224 ±0)` - // Minimum execution time: 4_425_457 nanoseconds. - Weight::from_parts(4_445_889_000, 5222) - // Standard Error: 13_250 - .saturating_add(Weight::from_parts(48_844, 0).saturating_mul(v.into())) - // Standard Error: 39_266 - .saturating_add(Weight::from_parts(4_144_034, 0).saturating_mul(a.into())) + // Measured: `219 + v * (553 ±0) + t * (32 ±0)` + // Estimated: `11928 + v * (3871 ±0) + t * (224 ±0)` + // Minimum execution time: 4_702_825_000 picoseconds. + Weight::from_parts(4_752_015_000, 11928) + // Standard Error: 14_906 + .saturating_add(Weight::from_parts(131_585, 0).saturating_mul(v.into())) + // Standard Error: 44_174 + .saturating_add(Weight::from_parts(4_167_676, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 3871).saturating_mul(v.into())) .saturating_add(Weight::from_parts(0, 224).saturating_mul(t.into())) } - /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) - /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) /// Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) /// Proof Skipped: ElectionProviderMultiPhase DesiredTargets (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) - /// Proof Skipped: ElectionProviderMultiPhase MinimumUntrustedScore (max_values: Some(1), max_size: None, mode: Measured) /// Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) /// Proof Skipped: ElectionProviderMultiPhase Snapshot (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase MinimumUntrustedScore (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. fn feasibility_check(v: u32, t: u32, a: u32, _d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `226 + v * (553 ±0) + t * (32 ±0)` - // Estimated: `2884 + v * (2212 ±0) + t * (128 ±0)` - // Minimum execution time: 3_812_071 nanoseconds. - Weight::from_parts(3_826_375_000, 2884) - // Standard Error: 11_601 - .saturating_add(Weight::from_parts(145_309, 0).saturating_mul(v.into())) - // Standard Error: 34_378 - .saturating_add(Weight::from_parts(3_223_977, 0).saturating_mul(a.into())) + // Measured: `194 + v * (553 ±0) + t * (32 ±0)` + // Estimated: `6716 + v * (2212 ±0) + t * (128 ±0)` + // Minimum execution time: 4_069_075_000 picoseconds. + Weight::from_parts(4_105_635_000, 6716) + // Standard Error: 12_539 + .saturating_add(Weight::from_parts(163_040, 0).saturating_mul(v.into())) + // Standard Error: 37_160 + .saturating_add(Weight::from_parts(3_343_858, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(Weight::from_parts(0, 2212).saturating_mul(v.into())) .saturating_add(Weight::from_parts(0, 128).saturating_mul(t.into())) @@ -293,9 +296,9 @@ impl WeightInfo for () { fn on_initialize_nothing() -> Weight { // Proof Size summary in bytes: // Measured: `994` - // Estimated: `6983` - // Minimum execution time: 17_801 nanoseconds. - Weight::from_parts(18_364_000, 6983) + // Estimated: `14903` + // Minimum execution time: 21_538_000 picoseconds. + Weight::from_parts(22_045_000, 14903) .saturating_add(RocksDbWeight::get().reads(8_u64)) } /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) @@ -305,9 +308,9 @@ impl WeightInfo for () { fn on_initialize_open_signed() -> Weight { // Proof Size summary in bytes: // Measured: `114` - // Estimated: `1218` - // Minimum execution time: 12_814 nanoseconds. - Weight::from_parts(13_154_000, 1218) + // Estimated: `3198` + // Minimum execution time: 12_696_000 picoseconds. + Weight::from_parts(12_950_000, 3198) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -318,9 +321,9 @@ impl WeightInfo for () { fn on_initialize_open_unsigned() -> Weight { // Proof Size summary in bytes: // Measured: `114` - // Estimated: `1218` - // Minimum execution time: 14_565 nanoseconds. - Weight::from_parts(15_097_000, 1218) + // Estimated: `3198` + // Minimum execution time: 14_029_000 picoseconds. + Weight::from_parts(14_288_000, 3198) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -330,10 +333,10 @@ impl WeightInfo for () { /// Proof Skipped: ElectionProviderMultiPhase QueuedSolution (max_values: Some(1), max_size: None, mode: Measured) fn finalize_signed_phase_accept_solution() -> Weight { // Proof Size summary in bytes: - // Measured: `206` - // Estimated: `2809` - // Minimum execution time: 23_341 nanoseconds. - Weight::from_parts(23_770_000, 2809) + // Measured: `174` + // Estimated: `3767` + // Minimum execution time: 26_468_000 picoseconds. + Weight::from_parts(26_790_000, 3767) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -341,10 +344,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn finalize_signed_phase_reject_solution() -> Weight { // Proof Size summary in bytes: - // Measured: `206` - // Estimated: `2603` - // Minimum execution time: 16_662 nanoseconds. - Weight::from_parts(16_898_000, 2603) + // Measured: `174` + // Estimated: `3593` + // Minimum execution time: 18_401_000 picoseconds. + Weight::from_parts(18_686_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -360,10 +363,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 215_168 nanoseconds. - Weight::from_parts(219_887_000, 0) - // Standard Error: 1_444 - .saturating_add(Weight::from_parts(146_388, 0).saturating_mul(v.into())) + // Minimum execution time: 266_901_000 picoseconds. + Weight::from_parts(270_251_000, 0) + // Standard Error: 1_758 + .saturating_add(Weight::from_parts(167_310, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) @@ -388,14 +391,14 @@ impl WeightInfo for () { /// The range of component `d` is `[200, 400]`. fn elect_queued(a: u32, d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `368 + a * (768 ±0) + d * (48 ±0)` - // Estimated: `9540 + a * (6912 ±0) + d * (441 ±0)` - // Minimum execution time: 268_021 nanoseconds. - Weight::from_parts(72_491_937, 9540) - // Standard Error: 2_910 - .saturating_add(Weight::from_parts(303_955, 0).saturating_mul(a.into())) - // Standard Error: 4_363 - .saturating_add(Weight::from_parts(167_369, 0).saturating_mul(d.into())) + // Measured: `337 + a * (768 ±0) + d * (48 ±0)` + // Estimated: `16191 + a * (6912 ±0) + d * (441 ±0)` + // Minimum execution time: 286_523_000 picoseconds. + Weight::from_parts(19_101_753, 16191) + // Standard Error: 4_194 + .saturating_add(Weight::from_parts(398_102, 0).saturating_mul(a.into())) + // Standard Error: 6_287 + .saturating_add(Weight::from_parts(188_928, 0).saturating_mul(d.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(8_u64)) .saturating_add(Weight::from_parts(0, 6912).saturating_mul(a.into())) @@ -415,10 +418,10 @@ impl WeightInfo for () { /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionsMap (max_values: None, max_size: None, mode: Measured) fn submit() -> Weight { // Proof Size summary in bytes: - // Measured: `924` - // Estimated: `7111` - // Minimum execution time: 44_177 nanoseconds. - Weight::from_parts(44_663_000, 7111) + // Measured: `893` + // Estimated: `11906` + // Minimum execution time: 47_876_000 picoseconds. + Weight::from_parts(48_464_000, 11906) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -432,51 +435,51 @@ impl WeightInfo for () { /// Proof Skipped: ElectionProviderMultiPhase QueuedSolution (max_values: Some(1), max_size: None, mode: Measured) /// Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) /// Proof Skipped: ElectionProviderMultiPhase SnapshotMetadata (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) - /// Proof Skipped: ElectionProviderMultiPhase MinimumUntrustedScore (max_values: Some(1), max_size: None, mode: Measured) /// Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) /// Proof Skipped: ElectionProviderMultiPhase Snapshot (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase MinimumUntrustedScore (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. fn submit_unsigned(v: u32, t: u32, a: u32, _d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `251 + v * (553 ±0) + t * (32 ±0)` - // Estimated: `5222 + v * (3871 ±0) + t * (224 ±0)` - // Minimum execution time: 4_425_457 nanoseconds. - Weight::from_parts(4_445_889_000, 5222) - // Standard Error: 13_250 - .saturating_add(Weight::from_parts(48_844, 0).saturating_mul(v.into())) - // Standard Error: 39_266 - .saturating_add(Weight::from_parts(4_144_034, 0).saturating_mul(a.into())) + // Measured: `219 + v * (553 ±0) + t * (32 ±0)` + // Estimated: `11928 + v * (3871 ±0) + t * (224 ±0)` + // Minimum execution time: 4_702_825_000 picoseconds. + Weight::from_parts(4_752_015_000, 11928) + // Standard Error: 14_906 + .saturating_add(Weight::from_parts(131_585, 0).saturating_mul(v.into())) + // Standard Error: 44_174 + .saturating_add(Weight::from_parts(4_167_676, 0).saturating_mul(a.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 3871).saturating_mul(v.into())) .saturating_add(Weight::from_parts(0, 224).saturating_mul(t.into())) } - /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) - /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) /// Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) /// Proof Skipped: ElectionProviderMultiPhase DesiredTargets (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) - /// Proof Skipped: ElectionProviderMultiPhase MinimumUntrustedScore (max_values: Some(1), max_size: None, mode: Measured) /// Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) /// Proof Skipped: ElectionProviderMultiPhase Snapshot (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase MinimumUntrustedScore (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. fn feasibility_check(v: u32, t: u32, a: u32, _d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `226 + v * (553 ±0) + t * (32 ±0)` - // Estimated: `2884 + v * (2212 ±0) + t * (128 ±0)` - // Minimum execution time: 3_812_071 nanoseconds. - Weight::from_parts(3_826_375_000, 2884) - // Standard Error: 11_601 - .saturating_add(Weight::from_parts(145_309, 0).saturating_mul(v.into())) - // Standard Error: 34_378 - .saturating_add(Weight::from_parts(3_223_977, 0).saturating_mul(a.into())) + // Measured: `194 + v * (553 ±0) + t * (32 ±0)` + // Estimated: `6716 + v * (2212 ±0) + t * (128 ±0)` + // Minimum execution time: 4_069_075_000 picoseconds. + Weight::from_parts(4_105_635_000, 6716) + // Standard Error: 12_539 + .saturating_add(Weight::from_parts(163_040, 0).saturating_mul(v.into())) + // Standard Error: 37_160 + .saturating_add(Weight::from_parts(3_343_858, 0).saturating_mul(a.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(Weight::from_parts(0, 2212).saturating_mul(v.into())) .saturating_add(Weight::from_parts(0, 128).saturating_mul(t.into())) diff --git a/frame/elections-phragmen/src/weights.rs b/frame/elections-phragmen/src/weights.rs index bbe66d52981c5..0ff6ecf290036 100644 --- a/frame/elections-phragmen/src/weights.rs +++ b/frame/elections-phragmen/src/weights.rs @@ -18,26 +18,28 @@ //! Autogenerated weights for pallet_elections_phragmen //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-02-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-b3zmxxc-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_elections_phragmen +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_elections_phragmen -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/elections-phragmen/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -79,12 +81,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[1, 16]`. fn vote_equal(v: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `499 + v * (80 ±0)` - // Estimated: `9726 + v * (320 ±0)` - // Minimum execution time: 27_362 nanoseconds. - Weight::from_parts(28_497_963, 9726) - // Standard Error: 3_968 - .saturating_add(Weight::from_parts(176_840, 0).saturating_mul(v.into())) + // Measured: `403 + v * (80 ±0)` + // Estimated: `14292 + v * (320 ±0)` + // Minimum execution time: 30_206_000 picoseconds. + Weight::from_parts(30_696_455, 14292) + // Standard Error: 1_864 + .saturating_add(Weight::from_parts(124_941, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 320).saturating_mul(v.into())) @@ -102,12 +104,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[2, 16]`. fn vote_more(v: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `467 + v * (80 ±0)` - // Estimated: `9598 + v * (320 ±0)` - // Minimum execution time: 37_120 nanoseconds. - Weight::from_parts(38_455_302, 9598) - // Standard Error: 5_478 - .saturating_add(Weight::from_parts(219_678, 0).saturating_mul(v.into())) + // Measured: `371 + v * (80 ±0)` + // Estimated: `14164 + v * (320 ±0)` + // Minimum execution time: 40_331_000 picoseconds. + Weight::from_parts(40_936_971, 14164) + // Standard Error: 2_377 + .saturating_add(Weight::from_parts(142_332, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 320).saturating_mul(v.into())) @@ -125,12 +127,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[2, 16]`. fn vote_less(v: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `499 + v * (80 ±0)` - // Estimated: `9726 + v * (320 ±0)` - // Minimum execution time: 36_928 nanoseconds. - Weight::from_parts(38_334_669, 9726) - // Standard Error: 5_271 - .saturating_add(Weight::from_parts(232_355, 0).saturating_mul(v.into())) + // Measured: `403 + v * (80 ±0)` + // Estimated: `14292 + v * (320 ±0)` + // Minimum execution time: 40_343_000 picoseconds. + Weight::from_parts(41_055_673, 14292) + // Standard Error: 3_150 + .saturating_add(Weight::from_parts(129_894, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 320).saturating_mul(v.into())) @@ -141,10 +143,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn remove_voter() -> Weight { // Proof Size summary in bytes: - // Measured: `989` - // Estimated: `7238` - // Minimum execution time: 34_338 nanoseconds. - Weight::from_parts(35_672_000, 7238) + // Measured: `925` + // Estimated: `9154` + // Minimum execution time: 36_348_000 picoseconds. + Weight::from_parts(36_677_000, 9154) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -157,12 +159,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[1, 64]`. fn submit_candidacy(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1697 + c * (48 ±0)` - // Estimated: `6576 + c * (144 ±0)` - // Minimum execution time: 31_864 nanoseconds. - Weight::from_parts(33_490_161, 6576) - // Standard Error: 2_643 - .saturating_add(Weight::from_parts(158_386, 0).saturating_mul(c.into())) + // Measured: `1570 + c * (48 ±0)` + // Estimated: `9165 + c * (144 ±0)` + // Minimum execution time: 32_963_000 picoseconds. + Weight::from_parts(33_778_406, 9165) + // Standard Error: 2_792 + .saturating_add(Weight::from_parts(71_214, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 144).saturating_mul(c.into())) @@ -172,12 +174,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[1, 64]`. fn renounce_candidacy_candidate(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `349 + c * (48 ±0)` - // Estimated: `844 + c * (48 ±0)` - // Minimum execution time: 27_292 nanoseconds. - Weight::from_parts(28_364_955, 844) - // Standard Error: 1_335 - .saturating_add(Weight::from_parts(78_086, 0).saturating_mul(c.into())) + // Measured: `285 + c * (48 ±0)` + // Estimated: `1770 + c * (48 ±0)` + // Minimum execution time: 26_462_000 picoseconds. + Weight::from_parts(27_289_268, 1770) + // Standard Error: 915 + .saturating_add(Weight::from_parts(45_079, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 48).saturating_mul(c.into())) @@ -194,10 +196,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) fn renounce_candidacy_members() -> Weight { // Proof Size summary in bytes: - // Measured: `2027` - // Estimated: `12115` - // Minimum execution time: 45_975 nanoseconds. - Weight::from_parts(47_103_000, 12115) + // Measured: `1900` + // Estimated: `15440` + // Minimum execution time: 44_414_000 picoseconds. + Weight::from_parts(44_900_000, 15440) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -205,10 +207,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) fn renounce_candidacy_runners_up() -> Weight { // Proof Size summary in bytes: - // Measured: `975` - // Estimated: `1470` - // Minimum execution time: 29_243 nanoseconds. - Weight::from_parts(30_582_000, 1470) + // Measured: `880` + // Estimated: `2365` + // Minimum execution time: 28_688_000 picoseconds. + Weight::from_parts(29_027_000, 2365) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -218,7 +220,7 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_000_000_000 nanoseconds. + // Minimum execution time: 2_000_000_000_000 picoseconds. Weight::from_parts(2_000_000_000_000, 0) } /// Storage: Elections Members (r:1 w:1) @@ -235,10 +237,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) fn remove_member_with_replacement() -> Weight { // Proof Size summary in bytes: - // Measured: `2027` - // Estimated: `14718` - // Minimum execution time: 52_527 nanoseconds. - Weight::from_parts(53_538_000, 14718) + // Measured: `1900` + // Estimated: `19033` + // Minimum execution time: 50_280_000 picoseconds. + Weight::from_parts(50_906_000, 19033) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -258,16 +260,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `d` is `[0, 256]`. fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1115 + v * (875 ±0)` - // Estimated: `8448 + v * (12352 ±0)` - // Minimum execution time: 14_934_185 nanoseconds. - Weight::from_parts(15_014_057_000, 8448) - // Standard Error: 245_588 - .saturating_add(Weight::from_parts(35_586_946, 0).saturating_mul(v.into())) + // Measured: `1115 + v * (811 ±0)` + // Estimated: `14388 + v * (12096 ±0)` + // Minimum execution time: 14_785_043_000 picoseconds. + Weight::from_parts(14_842_583_000, 14388) + // Standard Error: 242_757 + .saturating_add(Weight::from_parts(36_168_971, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(v.into()))) - .saturating_add(Weight::from_parts(0, 12352).saturating_mul(v.into())) + .saturating_add(Weight::from_parts(0, 12096).saturating_mul(v.into())) } /// Storage: Elections Candidates (r:1 w:1) /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) @@ -292,20 +294,20 @@ impl WeightInfo for SubstrateWeight { /// The range of component `e` is `[512, 8192]`. fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + v * (638 ±0) + e * (28 ±0)` - // Estimated: `330033 + v * (5229 ±6) + e * (89 ±0) + c * (2135 ±7)` - // Minimum execution time: 1_273_671 nanoseconds. - Weight::from_parts(1_279_716_000, 330033) - // Standard Error: 543_277 - .saturating_add(Weight::from_parts(20_613_753, 0).saturating_mul(v.into())) - // Standard Error: 34_857 - .saturating_add(Weight::from_parts(688_354, 0).saturating_mul(e.into())) + // Measured: `0 + v * (606 ±0) + e * (28 ±0)` + // Estimated: `309059 + v * (5005 ±8) + e * (89 ±0) + c * (2135 ±7)` + // Minimum execution time: 1_074_961_000 picoseconds. + Weight::from_parts(1_079_460_000, 309059) + // Standard Error: 598_993 + .saturating_add(Weight::from_parts(17_097_981, 0).saturating_mul(v.into())) + // Standard Error: 38_432 + .saturating_add(Weight::from_parts(820_141, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(21_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) - .saturating_add(Weight::from_parts(0, 5229).saturating_mul(v.into())) + .saturating_add(Weight::from_parts(0, 5005).saturating_mul(v.into())) .saturating_add(Weight::from_parts(0, 89).saturating_mul(e.into())) .saturating_add(Weight::from_parts(0, 2135).saturating_mul(c.into())) } @@ -326,12 +328,12 @@ impl WeightInfo for () { /// The range of component `v` is `[1, 16]`. fn vote_equal(v: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `499 + v * (80 ±0)` - // Estimated: `9726 + v * (320 ±0)` - // Minimum execution time: 27_362 nanoseconds. - Weight::from_parts(28_497_963, 9726) - // Standard Error: 3_968 - .saturating_add(Weight::from_parts(176_840, 0).saturating_mul(v.into())) + // Measured: `403 + v * (80 ±0)` + // Estimated: `14292 + v * (320 ±0)` + // Minimum execution time: 30_206_000 picoseconds. + Weight::from_parts(30_696_455, 14292) + // Standard Error: 1_864 + .saturating_add(Weight::from_parts(124_941, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 320).saturating_mul(v.into())) @@ -349,12 +351,12 @@ impl WeightInfo for () { /// The range of component `v` is `[2, 16]`. fn vote_more(v: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `467 + v * (80 ±0)` - // Estimated: `9598 + v * (320 ±0)` - // Minimum execution time: 37_120 nanoseconds. - Weight::from_parts(38_455_302, 9598) - // Standard Error: 5_478 - .saturating_add(Weight::from_parts(219_678, 0).saturating_mul(v.into())) + // Measured: `371 + v * (80 ±0)` + // Estimated: `14164 + v * (320 ±0)` + // Minimum execution time: 40_331_000 picoseconds. + Weight::from_parts(40_936_971, 14164) + // Standard Error: 2_377 + .saturating_add(Weight::from_parts(142_332, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 320).saturating_mul(v.into())) @@ -372,12 +374,12 @@ impl WeightInfo for () { /// The range of component `v` is `[2, 16]`. fn vote_less(v: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `499 + v * (80 ±0)` - // Estimated: `9726 + v * (320 ±0)` - // Minimum execution time: 36_928 nanoseconds. - Weight::from_parts(38_334_669, 9726) - // Standard Error: 5_271 - .saturating_add(Weight::from_parts(232_355, 0).saturating_mul(v.into())) + // Measured: `403 + v * (80 ±0)` + // Estimated: `14292 + v * (320 ±0)` + // Minimum execution time: 40_343_000 picoseconds. + Weight::from_parts(41_055_673, 14292) + // Standard Error: 3_150 + .saturating_add(Weight::from_parts(129_894, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 320).saturating_mul(v.into())) @@ -388,10 +390,10 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn remove_voter() -> Weight { // Proof Size summary in bytes: - // Measured: `989` - // Estimated: `7238` - // Minimum execution time: 34_338 nanoseconds. - Weight::from_parts(35_672_000, 7238) + // Measured: `925` + // Estimated: `9154` + // Minimum execution time: 36_348_000 picoseconds. + Weight::from_parts(36_677_000, 9154) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -404,12 +406,12 @@ impl WeightInfo for () { /// The range of component `c` is `[1, 64]`. fn submit_candidacy(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1697 + c * (48 ±0)` - // Estimated: `6576 + c * (144 ±0)` - // Minimum execution time: 31_864 nanoseconds. - Weight::from_parts(33_490_161, 6576) - // Standard Error: 2_643 - .saturating_add(Weight::from_parts(158_386, 0).saturating_mul(c.into())) + // Measured: `1570 + c * (48 ±0)` + // Estimated: `9165 + c * (144 ±0)` + // Minimum execution time: 32_963_000 picoseconds. + Weight::from_parts(33_778_406, 9165) + // Standard Error: 2_792 + .saturating_add(Weight::from_parts(71_214, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 144).saturating_mul(c.into())) @@ -419,12 +421,12 @@ impl WeightInfo for () { /// The range of component `c` is `[1, 64]`. fn renounce_candidacy_candidate(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `349 + c * (48 ±0)` - // Estimated: `844 + c * (48 ±0)` - // Minimum execution time: 27_292 nanoseconds. - Weight::from_parts(28_364_955, 844) - // Standard Error: 1_335 - .saturating_add(Weight::from_parts(78_086, 0).saturating_mul(c.into())) + // Measured: `285 + c * (48 ±0)` + // Estimated: `1770 + c * (48 ±0)` + // Minimum execution time: 26_462_000 picoseconds. + Weight::from_parts(27_289_268, 1770) + // Standard Error: 915 + .saturating_add(Weight::from_parts(45_079, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 48).saturating_mul(c.into())) @@ -441,10 +443,10 @@ impl WeightInfo for () { /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) fn renounce_candidacy_members() -> Weight { // Proof Size summary in bytes: - // Measured: `2027` - // Estimated: `12115` - // Minimum execution time: 45_975 nanoseconds. - Weight::from_parts(47_103_000, 12115) + // Measured: `1900` + // Estimated: `15440` + // Minimum execution time: 44_414_000 picoseconds. + Weight::from_parts(44_900_000, 15440) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -452,10 +454,10 @@ impl WeightInfo for () { /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) fn renounce_candidacy_runners_up() -> Weight { // Proof Size summary in bytes: - // Measured: `975` - // Estimated: `1470` - // Minimum execution time: 29_243 nanoseconds. - Weight::from_parts(30_582_000, 1470) + // Measured: `880` + // Estimated: `2365` + // Minimum execution time: 28_688_000 picoseconds. + Weight::from_parts(29_027_000, 2365) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -465,7 +467,7 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_000_000_000 nanoseconds. + // Minimum execution time: 2_000_000_000_000 picoseconds. Weight::from_parts(2_000_000_000_000, 0) } /// Storage: Elections Members (r:1 w:1) @@ -482,10 +484,10 @@ impl WeightInfo for () { /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) fn remove_member_with_replacement() -> Weight { // Proof Size summary in bytes: - // Measured: `2027` - // Estimated: `14718` - // Minimum execution time: 52_527 nanoseconds. - Weight::from_parts(53_538_000, 14718) + // Measured: `1900` + // Estimated: `19033` + // Minimum execution time: 50_280_000 picoseconds. + Weight::from_parts(50_906_000, 19033) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -505,16 +507,16 @@ impl WeightInfo for () { /// The range of component `d` is `[0, 256]`. fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1115 + v * (875 ±0)` - // Estimated: `8448 + v * (12352 ±0)` - // Minimum execution time: 14_934_185 nanoseconds. - Weight::from_parts(15_014_057_000, 8448) - // Standard Error: 245_588 - .saturating_add(Weight::from_parts(35_586_946, 0).saturating_mul(v.into())) + // Measured: `1115 + v * (811 ±0)` + // Estimated: `14388 + v * (12096 ±0)` + // Minimum execution time: 14_785_043_000 picoseconds. + Weight::from_parts(14_842_583_000, 14388) + // Standard Error: 242_757 + .saturating_add(Weight::from_parts(36_168_971, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(v.into()))) - .saturating_add(Weight::from_parts(0, 12352).saturating_mul(v.into())) + .saturating_add(Weight::from_parts(0, 12096).saturating_mul(v.into())) } /// Storage: Elections Candidates (r:1 w:1) /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) @@ -539,20 +541,20 @@ impl WeightInfo for () { /// The range of component `e` is `[512, 8192]`. fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + v * (638 ±0) + e * (28 ±0)` - // Estimated: `330033 + v * (5229 ±6) + e * (89 ±0) + c * (2135 ±7)` - // Minimum execution time: 1_273_671 nanoseconds. - Weight::from_parts(1_279_716_000, 330033) - // Standard Error: 543_277 - .saturating_add(Weight::from_parts(20_613_753, 0).saturating_mul(v.into())) - // Standard Error: 34_857 - .saturating_add(Weight::from_parts(688_354, 0).saturating_mul(e.into())) + // Measured: `0 + v * (606 ±0) + e * (28 ±0)` + // Estimated: `309059 + v * (5005 ±8) + e * (89 ±0) + c * (2135 ±7)` + // Minimum execution time: 1_074_961_000 picoseconds. + Weight::from_parts(1_079_460_000, 309059) + // Standard Error: 598_993 + .saturating_add(Weight::from_parts(17_097_981, 0).saturating_mul(v.into())) + // Standard Error: 38_432 + .saturating_add(Weight::from_parts(820_141, 0).saturating_mul(e.into())) .saturating_add(RocksDbWeight::get().reads(21_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(c.into()))) - .saturating_add(Weight::from_parts(0, 5229).saturating_mul(v.into())) + .saturating_add(Weight::from_parts(0, 5005).saturating_mul(v.into())) .saturating_add(Weight::from_parts(0, 89).saturating_mul(e.into())) .saturating_add(Weight::from_parts(0, 2135).saturating_mul(c.into())) } diff --git a/frame/fast-unstake/src/weights.rs b/frame/fast-unstake/src/weights.rs index ced7acb951229..b47d4f056e524 100644 --- a/frame/fast-unstake/src/weights.rs +++ b/frame/fast-unstake/src/weights.rs @@ -18,25 +18,28 @@ //! Autogenerated weights for pallet_fast_unstake //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `runner-b3zmxxc-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_fast_unstake +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_fast_unstake -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/fast-unstake/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -58,172 +61,290 @@ pub trait WeightInfo { /// Weights for pallet_fast_unstake using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) - // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: FastUnstake Head (r:1 w:1) - // Storage: FastUnstake CounterForQueue (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking Payee (r:0 w:1) + /// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + /// Proof: FastUnstake ErasToCheckPerBlock (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ValidatorCount (r:1 w:0) + /// Proof: Staking ValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: FastUnstake Head (r:1 w:1) + /// Proof: FastUnstake Head (max_values: Some(1), max_size: Some(5768), added: 6263, mode: MaxEncodedLen) + /// Storage: FastUnstake CounterForQueue (r:1 w:0) + /// Proof: FastUnstake CounterForQueue (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking SlashingSpans (r:64 w:0) + /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking Bonded (r:64 w:64) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:64 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:64 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: System Account (r:64 w:64) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:64 w:64) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:0 w:64) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:64) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// The range of component `b` is `[1, 64]`. fn on_idle_unstake(b: u32, ) -> Weight { - // Minimum execution time: 92_833 nanoseconds. - Weight::from_parts(62_136_346, 0) - // Standard Error: 25_541 - .saturating_add(Weight::from_parts(42_904_859, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `1344 + b * (343 ±0)` + // Estimated: `23254 + b * (17642 ±0)` + // Minimum execution time: 78_484_000 picoseconds. + Weight::from_parts(39_186_541, 23254) + // Standard Error: 37_606 + .saturating_add(Weight::from_parts(42_433_199, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(b.into()))) - .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(b.into()))) + .saturating_add(Weight::from_parts(0, 17642).saturating_mul(b.into())) } - // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) - // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: FastUnstake Head (r:1 w:1) - // Storage: FastUnstake CounterForQueue (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking ErasStakers (r:2 w:0) + /// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + /// Proof: FastUnstake ErasToCheckPerBlock (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ValidatorCount (r:1 w:0) + /// Proof: Staking ValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: FastUnstake Head (r:1 w:1) + /// Proof: FastUnstake Head (max_values: Some(1), max_size: Some(5768), added: 6263, mode: MaxEncodedLen) + /// Storage: FastUnstake CounterForQueue (r:1 w:0) + /// Proof: FastUnstake CounterForQueue (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ErasStakers (r:257 w:0) + /// Proof Skipped: Staking ErasStakers (max_values: None, max_size: None, mode: Measured) /// The range of component `v` is `[1, 256]`. /// The range of component `b` is `[1, 64]`. fn on_idle_check(v: u32, b: u32, ) -> Weight { - // Minimum execution time: 1_775_293 nanoseconds. - Weight::from_parts(1_787_133_000, 0) - // Standard Error: 17_109_142 - .saturating_add(Weight::from_parts(546_766_552, 0).saturating_mul(v.into())) - // Standard Error: 68_455_625 - .saturating_add(Weight::from_parts(2_135_980_830, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(7)) + // Proof Size summary in bytes: + // Measured: `1512 + v * (10037 ±0) + b * (48 ±0)` + // Estimated: `20889 + v * (22551 ±0) + b * (98 ±0)` + // Minimum execution time: 1_538_727_000 picoseconds. + Weight::from_parts(1_549_586_000, 20889) + // Standard Error: 14_184_223 + .saturating_add(Weight::from_parts(452_966_006, 0).saturating_mul(v.into())) + // Standard Error: 56_752_692 + .saturating_add(Weight::from_parts(1_775_601_329, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into()))) - .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_parts(0, 22551).saturating_mul(v.into())) + .saturating_add(Weight::from_parts(0, 98).saturating_mul(b.into())) } - // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: FastUnstake Queue (r:1 w:1) - // Storage: FastUnstake Head (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: VoterList ListNodes (r:1 w:1) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: FastUnstake CounterForQueue (r:1 w:1) + /// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + /// Proof: FastUnstake ErasToCheckPerBlock (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: FastUnstake Queue (r:1 w:1) + /// Proof: FastUnstake Queue (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: FastUnstake Head (r:1 w:0) + /// Proof: FastUnstake Head (max_values: Some(1), max_size: Some(5768), added: 6263, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:1 w:1) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: FastUnstake CounterForQueue (r:1 w:1) + /// Proof: FastUnstake CounterForQueue (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn register_fast_unstake() -> Weight { - // Minimum execution time: 124_849 nanoseconds. - Weight::from_parts(128_176_000, 0) - .saturating_add(T::DbWeight::get().reads(14)) - .saturating_add(T::DbWeight::get().writes(9)) + // Proof Size summary in bytes: + // Measured: `1964` + // Estimated: `45775` + // Minimum execution time: 117_552_000 picoseconds. + Weight::from_parts(118_303_000, 45775) + .saturating_add(T::DbWeight::get().reads(14_u64)) + .saturating_add(T::DbWeight::get().writes(9_u64)) } - // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: FastUnstake Queue (r:1 w:1) - // Storage: FastUnstake Head (r:1 w:0) - // Storage: FastUnstake CounterForQueue (r:1 w:1) + /// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + /// Proof: FastUnstake ErasToCheckPerBlock (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: FastUnstake Queue (r:1 w:1) + /// Proof: FastUnstake Queue (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: FastUnstake Head (r:1 w:0) + /// Proof: FastUnstake Head (max_values: Some(1), max_size: Some(5768), added: 6263, mode: MaxEncodedLen) + /// Storage: FastUnstake CounterForQueue (r:1 w:1) + /// Proof: FastUnstake CounterForQueue (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn deregister() -> Weight { - // Minimum execution time: 48_246 nanoseconds. - Weight::from_parts(49_720_000, 0) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `1223` + // Estimated: `18308` + // Minimum execution time: 42_291_000 picoseconds. + Weight::from_parts(42_835_000, 18308) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1) + /// Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1) + /// Proof: FastUnstake ErasToCheckPerBlock (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn control() -> Weight { - // Minimum execution time: 4_611 nanoseconds. - Weight::from_parts(4_844_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_551_000 picoseconds. + Weight::from_parts(3_632_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) - // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: FastUnstake Head (r:1 w:1) - // Storage: FastUnstake CounterForQueue (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking Payee (r:0 w:1) + /// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + /// Proof: FastUnstake ErasToCheckPerBlock (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ValidatorCount (r:1 w:0) + /// Proof: Staking ValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: FastUnstake Head (r:1 w:1) + /// Proof: FastUnstake Head (max_values: Some(1), max_size: Some(5768), added: 6263, mode: MaxEncodedLen) + /// Storage: FastUnstake CounterForQueue (r:1 w:0) + /// Proof: FastUnstake CounterForQueue (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking SlashingSpans (r:64 w:0) + /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking Bonded (r:64 w:64) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:64 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:64 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: System Account (r:64 w:64) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:64 w:64) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:0 w:64) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:64) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// The range of component `b` is `[1, 64]`. fn on_idle_unstake(b: u32, ) -> Weight { - // Minimum execution time: 92_833 nanoseconds. - Weight::from_parts(62_136_346, 0) - // Standard Error: 25_541 - .saturating_add(Weight::from_parts(42_904_859, 0).saturating_mul(b.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `1344 + b * (343 ±0)` + // Estimated: `23254 + b * (17642 ±0)` + // Minimum execution time: 78_484_000 picoseconds. + Weight::from_parts(39_186_541, 23254) + // Standard Error: 37_606 + .saturating_add(Weight::from_parts(42_433_199, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(b.into()))) - .saturating_add(RocksDbWeight::get().writes(1)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(RocksDbWeight::get().writes((5_u64).saturating_mul(b.into()))) + .saturating_add(Weight::from_parts(0, 17642).saturating_mul(b.into())) } - // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) - // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: FastUnstake Head (r:1 w:1) - // Storage: FastUnstake CounterForQueue (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking ErasStakers (r:2 w:0) + /// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + /// Proof: FastUnstake ErasToCheckPerBlock (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ValidatorCount (r:1 w:0) + /// Proof: Staking ValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: FastUnstake Head (r:1 w:1) + /// Proof: FastUnstake Head (max_values: Some(1), max_size: Some(5768), added: 6263, mode: MaxEncodedLen) + /// Storage: FastUnstake CounterForQueue (r:1 w:0) + /// Proof: FastUnstake CounterForQueue (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ErasStakers (r:257 w:0) + /// Proof Skipped: Staking ErasStakers (max_values: None, max_size: None, mode: Measured) /// The range of component `v` is `[1, 256]`. /// The range of component `b` is `[1, 64]`. fn on_idle_check(v: u32, b: u32, ) -> Weight { - // Minimum execution time: 1_775_293 nanoseconds. - Weight::from_parts(1_787_133_000, 0) - // Standard Error: 17_109_142 - .saturating_add(Weight::from_parts(546_766_552, 0).saturating_mul(v.into())) - // Standard Error: 68_455_625 - .saturating_add(Weight::from_parts(2_135_980_830, 0).saturating_mul(b.into())) - .saturating_add(RocksDbWeight::get().reads(7)) + // Proof Size summary in bytes: + // Measured: `1512 + v * (10037 ±0) + b * (48 ±0)` + // Estimated: `20889 + v * (22551 ±0) + b * (98 ±0)` + // Minimum execution time: 1_538_727_000 picoseconds. + Weight::from_parts(1_549_586_000, 20889) + // Standard Error: 14_184_223 + .saturating_add(Weight::from_parts(452_966_006, 0).saturating_mul(v.into())) + // Standard Error: 56_752_692 + .saturating_add(Weight::from_parts(1_775_601_329, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into()))) - .saturating_add(RocksDbWeight::get().writes(1)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_parts(0, 22551).saturating_mul(v.into())) + .saturating_add(Weight::from_parts(0, 98).saturating_mul(b.into())) } - // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: FastUnstake Queue (r:1 w:1) - // Storage: FastUnstake Head (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: VoterList ListNodes (r:1 w:1) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: FastUnstake CounterForQueue (r:1 w:1) + /// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + /// Proof: FastUnstake ErasToCheckPerBlock (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: FastUnstake Queue (r:1 w:1) + /// Proof: FastUnstake Queue (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: FastUnstake Head (r:1 w:0) + /// Proof: FastUnstake Head (max_values: Some(1), max_size: Some(5768), added: 6263, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:1 w:1) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: FastUnstake CounterForQueue (r:1 w:1) + /// Proof: FastUnstake CounterForQueue (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn register_fast_unstake() -> Weight { - // Minimum execution time: 124_849 nanoseconds. - Weight::from_parts(128_176_000, 0) - .saturating_add(RocksDbWeight::get().reads(14)) - .saturating_add(RocksDbWeight::get().writes(9)) + // Proof Size summary in bytes: + // Measured: `1964` + // Estimated: `45775` + // Minimum execution time: 117_552_000 picoseconds. + Weight::from_parts(118_303_000, 45775) + .saturating_add(RocksDbWeight::get().reads(14_u64)) + .saturating_add(RocksDbWeight::get().writes(9_u64)) } - // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: FastUnstake Queue (r:1 w:1) - // Storage: FastUnstake Head (r:1 w:0) - // Storage: FastUnstake CounterForQueue (r:1 w:1) + /// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + /// Proof: FastUnstake ErasToCheckPerBlock (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: FastUnstake Queue (r:1 w:1) + /// Proof: FastUnstake Queue (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: FastUnstake Head (r:1 w:0) + /// Proof: FastUnstake Head (max_values: Some(1), max_size: Some(5768), added: 6263, mode: MaxEncodedLen) + /// Storage: FastUnstake CounterForQueue (r:1 w:1) + /// Proof: FastUnstake CounterForQueue (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn deregister() -> Weight { - // Minimum execution time: 48_246 nanoseconds. - Weight::from_parts(49_720_000, 0) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `1223` + // Estimated: `18308` + // Minimum execution time: 42_291_000 picoseconds. + Weight::from_parts(42_835_000, 18308) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1) + /// Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1) + /// Proof: FastUnstake ErasToCheckPerBlock (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn control() -> Weight { - // Minimum execution time: 4_611 nanoseconds. - Weight::from_parts(4_844_000, 0) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_551_000 picoseconds. + Weight::from_parts(3_632_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/glutton/src/weights.rs b/frame/glutton/src/weights.rs index 1a7020c17a9ab..bd409645ae8ff 100644 --- a/frame/glutton/src/weights.rs +++ b/frame/glutton/src/weights.rs @@ -18,26 +18,28 @@ //! Autogenerated weights for pallet_glutton //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-02-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_glutton +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_glutton -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/glutton/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -72,11 +74,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4` // Estimated: `1489` - // Minimum execution time: 10_218 nanoseconds. - Weight::from_parts(10_510_000, 0) - .saturating_add(Weight::from_parts(0, 1489)) - // Standard Error: 1_582 - .saturating_add(Weight::from_parts(1_577_660, 0).saturating_mul(n.into())) + // Minimum execution time: 10_384_000 picoseconds. + Weight::from_parts(10_598_000, 1489) + // Standard Error: 1_369 + .saturating_add(Weight::from_parts(1_580_155, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) @@ -90,11 +91,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `65` // Estimated: `1489` - // Minimum execution time: 10_993 nanoseconds. - Weight::from_parts(11_208_000, 0) - .saturating_add(Weight::from_parts(0, 1489)) - // Standard Error: 1_386 - .saturating_add(Weight::from_parts(1_072_330, 0).saturating_mul(n.into())) + // Minimum execution time: 11_022_000 picoseconds. + Weight::from_parts(11_319_000, 1489) + // Standard Error: 1_108 + .saturating_add(Weight::from_parts(1_048_682, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) @@ -104,24 +104,22 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 740 nanoseconds. - Weight::from_parts(770_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 24 - .saturating_add(Weight::from_parts(96_434, 0).saturating_mul(i.into())) + // Minimum execution time: 660_000 picoseconds. + Weight::from_parts(7_814_200, 0) + // Standard Error: 33 + .saturating_add(Weight::from_parts(94_390, 0).saturating_mul(i.into())) } /// Storage: Glutton TrashData (r:5000 w:0) /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) /// The range of component `i` is `[0, 5000]`. fn waste_proof_size_some(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `119036 + i * (1053 ±0)` + // Measured: `119036 + i * (1022 ±0)` // Estimated: `990 + i * (3016 ±0)` - // Minimum execution time: 630 nanoseconds. - Weight::from_parts(712_000, 0) - .saturating_add(Weight::from_parts(0, 990)) - // Standard Error: 4_326 - .saturating_add(Weight::from_parts(5_500_880, 0).saturating_mul(i.into())) + // Minimum execution time: 712_000 picoseconds. + Weight::from_parts(814_000, 990) + // Standard Error: 1_805 + .saturating_add(Weight::from_parts(5_407_690, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(Weight::from_parts(0, 3016).saturating_mul(i.into())) } @@ -133,11 +131,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) fn on_idle_high_proof_waste() -> Weight { // Proof Size summary in bytes: - // Measured: `1954313` + // Measured: `1900466` // Estimated: `5242760` - // Minimum execution time: 56_743_236 nanoseconds. - Weight::from_parts(57_088_040_000, 0) - .saturating_add(Weight::from_parts(0, 5242760)) + // Minimum execution time: 54_903_045_000 picoseconds. + Weight::from_parts(55_194_691_000, 5242760) .saturating_add(T::DbWeight::get().reads(1739_u64)) } /// Storage: Glutton Storage (r:1 w:0) @@ -148,11 +145,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) fn on_idle_low_proof_waste() -> Weight { // Proof Size summary in bytes: - // Measured: `9671` + // Measured: `9516` // Estimated: `19048` - // Minimum execution time: 100_387_042 nanoseconds. - Weight::from_parts(100_987_577_000, 0) - .saturating_add(Weight::from_parts(0, 19048)) + // Minimum execution time: 97_295_331_000 picoseconds. + Weight::from_parts(97_853_502_000, 19048) .saturating_add(T::DbWeight::get().reads(7_u64)) } /// Storage: Glutton Storage (r:1 w:0) @@ -163,9 +159,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4` // Estimated: `2978` - // Minimum execution time: 4_256 nanoseconds. - Weight::from_parts(4_447_000, 0) - .saturating_add(Weight::from_parts(0, 2978)) + // Minimum execution time: 4_280_000 picoseconds. + Weight::from_parts(4_381_000, 2978) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: Glutton Compute (r:0 w:1) @@ -174,9 +169,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_663 nanoseconds. - Weight::from_parts(8_864_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 8_758_000 picoseconds. + Weight::from_parts(8_988_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Glutton Storage (r:0 w:1) @@ -185,9 +179,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_653 nanoseconds. - Weight::from_parts(8_998_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 8_901_000 picoseconds. + Weight::from_parts(9_291_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -203,11 +196,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4` // Estimated: `1489` - // Minimum execution time: 10_218 nanoseconds. - Weight::from_parts(10_510_000, 0) - .saturating_add(Weight::from_parts(0, 1489)) - // Standard Error: 1_582 - .saturating_add(Weight::from_parts(1_577_660, 0).saturating_mul(n.into())) + // Minimum execution time: 10_384_000 picoseconds. + Weight::from_parts(10_598_000, 1489) + // Standard Error: 1_369 + .saturating_add(Weight::from_parts(1_580_155, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) @@ -221,11 +213,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `65` // Estimated: `1489` - // Minimum execution time: 10_993 nanoseconds. - Weight::from_parts(11_208_000, 0) - .saturating_add(Weight::from_parts(0, 1489)) - // Standard Error: 1_386 - .saturating_add(Weight::from_parts(1_072_330, 0).saturating_mul(n.into())) + // Minimum execution time: 11_022_000 picoseconds. + Weight::from_parts(11_319_000, 1489) + // Standard Error: 1_108 + .saturating_add(Weight::from_parts(1_048_682, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) @@ -235,24 +226,22 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 740 nanoseconds. - Weight::from_parts(770_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 24 - .saturating_add(Weight::from_parts(96_434, 0).saturating_mul(i.into())) + // Minimum execution time: 660_000 picoseconds. + Weight::from_parts(7_814_200, 0) + // Standard Error: 33 + .saturating_add(Weight::from_parts(94_390, 0).saturating_mul(i.into())) } /// Storage: Glutton TrashData (r:5000 w:0) /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) /// The range of component `i` is `[0, 5000]`. fn waste_proof_size_some(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `119036 + i * (1053 ±0)` + // Measured: `119036 + i * (1022 ±0)` // Estimated: `990 + i * (3016 ±0)` - // Minimum execution time: 630 nanoseconds. - Weight::from_parts(712_000, 0) - .saturating_add(Weight::from_parts(0, 990)) - // Standard Error: 4_326 - .saturating_add(Weight::from_parts(5_500_880, 0).saturating_mul(i.into())) + // Minimum execution time: 712_000 picoseconds. + Weight::from_parts(814_000, 990) + // Standard Error: 1_805 + .saturating_add(Weight::from_parts(5_407_690, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(Weight::from_parts(0, 3016).saturating_mul(i.into())) } @@ -264,11 +253,10 @@ impl WeightInfo for () { /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) fn on_idle_high_proof_waste() -> Weight { // Proof Size summary in bytes: - // Measured: `1954313` + // Measured: `1900466` // Estimated: `5242760` - // Minimum execution time: 56_743_236 nanoseconds. - Weight::from_parts(57_088_040_000, 0) - .saturating_add(Weight::from_parts(0, 5242760)) + // Minimum execution time: 54_903_045_000 picoseconds. + Weight::from_parts(55_194_691_000, 5242760) .saturating_add(RocksDbWeight::get().reads(1739_u64)) } /// Storage: Glutton Storage (r:1 w:0) @@ -279,11 +267,10 @@ impl WeightInfo for () { /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) fn on_idle_low_proof_waste() -> Weight { // Proof Size summary in bytes: - // Measured: `9671` + // Measured: `9516` // Estimated: `19048` - // Minimum execution time: 100_387_042 nanoseconds. - Weight::from_parts(100_987_577_000, 0) - .saturating_add(Weight::from_parts(0, 19048)) + // Minimum execution time: 97_295_331_000 picoseconds. + Weight::from_parts(97_853_502_000, 19048) .saturating_add(RocksDbWeight::get().reads(7_u64)) } /// Storage: Glutton Storage (r:1 w:0) @@ -294,9 +281,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4` // Estimated: `2978` - // Minimum execution time: 4_256 nanoseconds. - Weight::from_parts(4_447_000, 0) - .saturating_add(Weight::from_parts(0, 2978)) + // Minimum execution time: 4_280_000 picoseconds. + Weight::from_parts(4_381_000, 2978) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// Storage: Glutton Compute (r:0 w:1) @@ -305,9 +291,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_663 nanoseconds. - Weight::from_parts(8_864_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 8_758_000 picoseconds. + Weight::from_parts(8_988_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Glutton Storage (r:0 w:1) @@ -316,9 +301,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_653 nanoseconds. - Weight::from_parts(8_998_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 8_901_000 picoseconds. + Weight::from_parts(9_291_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/identity/src/weights.rs b/frame/identity/src/weights.rs index 65fe2b17ba527..bad6aa76854ea 100644 --- a/frame/identity/src/weights.rs +++ b/frame/identity/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_identity //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_identity +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -74,12 +77,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[1, 19]`. fn add_registrar(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `64 + r * (57 ±0)` - // Estimated: `1636` - // Minimum execution time: 10_964 nanoseconds. - Weight::from_parts(11_800_935, 1636) - // Standard Error: 1_334 - .saturating_add(Weight::from_parts(96_038, 0).saturating_mul(r.into())) + // Measured: `32 + r * (57 ±0)` + // Estimated: `2626` + // Minimum execution time: 13_092_000 picoseconds. + Weight::from_parts(13_798_719, 2626) + // Standard Error: 1_553 + .saturating_add(Weight::from_parts(109_215, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -89,14 +92,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[0, 100]`. fn set_identity(r: u32, x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `474 + r * (5 ±0)` - // Estimated: `10013` - // Minimum execution time: 26_400 nanoseconds. - Weight::from_parts(26_060_549, 10013) - // Standard Error: 1_561 - .saturating_add(Weight::from_parts(72_083, 0).saturating_mul(r.into())) - // Standard Error: 304 - .saturating_add(Weight::from_parts(306_994, 0).saturating_mul(x.into())) + // Measured: `442 + r * (5 ±0)` + // Estimated: `11003` + // Minimum execution time: 30_800_000 picoseconds. + Weight::from_parts(31_140_040, 11003) + // Standard Error: 4_896 + .saturating_add(Weight::from_parts(69_348, 0).saturating_mul(r.into())) + // Standard Error: 955 + .saturating_add(Weight::from_parts(430_082, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -110,11 +113,11 @@ impl WeightInfo for SubstrateWeight { fn set_subs_new(s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `101` - // Estimated: `15746 + s * (2589 ±0)` - // Minimum execution time: 8_492 nanoseconds. - Weight::from_parts(21_645_924, 15746) - // Standard Error: 3_452 - .saturating_add(Weight::from_parts(2_442_604, 0).saturating_mul(s.into())) + // Estimated: `18716 + s * (2589 ±0)` + // Minimum execution time: 10_301_000 picoseconds. + Weight::from_parts(23_255_636, 18716) + // Standard Error: 5_562 + .saturating_add(Weight::from_parts(2_978_765, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(s.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -130,12 +133,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[0, 100]`. fn set_subs_old(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `226 + p * (32 ±0)` - // Estimated: `15746` - // Minimum execution time: 8_488 nanoseconds. - Weight::from_parts(20_202_601, 15746) - // Standard Error: 2_834 - .saturating_add(Weight::from_parts(1_082_941, 0).saturating_mul(p.into())) + // Measured: `194 + p * (32 ±0)` + // Estimated: `17726` + // Minimum execution time: 10_095_000 picoseconds. + Weight::from_parts(23_197_533, 17726) + // Standard Error: 3_460 + .saturating_add(Weight::from_parts(1_227_498, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) @@ -149,18 +152,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[1, 20]`. /// The range of component `s` is `[0, 100]`. /// The range of component `x` is `[0, 100]`. - fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `533 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` - // Estimated: `15746` - // Minimum execution time: 41_319 nanoseconds. - Weight::from_parts(25_850_055, 15746) - // Standard Error: 4_144 - .saturating_add(Weight::from_parts(59_619, 0).saturating_mul(r.into())) - // Standard Error: 809 - .saturating_add(Weight::from_parts(1_076_550, 0).saturating_mul(s.into())) - // Standard Error: 809 - .saturating_add(Weight::from_parts(163_191, 0).saturating_mul(x.into())) + fn clear_identity(_r: u32, s: u32, x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `469 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` + // Estimated: `17726` + // Minimum execution time: 51_054_000 picoseconds. + Weight::from_parts(30_184_047, 17726) + // Standard Error: 2_441 + .saturating_add(Weight::from_parts(1_221_983, 0).saturating_mul(s.into())) + // Standard Error: 2_441 + .saturating_add(Weight::from_parts(234_084, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -173,14 +174,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[0, 100]`. fn request_judgement(r: u32, x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `431 + r * (57 ±0) + x * (66 ±0)` - // Estimated: `11649` - // Minimum execution time: 28_118 nanoseconds. - Weight::from_parts(27_359_471, 11649) - // Standard Error: 2_707 - .saturating_add(Weight::from_parts(107_279, 0).saturating_mul(r.into())) - // Standard Error: 528 - .saturating_add(Weight::from_parts(325_165, 0).saturating_mul(x.into())) + // Measured: `367 + r * (57 ±0) + x * (66 ±0)` + // Estimated: `13629` + // Minimum execution time: 32_747_000 picoseconds. + Weight::from_parts(29_557_659, 13629) + // Standard Error: 4_616 + .saturating_add(Weight::from_parts(200_494, 0).saturating_mul(r.into())) + // Standard Error: 900 + .saturating_add(Weight::from_parts(468_381, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -190,14 +191,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[0, 100]`. fn cancel_request(r: u32, x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `430 + x * (66 ±0)` - // Estimated: `10013` - // Minimum execution time: 24_817 nanoseconds. - Weight::from_parts(24_749_808, 10013) - // Standard Error: 1_938 - .saturating_add(Weight::from_parts(63_396, 0).saturating_mul(r.into())) - // Standard Error: 378 - .saturating_add(Weight::from_parts(327_083, 0).saturating_mul(x.into())) + // Measured: `398 + x * (66 ±0)` + // Estimated: `11003` + // Minimum execution time: 28_853_000 picoseconds. + Weight::from_parts(26_811_119, 11003) + // Standard Error: 15_667 + .saturating_add(Weight::from_parts(240_647, 0).saturating_mul(r.into())) + // Standard Error: 3_056 + .saturating_add(Weight::from_parts(462_536, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -206,12 +207,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[1, 19]`. fn set_fee(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `121 + r * (57 ±0)` - // Estimated: `1636` - // Minimum execution time: 6_664 nanoseconds. - Weight::from_parts(7_286_307, 1636) - // Standard Error: 1_560 - .saturating_add(Weight::from_parts(96_416, 0).saturating_mul(r.into())) + // Measured: `89 + r * (57 ±0)` + // Estimated: `2626` + // Minimum execution time: 8_413_000 picoseconds. + Weight::from_parts(8_846_436, 2626) + // Standard Error: 1_470 + .saturating_add(Weight::from_parts(113_780, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -220,12 +221,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[1, 19]`. fn set_account_id(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `121 + r * (57 ±0)` - // Estimated: `1636` - // Minimum execution time: 7_054 nanoseconds. - Weight::from_parts(7_382_954, 1636) - // Standard Error: 1_621 - .saturating_add(Weight::from_parts(101_595, 0).saturating_mul(r.into())) + // Measured: `89 + r * (57 ±0)` + // Estimated: `2626` + // Minimum execution time: 8_753_000 picoseconds. + Weight::from_parts(9_143_938, 2626) + // Standard Error: 1_490 + .saturating_add(Weight::from_parts(113_406, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -234,12 +235,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[1, 19]`. fn set_fields(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `121 + r * (57 ±0)` - // Estimated: `1636` - // Minimum execution time: 6_659 nanoseconds. - Weight::from_parts(7_188_883, 1636) - // Standard Error: 1_377 - .saturating_add(Weight::from_parts(98_965, 0).saturating_mul(r.into())) + // Measured: `89 + r * (57 ±0)` + // Estimated: `2626` + // Minimum execution time: 8_320_000 picoseconds. + Weight::from_parts(8_800_306, 2626) + // Standard Error: 1_345 + .saturating_add(Weight::from_parts(125_258, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -251,14 +252,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[0, 100]`. fn provide_judgement(r: u32, x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `509 + r * (57 ±0) + x * (66 ±0)` - // Estimated: `11649` - // Minimum execution time: 21_567 nanoseconds. - Weight::from_parts(21_015_310, 11649) - // Standard Error: 2_516 - .saturating_add(Weight::from_parts(123_992, 0).saturating_mul(r.into())) - // Standard Error: 465 - .saturating_add(Weight::from_parts(552_116, 0).saturating_mul(x.into())) + // Measured: `445 + r * (57 ±0) + x * (66 ±0)` + // Estimated: `13629` + // Minimum execution time: 25_313_000 picoseconds. + Weight::from_parts(23_968_548, 13629) + // Standard Error: 4_143 + .saturating_add(Weight::from_parts(164_678, 0).saturating_mul(r.into())) + // Standard Error: 766 + .saturating_add(Weight::from_parts(713_576, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -275,16 +276,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[0, 100]`. fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `772 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` - // Estimated: `18349` - // Minimum execution time: 52_881 nanoseconds. - Weight::from_parts(38_504_388, 18349) - // Standard Error: 3_909 - .saturating_add(Weight::from_parts(51_452, 0).saturating_mul(r.into())) - // Standard Error: 763 - .saturating_add(Weight::from_parts(1_069_924, 0).saturating_mul(s.into())) - // Standard Error: 763 - .saturating_add(Weight::from_parts(164_906, 0).saturating_mul(x.into())) + // Measured: `676 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` + // Estimated: `21319` + // Minimum execution time: 64_638_000 picoseconds. + Weight::from_parts(43_317_654, 21319) + // Standard Error: 10_182 + .saturating_add(Weight::from_parts(61_967, 0).saturating_mul(r.into())) + // Standard Error: 1_988 + .saturating_add(Weight::from_parts(1_224_202, 0).saturating_mul(s.into())) + // Standard Error: 1_988 + .saturating_add(Weight::from_parts(233_897, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -298,12 +299,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 99]`. fn add_sub(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `507 + s * (36 ±0)` - // Estimated: `18335` - // Minimum execution time: 24_556 nanoseconds. - Weight::from_parts(28_641_160, 18335) - // Standard Error: 1_327 - .saturating_add(Weight::from_parts(66_150, 0).saturating_mul(s.into())) + // Measured: `475 + s * (36 ±0)` + // Estimated: `21305` + // Minimum execution time: 28_661_000 picoseconds. + Weight::from_parts(33_432_641, 21305) + // Standard Error: 1_547 + .saturating_add(Weight::from_parts(71_314, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -314,12 +315,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 100]`. fn rename_sub(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `623 + s * (3 ±0)` - // Estimated: `12602` - // Minimum execution time: 11_347 nanoseconds. - Weight::from_parts(13_299_367, 12602) - // Standard Error: 525 - .saturating_add(Weight::from_parts(16_472, 0).saturating_mul(s.into())) + // Measured: `591 + s * (3 ±0)` + // Estimated: `14582` + // Minimum execution time: 13_885_000 picoseconds. + Weight::from_parts(16_105_165, 14582) + // Standard Error: 562 + .saturating_add(Weight::from_parts(17_087, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -332,12 +333,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 100]`. fn remove_sub(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `702 + s * (35 ±0)` - // Estimated: `18335` - // Minimum execution time: 27_810 nanoseconds. - Weight::from_parts(30_347_763, 18335) - // Standard Error: 928 - .saturating_add(Weight::from_parts(55_342, 0).saturating_mul(s.into())) + // Measured: `638 + s * (35 ±0)` + // Estimated: `21305` + // Minimum execution time: 32_192_000 picoseconds. + Weight::from_parts(35_393_444, 21305) + // Standard Error: 2_198 + .saturating_add(Weight::from_parts(62_316, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -348,12 +349,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 99]`. fn quit_sub(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `628 + s * (37 ±0)` - // Estimated: `8322` - // Minimum execution time: 17_601 nanoseconds. - Weight::from_parts(19_794_971, 8322) - // Standard Error: 934 - .saturating_add(Weight::from_parts(59_289, 0).saturating_mul(s.into())) + // Measured: `564 + s * (37 ±0)` + // Estimated: `10302` + // Minimum execution time: 20_803_000 picoseconds. + Weight::from_parts(23_462_393, 10302) + // Standard Error: 1_619 + .saturating_add(Weight::from_parts(59_938, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -366,12 +367,12 @@ impl WeightInfo for () { /// The range of component `r` is `[1, 19]`. fn add_registrar(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `64 + r * (57 ±0)` - // Estimated: `1636` - // Minimum execution time: 10_964 nanoseconds. - Weight::from_parts(11_800_935, 1636) - // Standard Error: 1_334 - .saturating_add(Weight::from_parts(96_038, 0).saturating_mul(r.into())) + // Measured: `32 + r * (57 ±0)` + // Estimated: `2626` + // Minimum execution time: 13_092_000 picoseconds. + Weight::from_parts(13_798_719, 2626) + // Standard Error: 1_553 + .saturating_add(Weight::from_parts(109_215, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -381,14 +382,14 @@ impl WeightInfo for () { /// The range of component `x` is `[0, 100]`. fn set_identity(r: u32, x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `474 + r * (5 ±0)` - // Estimated: `10013` - // Minimum execution time: 26_400 nanoseconds. - Weight::from_parts(26_060_549, 10013) - // Standard Error: 1_561 - .saturating_add(Weight::from_parts(72_083, 0).saturating_mul(r.into())) - // Standard Error: 304 - .saturating_add(Weight::from_parts(306_994, 0).saturating_mul(x.into())) + // Measured: `442 + r * (5 ±0)` + // Estimated: `11003` + // Minimum execution time: 30_800_000 picoseconds. + Weight::from_parts(31_140_040, 11003) + // Standard Error: 4_896 + .saturating_add(Weight::from_parts(69_348, 0).saturating_mul(r.into())) + // Standard Error: 955 + .saturating_add(Weight::from_parts(430_082, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -402,11 +403,11 @@ impl WeightInfo for () { fn set_subs_new(s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `101` - // Estimated: `15746 + s * (2589 ±0)` - // Minimum execution time: 8_492 nanoseconds. - Weight::from_parts(21_645_924, 15746) - // Standard Error: 3_452 - .saturating_add(Weight::from_parts(2_442_604, 0).saturating_mul(s.into())) + // Estimated: `18716 + s * (2589 ±0)` + // Minimum execution time: 10_301_000 picoseconds. + Weight::from_parts(23_255_636, 18716) + // Standard Error: 5_562 + .saturating_add(Weight::from_parts(2_978_765, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(s.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -422,12 +423,12 @@ impl WeightInfo for () { /// The range of component `p` is `[0, 100]`. fn set_subs_old(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `226 + p * (32 ±0)` - // Estimated: `15746` - // Minimum execution time: 8_488 nanoseconds. - Weight::from_parts(20_202_601, 15746) - // Standard Error: 2_834 - .saturating_add(Weight::from_parts(1_082_941, 0).saturating_mul(p.into())) + // Measured: `194 + p * (32 ±0)` + // Estimated: `17726` + // Minimum execution time: 10_095_000 picoseconds. + Weight::from_parts(23_197_533, 17726) + // Standard Error: 3_460 + .saturating_add(Weight::from_parts(1_227_498, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(p.into()))) @@ -441,18 +442,16 @@ impl WeightInfo for () { /// The range of component `r` is `[1, 20]`. /// The range of component `s` is `[0, 100]`. /// The range of component `x` is `[0, 100]`. - fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `533 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` - // Estimated: `15746` - // Minimum execution time: 41_319 nanoseconds. - Weight::from_parts(25_850_055, 15746) - // Standard Error: 4_144 - .saturating_add(Weight::from_parts(59_619, 0).saturating_mul(r.into())) - // Standard Error: 809 - .saturating_add(Weight::from_parts(1_076_550, 0).saturating_mul(s.into())) - // Standard Error: 809 - .saturating_add(Weight::from_parts(163_191, 0).saturating_mul(x.into())) + fn clear_identity(_r: u32, s: u32, x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `469 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` + // Estimated: `17726` + // Minimum execution time: 51_054_000 picoseconds. + Weight::from_parts(30_184_047, 17726) + // Standard Error: 2_441 + .saturating_add(Weight::from_parts(1_221_983, 0).saturating_mul(s.into())) + // Standard Error: 2_441 + .saturating_add(Weight::from_parts(234_084, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -465,14 +464,14 @@ impl WeightInfo for () { /// The range of component `x` is `[0, 100]`. fn request_judgement(r: u32, x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `431 + r * (57 ±0) + x * (66 ±0)` - // Estimated: `11649` - // Minimum execution time: 28_118 nanoseconds. - Weight::from_parts(27_359_471, 11649) - // Standard Error: 2_707 - .saturating_add(Weight::from_parts(107_279, 0).saturating_mul(r.into())) - // Standard Error: 528 - .saturating_add(Weight::from_parts(325_165, 0).saturating_mul(x.into())) + // Measured: `367 + r * (57 ±0) + x * (66 ±0)` + // Estimated: `13629` + // Minimum execution time: 32_747_000 picoseconds. + Weight::from_parts(29_557_659, 13629) + // Standard Error: 4_616 + .saturating_add(Weight::from_parts(200_494, 0).saturating_mul(r.into())) + // Standard Error: 900 + .saturating_add(Weight::from_parts(468_381, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -482,14 +481,14 @@ impl WeightInfo for () { /// The range of component `x` is `[0, 100]`. fn cancel_request(r: u32, x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `430 + x * (66 ±0)` - // Estimated: `10013` - // Minimum execution time: 24_817 nanoseconds. - Weight::from_parts(24_749_808, 10013) - // Standard Error: 1_938 - .saturating_add(Weight::from_parts(63_396, 0).saturating_mul(r.into())) - // Standard Error: 378 - .saturating_add(Weight::from_parts(327_083, 0).saturating_mul(x.into())) + // Measured: `398 + x * (66 ±0)` + // Estimated: `11003` + // Minimum execution time: 28_853_000 picoseconds. + Weight::from_parts(26_811_119, 11003) + // Standard Error: 15_667 + .saturating_add(Weight::from_parts(240_647, 0).saturating_mul(r.into())) + // Standard Error: 3_056 + .saturating_add(Weight::from_parts(462_536, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -498,12 +497,12 @@ impl WeightInfo for () { /// The range of component `r` is `[1, 19]`. fn set_fee(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `121 + r * (57 ±0)` - // Estimated: `1636` - // Minimum execution time: 6_664 nanoseconds. - Weight::from_parts(7_286_307, 1636) - // Standard Error: 1_560 - .saturating_add(Weight::from_parts(96_416, 0).saturating_mul(r.into())) + // Measured: `89 + r * (57 ±0)` + // Estimated: `2626` + // Minimum execution time: 8_413_000 picoseconds. + Weight::from_parts(8_846_436, 2626) + // Standard Error: 1_470 + .saturating_add(Weight::from_parts(113_780, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -512,12 +511,12 @@ impl WeightInfo for () { /// The range of component `r` is `[1, 19]`. fn set_account_id(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `121 + r * (57 ±0)` - // Estimated: `1636` - // Minimum execution time: 7_054 nanoseconds. - Weight::from_parts(7_382_954, 1636) - // Standard Error: 1_621 - .saturating_add(Weight::from_parts(101_595, 0).saturating_mul(r.into())) + // Measured: `89 + r * (57 ±0)` + // Estimated: `2626` + // Minimum execution time: 8_753_000 picoseconds. + Weight::from_parts(9_143_938, 2626) + // Standard Error: 1_490 + .saturating_add(Weight::from_parts(113_406, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -526,12 +525,12 @@ impl WeightInfo for () { /// The range of component `r` is `[1, 19]`. fn set_fields(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `121 + r * (57 ±0)` - // Estimated: `1636` - // Minimum execution time: 6_659 nanoseconds. - Weight::from_parts(7_188_883, 1636) - // Standard Error: 1_377 - .saturating_add(Weight::from_parts(98_965, 0).saturating_mul(r.into())) + // Measured: `89 + r * (57 ±0)` + // Estimated: `2626` + // Minimum execution time: 8_320_000 picoseconds. + Weight::from_parts(8_800_306, 2626) + // Standard Error: 1_345 + .saturating_add(Weight::from_parts(125_258, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -543,14 +542,14 @@ impl WeightInfo for () { /// The range of component `x` is `[0, 100]`. fn provide_judgement(r: u32, x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `509 + r * (57 ±0) + x * (66 ±0)` - // Estimated: `11649` - // Minimum execution time: 21_567 nanoseconds. - Weight::from_parts(21_015_310, 11649) - // Standard Error: 2_516 - .saturating_add(Weight::from_parts(123_992, 0).saturating_mul(r.into())) - // Standard Error: 465 - .saturating_add(Weight::from_parts(552_116, 0).saturating_mul(x.into())) + // Measured: `445 + r * (57 ±0) + x * (66 ±0)` + // Estimated: `13629` + // Minimum execution time: 25_313_000 picoseconds. + Weight::from_parts(23_968_548, 13629) + // Standard Error: 4_143 + .saturating_add(Weight::from_parts(164_678, 0).saturating_mul(r.into())) + // Standard Error: 766 + .saturating_add(Weight::from_parts(713_576, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -567,16 +566,16 @@ impl WeightInfo for () { /// The range of component `x` is `[0, 100]`. fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `772 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` - // Estimated: `18349` - // Minimum execution time: 52_881 nanoseconds. - Weight::from_parts(38_504_388, 18349) - // Standard Error: 3_909 - .saturating_add(Weight::from_parts(51_452, 0).saturating_mul(r.into())) - // Standard Error: 763 - .saturating_add(Weight::from_parts(1_069_924, 0).saturating_mul(s.into())) - // Standard Error: 763 - .saturating_add(Weight::from_parts(164_906, 0).saturating_mul(x.into())) + // Measured: `676 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` + // Estimated: `21319` + // Minimum execution time: 64_638_000 picoseconds. + Weight::from_parts(43_317_654, 21319) + // Standard Error: 10_182 + .saturating_add(Weight::from_parts(61_967, 0).saturating_mul(r.into())) + // Standard Error: 1_988 + .saturating_add(Weight::from_parts(1_224_202, 0).saturating_mul(s.into())) + // Standard Error: 1_988 + .saturating_add(Weight::from_parts(233_897, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -590,12 +589,12 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 99]`. fn add_sub(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `507 + s * (36 ±0)` - // Estimated: `18335` - // Minimum execution time: 24_556 nanoseconds. - Weight::from_parts(28_641_160, 18335) - // Standard Error: 1_327 - .saturating_add(Weight::from_parts(66_150, 0).saturating_mul(s.into())) + // Measured: `475 + s * (36 ±0)` + // Estimated: `21305` + // Minimum execution time: 28_661_000 picoseconds. + Weight::from_parts(33_432_641, 21305) + // Standard Error: 1_547 + .saturating_add(Weight::from_parts(71_314, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -606,12 +605,12 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 100]`. fn rename_sub(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `623 + s * (3 ±0)` - // Estimated: `12602` - // Minimum execution time: 11_347 nanoseconds. - Weight::from_parts(13_299_367, 12602) - // Standard Error: 525 - .saturating_add(Weight::from_parts(16_472, 0).saturating_mul(s.into())) + // Measured: `591 + s * (3 ±0)` + // Estimated: `14582` + // Minimum execution time: 13_885_000 picoseconds. + Weight::from_parts(16_105_165, 14582) + // Standard Error: 562 + .saturating_add(Weight::from_parts(17_087, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -624,12 +623,12 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 100]`. fn remove_sub(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `702 + s * (35 ±0)` - // Estimated: `18335` - // Minimum execution time: 27_810 nanoseconds. - Weight::from_parts(30_347_763, 18335) - // Standard Error: 928 - .saturating_add(Weight::from_parts(55_342, 0).saturating_mul(s.into())) + // Measured: `638 + s * (35 ±0)` + // Estimated: `21305` + // Minimum execution time: 32_192_000 picoseconds. + Weight::from_parts(35_393_444, 21305) + // Standard Error: 2_198 + .saturating_add(Weight::from_parts(62_316, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -640,12 +639,12 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 99]`. fn quit_sub(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `628 + s * (37 ±0)` - // Estimated: `8322` - // Minimum execution time: 17_601 nanoseconds. - Weight::from_parts(19_794_971, 8322) - // Standard Error: 934 - .saturating_add(Weight::from_parts(59_289, 0).saturating_mul(s.into())) + // Measured: `564 + s * (37 ±0)` + // Estimated: `10302` + // Minimum execution time: 20_803_000 picoseconds. + Weight::from_parts(23_462_393, 10302) + // Standard Error: 1_619 + .saturating_add(Weight::from_parts(59_938, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } diff --git a/frame/im-online/src/weights.rs b/frame/im-online/src/weights.rs index 675feb075473f..f97df1c367562 100644 --- a/frame/im-online/src/weights.rs +++ b/frame/im-online/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_im_online //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_im_online +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -68,17 +71,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `e` is `[1, 100]`. fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `359 + k * (32 ±0)` - // Estimated: `10345712 + e * (25 ±0) + k * (64 ±0)` - // Minimum execution time: 91_116 nanoseconds. - Weight::from_parts(72_526_877, 10345712) - // Standard Error: 95 - .saturating_add(Weight::from_parts(20_461, 0).saturating_mul(k.into())) - // Standard Error: 967 - .saturating_add(Weight::from_parts(307_869, 0).saturating_mul(e.into())) + // Measured: `295 + k * (32 ±0)` + // Estimated: `10349544 + e * (35 ±0) + k * (64 ±0)` + // Minimum execution time: 106_224_000 picoseconds. + Weight::from_parts(79_172_319, 10349544) + // Standard Error: 259 + .saturating_add(Weight::from_parts(29_576, 0).saturating_mul(k.into())) + // Standard Error: 2_611 + .saturating_add(Weight::from_parts(422_369, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 25).saturating_mul(e.into())) + .saturating_add(Weight::from_parts(0, 35).saturating_mul(e.into())) .saturating_add(Weight::from_parts(0, 64).saturating_mul(k.into())) } } @@ -99,17 +102,17 @@ impl WeightInfo for () { /// The range of component `e` is `[1, 100]`. fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `359 + k * (32 ±0)` - // Estimated: `10345712 + e * (25 ±0) + k * (64 ±0)` - // Minimum execution time: 91_116 nanoseconds. - Weight::from_parts(72_526_877, 10345712) - // Standard Error: 95 - .saturating_add(Weight::from_parts(20_461, 0).saturating_mul(k.into())) - // Standard Error: 967 - .saturating_add(Weight::from_parts(307_869, 0).saturating_mul(e.into())) + // Measured: `295 + k * (32 ±0)` + // Estimated: `10349544 + e * (35 ±0) + k * (64 ±0)` + // Minimum execution time: 106_224_000 picoseconds. + Weight::from_parts(79_172_319, 10349544) + // Standard Error: 259 + .saturating_add(Weight::from_parts(29_576, 0).saturating_mul(k.into())) + // Standard Error: 2_611 + .saturating_add(Weight::from_parts(422_369, 0).saturating_mul(e.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 25).saturating_mul(e.into())) + .saturating_add(Weight::from_parts(0, 35).saturating_mul(e.into())) .saturating_add(Weight::from_parts(0, 64).saturating_mul(k.into())) } } diff --git a/frame/indices/src/weights.rs b/frame/indices/src/weights.rs index fcb71177a5951..87160ccfbb208 100644 --- a/frame/indices/src/weights.rs +++ b/frame/indices/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_indices //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_indices +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -63,9 +66,9 @@ impl WeightInfo for SubstrateWeight { fn claim() -> Weight { // Proof Size summary in bytes: // Measured: `76` - // Estimated: `2544` - // Minimum execution time: 19_738 nanoseconds. - Weight::from_parts(20_029_000, 2544) + // Estimated: `3534` + // Minimum execution time: 22_365_000 picoseconds. + Weight::from_parts(22_713_000, 3534) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -75,10 +78,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `339` - // Estimated: `5147` - // Minimum execution time: 24_494 nanoseconds. - Weight::from_parts(24_794_000, 5147) + // Measured: `275` + // Estimated: `7127` + // Minimum execution time: 28_380_000 picoseconds. + Weight::from_parts(29_251_000, 7127) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -86,10 +89,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn free() -> Weight { // Proof Size summary in bytes: - // Measured: `204` - // Estimated: `2544` - // Minimum execution time: 20_041 nanoseconds. - Weight::from_parts(20_473_000, 2544) + // Measured: `172` + // Estimated: `3534` + // Minimum execution time: 22_932_000 picoseconds. + Weight::from_parts(23_442_000, 3534) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -99,10 +102,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `339` - // Estimated: `5147` - // Minimum execution time: 21_874 nanoseconds. - Weight::from_parts(22_438_000, 5147) + // Measured: `275` + // Estimated: `7127` + // Minimum execution time: 25_223_000 picoseconds. + Weight::from_parts(25_519_000, 7127) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -110,10 +113,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn freeze() -> Weight { // Proof Size summary in bytes: - // Measured: `204` - // Estimated: `2544` - // Minimum execution time: 22_407 nanoseconds. - Weight::from_parts(22_768_000, 2544) + // Measured: `172` + // Estimated: `3534` + // Minimum execution time: 25_223_000 picoseconds. + Weight::from_parts(26_127_000, 3534) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -126,9 +129,9 @@ impl WeightInfo for () { fn claim() -> Weight { // Proof Size summary in bytes: // Measured: `76` - // Estimated: `2544` - // Minimum execution time: 19_738 nanoseconds. - Weight::from_parts(20_029_000, 2544) + // Estimated: `3534` + // Minimum execution time: 22_365_000 picoseconds. + Weight::from_parts(22_713_000, 3534) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -138,10 +141,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `339` - // Estimated: `5147` - // Minimum execution time: 24_494 nanoseconds. - Weight::from_parts(24_794_000, 5147) + // Measured: `275` + // Estimated: `7127` + // Minimum execution time: 28_380_000 picoseconds. + Weight::from_parts(29_251_000, 7127) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -149,10 +152,10 @@ impl WeightInfo for () { /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn free() -> Weight { // Proof Size summary in bytes: - // Measured: `204` - // Estimated: `2544` - // Minimum execution time: 20_041 nanoseconds. - Weight::from_parts(20_473_000, 2544) + // Measured: `172` + // Estimated: `3534` + // Minimum execution time: 22_932_000 picoseconds. + Weight::from_parts(23_442_000, 3534) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -162,10 +165,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `339` - // Estimated: `5147` - // Minimum execution time: 21_874 nanoseconds. - Weight::from_parts(22_438_000, 5147) + // Measured: `275` + // Estimated: `7127` + // Minimum execution time: 25_223_000 picoseconds. + Weight::from_parts(25_519_000, 7127) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -173,10 +176,10 @@ impl WeightInfo for () { /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn freeze() -> Weight { // Proof Size summary in bytes: - // Measured: `204` - // Estimated: `2544` - // Minimum execution time: 22_407 nanoseconds. - Weight::from_parts(22_768_000, 2544) + // Measured: `172` + // Estimated: `3534` + // Minimum execution time: 25_223_000 picoseconds. + Weight::from_parts(26_127_000, 3534) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/lottery/src/weights.rs b/frame/lottery/src/weights.rs index 0038db6210d2b..c8c373ad6f88d 100644 --- a/frame/lottery/src/weights.rs +++ b/frame/lottery/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_lottery //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_lottery +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -75,10 +78,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Lottery Tickets (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) fn buy_ticket() -> Weight { // Proof Size summary in bytes: - // Measured: `484` - // Estimated: `7181` - // Minimum execution time: 62_125 nanoseconds. - Weight::from_parts(63_145_000, 7181) + // Measured: `452` + // Estimated: `13121` + // Minimum execution time: 43_076_000 picoseconds. + Weight::from_parts(43_902_000, 13121) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -89,10 +92,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_650 nanoseconds. - Weight::from_parts(8_344_960, 0) - // Standard Error: 2_629 - .saturating_add(Weight::from_parts(268_557, 0).saturating_mul(n.into())) + // Minimum execution time: 8_222_000 picoseconds. + Weight::from_parts(9_166_238, 0) + // Standard Error: 3_489 + .saturating_add(Weight::from_parts(328_564, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Lottery Lottery (r:1 w:1) @@ -104,9 +107,9 @@ impl WeightInfo for SubstrateWeight { fn start_lottery() -> Weight { // Proof Size summary in bytes: // Measured: `161` - // Estimated: `3626` - // Minimum execution time: 31_324 nanoseconds. - Weight::from_parts(31_985_000, 3626) + // Estimated: `6596` + // Minimum execution time: 36_555_000 picoseconds. + Weight::from_parts(37_008_000, 6596) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -115,9 +118,9 @@ impl WeightInfo for SubstrateWeight { fn stop_repeat() -> Weight { // Proof Size summary in bytes: // Measured: `219` - // Estimated: `524` - // Minimum execution time: 7_124 nanoseconds. - Weight::from_parts(7_285_000, 524) + // Estimated: `1514` + // Minimum execution time: 8_230_000 picoseconds. + Weight::from_parts(8_355_000, 1514) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -133,10 +136,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Lottery Tickets (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) fn on_initialize_end() -> Weight { // Proof Size summary in bytes: - // Measured: `556` - // Estimated: `11837` - // Minimum execution time: 50_745 nanoseconds. - Weight::from_parts(52_232_000, 11837) + // Measured: `524` + // Estimated: `16787` + // Minimum execution time: 60_097_000 picoseconds. + Weight::from_parts(62_055_000, 16787) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -154,10 +157,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Lottery LotteryIndex (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn on_initialize_repeat() -> Weight { // Proof Size summary in bytes: - // Measured: `556` - // Estimated: `12336` - // Minimum execution time: 52_437 nanoseconds. - Weight::from_parts(53_063_000, 12336) + // Measured: `524` + // Estimated: `18276` + // Minimum execution time: 61_354_000 picoseconds. + Weight::from_parts(62_429_000, 18276) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -181,10 +184,10 @@ impl WeightInfo for () { /// Proof: Lottery Tickets (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) fn buy_ticket() -> Weight { // Proof Size summary in bytes: - // Measured: `484` - // Estimated: `7181` - // Minimum execution time: 62_125 nanoseconds. - Weight::from_parts(63_145_000, 7181) + // Measured: `452` + // Estimated: `13121` + // Minimum execution time: 43_076_000 picoseconds. + Weight::from_parts(43_902_000, 13121) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -195,10 +198,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_650 nanoseconds. - Weight::from_parts(8_344_960, 0) - // Standard Error: 2_629 - .saturating_add(Weight::from_parts(268_557, 0).saturating_mul(n.into())) + // Minimum execution time: 8_222_000 picoseconds. + Weight::from_parts(9_166_238, 0) + // Standard Error: 3_489 + .saturating_add(Weight::from_parts(328_564, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Lottery Lottery (r:1 w:1) @@ -210,9 +213,9 @@ impl WeightInfo for () { fn start_lottery() -> Weight { // Proof Size summary in bytes: // Measured: `161` - // Estimated: `3626` - // Minimum execution time: 31_324 nanoseconds. - Weight::from_parts(31_985_000, 3626) + // Estimated: `6596` + // Minimum execution time: 36_555_000 picoseconds. + Weight::from_parts(37_008_000, 6596) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -221,9 +224,9 @@ impl WeightInfo for () { fn stop_repeat() -> Weight { // Proof Size summary in bytes: // Measured: `219` - // Estimated: `524` - // Minimum execution time: 7_124 nanoseconds. - Weight::from_parts(7_285_000, 524) + // Estimated: `1514` + // Minimum execution time: 8_230_000 picoseconds. + Weight::from_parts(8_355_000, 1514) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -239,10 +242,10 @@ impl WeightInfo for () { /// Proof: Lottery Tickets (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) fn on_initialize_end() -> Weight { // Proof Size summary in bytes: - // Measured: `556` - // Estimated: `11837` - // Minimum execution time: 50_745 nanoseconds. - Weight::from_parts(52_232_000, 11837) + // Measured: `524` + // Estimated: `16787` + // Minimum execution time: 60_097_000 picoseconds. + Weight::from_parts(62_055_000, 16787) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -260,10 +263,10 @@ impl WeightInfo for () { /// Proof: Lottery LotteryIndex (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn on_initialize_repeat() -> Weight { // Proof Size summary in bytes: - // Measured: `556` - // Estimated: `12336` - // Minimum execution time: 52_437 nanoseconds. - Weight::from_parts(53_063_000, 12336) + // Measured: `524` + // Estimated: `18276` + // Minimum execution time: 61_354_000 picoseconds. + Weight::from_parts(62_429_000, 18276) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } diff --git a/frame/membership/src/weights.rs b/frame/membership/src/weights.rs index f080f842c54b4..31c359b4469eb 100644 --- a/frame/membership/src/weights.rs +++ b/frame/membership/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_membership //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_membership +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -71,12 +74,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[1, 99]`. fn add_member(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `238 + m * (64 ±0)` - // Estimated: `4903 + m * (192 ±0)` - // Minimum execution time: 15_673 nanoseconds. - Weight::from_parts(16_830_288, 4903) - // Standard Error: 570 - .saturating_add(Weight::from_parts(41_959, 0).saturating_mul(m.into())) + // Measured: `174 + m * (64 ±0)` + // Estimated: `6691 + m * (192 ±0)` + // Minimum execution time: 17_587_000 picoseconds. + Weight::from_parts(18_658_163, 6691) + // Standard Error: 710 + .saturating_add(Weight::from_parts(46_294, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) @@ -94,12 +97,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[2, 100]`. fn remove_member(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `342 + m * (64 ±0)` - // Estimated: `5742 + m * (192 ±0)` - // Minimum execution time: 18_231 nanoseconds. - Weight::from_parts(19_081_297, 5742) - // Standard Error: 571 - .saturating_add(Weight::from_parts(41_331, 0).saturating_mul(m.into())) + // Measured: `278 + m * (64 ±0)` + // Estimated: `8520 + m * (192 ±0)` + // Minimum execution time: 20_402_000 picoseconds. + Weight::from_parts(21_165_819, 8520) + // Standard Error: 643 + .saturating_add(Weight::from_parts(45_481, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) @@ -117,12 +120,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[2, 100]`. fn swap_member(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `342 + m * (64 ±0)` - // Estimated: `5742 + m * (192 ±0)` - // Minimum execution time: 18_517 nanoseconds. - Weight::from_parts(19_388_310, 5742) - // Standard Error: 625 - .saturating_add(Weight::from_parts(51_422, 0).saturating_mul(m.into())) + // Measured: `278 + m * (64 ±0)` + // Estimated: `8520 + m * (192 ±0)` + // Minimum execution time: 20_380_000 picoseconds. + Weight::from_parts(21_633_260, 8520) + // Standard Error: 770 + .saturating_add(Weight::from_parts(55_504, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) @@ -140,12 +143,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[1, 100]`. fn reset_member(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `342 + m * (64 ±0)` - // Estimated: `5742 + m * (192 ±0)` - // Minimum execution time: 17_628 nanoseconds. - Weight::from_parts(19_258_882, 5742) - // Standard Error: 820 - .saturating_add(Weight::from_parts(153_956, 0).saturating_mul(m.into())) + // Measured: `278 + m * (64 ±0)` + // Estimated: `8520 + m * (192 ±0)` + // Minimum execution time: 19_989_000 picoseconds. + Weight::from_parts(22_352_059, 8520) + // Standard Error: 2_878 + .saturating_add(Weight::from_parts(156_367, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) @@ -163,12 +166,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[1, 100]`. fn change_key(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `342 + m * (64 ±0)` - // Estimated: `5742 + m * (192 ±0)` - // Minimum execution time: 19_031 nanoseconds. - Weight::from_parts(20_264_948, 5742) - // Standard Error: 707 - .saturating_add(Weight::from_parts(51_060, 0).saturating_mul(m.into())) + // Measured: `278 + m * (64 ±0)` + // Estimated: `8520 + m * (192 ±0)` + // Minimum execution time: 21_275_000 picoseconds. + Weight::from_parts(23_344_594, 8520) + // Standard Error: 2_750 + .saturating_add(Weight::from_parts(46_736, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) @@ -182,12 +185,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[1, 100]`. fn set_prime(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `64 + m * (32 ±0)` - // Estimated: `3761 + m * (32 ±0)` - // Minimum execution time: 6_897 nanoseconds. - Weight::from_parts(7_455_387, 3761) - // Standard Error: 326 - .saturating_add(Weight::from_parts(16_653, 0).saturating_mul(m.into())) + // Measured: `32 + m * (32 ±0)` + // Estimated: `4719 + m * (32 ±0)` + // Minimum execution time: 8_087_000 picoseconds. + Weight::from_parts(8_909_627, 4719) + // Standard Error: 1_572 + .saturating_add(Weight::from_parts(17_186, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) @@ -201,10 +204,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_400 nanoseconds. - Weight::from_parts(3_703_421, 0) - // Standard Error: 119 - .saturating_add(Weight::from_parts(915, 0).saturating_mul(m.into())) + // Minimum execution time: 3_752_000 picoseconds. + Weight::from_parts(4_081_144, 0) + // Standard Error: 229 + .saturating_add(Weight::from_parts(1_298, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().writes(2_u64)) } } @@ -222,12 +225,12 @@ impl WeightInfo for () { /// The range of component `m` is `[1, 99]`. fn add_member(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `238 + m * (64 ±0)` - // Estimated: `4903 + m * (192 ±0)` - // Minimum execution time: 15_673 nanoseconds. - Weight::from_parts(16_830_288, 4903) - // Standard Error: 570 - .saturating_add(Weight::from_parts(41_959, 0).saturating_mul(m.into())) + // Measured: `174 + m * (64 ±0)` + // Estimated: `6691 + m * (192 ±0)` + // Minimum execution time: 17_587_000 picoseconds. + Weight::from_parts(18_658_163, 6691) + // Standard Error: 710 + .saturating_add(Weight::from_parts(46_294, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) @@ -245,12 +248,12 @@ impl WeightInfo for () { /// The range of component `m` is `[2, 100]`. fn remove_member(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `342 + m * (64 ±0)` - // Estimated: `5742 + m * (192 ±0)` - // Minimum execution time: 18_231 nanoseconds. - Weight::from_parts(19_081_297, 5742) - // Standard Error: 571 - .saturating_add(Weight::from_parts(41_331, 0).saturating_mul(m.into())) + // Measured: `278 + m * (64 ±0)` + // Estimated: `8520 + m * (192 ±0)` + // Minimum execution time: 20_402_000 picoseconds. + Weight::from_parts(21_165_819, 8520) + // Standard Error: 643 + .saturating_add(Weight::from_parts(45_481, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) @@ -268,12 +271,12 @@ impl WeightInfo for () { /// The range of component `m` is `[2, 100]`. fn swap_member(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `342 + m * (64 ±0)` - // Estimated: `5742 + m * (192 ±0)` - // Minimum execution time: 18_517 nanoseconds. - Weight::from_parts(19_388_310, 5742) - // Standard Error: 625 - .saturating_add(Weight::from_parts(51_422, 0).saturating_mul(m.into())) + // Measured: `278 + m * (64 ±0)` + // Estimated: `8520 + m * (192 ±0)` + // Minimum execution time: 20_380_000 picoseconds. + Weight::from_parts(21_633_260, 8520) + // Standard Error: 770 + .saturating_add(Weight::from_parts(55_504, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) @@ -291,12 +294,12 @@ impl WeightInfo for () { /// The range of component `m` is `[1, 100]`. fn reset_member(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `342 + m * (64 ±0)` - // Estimated: `5742 + m * (192 ±0)` - // Minimum execution time: 17_628 nanoseconds. - Weight::from_parts(19_258_882, 5742) - // Standard Error: 820 - .saturating_add(Weight::from_parts(153_956, 0).saturating_mul(m.into())) + // Measured: `278 + m * (64 ±0)` + // Estimated: `8520 + m * (192 ±0)` + // Minimum execution time: 19_989_000 picoseconds. + Weight::from_parts(22_352_059, 8520) + // Standard Error: 2_878 + .saturating_add(Weight::from_parts(156_367, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) @@ -314,12 +317,12 @@ impl WeightInfo for () { /// The range of component `m` is `[1, 100]`. fn change_key(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `342 + m * (64 ±0)` - // Estimated: `5742 + m * (192 ±0)` - // Minimum execution time: 19_031 nanoseconds. - Weight::from_parts(20_264_948, 5742) - // Standard Error: 707 - .saturating_add(Weight::from_parts(51_060, 0).saturating_mul(m.into())) + // Measured: `278 + m * (64 ±0)` + // Estimated: `8520 + m * (192 ±0)` + // Minimum execution time: 21_275_000 picoseconds. + Weight::from_parts(23_344_594, 8520) + // Standard Error: 2_750 + .saturating_add(Weight::from_parts(46_736, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) @@ -333,12 +336,12 @@ impl WeightInfo for () { /// The range of component `m` is `[1, 100]`. fn set_prime(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `64 + m * (32 ±0)` - // Estimated: `3761 + m * (32 ±0)` - // Minimum execution time: 6_897 nanoseconds. - Weight::from_parts(7_455_387, 3761) - // Standard Error: 326 - .saturating_add(Weight::from_parts(16_653, 0).saturating_mul(m.into())) + // Measured: `32 + m * (32 ±0)` + // Estimated: `4719 + m * (32 ±0)` + // Minimum execution time: 8_087_000 picoseconds. + Weight::from_parts(8_909_627, 4719) + // Standard Error: 1_572 + .saturating_add(Weight::from_parts(17_186, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) @@ -352,10 +355,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_400 nanoseconds. - Weight::from_parts(3_703_421, 0) - // Standard Error: 119 - .saturating_add(Weight::from_parts(915, 0).saturating_mul(m.into())) + // Minimum execution time: 3_752_000 picoseconds. + Weight::from_parts(4_081_144, 0) + // Standard Error: 229 + .saturating_add(Weight::from_parts(1_298, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().writes(2_u64)) } } diff --git a/frame/message-queue/src/weights.rs b/frame/message-queue/src/weights.rs index fd788f2ba4052..fc44456db28bd 100644 --- a/frame/message-queue/src/weights.rs +++ b/frame/message-queue/src/weights.rs @@ -18,26 +18,28 @@ //! Autogenerated weights for pallet_message_queue //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_message_queue +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet-message-queue -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/message-queue/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -70,10 +72,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) fn ready_ring_knit() -> Weight { // Proof Size summary in bytes: - // Measured: `295` + // Measured: `233` // Estimated: `7527` - // Minimum execution time: 12_283_000 picoseconds. - Weight::from_parts(12_554_000, 7527) + // Minimum execution time: 12_561_000 picoseconds. + Weight::from_parts(12_758_000, 7527) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -83,10 +85,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn ready_ring_unknit() -> Weight { // Proof Size summary in bytes: - // Measured: `295` + // Measured: `233` // Estimated: `7527` - // Minimum execution time: 11_484_000 picoseconds. - Weight::from_parts(11_900_000, 7527) + // Minimum execution time: 11_854_000 picoseconds. + Weight::from_parts(12_178_000, 7527) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -96,8 +98,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3514` - // Minimum execution time: 4_793_000 picoseconds. - Weight::from_parts(4_990_000, 3514) + // Minimum execution time: 7_900_000 picoseconds. + Weight::from_parts(8_046_000, 3514) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -107,8 +109,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `113` // Estimated: `69049` - // Minimum execution time: 6_231_000 picoseconds. - Weight::from_parts(6_442_000, 69049) + // Minimum execution time: 6_284_000 picoseconds. + Weight::from_parts(6_433_000, 69049) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -118,8 +120,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `113` // Estimated: `69049` - // Minimum execution time: 6_660_000 picoseconds. - Weight::from_parts(6_825_000, 69049) + // Minimum execution time: 6_418_000 picoseconds. + Weight::from_parts(6_633_000, 69049) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -127,8 +129,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 72_805_000 picoseconds. - Weight::from_parts(74_650_000, 0) + // Minimum execution time: 52_661_000 picoseconds. + Weight::from_parts(52_994_000, 0) } /// Storage: MessageQueue ServiceHead (r:1 w:1) /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -136,10 +138,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) fn bump_service_head() -> Weight { // Proof Size summary in bytes: - // Measured: `172` + // Measured: `140` // Estimated: `5003` - // Minimum execution time: 7_078_000 picoseconds. - Weight::from_parts(7_230_000, 5003) + // Minimum execution time: 7_132_000 picoseconds. + Weight::from_parts(7_386_000, 5003) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -149,10 +151,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn reap_page() -> Weight { // Proof Size summary in bytes: - // Measured: `65742` + // Measured: `65710` // Estimated: `72563` - // Minimum execution time: 56_799_000 picoseconds. - Weight::from_parts(57_634_000, 72563) + // Minimum execution time: 54_377_000 picoseconds. + Weight::from_parts(54_804_000, 72563) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -162,10 +164,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn execute_overweight_page_removed() -> Weight { // Proof Size summary in bytes: - // Measured: `65742` + // Measured: `65710` // Estimated: `72563` - // Minimum execution time: 72_290_000 picoseconds. - Weight::from_parts(72_754_000, 72563) + // Minimum execution time: 69_461_000 picoseconds. + Weight::from_parts(70_016_000, 72563) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -175,10 +177,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn execute_overweight_page_updated() -> Weight { // Proof Size summary in bytes: - // Measured: `65742` + // Measured: `65710` // Estimated: `72563` - // Minimum execution time: 84_987_000 picoseconds. - Weight::from_parts(85_562_000, 72563) + // Minimum execution time: 81_787_000 picoseconds. + Weight::from_parts(83_100_000, 72563) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -192,10 +194,10 @@ impl WeightInfo for () { /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) fn ready_ring_knit() -> Weight { // Proof Size summary in bytes: - // Measured: `295` + // Measured: `233` // Estimated: `7527` - // Minimum execution time: 12_283_000 picoseconds. - Weight::from_parts(12_554_000, 7527) + // Minimum execution time: 12_561_000 picoseconds. + Weight::from_parts(12_758_000, 7527) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -205,10 +207,10 @@ impl WeightInfo for () { /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn ready_ring_unknit() -> Weight { // Proof Size summary in bytes: - // Measured: `295` + // Measured: `233` // Estimated: `7527` - // Minimum execution time: 11_484_000 picoseconds. - Weight::from_parts(11_900_000, 7527) + // Minimum execution time: 11_854_000 picoseconds. + Weight::from_parts(12_178_000, 7527) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -218,8 +220,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3514` - // Minimum execution time: 4_793_000 picoseconds. - Weight::from_parts(4_990_000, 3514) + // Minimum execution time: 7_900_000 picoseconds. + Weight::from_parts(8_046_000, 3514) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -229,8 +231,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `113` // Estimated: `69049` - // Minimum execution time: 6_231_000 picoseconds. - Weight::from_parts(6_442_000, 69049) + // Minimum execution time: 6_284_000 picoseconds. + Weight::from_parts(6_433_000, 69049) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -240,8 +242,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `113` // Estimated: `69049` - // Minimum execution time: 6_660_000 picoseconds. - Weight::from_parts(6_825_000, 69049) + // Minimum execution time: 6_418_000 picoseconds. + Weight::from_parts(6_633_000, 69049) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -249,8 +251,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 72_805_000 picoseconds. - Weight::from_parts(74_650_000, 0) + // Minimum execution time: 52_661_000 picoseconds. + Weight::from_parts(52_994_000, 0) } /// Storage: MessageQueue ServiceHead (r:1 w:1) /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -258,10 +260,10 @@ impl WeightInfo for () { /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) fn bump_service_head() -> Weight { // Proof Size summary in bytes: - // Measured: `172` + // Measured: `140` // Estimated: `5003` - // Minimum execution time: 7_078_000 picoseconds. - Weight::from_parts(7_230_000, 5003) + // Minimum execution time: 7_132_000 picoseconds. + Weight::from_parts(7_386_000, 5003) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -271,10 +273,10 @@ impl WeightInfo for () { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn reap_page() -> Weight { // Proof Size summary in bytes: - // Measured: `65742` + // Measured: `65710` // Estimated: `72563` - // Minimum execution time: 56_799_000 picoseconds. - Weight::from_parts(57_634_000, 72563) + // Minimum execution time: 54_377_000 picoseconds. + Weight::from_parts(54_804_000, 72563) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -284,10 +286,10 @@ impl WeightInfo for () { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn execute_overweight_page_removed() -> Weight { // Proof Size summary in bytes: - // Measured: `65742` + // Measured: `65710` // Estimated: `72563` - // Minimum execution time: 72_290_000 picoseconds. - Weight::from_parts(72_754_000, 72563) + // Minimum execution time: 69_461_000 picoseconds. + Weight::from_parts(70_016_000, 72563) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -297,10 +299,10 @@ impl WeightInfo for () { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn execute_overweight_page_updated() -> Weight { // Proof Size summary in bytes: - // Measured: `65742` + // Measured: `65710` // Estimated: `72563` - // Minimum execution time: 84_987_000 picoseconds. - Weight::from_parts(85_562_000, 72563) + // Minimum execution time: 81_787_000 picoseconds. + Weight::from_parts(83_100_000, 72563) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } diff --git a/frame/multisig/src/weights.rs b/frame/multisig/src/weights.rs index fb155c97f2def..8941ce44f9a2b 100644 --- a/frame/multisig/src/weights.rs +++ b/frame/multisig/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_multisig //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_multisig +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -65,8 +68,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_086 nanoseconds. - Weight::from_parts(12_464_828, 0) + // Minimum execution time: 12_096_000 picoseconds. + Weight::from_parts(12_442_958, 0) // Standard Error: 1 .saturating_add(Weight::from_parts(494, 0).saturating_mul(z.into())) } @@ -76,14 +79,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `z` is `[0, 10000]`. fn as_multi_create(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `352 + s * (2 ±0)` - // Estimated: `5821` - // Minimum execution time: 35_377 nanoseconds. - Weight::from_parts(29_088_956, 5821) - // Standard Error: 335 - .saturating_add(Weight::from_parts(67_846, 0).saturating_mul(s.into())) - // Standard Error: 3 - .saturating_add(Weight::from_parts(1_523, 0).saturating_mul(z.into())) + // Measured: `301 + s * (2 ±0)` + // Estimated: `6811` + // Minimum execution time: 37_609_000 picoseconds. + Weight::from_parts(32_693_100, 6811) + // Standard Error: 449 + .saturating_add(Weight::from_parts(56_623, 0).saturating_mul(s.into())) + // Standard Error: 4 + .saturating_add(Weight::from_parts(1_203, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -93,14 +96,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `z` is `[0, 10000]`. fn as_multi_approve(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `351` - // Estimated: `5821` - // Minimum execution time: 26_138 nanoseconds. - Weight::from_parts(20_479_380, 5821) - // Standard Error: 259 - .saturating_add(Weight::from_parts(64_116, 0).saturating_mul(s.into())) - // Standard Error: 2 - .saturating_add(Weight::from_parts(1_520, 0).saturating_mul(z.into())) + // Measured: `320` + // Estimated: `6811` + // Minimum execution time: 27_434_000 picoseconds. + Weight::from_parts(22_659_090, 6811) + // Standard Error: 328 + .saturating_add(Weight::from_parts(53_508, 0).saturating_mul(s.into())) + // Standard Error: 3 + .saturating_add(Weight::from_parts(1_213, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -112,14 +115,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `z` is `[0, 10000]`. fn as_multi_complete(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `489 + s * (33 ±0)` - // Estimated: `8424` - // Minimum execution time: 40_323 nanoseconds. - Weight::from_parts(32_311_615, 8424) - // Standard Error: 401 - .saturating_add(Weight::from_parts(85_999, 0).saturating_mul(s.into())) - // Standard Error: 3 - .saturating_add(Weight::from_parts(1_534, 0).saturating_mul(z.into())) + // Measured: `426 + s * (33 ±0)` + // Estimated: `10404` + // Minimum execution time: 43_592_000 picoseconds. + Weight::from_parts(36_465_266, 10404) + // Standard Error: 1_049 + .saturating_add(Weight::from_parts(78_833, 0).saturating_mul(s.into())) + // Standard Error: 10 + .saturating_add(Weight::from_parts(1_238, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -128,12 +131,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[2, 100]`. fn approve_as_multi_create(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `359 + s * (2 ±0)` - // Estimated: `5821` - // Minimum execution time: 26_938 nanoseconds. - Weight::from_parts(27_802_216, 5821) - // Standard Error: 342 - .saturating_add(Weight::from_parts(69_282, 0).saturating_mul(s.into())) + // Measured: `301 + s * (2 ±0)` + // Estimated: `6811` + // Minimum execution time: 30_216_000 picoseconds. + Weight::from_parts(31_430_373, 6811) + // Standard Error: 967 + .saturating_add(Weight::from_parts(57_035, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -142,12 +145,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[2, 100]`. fn approve_as_multi_approve(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `351` - // Estimated: `5821` - // Minimum execution time: 18_050 nanoseconds. - Weight::from_parts(19_095_404, 5821) - // Standard Error: 419 - .saturating_add(Weight::from_parts(66_914, 0).saturating_mul(s.into())) + // Measured: `320` + // Estimated: `6811` + // Minimum execution time: 19_960_000 picoseconds. + Weight::from_parts(21_281_659, 6811) + // Standard Error: 435 + .saturating_add(Weight::from_parts(56_445, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -156,12 +159,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[2, 100]`. fn cancel_as_multi(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `555 + s * (1 ±0)` - // Estimated: `5821` - // Minimum execution time: 27_508 nanoseconds. - Weight::from_parts(28_702_686, 5821) - // Standard Error: 466 - .saturating_add(Weight::from_parts(69_419, 0).saturating_mul(s.into())) + // Measured: `492 + s * (1 ±0)` + // Estimated: `6811` + // Minimum execution time: 31_219_000 picoseconds. + Weight::from_parts(32_395_963, 6811) + // Standard Error: 500 + .saturating_add(Weight::from_parts(56_853, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -174,8 +177,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_086 nanoseconds. - Weight::from_parts(12_464_828, 0) + // Minimum execution time: 12_096_000 picoseconds. + Weight::from_parts(12_442_958, 0) // Standard Error: 1 .saturating_add(Weight::from_parts(494, 0).saturating_mul(z.into())) } @@ -185,14 +188,14 @@ impl WeightInfo for () { /// The range of component `z` is `[0, 10000]`. fn as_multi_create(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `352 + s * (2 ±0)` - // Estimated: `5821` - // Minimum execution time: 35_377 nanoseconds. - Weight::from_parts(29_088_956, 5821) - // Standard Error: 335 - .saturating_add(Weight::from_parts(67_846, 0).saturating_mul(s.into())) - // Standard Error: 3 - .saturating_add(Weight::from_parts(1_523, 0).saturating_mul(z.into())) + // Measured: `301 + s * (2 ±0)` + // Estimated: `6811` + // Minimum execution time: 37_609_000 picoseconds. + Weight::from_parts(32_693_100, 6811) + // Standard Error: 449 + .saturating_add(Weight::from_parts(56_623, 0).saturating_mul(s.into())) + // Standard Error: 4 + .saturating_add(Weight::from_parts(1_203, 0).saturating_mul(z.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -202,14 +205,14 @@ impl WeightInfo for () { /// The range of component `z` is `[0, 10000]`. fn as_multi_approve(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `351` - // Estimated: `5821` - // Minimum execution time: 26_138 nanoseconds. - Weight::from_parts(20_479_380, 5821) - // Standard Error: 259 - .saturating_add(Weight::from_parts(64_116, 0).saturating_mul(s.into())) - // Standard Error: 2 - .saturating_add(Weight::from_parts(1_520, 0).saturating_mul(z.into())) + // Measured: `320` + // Estimated: `6811` + // Minimum execution time: 27_434_000 picoseconds. + Weight::from_parts(22_659_090, 6811) + // Standard Error: 328 + .saturating_add(Weight::from_parts(53_508, 0).saturating_mul(s.into())) + // Standard Error: 3 + .saturating_add(Weight::from_parts(1_213, 0).saturating_mul(z.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -221,14 +224,14 @@ impl WeightInfo for () { /// The range of component `z` is `[0, 10000]`. fn as_multi_complete(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `489 + s * (33 ±0)` - // Estimated: `8424` - // Minimum execution time: 40_323 nanoseconds. - Weight::from_parts(32_311_615, 8424) - // Standard Error: 401 - .saturating_add(Weight::from_parts(85_999, 0).saturating_mul(s.into())) - // Standard Error: 3 - .saturating_add(Weight::from_parts(1_534, 0).saturating_mul(z.into())) + // Measured: `426 + s * (33 ±0)` + // Estimated: `10404` + // Minimum execution time: 43_592_000 picoseconds. + Weight::from_parts(36_465_266, 10404) + // Standard Error: 1_049 + .saturating_add(Weight::from_parts(78_833, 0).saturating_mul(s.into())) + // Standard Error: 10 + .saturating_add(Weight::from_parts(1_238, 0).saturating_mul(z.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -237,12 +240,12 @@ impl WeightInfo for () { /// The range of component `s` is `[2, 100]`. fn approve_as_multi_create(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `359 + s * (2 ±0)` - // Estimated: `5821` - // Minimum execution time: 26_938 nanoseconds. - Weight::from_parts(27_802_216, 5821) - // Standard Error: 342 - .saturating_add(Weight::from_parts(69_282, 0).saturating_mul(s.into())) + // Measured: `301 + s * (2 ±0)` + // Estimated: `6811` + // Minimum execution time: 30_216_000 picoseconds. + Weight::from_parts(31_430_373, 6811) + // Standard Error: 967 + .saturating_add(Weight::from_parts(57_035, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -251,12 +254,12 @@ impl WeightInfo for () { /// The range of component `s` is `[2, 100]`. fn approve_as_multi_approve(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `351` - // Estimated: `5821` - // Minimum execution time: 18_050 nanoseconds. - Weight::from_parts(19_095_404, 5821) - // Standard Error: 419 - .saturating_add(Weight::from_parts(66_914, 0).saturating_mul(s.into())) + // Measured: `320` + // Estimated: `6811` + // Minimum execution time: 19_960_000 picoseconds. + Weight::from_parts(21_281_659, 6811) + // Standard Error: 435 + .saturating_add(Weight::from_parts(56_445, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -265,12 +268,12 @@ impl WeightInfo for () { /// The range of component `s` is `[2, 100]`. fn cancel_as_multi(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `555 + s * (1 ±0)` - // Estimated: `5821` - // Minimum execution time: 27_508 nanoseconds. - Weight::from_parts(28_702_686, 5821) - // Standard Error: 466 - .saturating_add(Weight::from_parts(69_419, 0).saturating_mul(s.into())) + // Measured: `492 + s * (1 ±0)` + // Estimated: `6811` + // Minimum execution time: 31_219_000 picoseconds. + Weight::from_parts(32_395_963, 6811) + // Standard Error: 500 + .saturating_add(Weight::from_parts(56_853, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/nfts/src/weights.rs b/frame/nfts/src/weights.rs index 3d447c8d264d4..c5010a73cc7cb 100644 --- a/frame/nfts/src/weights.rs +++ b/frame/nfts/src/weights.rs @@ -18,26 +18,28 @@ //! Autogenerated weights for pallet_nfts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_nfts +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_nfts -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/nfts/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -105,10 +107,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn create() -> Weight { // Proof Size summary in bytes: - // Measured: `214` + // Measured: `182` // Estimated: `5038` - // Minimum execution time: 37_598_000 picoseconds. - Weight::from_parts(38_703_000, 5038) + // Minimum execution time: 36_780_000 picoseconds. + Weight::from_parts(37_508_000, 5038) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -126,8 +128,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `42` // Estimated: `5038` - // Minimum execution time: 25_899_000 picoseconds. - Weight::from_parts(26_385_000, 5038) + // Minimum execution time: 25_144_000 picoseconds. + Weight::from_parts(25_800_000, 5038) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -152,14 +154,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `a` is `[0, 1000]`. fn destroy(m: u32, _c: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `32218 + a * (364 ±0)` + // Measured: `32186 + a * (332 ±0)` // Estimated: `2538589 + a * (2921 ±0)` - // Minimum execution time: 1_129_980_000 picoseconds. - Weight::from_parts(1_096_213_543, 2538589) - // Standard Error: 5_210 - .saturating_add(Weight::from_parts(92, 0).saturating_mul(m.into())) - // Standard Error: 5_210 - .saturating_add(Weight::from_parts(5_480_550, 0).saturating_mul(a.into())) + // Minimum execution time: 1_122_858_000 picoseconds. + Weight::from_parts(1_094_711_913, 2538589) + // Standard Error: 4_485 + .saturating_add(Weight::from_parts(3_481, 0).saturating_mul(m.into())) + // Standard Error: 4_485 + .saturating_add(Weight::from_parts(5_520_602, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(1004_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(1005_u64)) @@ -180,10 +182,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `453` + // Measured: `421` // Estimated: `18460` - // Minimum execution time: 49_434_000 picoseconds. - Weight::from_parts(50_248_000, 18460) + // Minimum execution time: 48_590_000 picoseconds. + Weight::from_parts(49_260_000, 18460) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -201,10 +203,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn force_mint() -> Weight { // Proof Size summary in bytes: - // Measured: `453` + // Measured: `421` // Estimated: `18460` - // Minimum execution time: 47_393_000 picoseconds. - Weight::from_parts(47_906_000, 18460) + // Minimum execution time: 46_646_000 picoseconds. + Weight::from_parts(47_331_000, 18460) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -226,10 +228,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn burn() -> Weight { // Proof Size summary in bytes: - // Measured: `594` + // Measured: `530` // Estimated: `14993` - // Minimum execution time: 47_188_000 picoseconds. - Weight::from_parts(47_746_000, 14993) + // Minimum execution time: 46_976_000 picoseconds. + Weight::from_parts(47_606_000, 14993) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -249,10 +251,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `623` + // Measured: `559` // Estimated: `14926` - // Minimum execution time: 37_984_000 picoseconds. - Weight::from_parts(38_446_000, 14926) + // Minimum execution time: 38_013_000 picoseconds. + Weight::from_parts(38_420_000, 14926) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -265,12 +267,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `761 + i * (140 ±0)` + // Measured: `729 + i * (108 ±0)` // Estimated: `8077 + i * (3336 ±0)` - // Minimum execution time: 17_297_000 picoseconds. - Weight::from_parts(17_634_000, 8077) - // Standard Error: 17_773 - .saturating_add(Weight::from_parts(14_395_819, 0).saturating_mul(i.into())) + // Minimum execution time: 17_428_000 picoseconds. + Weight::from_parts(17_664_000, 8077) + // Standard Error: 16_385 + .saturating_add(Weight::from_parts(14_150_405, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -284,8 +286,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `401` // Estimated: `7047` - // Minimum execution time: 21_827_000 picoseconds. - Weight::from_parts(22_134_000, 7047) + // Minimum execution time: 21_760_000 picoseconds. + Weight::from_parts(22_063_000, 7047) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -297,8 +299,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `401` // Estimated: `7047` - // Minimum execution time: 21_549_000 picoseconds. - Weight::from_parts(21_987_000, 7047) + // Minimum execution time: 21_622_000 picoseconds. + Weight::from_parts(22_056_000, 7047) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -308,10 +310,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn lock_collection() -> Weight { // Proof Size summary in bytes: - // Measured: `338` + // Measured: `306` // Estimated: `7087` - // Minimum execution time: 18_930_000 picoseconds. - Weight::from_parts(19_200_000, 7087) + // Minimum execution time: 18_820_000 picoseconds. + Weight::from_parts(19_212_000, 7087) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -323,24 +325,24 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { // Proof Size summary in bytes: - // Measured: `386` + // Measured: `354` // Estimated: `7066` - // Minimum execution time: 24_929_000 picoseconds. - Weight::from_parts(25_786_000, 7066) + // Minimum execution time: 25_433_000 picoseconds. + Weight::from_parts(25_793_000, 7066) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: Nfts Collection (r:1 w:1) /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:1 w:4) + /// Storage: Nfts CollectionRoleOf (r:2 w:4) /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn set_team() -> Weight { // Proof Size summary in bytes: - // Measured: `367` - // Estimated: `7083` - // Minimum execution time: 28_245_000 picoseconds. - Weight::from_parts(28_490_000, 7083) - .saturating_add(T::DbWeight::get().reads(2_u64)) + // Measured: `335` + // Estimated: `9627` + // Minimum execution time: 43_368_000 picoseconds. + Weight::from_parts(43_974_000, 9627) + .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Nfts Collection (r:1 w:1) @@ -349,10 +351,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_collection_owner() -> Weight { // Proof Size summary in bytes: - // Measured: `309` + // Measured: `277` // Estimated: `3549` - // Minimum execution time: 19_971_000 picoseconds. - Weight::from_parts(20_276_000, 3549) + // Minimum execution time: 20_009_000 picoseconds. + Weight::from_parts(20_220_000, 3549) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -364,8 +366,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `242` // Estimated: `3549` - // Minimum execution time: 15_924_000 picoseconds. - Weight::from_parts(16_258_000, 3549) + // Minimum execution time: 16_048_000 picoseconds. + Weight::from_parts(16_353_000, 3549) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -377,8 +379,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `401` // Estimated: `7047` - // Minimum execution time: 20_780_000 picoseconds. - Weight::from_parts(21_109_000, 7047) + // Minimum execution time: 20_890_000 picoseconds. + Weight::from_parts(21_237_000, 7047) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -394,10 +396,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) fn set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `537` + // Measured: `505` // Estimated: `18045` - // Minimum execution time: 50_817_000 picoseconds. - Weight::from_parts(51_585_000, 18045) + // Minimum execution time: 50_686_000 picoseconds. + Weight::from_parts(50_981_000, 18045) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -407,10 +409,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) fn force_set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `342` + // Measured: `310` // Estimated: `7460` - // Minimum execution time: 28_821_000 picoseconds. - Weight::from_parts(29_417_000, 7460) + // Minimum execution time: 28_714_000 picoseconds. + Weight::from_parts(29_044_000, 7460) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -424,10 +426,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) fn clear_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `979` + // Measured: `916` // Estimated: `14507` - // Minimum execution time: 47_021_000 picoseconds. - Weight::from_parts(47_509_000, 14507) + // Minimum execution time: 46_232_000 picoseconds. + Weight::from_parts(46_738_000, 14507) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -437,10 +439,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(681), added: 3156, mode: MaxEncodedLen) fn approve_item_attributes() -> Weight { // Proof Size summary in bytes: - // Measured: `379` + // Measured: `347` // Estimated: `8472` - // Minimum execution time: 19_457_000 picoseconds. - Weight::from_parts(19_738_000, 8472) + // Minimum execution time: 19_332_000 picoseconds. + Weight::from_parts(19_765_000, 8472) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -455,12 +457,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1000]`. fn cancel_item_attributes_approval(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `899 + n * (396 ±0)` + // Measured: `803 + n * (364 ±0)` // Estimated: `15976 + n * (2921 ±0)` - // Minimum execution time: 29_027_000 picoseconds. - Weight::from_parts(29_376_000, 15976) - // Standard Error: 3_500 - .saturating_add(Weight::from_parts(5_568_116, 0).saturating_mul(n.into())) + // Minimum execution time: 29_227_000 picoseconds. + Weight::from_parts(29_661_000, 15976) + // Standard Error: 3_574 + .saturating_add(Weight::from_parts(5_442_937, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -479,10 +481,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn set_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `537` + // Measured: `505` // Estimated: `17739` - // Minimum execution time: 41_658_000 picoseconds. - Weight::from_parts(42_241_000, 17739) + // Minimum execution time: 41_297_000 picoseconds. + Weight::from_parts(41_902_000, 17739) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -496,10 +498,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `672` + // Measured: `608` // Estimated: `14201` - // Minimum execution time: 39_838_000 picoseconds. - Weight::from_parts(40_757_000, 14201) + // Minimum execution time: 39_312_000 picoseconds. + Weight::from_parts(40_048_000, 14201) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -513,10 +515,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `396` + // Measured: `364` // Estimated: `14173` - // Minimum execution time: 37_327_000 picoseconds. - Weight::from_parts(37_874_000, 14173) + // Minimum execution time: 36_932_000 picoseconds. + Weight::from_parts(38_207_000, 14173) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -530,10 +532,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `539` + // Measured: `475` // Estimated: `14173` - // Minimum execution time: 35_305_000 picoseconds. - Weight::from_parts(36_213_000, 14173) + // Minimum execution time: 35_264_000 picoseconds. + Weight::from_parts(35_829_000, 14173) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -543,10 +545,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn approve_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `408` + // Measured: `376` // Estimated: `7864` - // Minimum execution time: 22_680_000 picoseconds. - Weight::from_parts(23_126_000, 7864) + // Minimum execution time: 22_819_000 picoseconds. + Weight::from_parts(23_121_000, 7864) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -554,10 +556,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) fn cancel_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `416` + // Measured: `384` // Estimated: `4326` - // Minimum execution time: 19_837_000 picoseconds. - Weight::from_parts(20_352_000, 4326) + // Minimum execution time: 20_377_000 picoseconds. + Weight::from_parts(20_625_000, 4326) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -565,10 +567,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) fn clear_all_transfer_approvals() -> Weight { // Proof Size summary in bytes: - // Measured: `416` + // Measured: `384` // Estimated: `4326` - // Minimum execution time: 18_911_000 picoseconds. - Weight::from_parts(19_233_000, 4326) + // Minimum execution time: 19_180_000 picoseconds. + Weight::from_parts(19_468_000, 4326) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -578,8 +580,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3517` - // Minimum execution time: 17_292_000 picoseconds. - Weight::from_parts(17_568_000, 3517) + // Minimum execution time: 17_381_000 picoseconds. + Weight::from_parts(17_718_000, 3517) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -589,10 +591,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: - // Measured: `338` + // Measured: `306` // Estimated: `7087` - // Minimum execution time: 20_323_000 picoseconds. - Weight::from_parts(20_692_000, 7087) + // Minimum execution time: 20_373_000 picoseconds. + Weight::from_parts(20_662_000, 7087) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -604,8 +606,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `289` // Estimated: `7072` - // Minimum execution time: 19_971_000 picoseconds. - Weight::from_parts(20_159_000, 7072) + // Minimum execution time: 20_154_000 picoseconds. + Weight::from_parts(20_592_000, 7072) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -619,10 +621,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn set_price() -> Weight { // Proof Size summary in bytes: - // Measured: `516` + // Measured: `484` // Estimated: `11377` - // Minimum execution time: 26_202_000 picoseconds. - Weight::from_parts(26_499_000, 11377) + // Minimum execution time: 25_644_000 picoseconds. + Weight::from_parts(25_999_000, 11377) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -642,10 +644,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn buy_item() -> Weight { // Proof Size summary in bytes: - // Measured: `767` + // Measured: `671` // Estimated: `18480` - // Minimum execution time: 50_601_000 picoseconds. - Weight::from_parts(51_283_000, 18480) + // Minimum execution time: 51_542_000 picoseconds. + Weight::from_parts(52_203_000, 18480) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -654,10 +656,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_733_000 picoseconds. - Weight::from_parts(5_568_590, 0) - // Standard Error: 14_136 - .saturating_add(Weight::from_parts(3_763_928, 0).saturating_mul(n.into())) + // Minimum execution time: 2_796_000 picoseconds. + Weight::from_parts(5_517_617, 0) + // Standard Error: 14_247 + .saturating_add(Weight::from_parts(3_757_796, 0).saturating_mul(n.into())) } /// Storage: Nfts Item (r:2 w:0) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) @@ -665,10 +667,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn create_swap() -> Weight { // Proof Size summary in bytes: - // Measured: `524` + // Measured: `460` // Estimated: `7662` - // Minimum execution time: 22_901_000 picoseconds. - Weight::from_parts(23_673_000, 7662) + // Minimum execution time: 23_218_000 picoseconds. + Weight::from_parts(23_590_000, 7662) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -678,10 +680,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) fn cancel_swap() -> Weight { // Proof Size summary in bytes: - // Measured: `511` + // Measured: `479` // Estimated: `7862` - // Minimum execution time: 22_532_000 picoseconds. - Weight::from_parts(22_831_000, 7862) + // Minimum execution time: 22_536_000 picoseconds. + Weight::from_parts(22_874_000, 7862) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -701,21 +703,21 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn claim_swap() -> Weight { // Proof Size summary in bytes: - // Measured: `896` + // Measured: `800` // Estimated: `24321` - // Minimum execution time: 77_668_000 picoseconds. - Weight::from_parts(78_407_000, 24321) + // Minimum execution time: 77_372_000 picoseconds. + Weight::from_parts(78_109_000, 24321) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } - /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionRoleOf (r:2 w:0) /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:1) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) @@ -729,12 +731,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 10]`. fn mint_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `659` + // Measured: `595` // Estimated: `29192 + n * (2921 ±0)` - // Minimum execution time: 133_147_000 picoseconds. - Weight::from_parts(138_031_439, 29192) - // Standard Error: 28_665 - .saturating_add(Weight::from_parts(28_206_062, 0).saturating_mul(n.into())) + // Minimum execution time: 131_935_000 picoseconds. + Weight::from_parts(137_455_891, 29192) + // Standard Error: 31_617 + .saturating_add(Weight::from_parts(27_550_750, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) @@ -756,12 +758,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 10]`. fn set_attributes_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `721` + // Measured: `625` // Estimated: `20142 + n * (2921 ±0)` - // Minimum execution time: 78_243_000 picoseconds. - Weight::from_parts(90_947_408, 20142) - // Standard Error: 75_516 - .saturating_add(Weight::from_parts(28_059_623, 0).saturating_mul(n.into())) + // Minimum execution time: 77_694_000 picoseconds. + Weight::from_parts(90_089_732, 20142) + // Standard Error: 71_327 + .saturating_add(Weight::from_parts(27_832_189, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -784,10 +786,10 @@ impl WeightInfo for () { /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn create() -> Weight { // Proof Size summary in bytes: - // Measured: `214` + // Measured: `182` // Estimated: `5038` - // Minimum execution time: 37_598_000 picoseconds. - Weight::from_parts(38_703_000, 5038) + // Minimum execution time: 36_780_000 picoseconds. + Weight::from_parts(37_508_000, 5038) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -805,8 +807,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `42` // Estimated: `5038` - // Minimum execution time: 25_899_000 picoseconds. - Weight::from_parts(26_385_000, 5038) + // Minimum execution time: 25_144_000 picoseconds. + Weight::from_parts(25_800_000, 5038) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -831,14 +833,14 @@ impl WeightInfo for () { /// The range of component `a` is `[0, 1000]`. fn destroy(m: u32, _c: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `32218 + a * (364 ±0)` + // Measured: `32186 + a * (332 ±0)` // Estimated: `2538589 + a * (2921 ±0)` - // Minimum execution time: 1_129_980_000 picoseconds. - Weight::from_parts(1_096_213_543, 2538589) - // Standard Error: 5_210 - .saturating_add(Weight::from_parts(92, 0).saturating_mul(m.into())) - // Standard Error: 5_210 - .saturating_add(Weight::from_parts(5_480_550, 0).saturating_mul(a.into())) + // Minimum execution time: 1_122_858_000 picoseconds. + Weight::from_parts(1_094_711_913, 2538589) + // Standard Error: 4_485 + .saturating_add(Weight::from_parts(3_481, 0).saturating_mul(m.into())) + // Standard Error: 4_485 + .saturating_add(Weight::from_parts(5_520_602, 0).saturating_mul(a.into())) .saturating_add(RocksDbWeight::get().reads(1004_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(RocksDbWeight::get().writes(1005_u64)) @@ -859,10 +861,10 @@ impl WeightInfo for () { /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `453` + // Measured: `421` // Estimated: `18460` - // Minimum execution time: 49_434_000 picoseconds. - Weight::from_parts(50_248_000, 18460) + // Minimum execution time: 48_590_000 picoseconds. + Weight::from_parts(49_260_000, 18460) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -880,10 +882,10 @@ impl WeightInfo for () { /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn force_mint() -> Weight { // Proof Size summary in bytes: - // Measured: `453` + // Measured: `421` // Estimated: `18460` - // Minimum execution time: 47_393_000 picoseconds. - Weight::from_parts(47_906_000, 18460) + // Minimum execution time: 46_646_000 picoseconds. + Weight::from_parts(47_331_000, 18460) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -905,10 +907,10 @@ impl WeightInfo for () { /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn burn() -> Weight { // Proof Size summary in bytes: - // Measured: `594` + // Measured: `530` // Estimated: `14993` - // Minimum execution time: 47_188_000 picoseconds. - Weight::from_parts(47_746_000, 14993) + // Minimum execution time: 46_976_000 picoseconds. + Weight::from_parts(47_606_000, 14993) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -928,10 +930,10 @@ impl WeightInfo for () { /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `623` + // Measured: `559` // Estimated: `14926` - // Minimum execution time: 37_984_000 picoseconds. - Weight::from_parts(38_446_000, 14926) + // Minimum execution time: 38_013_000 picoseconds. + Weight::from_parts(38_420_000, 14926) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -944,12 +946,12 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `761 + i * (140 ±0)` + // Measured: `729 + i * (108 ±0)` // Estimated: `8077 + i * (3336 ±0)` - // Minimum execution time: 17_297_000 picoseconds. - Weight::from_parts(17_634_000, 8077) - // Standard Error: 17_773 - .saturating_add(Weight::from_parts(14_395_819, 0).saturating_mul(i.into())) + // Minimum execution time: 17_428_000 picoseconds. + Weight::from_parts(17_664_000, 8077) + // Standard Error: 16_385 + .saturating_add(Weight::from_parts(14_150_405, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -963,8 +965,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `401` // Estimated: `7047` - // Minimum execution time: 21_827_000 picoseconds. - Weight::from_parts(22_134_000, 7047) + // Minimum execution time: 21_760_000 picoseconds. + Weight::from_parts(22_063_000, 7047) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -976,8 +978,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `401` // Estimated: `7047` - // Minimum execution time: 21_549_000 picoseconds. - Weight::from_parts(21_987_000, 7047) + // Minimum execution time: 21_622_000 picoseconds. + Weight::from_parts(22_056_000, 7047) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -987,10 +989,10 @@ impl WeightInfo for () { /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn lock_collection() -> Weight { // Proof Size summary in bytes: - // Measured: `338` + // Measured: `306` // Estimated: `7087` - // Minimum execution time: 18_930_000 picoseconds. - Weight::from_parts(19_200_000, 7087) + // Minimum execution time: 18_820_000 picoseconds. + Weight::from_parts(19_212_000, 7087) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1002,24 +1004,24 @@ impl WeightInfo for () { /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { // Proof Size summary in bytes: - // Measured: `386` + // Measured: `354` // Estimated: `7066` - // Minimum execution time: 24_929_000 picoseconds. - Weight::from_parts(25_786_000, 7066) + // Minimum execution time: 25_433_000 picoseconds. + Weight::from_parts(25_793_000, 7066) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } /// Storage: Nfts Collection (r:1 w:1) /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) - /// Storage: Nfts CollectionRoleOf (r:1 w:4) + /// Storage: Nfts CollectionRoleOf (r:2 w:4) /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn set_team() -> Weight { // Proof Size summary in bytes: - // Measured: `367` - // Estimated: `7083` - // Minimum execution time: 28_245_000 picoseconds. - Weight::from_parts(28_490_000, 7083) - .saturating_add(RocksDbWeight::get().reads(2_u64)) + // Measured: `335` + // Estimated: `9627` + // Minimum execution time: 43_368_000 picoseconds. + Weight::from_parts(43_974_000, 9627) + .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Nfts Collection (r:1 w:1) @@ -1028,10 +1030,10 @@ impl WeightInfo for () { /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_collection_owner() -> Weight { // Proof Size summary in bytes: - // Measured: `309` + // Measured: `277` // Estimated: `3549` - // Minimum execution time: 19_971_000 picoseconds. - Weight::from_parts(20_276_000, 3549) + // Minimum execution time: 20_009_000 picoseconds. + Weight::from_parts(20_220_000, 3549) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1043,8 +1045,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `242` // Estimated: `3549` - // Minimum execution time: 15_924_000 picoseconds. - Weight::from_parts(16_258_000, 3549) + // Minimum execution time: 16_048_000 picoseconds. + Weight::from_parts(16_353_000, 3549) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1056,8 +1058,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `401` // Estimated: `7047` - // Minimum execution time: 20_780_000 picoseconds. - Weight::from_parts(21_109_000, 7047) + // Minimum execution time: 20_890_000 picoseconds. + Weight::from_parts(21_237_000, 7047) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1073,10 +1075,10 @@ impl WeightInfo for () { /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) fn set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `537` + // Measured: `505` // Estimated: `18045` - // Minimum execution time: 50_817_000 picoseconds. - Weight::from_parts(51_585_000, 18045) + // Minimum execution time: 50_686_000 picoseconds. + Weight::from_parts(50_981_000, 18045) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1086,10 +1088,10 @@ impl WeightInfo for () { /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) fn force_set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `342` + // Measured: `310` // Estimated: `7460` - // Minimum execution time: 28_821_000 picoseconds. - Weight::from_parts(29_417_000, 7460) + // Minimum execution time: 28_714_000 picoseconds. + Weight::from_parts(29_044_000, 7460) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1103,10 +1105,10 @@ impl WeightInfo for () { /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) fn clear_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `979` + // Measured: `916` // Estimated: `14507` - // Minimum execution time: 47_021_000 picoseconds. - Weight::from_parts(47_509_000, 14507) + // Minimum execution time: 46_232_000 picoseconds. + Weight::from_parts(46_738_000, 14507) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1116,10 +1118,10 @@ impl WeightInfo for () { /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(681), added: 3156, mode: MaxEncodedLen) fn approve_item_attributes() -> Weight { // Proof Size summary in bytes: - // Measured: `379` + // Measured: `347` // Estimated: `8472` - // Minimum execution time: 19_457_000 picoseconds. - Weight::from_parts(19_738_000, 8472) + // Minimum execution time: 19_332_000 picoseconds. + Weight::from_parts(19_765_000, 8472) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1134,12 +1136,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1000]`. fn cancel_item_attributes_approval(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `899 + n * (396 ±0)` + // Measured: `803 + n * (364 ±0)` // Estimated: `15976 + n * (2921 ±0)` - // Minimum execution time: 29_027_000 picoseconds. - Weight::from_parts(29_376_000, 15976) - // Standard Error: 3_500 - .saturating_add(Weight::from_parts(5_568_116, 0).saturating_mul(n.into())) + // Minimum execution time: 29_227_000 picoseconds. + Weight::from_parts(29_661_000, 15976) + // Standard Error: 3_574 + .saturating_add(Weight::from_parts(5_442_937, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -1158,10 +1160,10 @@ impl WeightInfo for () { /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn set_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `537` + // Measured: `505` // Estimated: `17739` - // Minimum execution time: 41_658_000 picoseconds. - Weight::from_parts(42_241_000, 17739) + // Minimum execution time: 41_297_000 picoseconds. + Weight::from_parts(41_902_000, 17739) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1175,10 +1177,10 @@ impl WeightInfo for () { /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `672` + // Measured: `608` // Estimated: `14201` - // Minimum execution time: 39_838_000 picoseconds. - Weight::from_parts(40_757_000, 14201) + // Minimum execution time: 39_312_000 picoseconds. + Weight::from_parts(40_048_000, 14201) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1192,10 +1194,10 @@ impl WeightInfo for () { /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `396` + // Measured: `364` // Estimated: `14173` - // Minimum execution time: 37_327_000 picoseconds. - Weight::from_parts(37_874_000, 14173) + // Minimum execution time: 36_932_000 picoseconds. + Weight::from_parts(38_207_000, 14173) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1209,10 +1211,10 @@ impl WeightInfo for () { /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `539` + // Measured: `475` // Estimated: `14173` - // Minimum execution time: 35_305_000 picoseconds. - Weight::from_parts(36_213_000, 14173) + // Minimum execution time: 35_264_000 picoseconds. + Weight::from_parts(35_829_000, 14173) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1222,10 +1224,10 @@ impl WeightInfo for () { /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn approve_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `408` + // Measured: `376` // Estimated: `7864` - // Minimum execution time: 22_680_000 picoseconds. - Weight::from_parts(23_126_000, 7864) + // Minimum execution time: 22_819_000 picoseconds. + Weight::from_parts(23_121_000, 7864) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1233,10 +1235,10 @@ impl WeightInfo for () { /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) fn cancel_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `416` + // Measured: `384` // Estimated: `4326` - // Minimum execution time: 19_837_000 picoseconds. - Weight::from_parts(20_352_000, 4326) + // Minimum execution time: 20_377_000 picoseconds. + Weight::from_parts(20_625_000, 4326) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1244,10 +1246,10 @@ impl WeightInfo for () { /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) fn clear_all_transfer_approvals() -> Weight { // Proof Size summary in bytes: - // Measured: `416` + // Measured: `384` // Estimated: `4326` - // Minimum execution time: 18_911_000 picoseconds. - Weight::from_parts(19_233_000, 4326) + // Minimum execution time: 19_180_000 picoseconds. + Weight::from_parts(19_468_000, 4326) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1257,8 +1259,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3517` - // Minimum execution time: 17_292_000 picoseconds. - Weight::from_parts(17_568_000, 3517) + // Minimum execution time: 17_381_000 picoseconds. + Weight::from_parts(17_718_000, 3517) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1268,10 +1270,10 @@ impl WeightInfo for () { /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: - // Measured: `338` + // Measured: `306` // Estimated: `7087` - // Minimum execution time: 20_323_000 picoseconds. - Weight::from_parts(20_692_000, 7087) + // Minimum execution time: 20_373_000 picoseconds. + Weight::from_parts(20_662_000, 7087) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1283,8 +1285,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `289` // Estimated: `7072` - // Minimum execution time: 19_971_000 picoseconds. - Weight::from_parts(20_159_000, 7072) + // Minimum execution time: 20_154_000 picoseconds. + Weight::from_parts(20_592_000, 7072) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1298,10 +1300,10 @@ impl WeightInfo for () { /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn set_price() -> Weight { // Proof Size summary in bytes: - // Measured: `516` + // Measured: `484` // Estimated: `11377` - // Minimum execution time: 26_202_000 picoseconds. - Weight::from_parts(26_499_000, 11377) + // Minimum execution time: 25_644_000 picoseconds. + Weight::from_parts(25_999_000, 11377) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1321,10 +1323,10 @@ impl WeightInfo for () { /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn buy_item() -> Weight { // Proof Size summary in bytes: - // Measured: `767` + // Measured: `671` // Estimated: `18480` - // Minimum execution time: 50_601_000 picoseconds. - Weight::from_parts(51_283_000, 18480) + // Minimum execution time: 51_542_000 picoseconds. + Weight::from_parts(52_203_000, 18480) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -1333,10 +1335,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_733_000 picoseconds. - Weight::from_parts(5_568_590, 0) - // Standard Error: 14_136 - .saturating_add(Weight::from_parts(3_763_928, 0).saturating_mul(n.into())) + // Minimum execution time: 2_796_000 picoseconds. + Weight::from_parts(5_517_617, 0) + // Standard Error: 14_247 + .saturating_add(Weight::from_parts(3_757_796, 0).saturating_mul(n.into())) } /// Storage: Nfts Item (r:2 w:0) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) @@ -1344,10 +1346,10 @@ impl WeightInfo for () { /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn create_swap() -> Weight { // Proof Size summary in bytes: - // Measured: `524` + // Measured: `460` // Estimated: `7662` - // Minimum execution time: 22_901_000 picoseconds. - Weight::from_parts(23_673_000, 7662) + // Minimum execution time: 23_218_000 picoseconds. + Weight::from_parts(23_590_000, 7662) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1357,10 +1359,10 @@ impl WeightInfo for () { /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) fn cancel_swap() -> Weight { // Proof Size summary in bytes: - // Measured: `511` + // Measured: `479` // Estimated: `7862` - // Minimum execution time: 22_532_000 picoseconds. - Weight::from_parts(22_831_000, 7862) + // Minimum execution time: 22_536_000 picoseconds. + Weight::from_parts(22_874_000, 7862) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1380,21 +1382,21 @@ impl WeightInfo for () { /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn claim_swap() -> Weight { // Proof Size summary in bytes: - // Measured: `896` + // Measured: `800` // Estimated: `24321` - // Minimum execution time: 77_668_000 picoseconds. - Weight::from_parts(78_407_000, 24321) + // Minimum execution time: 77_372_000 picoseconds. + Weight::from_parts(78_109_000, 24321) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(10_u64)) } - /// Storage: Nfts Collection (r:1 w:1) - /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts CollectionRoleOf (r:2 w:0) /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// Storage: Nfts Item (r:1 w:1) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) /// Storage: Nfts ItemConfigOf (r:1 w:1) /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) @@ -1408,12 +1410,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 10]`. fn mint_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `659` + // Measured: `595` // Estimated: `29192 + n * (2921 ±0)` - // Minimum execution time: 133_147_000 picoseconds. - Weight::from_parts(138_031_439, 29192) - // Standard Error: 28_665 - .saturating_add(Weight::from_parts(28_206_062, 0).saturating_mul(n.into())) + // Minimum execution time: 131_935_000 picoseconds. + Weight::from_parts(137_455_891, 29192) + // Standard Error: 31_617 + .saturating_add(Weight::from_parts(27_550_750, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) @@ -1435,12 +1437,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 10]`. fn set_attributes_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `721` + // Measured: `625` // Estimated: `20142 + n * (2921 ±0)` - // Minimum execution time: 78_243_000 picoseconds. - Weight::from_parts(90_947_408, 20142) - // Standard Error: 75_516 - .saturating_add(Weight::from_parts(28_059_623, 0).saturating_mul(n.into())) + // Minimum execution time: 77_694_000 picoseconds. + Weight::from_parts(90_089_732, 20142) + // Standard Error: 71_327 + .saturating_add(Weight::from_parts(27_832_189, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) diff --git a/frame/nis/src/weights.rs b/frame/nis/src/weights.rs index 27c2f23e0e9ec..14b7b4d9c6f9a 100644 --- a/frame/nis/src/weights.rs +++ b/frame/nis/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_nis //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_nis +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -73,12 +76,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `l` is `[0, 999]`. fn place_bid(l: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `6245 + l * (48 ±0)` - // Estimated: `60718` - // Minimum execution time: 28_814 nanoseconds. - Weight::from_parts(35_245_917, 60718) - // Standard Error: 189 - .saturating_add(Weight::from_parts(45_322, 0).saturating_mul(l.into())) + // Measured: `6182 + l * (48 ±0)` + // Estimated: `63688` + // Minimum execution time: 31_160_000 picoseconds. + Weight::from_parts(39_023_414, 63688) + // Standard Error: 214 + .saturating_add(Weight::from_parts(46_106, 0).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -90,10 +93,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nis QueueTotals (max_values: Some(1), max_size: Some(6002), added: 6497, mode: MaxEncodedLen) fn place_bid_max() -> Weight { // Proof Size summary in bytes: - // Measured: `54247` - // Estimated: `60718` - // Minimum execution time: 80_332 nanoseconds. - Weight::from_parts(81_050_000, 60718) + // Measured: `54184` + // Estimated: `63688` + // Minimum execution time: 85_703_000 picoseconds. + Weight::from_parts(86_613_000, 63688) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -106,12 +109,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `l` is `[1, 1000]`. fn retract_bid(l: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `6245 + l * (48 ±0)` - // Estimated: `60718` - // Minimum execution time: 34_426 nanoseconds. - Weight::from_parts(36_434_166, 60718) - // Standard Error: 135 - .saturating_add(Weight::from_parts(33_923, 0).saturating_mul(l.into())) + // Measured: `6182 + l * (48 ±0)` + // Estimated: `63688` + // Minimum execution time: 37_637_000 picoseconds. + Weight::from_parts(39_977_788, 63688) + // Standard Error: 152 + .saturating_add(Weight::from_parts(34_595, 0).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -121,10 +124,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn fund_deficit() -> Weight { // Proof Size summary in bytes: - // Measured: `222` - // Estimated: `3138` - // Minimum execution time: 32_566 nanoseconds. - Weight::from_parts(32_880_000, 3138) + // Measured: `191` + // Estimated: `5118` + // Minimum execution time: 35_807_000 picoseconds. + Weight::from_parts(36_329_000, 5118) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -138,10 +141,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) fn thaw_private() -> Weight { // Proof Size summary in bytes: - // Measured: `423` - // Estimated: `9418` - // Minimum execution time: 46_212 nanoseconds. - Weight::from_parts(46_748_000, 9418) + // Measured: `360` + // Estimated: `13378` + // Minimum execution time: 51_342_000 picoseconds. + Weight::from_parts(51_976_000, 13378) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -157,10 +160,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn thaw_communal() -> Weight { // Proof Size summary in bytes: - // Measured: `868` - // Estimated: `10956` - // Minimum execution time: 68_791 nanoseconds. - Weight::from_parts(69_504_000, 10956) + // Measured: `773` + // Estimated: `15906` + // Minimum execution time: 76_535_000 picoseconds. + Weight::from_parts(78_073_000, 15906) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -178,10 +181,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) fn privatize() -> Weight { // Proof Size summary in bytes: - // Measured: `930` - // Estimated: `14680` - // Minimum execution time: 76_784 nanoseconds. - Weight::from_parts(77_575_000, 14680) + // Measured: `835` + // Estimated: `20620` + // Minimum execution time: 84_680_000 picoseconds. + Weight::from_parts(85_661_000, 20620) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -199,10 +202,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn communify() -> Weight { // Proof Size summary in bytes: - // Measured: `769` - // Estimated: `14680` - // Minimum execution time: 64_543 nanoseconds. - Weight::from_parts(65_258_000, 14680) + // Measured: `674` + // Estimated: `20620` + // Minimum execution time: 72_828_000 picoseconds. + Weight::from_parts(73_553_000, 20620) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -214,10 +217,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Nis QueueTotals (max_values: Some(1), max_size: Some(6002), added: 6497, mode: MaxEncodedLen) fn process_queues() -> Weight { // Proof Size summary in bytes: - // Measured: `6655` - // Estimated: `9635` - // Minimum execution time: 21_379 nanoseconds. - Weight::from_parts(21_736_000, 9635) + // Measured: `6624` + // Estimated: `12605` + // Minimum execution time: 23_311_000 picoseconds. + Weight::from_parts(23_855_000, 12605) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -226,9 +229,9 @@ impl WeightInfo for SubstrateWeight { fn process_queue() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `50497` - // Minimum execution time: 4_302 nanoseconds. - Weight::from_parts(4_440_000, 50497) + // Estimated: `51487` + // Minimum execution time: 4_485_000 picoseconds. + Weight::from_parts(4_717_000, 51487) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -238,8 +241,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_758 nanoseconds. - Weight::from_parts(6_911_000, 0) + // Minimum execution time: 7_837_000 picoseconds. + Weight::from_parts(12_913_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -255,12 +258,12 @@ impl WeightInfo for () { /// The range of component `l` is `[0, 999]`. fn place_bid(l: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `6245 + l * (48 ±0)` - // Estimated: `60718` - // Minimum execution time: 28_814 nanoseconds. - Weight::from_parts(35_245_917, 60718) - // Standard Error: 189 - .saturating_add(Weight::from_parts(45_322, 0).saturating_mul(l.into())) + // Measured: `6182 + l * (48 ±0)` + // Estimated: `63688` + // Minimum execution time: 31_160_000 picoseconds. + Weight::from_parts(39_023_414, 63688) + // Standard Error: 214 + .saturating_add(Weight::from_parts(46_106, 0).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -272,10 +275,10 @@ impl WeightInfo for () { /// Proof: Nis QueueTotals (max_values: Some(1), max_size: Some(6002), added: 6497, mode: MaxEncodedLen) fn place_bid_max() -> Weight { // Proof Size summary in bytes: - // Measured: `54247` - // Estimated: `60718` - // Minimum execution time: 80_332 nanoseconds. - Weight::from_parts(81_050_000, 60718) + // Measured: `54184` + // Estimated: `63688` + // Minimum execution time: 85_703_000 picoseconds. + Weight::from_parts(86_613_000, 63688) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -288,12 +291,12 @@ impl WeightInfo for () { /// The range of component `l` is `[1, 1000]`. fn retract_bid(l: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `6245 + l * (48 ±0)` - // Estimated: `60718` - // Minimum execution time: 34_426 nanoseconds. - Weight::from_parts(36_434_166, 60718) - // Standard Error: 135 - .saturating_add(Weight::from_parts(33_923, 0).saturating_mul(l.into())) + // Measured: `6182 + l * (48 ±0)` + // Estimated: `63688` + // Minimum execution time: 37_637_000 picoseconds. + Weight::from_parts(39_977_788, 63688) + // Standard Error: 152 + .saturating_add(Weight::from_parts(34_595, 0).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -303,10 +306,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn fund_deficit() -> Weight { // Proof Size summary in bytes: - // Measured: `222` - // Estimated: `3138` - // Minimum execution time: 32_566 nanoseconds. - Weight::from_parts(32_880_000, 3138) + // Measured: `191` + // Estimated: `5118` + // Minimum execution time: 35_807_000 picoseconds. + Weight::from_parts(36_329_000, 5118) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -320,10 +323,10 @@ impl WeightInfo for () { /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) fn thaw_private() -> Weight { // Proof Size summary in bytes: - // Measured: `423` - // Estimated: `9418` - // Minimum execution time: 46_212 nanoseconds. - Weight::from_parts(46_748_000, 9418) + // Measured: `360` + // Estimated: `13378` + // Minimum execution time: 51_342_000 picoseconds. + Weight::from_parts(51_976_000, 13378) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -339,10 +342,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn thaw_communal() -> Weight { // Proof Size summary in bytes: - // Measured: `868` - // Estimated: `10956` - // Minimum execution time: 68_791 nanoseconds. - Weight::from_parts(69_504_000, 10956) + // Measured: `773` + // Estimated: `15906` + // Minimum execution time: 76_535_000 picoseconds. + Weight::from_parts(78_073_000, 15906) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -360,10 +363,10 @@ impl WeightInfo for () { /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) fn privatize() -> Weight { // Proof Size summary in bytes: - // Measured: `930` - // Estimated: `14680` - // Minimum execution time: 76_784 nanoseconds. - Weight::from_parts(77_575_000, 14680) + // Measured: `835` + // Estimated: `20620` + // Minimum execution time: 84_680_000 picoseconds. + Weight::from_parts(85_661_000, 20620) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -381,10 +384,10 @@ impl WeightInfo for () { /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn communify() -> Weight { // Proof Size summary in bytes: - // Measured: `769` - // Estimated: `14680` - // Minimum execution time: 64_543 nanoseconds. - Weight::from_parts(65_258_000, 14680) + // Measured: `674` + // Estimated: `20620` + // Minimum execution time: 72_828_000 picoseconds. + Weight::from_parts(73_553_000, 20620) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -396,10 +399,10 @@ impl WeightInfo for () { /// Proof: Nis QueueTotals (max_values: Some(1), max_size: Some(6002), added: 6497, mode: MaxEncodedLen) fn process_queues() -> Weight { // Proof Size summary in bytes: - // Measured: `6655` - // Estimated: `9635` - // Minimum execution time: 21_379 nanoseconds. - Weight::from_parts(21_736_000, 9635) + // Measured: `6624` + // Estimated: `12605` + // Minimum execution time: 23_311_000 picoseconds. + Weight::from_parts(23_855_000, 12605) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -408,9 +411,9 @@ impl WeightInfo for () { fn process_queue() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `50497` - // Minimum execution time: 4_302 nanoseconds. - Weight::from_parts(4_440_000, 50497) + // Estimated: `51487` + // Minimum execution time: 4_485_000 picoseconds. + Weight::from_parts(4_717_000, 51487) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -420,8 +423,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_758 nanoseconds. - Weight::from_parts(6_911_000, 0) + // Minimum execution time: 7_837_000 picoseconds. + Weight::from_parts(12_913_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/nomination-pools/src/weights.rs b/frame/nomination-pools/src/weights.rs index cf0048fa48dd9..003ba93eb8a7e 100644 --- a/frame/nomination-pools/src/weights.rs +++ b/frame/nomination-pools/src/weights.rs @@ -18,26 +18,28 @@ //! Autogenerated weights for pallet_nomination_pools //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_nomination_pools +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_nomination_pools -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/nomination-pools/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -104,10 +106,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn join() -> Weight { // Proof Size summary in bytes: - // Measured: `3650` + // Measured: `3300` // Estimated: `52435` - // Minimum execution time: 160_401_000 picoseconds. - Weight::from_parts(161_798_000, 52435) + // Minimum execution time: 160_675_000 picoseconds. + Weight::from_parts(162_605_000, 52435) .saturating_add(T::DbWeight::get().reads(18_u64)) .saturating_add(T::DbWeight::get().writes(12_u64)) } @@ -133,10 +135,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `3692` + // Measured: `3310` // Estimated: `49070` - // Minimum execution time: 157_668_000 picoseconds. - Weight::from_parts(161_129_000, 49070) + // Minimum execution time: 156_820_000 picoseconds. + Weight::from_parts(159_798_000, 49070) .saturating_add(T::DbWeight::get().reads(15_u64)) .saturating_add(T::DbWeight::get().writes(12_u64)) } @@ -164,10 +166,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra_other() -> Weight { // Proof Size summary in bytes: - // Measured: `3757` + // Measured: `3375` // Estimated: `52576` - // Minimum execution time: 176_034_000 picoseconds. - Weight::from_parts(176_956_000, 52576) + // Minimum execution time: 175_820_000 picoseconds. + Weight::from_parts(177_378_000, 52576) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(13_u64)) } @@ -185,10 +187,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn claim_payout() -> Weight { // Proof Size summary in bytes: - // Measured: `1331` + // Measured: `1171` // Estimated: `19532` - // Minimum execution time: 61_551_000 picoseconds. - Weight::from_parts(62_201_000, 19532) + // Minimum execution time: 62_011_000 picoseconds. + Weight::from_parts(62_680_000, 19532) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -224,10 +226,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: NominationPools CounterForSubPoolsStorage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn unbond() -> Weight { // Proof Size summary in bytes: - // Measured: `3935` + // Measured: `3586` // Estimated: `82816` - // Minimum execution time: 162_755_000 picoseconds. - Weight::from_parts(163_518_000, 82816) + // Minimum execution time: 163_294_000 picoseconds. + Weight::from_parts(164_375_000, 82816) .saturating_add(T::DbWeight::get().reads(19_u64)) .saturating_add(T::DbWeight::get().writes(13_u64)) } @@ -244,12 +246,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 100]`. fn pool_withdraw_unbonded(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1783` + // Measured: `1687` // Estimated: `18031` - // Minimum execution time: 54_752_000 picoseconds. - Weight::from_parts(56_248_171, 18031) - // Standard Error: 1_891 - .saturating_add(Weight::from_parts(4_767, 0).saturating_mul(s.into())) + // Minimum execution time: 54_775_000 picoseconds. + Weight::from_parts(55_724_944, 18031) + // Standard Error: 536 + .saturating_add(Weight::from_parts(10_059, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -276,12 +278,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2307` + // Measured: `2115` // Estimated: `54662` - // Minimum execution time: 106_166_000 picoseconds. - Weight::from_parts(107_806_373, 54662) - // Standard Error: 6_985 - .saturating_add(Weight::from_parts(18_449, 0).saturating_mul(s.into())) + // Minimum execution time: 106_820_000 picoseconds. + Weight::from_parts(109_870_849, 54662) + // Standard Error: 11_111 + .saturating_add(Weight::from_parts(2_006, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } @@ -330,12 +332,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_kill(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2694` - // Estimated: `87714` - // Minimum execution time: 170_047_000 picoseconds. - Weight::from_parts(172_125_770, 87714) - // Standard Error: 2_599 - .saturating_add(Weight::from_parts(9_964, 0).saturating_mul(s.into())) + // Measured: `2470` + // Estimated: `87490` + // Minimum execution time: 170_908_000 picoseconds. + Weight::from_parts(173_616_555, 87490) + // Standard Error: 2_324 + .saturating_add(Weight::from_parts(4_397, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(20_u64)) .saturating_add(T::DbWeight::get().writes(18_u64)) } @@ -383,10 +385,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn create() -> Weight { // Proof Size summary in bytes: - // Measured: `1321` + // Measured: `1289` // Estimated: `51410` - // Minimum execution time: 149_672_000 picoseconds. - Weight::from_parts(153_613_000, 51410) + // Minimum execution time: 148_934_000 picoseconds. + Weight::from_parts(149_702_000, 51410) .saturating_add(T::DbWeight::get().reads(21_u64)) .saturating_add(T::DbWeight::get().writes(15_u64)) } @@ -417,12 +419,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1913` + // Measured: `1849` // Estimated: `33934 + n * (2520 ±0)` - // Minimum execution time: 68_892_000 picoseconds. - Weight::from_parts(69_062_946, 33934) - // Standard Error: 6_448 - .saturating_add(Weight::from_parts(1_422_774, 0).saturating_mul(n.into())) + // Minimum execution time: 68_986_000 picoseconds. + Weight::from_parts(69_474_269, 33934) + // Standard Error: 6_602 + .saturating_add(Weight::from_parts(1_416_294, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(5_u64)) @@ -436,10 +438,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) fn set_state() -> Weight { // Proof Size summary in bytes: - // Measured: `1502` + // Measured: `1438` // Estimated: `11778` - // Minimum execution time: 36_447_000 picoseconds. - Weight::from_parts(36_837_000, 11778) + // Minimum execution time: 36_300_000 picoseconds. + Weight::from_parts(36_713_000, 11778) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -452,12 +454,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[1, 256]`. fn set_metadata(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `563` + // Measured: `531` // Estimated: `8909` - // Minimum execution time: 15_221_000 picoseconds. - Weight::from_parts(15_632_286, 8909) - // Standard Error: 343 - .saturating_add(Weight::from_parts(2_299, 0).saturating_mul(n.into())) + // Minimum execution time: 14_976_000 picoseconds. + Weight::from_parts(15_538_088, 8909) + // Standard Error: 71 + .saturating_add(Weight::from_parts(1_548, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -477,18 +479,18 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_409_000 picoseconds. - Weight::from_parts(7_702_000, 0) + // Minimum execution time: 7_259_000 picoseconds. + Weight::from_parts(7_499_000, 0) .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: NominationPools BondedPools (r:1 w:1) /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) fn update_roles() -> Weight { // Proof Size summary in bytes: - // Measured: `563` + // Measured: `531` // Estimated: `3685` - // Minimum execution time: 20_451_000 picoseconds. - Weight::from_parts(20_703_000, 3685) + // Minimum execution time: 20_454_000 picoseconds. + Weight::from_parts(20_771_000, 3685) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -512,10 +514,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill() -> Weight { // Proof Size summary in bytes: - // Measured: `2140` + // Measured: `2012` // Estimated: `29455` - // Minimum execution time: 66_001_000 picoseconds. - Weight::from_parts(66_894_000, 29455) + // Minimum execution time: 66_404_000 picoseconds. + Weight::from_parts(66_872_000, 29455) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -529,10 +531,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_commission() -> Weight { // Proof Size summary in bytes: - // Measured: `866` + // Measured: `770` // Estimated: `12324` - // Minimum execution time: 34_011_000 picoseconds. - Weight::from_parts(34_521_000, 12324) + // Minimum execution time: 34_240_000 picoseconds. + Weight::from_parts(34_797_000, 12324) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -540,10 +542,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) fn set_commission_max() -> Weight { // Proof Size summary in bytes: - // Measured: `603` + // Measured: `571` // Estimated: `3685` - // Minimum execution time: 19_524_000 picoseconds. - Weight::from_parts(19_855_000, 3685) + // Minimum execution time: 19_469_000 picoseconds. + Weight::from_parts(19_865_000, 3685) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -551,10 +553,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) fn set_commission_change_rate() -> Weight { // Proof Size summary in bytes: - // Measured: `563` + // Measured: `531` // Estimated: `3685` - // Minimum execution time: 20_457_000 picoseconds. - Weight::from_parts(20_698_000, 3685) + // Minimum execution time: 20_423_000 picoseconds. + Weight::from_parts(20_620_000, 3685) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -566,8 +568,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `542` // Estimated: `7208` - // Minimum execution time: 15_183_000 picoseconds. - Weight::from_parts(15_597_000, 7208) + // Minimum execution time: 15_346_000 picoseconds. + Weight::from_parts(15_613_000, 7208) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -581,10 +583,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn claim_commission() -> Weight { // Proof Size summary in bytes: - // Measured: `1096` + // Measured: `968` // Estimated: `12324` - // Minimum execution time: 48_957_000 picoseconds. - Weight::from_parts(50_207_000, 12324) + // Minimum execution time: 48_749_000 picoseconds. + Weight::from_parts(49_131_000, 12324) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -622,10 +624,10 @@ impl WeightInfo for () { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn join() -> Weight { // Proof Size summary in bytes: - // Measured: `3650` + // Measured: `3300` // Estimated: `52435` - // Minimum execution time: 160_401_000 picoseconds. - Weight::from_parts(161_798_000, 52435) + // Minimum execution time: 160_675_000 picoseconds. + Weight::from_parts(162_605_000, 52435) .saturating_add(RocksDbWeight::get().reads(18_u64)) .saturating_add(RocksDbWeight::get().writes(12_u64)) } @@ -651,10 +653,10 @@ impl WeightInfo for () { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `3692` + // Measured: `3310` // Estimated: `49070` - // Minimum execution time: 157_668_000 picoseconds. - Weight::from_parts(161_129_000, 49070) + // Minimum execution time: 156_820_000 picoseconds. + Weight::from_parts(159_798_000, 49070) .saturating_add(RocksDbWeight::get().reads(15_u64)) .saturating_add(RocksDbWeight::get().writes(12_u64)) } @@ -682,10 +684,10 @@ impl WeightInfo for () { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra_other() -> Weight { // Proof Size summary in bytes: - // Measured: `3757` + // Measured: `3375` // Estimated: `52576` - // Minimum execution time: 176_034_000 picoseconds. - Weight::from_parts(176_956_000, 52576) + // Minimum execution time: 175_820_000 picoseconds. + Weight::from_parts(177_378_000, 52576) .saturating_add(RocksDbWeight::get().reads(16_u64)) .saturating_add(RocksDbWeight::get().writes(13_u64)) } @@ -703,10 +705,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn claim_payout() -> Weight { // Proof Size summary in bytes: - // Measured: `1331` + // Measured: `1171` // Estimated: `19532` - // Minimum execution time: 61_551_000 picoseconds. - Weight::from_parts(62_201_000, 19532) + // Minimum execution time: 62_011_000 picoseconds. + Weight::from_parts(62_680_000, 19532) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -742,10 +744,10 @@ impl WeightInfo for () { /// Proof: NominationPools CounterForSubPoolsStorage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn unbond() -> Weight { // Proof Size summary in bytes: - // Measured: `3935` + // Measured: `3586` // Estimated: `82816` - // Minimum execution time: 162_755_000 picoseconds. - Weight::from_parts(163_518_000, 82816) + // Minimum execution time: 163_294_000 picoseconds. + Weight::from_parts(164_375_000, 82816) .saturating_add(RocksDbWeight::get().reads(19_u64)) .saturating_add(RocksDbWeight::get().writes(13_u64)) } @@ -762,12 +764,12 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 100]`. fn pool_withdraw_unbonded(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1783` + // Measured: `1687` // Estimated: `18031` - // Minimum execution time: 54_752_000 picoseconds. - Weight::from_parts(56_248_171, 18031) - // Standard Error: 1_891 - .saturating_add(Weight::from_parts(4_767, 0).saturating_mul(s.into())) + // Minimum execution time: 54_775_000 picoseconds. + Weight::from_parts(55_724_944, 18031) + // Standard Error: 536 + .saturating_add(Weight::from_parts(10_059, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -794,12 +796,12 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2307` + // Measured: `2115` // Estimated: `54662` - // Minimum execution time: 106_166_000 picoseconds. - Weight::from_parts(107_806_373, 54662) - // Standard Error: 6_985 - .saturating_add(Weight::from_parts(18_449, 0).saturating_mul(s.into())) + // Minimum execution time: 106_820_000 picoseconds. + Weight::from_parts(109_870_849, 54662) + // Standard Error: 11_111 + .saturating_add(Weight::from_parts(2_006, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(8_u64)) } @@ -848,12 +850,12 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_kill(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2694` - // Estimated: `87714` - // Minimum execution time: 170_047_000 picoseconds. - Weight::from_parts(172_125_770, 87714) - // Standard Error: 2_599 - .saturating_add(Weight::from_parts(9_964, 0).saturating_mul(s.into())) + // Measured: `2470` + // Estimated: `87490` + // Minimum execution time: 170_908_000 picoseconds. + Weight::from_parts(173_616_555, 87490) + // Standard Error: 2_324 + .saturating_add(Weight::from_parts(4_397, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(20_u64)) .saturating_add(RocksDbWeight::get().writes(18_u64)) } @@ -901,10 +903,10 @@ impl WeightInfo for () { /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn create() -> Weight { // Proof Size summary in bytes: - // Measured: `1321` + // Measured: `1289` // Estimated: `51410` - // Minimum execution time: 149_672_000 picoseconds. - Weight::from_parts(153_613_000, 51410) + // Minimum execution time: 148_934_000 picoseconds. + Weight::from_parts(149_702_000, 51410) .saturating_add(RocksDbWeight::get().reads(21_u64)) .saturating_add(RocksDbWeight::get().writes(15_u64)) } @@ -935,12 +937,12 @@ impl WeightInfo for () { /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1913` + // Measured: `1849` // Estimated: `33934 + n * (2520 ±0)` - // Minimum execution time: 68_892_000 picoseconds. - Weight::from_parts(69_062_946, 33934) - // Standard Error: 6_448 - .saturating_add(Weight::from_parts(1_422_774, 0).saturating_mul(n.into())) + // Minimum execution time: 68_986_000 picoseconds. + Weight::from_parts(69_474_269, 33934) + // Standard Error: 6_602 + .saturating_add(Weight::from_parts(1_416_294, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(5_u64)) @@ -954,10 +956,10 @@ impl WeightInfo for () { /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) fn set_state() -> Weight { // Proof Size summary in bytes: - // Measured: `1502` + // Measured: `1438` // Estimated: `11778` - // Minimum execution time: 36_447_000 picoseconds. - Weight::from_parts(36_837_000, 11778) + // Minimum execution time: 36_300_000 picoseconds. + Weight::from_parts(36_713_000, 11778) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -970,12 +972,12 @@ impl WeightInfo for () { /// The range of component `n` is `[1, 256]`. fn set_metadata(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `563` + // Measured: `531` // Estimated: `8909` - // Minimum execution time: 15_221_000 picoseconds. - Weight::from_parts(15_632_286, 8909) - // Standard Error: 343 - .saturating_add(Weight::from_parts(2_299, 0).saturating_mul(n.into())) + // Minimum execution time: 14_976_000 picoseconds. + Weight::from_parts(15_538_088, 8909) + // Standard Error: 71 + .saturating_add(Weight::from_parts(1_548, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -995,18 +997,18 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_409_000 picoseconds. - Weight::from_parts(7_702_000, 0) + // Minimum execution time: 7_259_000 picoseconds. + Weight::from_parts(7_499_000, 0) .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: NominationPools BondedPools (r:1 w:1) /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) fn update_roles() -> Weight { // Proof Size summary in bytes: - // Measured: `563` + // Measured: `531` // Estimated: `3685` - // Minimum execution time: 20_451_000 picoseconds. - Weight::from_parts(20_703_000, 3685) + // Minimum execution time: 20_454_000 picoseconds. + Weight::from_parts(20_771_000, 3685) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1030,10 +1032,10 @@ impl WeightInfo for () { /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill() -> Weight { // Proof Size summary in bytes: - // Measured: `2140` + // Measured: `2012` // Estimated: `29455` - // Minimum execution time: 66_001_000 picoseconds. - Weight::from_parts(66_894_000, 29455) + // Minimum execution time: 66_404_000 picoseconds. + Weight::from_parts(66_872_000, 29455) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -1047,10 +1049,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_commission() -> Weight { // Proof Size summary in bytes: - // Measured: `866` + // Measured: `770` // Estimated: `12324` - // Minimum execution time: 34_011_000 picoseconds. - Weight::from_parts(34_521_000, 12324) + // Minimum execution time: 34_240_000 picoseconds. + Weight::from_parts(34_797_000, 12324) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1058,10 +1060,10 @@ impl WeightInfo for () { /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) fn set_commission_max() -> Weight { // Proof Size summary in bytes: - // Measured: `603` + // Measured: `571` // Estimated: `3685` - // Minimum execution time: 19_524_000 picoseconds. - Weight::from_parts(19_855_000, 3685) + // Minimum execution time: 19_469_000 picoseconds. + Weight::from_parts(19_865_000, 3685) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1069,10 +1071,10 @@ impl WeightInfo for () { /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(220), added: 2695, mode: MaxEncodedLen) fn set_commission_change_rate() -> Weight { // Proof Size summary in bytes: - // Measured: `563` + // Measured: `531` // Estimated: `3685` - // Minimum execution time: 20_457_000 picoseconds. - Weight::from_parts(20_698_000, 3685) + // Minimum execution time: 20_423_000 picoseconds. + Weight::from_parts(20_620_000, 3685) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1084,8 +1086,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `542` // Estimated: `7208` - // Minimum execution time: 15_183_000 picoseconds. - Weight::from_parts(15_597_000, 7208) + // Minimum execution time: 15_346_000 picoseconds. + Weight::from_parts(15_613_000, 7208) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1099,10 +1101,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn claim_commission() -> Weight { // Proof Size summary in bytes: - // Measured: `1096` + // Measured: `968` // Estimated: `12324` - // Minimum execution time: 48_957_000 picoseconds. - Weight::from_parts(50_207_000, 12324) + // Minimum execution time: 48_749_000 picoseconds. + Weight::from_parts(49_131_000, 12324) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } diff --git a/frame/preimage/src/weights.rs b/frame/preimage/src/weights.rs index fa6bdc972fa47..168cb634c2d48 100644 --- a/frame/preimage/src/weights.rs +++ b/frame/preimage/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_preimage //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_preimage +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -72,12 +75,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 4194304]`. fn note_preimage(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `175` - // Estimated: `2566` - // Minimum execution time: 23_484 nanoseconds. - Weight::from_parts(23_828_000, 2566) + // Measured: `143` + // Estimated: `3556` + // Minimum execution time: 27_010_000 picoseconds. + Weight::from_parts(27_665_000, 3556) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_705, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_414, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -89,11 +92,11 @@ impl WeightInfo for SubstrateWeight { fn note_requested_preimage(s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 14_812 nanoseconds. - Weight::from_parts(14_949_000, 2566) + // Estimated: `3556` + // Minimum execution time: 16_984_000 picoseconds. + Weight::from_parts(17_455_000, 3556) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_707, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_414, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -105,11 +108,11 @@ impl WeightInfo for SubstrateWeight { fn note_no_deposit_preimage(s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 14_185 nanoseconds. - Weight::from_parts(14_398_000, 2566) + // Estimated: `3556` + // Minimum execution time: 16_579_000 picoseconds. + Weight::from_parts(16_849_000, 3556) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_709, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_414, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -119,10 +122,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) fn unnote_preimage() -> Weight { // Proof Size summary in bytes: - // Measured: `353` - // Estimated: `2566` - // Minimum execution time: 29_917 nanoseconds. - Weight::from_parts(30_691_000, 2566) + // Measured: `289` + // Estimated: `3556` + // Minimum execution time: 33_552_000 picoseconds. + Weight::from_parts(35_134_000, 3556) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -133,9 +136,9 @@ impl WeightInfo for SubstrateWeight { fn unnote_no_deposit_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `144` - // Estimated: `2566` - // Minimum execution time: 19_281 nanoseconds. - Weight::from_parts(20_121_000, 2566) + // Estimated: `3556` + // Minimum execution time: 22_102_000 picoseconds. + Weight::from_parts(22_860_000, 3556) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -143,10 +146,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn request_preimage() -> Weight { // Proof Size summary in bytes: - // Measured: `220` - // Estimated: `2566` - // Minimum execution time: 17_192 nanoseconds. - Weight::from_parts(18_637_000, 2566) + // Measured: `188` + // Estimated: `3556` + // Minimum execution time: 19_590_000 picoseconds. + Weight::from_parts(20_638_000, 3556) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -155,9 +158,9 @@ impl WeightInfo for SubstrateWeight { fn request_no_deposit_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `144` - // Estimated: `2566` - // Minimum execution time: 10_139 nanoseconds. - Weight::from_parts(10_773_000, 2566) + // Estimated: `3556` + // Minimum execution time: 11_689_000 picoseconds. + Weight::from_parts(12_577_000, 3556) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -166,9 +169,9 @@ impl WeightInfo for SubstrateWeight { fn request_unnoted_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `2566` - // Minimum execution time: 11_721 nanoseconds. - Weight::from_parts(12_313_000, 2566) + // Estimated: `3556` + // Minimum execution time: 13_673_000 picoseconds. + Weight::from_parts(14_210_000, 3556) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -177,9 +180,9 @@ impl WeightInfo for SubstrateWeight { fn request_requested_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 7_263 nanoseconds. - Weight::from_parts(7_547_000, 2566) + // Estimated: `3556` + // Minimum execution time: 8_810_000 picoseconds. + Weight::from_parts(9_044_000, 3556) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -190,9 +193,9 @@ impl WeightInfo for SubstrateWeight { fn unrequest_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `144` - // Estimated: `2566` - // Minimum execution time: 17_785 nanoseconds. - Weight::from_parts(18_501_000, 2566) + // Estimated: `3556` + // Minimum execution time: 21_236_000 picoseconds. + Weight::from_parts(21_684_000, 3556) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -201,9 +204,9 @@ impl WeightInfo for SubstrateWeight { fn unrequest_unnoted_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 7_090 nanoseconds. - Weight::from_parts(7_319_000, 2566) + // Estimated: `3556` + // Minimum execution time: 8_709_000 picoseconds. + Weight::from_parts(8_970_000, 3556) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -212,9 +215,9 @@ impl WeightInfo for SubstrateWeight { fn unrequest_multi_referenced_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 7_253 nanoseconds. - Weight::from_parts(7_508_000, 2566) + // Estimated: `3556` + // Minimum execution time: 8_976_000 picoseconds. + Weight::from_parts(9_164_000, 3556) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -229,12 +232,12 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 4194304]`. fn note_preimage(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `175` - // Estimated: `2566` - // Minimum execution time: 23_484 nanoseconds. - Weight::from_parts(23_828_000, 2566) + // Measured: `143` + // Estimated: `3556` + // Minimum execution time: 27_010_000 picoseconds. + Weight::from_parts(27_665_000, 3556) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_705, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_414, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -246,11 +249,11 @@ impl WeightInfo for () { fn note_requested_preimage(s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 14_812 nanoseconds. - Weight::from_parts(14_949_000, 2566) + // Estimated: `3556` + // Minimum execution time: 16_984_000 picoseconds. + Weight::from_parts(17_455_000, 3556) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_707, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_414, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -262,11 +265,11 @@ impl WeightInfo for () { fn note_no_deposit_preimage(s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 14_185 nanoseconds. - Weight::from_parts(14_398_000, 2566) + // Estimated: `3556` + // Minimum execution time: 16_579_000 picoseconds. + Weight::from_parts(16_849_000, 3556) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_709, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_414, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -276,10 +279,10 @@ impl WeightInfo for () { /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) fn unnote_preimage() -> Weight { // Proof Size summary in bytes: - // Measured: `353` - // Estimated: `2566` - // Minimum execution time: 29_917 nanoseconds. - Weight::from_parts(30_691_000, 2566) + // Measured: `289` + // Estimated: `3556` + // Minimum execution time: 33_552_000 picoseconds. + Weight::from_parts(35_134_000, 3556) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -290,9 +293,9 @@ impl WeightInfo for () { fn unnote_no_deposit_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `144` - // Estimated: `2566` - // Minimum execution time: 19_281 nanoseconds. - Weight::from_parts(20_121_000, 2566) + // Estimated: `3556` + // Minimum execution time: 22_102_000 picoseconds. + Weight::from_parts(22_860_000, 3556) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -300,10 +303,10 @@ impl WeightInfo for () { /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn request_preimage() -> Weight { // Proof Size summary in bytes: - // Measured: `220` - // Estimated: `2566` - // Minimum execution time: 17_192 nanoseconds. - Weight::from_parts(18_637_000, 2566) + // Measured: `188` + // Estimated: `3556` + // Minimum execution time: 19_590_000 picoseconds. + Weight::from_parts(20_638_000, 3556) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -312,9 +315,9 @@ impl WeightInfo for () { fn request_no_deposit_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `144` - // Estimated: `2566` - // Minimum execution time: 10_139 nanoseconds. - Weight::from_parts(10_773_000, 2566) + // Estimated: `3556` + // Minimum execution time: 11_689_000 picoseconds. + Weight::from_parts(12_577_000, 3556) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -323,9 +326,9 @@ impl WeightInfo for () { fn request_unnoted_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `2566` - // Minimum execution time: 11_721 nanoseconds. - Weight::from_parts(12_313_000, 2566) + // Estimated: `3556` + // Minimum execution time: 13_673_000 picoseconds. + Weight::from_parts(14_210_000, 3556) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -334,9 +337,9 @@ impl WeightInfo for () { fn request_requested_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 7_263 nanoseconds. - Weight::from_parts(7_547_000, 2566) + // Estimated: `3556` + // Minimum execution time: 8_810_000 picoseconds. + Weight::from_parts(9_044_000, 3556) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -347,9 +350,9 @@ impl WeightInfo for () { fn unrequest_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `144` - // Estimated: `2566` - // Minimum execution time: 17_785 nanoseconds. - Weight::from_parts(18_501_000, 2566) + // Estimated: `3556` + // Minimum execution time: 21_236_000 picoseconds. + Weight::from_parts(21_684_000, 3556) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -358,9 +361,9 @@ impl WeightInfo for () { fn unrequest_unnoted_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 7_090 nanoseconds. - Weight::from_parts(7_319_000, 2566) + // Estimated: `3556` + // Minimum execution time: 8_709_000 picoseconds. + Weight::from_parts(8_970_000, 3556) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -369,9 +372,9 @@ impl WeightInfo for () { fn unrequest_multi_referenced_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 7_253 nanoseconds. - Weight::from_parts(7_508_000, 2566) + // Estimated: `3556` + // Minimum execution time: 8_976_000 picoseconds. + Weight::from_parts(9_164_000, 3556) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/proxy/src/weights.rs b/frame/proxy/src/weights.rs index 5b70b61e569b4..28e24c4682f18 100644 --- a/frame/proxy/src/weights.rs +++ b/frame/proxy/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_proxy //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_proxy +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -68,12 +71,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 31]`. fn proxy(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `193 + p * (37 ±0)` - // Estimated: `3716` - // Minimum execution time: 14_461 nanoseconds. - Weight::from_parts(14_913_927, 3716) - // Standard Error: 1_174 - .saturating_add(Weight::from_parts(36_087, 0).saturating_mul(p.into())) + // Measured: `161 + p * (37 ±0)` + // Estimated: `4706` + // Minimum execution time: 16_407_000 picoseconds. + Weight::from_parts(17_044_509, 4706) + // Standard Error: 1_177 + .saturating_add(Weight::from_parts(36_533, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Proxy Proxies (r:1 w:0) @@ -86,14 +89,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 31]`. fn proxy_announced(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `584 + a * (68 ±0) + p * (37 ±0)` - // Estimated: `11027` - // Minimum execution time: 31_523 nanoseconds. - Weight::from_parts(31_116_270, 11027) - // Standard Error: 1_789 - .saturating_add(Weight::from_parts(135_656, 0).saturating_mul(a.into())) - // Standard Error: 1_849 - .saturating_add(Weight::from_parts(53_893, 0).saturating_mul(p.into())) + // Measured: `488 + a * (68 ±0) + p * (37 ±0)` + // Estimated: `13997` + // Minimum execution time: 38_523_000 picoseconds. + Weight::from_parts(39_227_232, 13997) + // Standard Error: 5_703 + .saturating_add(Weight::from_parts(136_003, 0).saturating_mul(a.into())) + // Standard Error: 5_893 + .saturating_add(Weight::from_parts(42_397, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -105,14 +108,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 31]`. fn remove_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `467 + a * (68 ±0)` - // Estimated: `7311` - // Minimum execution time: 19_363 nanoseconds. - Weight::from_parts(20_282_191, 7311) - // Standard Error: 1_084 - .saturating_add(Weight::from_parts(133_825, 0).saturating_mul(a.into())) - // Standard Error: 1_120 - .saturating_add(Weight::from_parts(3_434, 0).saturating_mul(p.into())) + // Measured: `403 + a * (68 ±0)` + // Estimated: `9291` + // Minimum execution time: 22_541_000 picoseconds. + Weight::from_parts(23_402_268, 9291) + // Standard Error: 3_242 + .saturating_add(Weight::from_parts(178_017, 0).saturating_mul(a.into())) + // Standard Error: 3_349 + .saturating_add(Weight::from_parts(6_230, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -124,14 +127,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 31]`. fn reject_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `467 + a * (68 ±0)` - // Estimated: `7311` - // Minimum execution time: 19_363 nanoseconds. - Weight::from_parts(20_211_584, 7311) - // Standard Error: 1_171 - .saturating_add(Weight::from_parts(136_984, 0).saturating_mul(a.into())) - // Standard Error: 1_210 - .saturating_add(Weight::from_parts(3_686, 0).saturating_mul(p.into())) + // Measured: `403 + a * (68 ±0)` + // Estimated: `9291` + // Minimum execution time: 22_539_000 picoseconds. + Weight::from_parts(23_479_286, 9291) + // Standard Error: 1_329 + .saturating_add(Weight::from_parts(174_021, 0).saturating_mul(a.into())) + // Standard Error: 1_373 + .saturating_add(Weight::from_parts(6_465, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -145,14 +148,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 31]`. fn announce(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `516 + a * (68 ±0) + p * (37 ±0)` - // Estimated: `11027` - // Minimum execution time: 27_811 nanoseconds. - Weight::from_parts(27_965_813, 11027) - // Standard Error: 1_987 - .saturating_add(Weight::from_parts(124_133, 0).saturating_mul(a.into())) - // Standard Error: 2_053 - .saturating_add(Weight::from_parts(54_692, 0).saturating_mul(p.into())) + // Measured: `420 + a * (68 ±0) + p * (37 ±0)` + // Estimated: `13997` + // Minimum execution time: 32_049_000 picoseconds. + Weight::from_parts(35_352_453, 13997) + // Standard Error: 4_389 + .saturating_add(Weight::from_parts(144_573, 0).saturating_mul(a.into())) + // Standard Error: 4_535 + .saturating_add(Weight::from_parts(41_849, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -161,12 +164,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 31]`. fn add_proxy(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `193 + p * (37 ±0)` - // Estimated: `3716` - // Minimum execution time: 20_922 nanoseconds. - Weight::from_parts(21_551_797, 3716) - // Standard Error: 1_425 - .saturating_add(Weight::from_parts(58_434, 0).saturating_mul(p.into())) + // Measured: `161 + p * (37 ±0)` + // Estimated: `4706` + // Minimum execution time: 24_491_000 picoseconds. + Weight::from_parts(25_291_582, 4706) + // Standard Error: 11_080 + .saturating_add(Weight::from_parts(68_024, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -175,12 +178,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 31]`. fn remove_proxy(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `193 + p * (37 ±0)` - // Estimated: `3716` - // Minimum execution time: 20_812 nanoseconds. - Weight::from_parts(21_660_732, 3716) - // Standard Error: 1_438 - .saturating_add(Weight::from_parts(68_740, 0).saturating_mul(p.into())) + // Measured: `161 + p * (37 ±0)` + // Estimated: `4706` + // Minimum execution time: 23_849_000 picoseconds. + Weight::from_parts(25_370_806, 4706) + // Standard Error: 8_763 + .saturating_add(Weight::from_parts(63_413, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -189,12 +192,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 31]`. fn remove_proxies(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `193 + p * (37 ±0)` - // Estimated: `3716` - // Minimum execution time: 16_786 nanoseconds. - Weight::from_parts(17_249_958, 3716) - // Standard Error: 1_007 - .saturating_add(Weight::from_parts(37_546, 0).saturating_mul(p.into())) + // Measured: `161 + p * (37 ±0)` + // Estimated: `4706` + // Minimum execution time: 19_488_000 picoseconds. + Weight::from_parts(20_219_817, 4706) + // Standard Error: 1_385 + .saturating_add(Weight::from_parts(30_354, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -204,11 +207,11 @@ impl WeightInfo for SubstrateWeight { fn create_pure(p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `173` - // Estimated: `3716` - // Minimum execution time: 22_764 nanoseconds. - Weight::from_parts(23_539_039, 3716) - // Standard Error: 814 - .saturating_add(Weight::from_parts(144, 0).saturating_mul(p.into())) + // Estimated: `4706` + // Minimum execution time: 25_864_000 picoseconds. + Weight::from_parts(26_712_232, 4706) + // Standard Error: 1_331 + .saturating_add(Weight::from_parts(4_401, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -217,12 +220,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[0, 30]`. fn kill_pure(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `230 + p * (37 ±0)` - // Estimated: `3716` - // Minimum execution time: 17_720 nanoseconds. - Weight::from_parts(18_428_849, 3716) - // Standard Error: 1_093 - .saturating_add(Weight::from_parts(34_600, 0).saturating_mul(p.into())) + // Measured: `198 + p * (37 ±0)` + // Estimated: `4706` + // Minimum execution time: 20_488_000 picoseconds. + Weight::from_parts(21_135_155, 4706) + // Standard Error: 1_255 + .saturating_add(Weight::from_parts(36_312, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -235,12 +238,12 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 31]`. fn proxy(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `193 + p * (37 ±0)` - // Estimated: `3716` - // Minimum execution time: 14_461 nanoseconds. - Weight::from_parts(14_913_927, 3716) - // Standard Error: 1_174 - .saturating_add(Weight::from_parts(36_087, 0).saturating_mul(p.into())) + // Measured: `161 + p * (37 ±0)` + // Estimated: `4706` + // Minimum execution time: 16_407_000 picoseconds. + Weight::from_parts(17_044_509, 4706) + // Standard Error: 1_177 + .saturating_add(Weight::from_parts(36_533, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Proxy Proxies (r:1 w:0) @@ -253,14 +256,14 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 31]`. fn proxy_announced(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `584 + a * (68 ±0) + p * (37 ±0)` - // Estimated: `11027` - // Minimum execution time: 31_523 nanoseconds. - Weight::from_parts(31_116_270, 11027) - // Standard Error: 1_789 - .saturating_add(Weight::from_parts(135_656, 0).saturating_mul(a.into())) - // Standard Error: 1_849 - .saturating_add(Weight::from_parts(53_893, 0).saturating_mul(p.into())) + // Measured: `488 + a * (68 ±0) + p * (37 ±0)` + // Estimated: `13997` + // Minimum execution time: 38_523_000 picoseconds. + Weight::from_parts(39_227_232, 13997) + // Standard Error: 5_703 + .saturating_add(Weight::from_parts(136_003, 0).saturating_mul(a.into())) + // Standard Error: 5_893 + .saturating_add(Weight::from_parts(42_397, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -272,14 +275,14 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 31]`. fn remove_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `467 + a * (68 ±0)` - // Estimated: `7311` - // Minimum execution time: 19_363 nanoseconds. - Weight::from_parts(20_282_191, 7311) - // Standard Error: 1_084 - .saturating_add(Weight::from_parts(133_825, 0).saturating_mul(a.into())) - // Standard Error: 1_120 - .saturating_add(Weight::from_parts(3_434, 0).saturating_mul(p.into())) + // Measured: `403 + a * (68 ±0)` + // Estimated: `9291` + // Minimum execution time: 22_541_000 picoseconds. + Weight::from_parts(23_402_268, 9291) + // Standard Error: 3_242 + .saturating_add(Weight::from_parts(178_017, 0).saturating_mul(a.into())) + // Standard Error: 3_349 + .saturating_add(Weight::from_parts(6_230, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -291,14 +294,14 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 31]`. fn reject_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `467 + a * (68 ±0)` - // Estimated: `7311` - // Minimum execution time: 19_363 nanoseconds. - Weight::from_parts(20_211_584, 7311) - // Standard Error: 1_171 - .saturating_add(Weight::from_parts(136_984, 0).saturating_mul(a.into())) - // Standard Error: 1_210 - .saturating_add(Weight::from_parts(3_686, 0).saturating_mul(p.into())) + // Measured: `403 + a * (68 ±0)` + // Estimated: `9291` + // Minimum execution time: 22_539_000 picoseconds. + Weight::from_parts(23_479_286, 9291) + // Standard Error: 1_329 + .saturating_add(Weight::from_parts(174_021, 0).saturating_mul(a.into())) + // Standard Error: 1_373 + .saturating_add(Weight::from_parts(6_465, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -312,14 +315,14 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 31]`. fn announce(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `516 + a * (68 ±0) + p * (37 ±0)` - // Estimated: `11027` - // Minimum execution time: 27_811 nanoseconds. - Weight::from_parts(27_965_813, 11027) - // Standard Error: 1_987 - .saturating_add(Weight::from_parts(124_133, 0).saturating_mul(a.into())) - // Standard Error: 2_053 - .saturating_add(Weight::from_parts(54_692, 0).saturating_mul(p.into())) + // Measured: `420 + a * (68 ±0) + p * (37 ±0)` + // Estimated: `13997` + // Minimum execution time: 32_049_000 picoseconds. + Weight::from_parts(35_352_453, 13997) + // Standard Error: 4_389 + .saturating_add(Weight::from_parts(144_573, 0).saturating_mul(a.into())) + // Standard Error: 4_535 + .saturating_add(Weight::from_parts(41_849, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -328,12 +331,12 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 31]`. fn add_proxy(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `193 + p * (37 ±0)` - // Estimated: `3716` - // Minimum execution time: 20_922 nanoseconds. - Weight::from_parts(21_551_797, 3716) - // Standard Error: 1_425 - .saturating_add(Weight::from_parts(58_434, 0).saturating_mul(p.into())) + // Measured: `161 + p * (37 ±0)` + // Estimated: `4706` + // Minimum execution time: 24_491_000 picoseconds. + Weight::from_parts(25_291_582, 4706) + // Standard Error: 11_080 + .saturating_add(Weight::from_parts(68_024, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -342,12 +345,12 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 31]`. fn remove_proxy(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `193 + p * (37 ±0)` - // Estimated: `3716` - // Minimum execution time: 20_812 nanoseconds. - Weight::from_parts(21_660_732, 3716) - // Standard Error: 1_438 - .saturating_add(Weight::from_parts(68_740, 0).saturating_mul(p.into())) + // Measured: `161 + p * (37 ±0)` + // Estimated: `4706` + // Minimum execution time: 23_849_000 picoseconds. + Weight::from_parts(25_370_806, 4706) + // Standard Error: 8_763 + .saturating_add(Weight::from_parts(63_413, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -356,12 +359,12 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 31]`. fn remove_proxies(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `193 + p * (37 ±0)` - // Estimated: `3716` - // Minimum execution time: 16_786 nanoseconds. - Weight::from_parts(17_249_958, 3716) - // Standard Error: 1_007 - .saturating_add(Weight::from_parts(37_546, 0).saturating_mul(p.into())) + // Measured: `161 + p * (37 ±0)` + // Estimated: `4706` + // Minimum execution time: 19_488_000 picoseconds. + Weight::from_parts(20_219_817, 4706) + // Standard Error: 1_385 + .saturating_add(Weight::from_parts(30_354, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -371,11 +374,11 @@ impl WeightInfo for () { fn create_pure(p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `173` - // Estimated: `3716` - // Minimum execution time: 22_764 nanoseconds. - Weight::from_parts(23_539_039, 3716) - // Standard Error: 814 - .saturating_add(Weight::from_parts(144, 0).saturating_mul(p.into())) + // Estimated: `4706` + // Minimum execution time: 25_864_000 picoseconds. + Weight::from_parts(26_712_232, 4706) + // Standard Error: 1_331 + .saturating_add(Weight::from_parts(4_401, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -384,12 +387,12 @@ impl WeightInfo for () { /// The range of component `p` is `[0, 30]`. fn kill_pure(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `230 + p * (37 ±0)` - // Estimated: `3716` - // Minimum execution time: 17_720 nanoseconds. - Weight::from_parts(18_428_849, 3716) - // Standard Error: 1_093 - .saturating_add(Weight::from_parts(34_600, 0).saturating_mul(p.into())) + // Measured: `198 + p * (37 ±0)` + // Estimated: `4706` + // Minimum execution time: 20_488_000 picoseconds. + Weight::from_parts(21_135_155, 4706) + // Standard Error: 1_255 + .saturating_add(Weight::from_parts(36_312, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/ranked-collective/src/weights.rs b/frame/ranked-collective/src/weights.rs index 8d6c1620d81f8..e25737a1df8f0 100644 --- a/frame/ranked-collective/src/weights.rs +++ b/frame/ranked-collective/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_ranked_collective //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_ranked_collective +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -70,9 +73,9 @@ impl WeightInfo for SubstrateWeight { fn add_member() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `5006` - // Minimum execution time: 16_334 nanoseconds. - Weight::from_parts(16_784_000, 5006) + // Estimated: `6986` + // Minimum execution time: 19_174_000 picoseconds. + Weight::from_parts(19_391_000, 6986) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -88,11 +91,11 @@ impl WeightInfo for SubstrateWeight { fn remove_member(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `583 + r * (281 ±0)` - // Estimated: `10064 + r * (7547 ±0)` - // Minimum execution time: 26_177 nanoseconds. - Weight::from_parts(29_245_248, 10064) - // Standard Error: 18_611 - .saturating_add(Weight::from_parts(10_916_516, 0).saturating_mul(r.into())) + // Estimated: `14024 + r * (7547 ±0)` + // Minimum execution time: 30_972_000 picoseconds. + Weight::from_parts(35_526_205, 14024) + // Standard Error: 47_832 + .saturating_add(Weight::from_parts(12_838_739, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) @@ -111,11 +114,11 @@ impl WeightInfo for SubstrateWeight { fn promote_member(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `281 + r * (17 ±0)` - // Estimated: `5006` - // Minimum execution time: 18_953 nanoseconds. - Weight::from_parts(19_570_567, 5006) - // Standard Error: 4_156 - .saturating_add(Weight::from_parts(263_843, 0).saturating_mul(r.into())) + // Estimated: `6986` + // Minimum execution time: 21_573_000 picoseconds. + Weight::from_parts(22_184_210, 6986) + // Standard Error: 10_584 + .saturating_add(Weight::from_parts(289_535, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -131,11 +134,11 @@ impl WeightInfo for SubstrateWeight { fn demote_member(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `599 + r * (72 ±0)` - // Estimated: `10064` - // Minimum execution time: 26_243 nanoseconds. - Weight::from_parts(28_532_816, 10064) - // Standard Error: 22_689 - .saturating_add(Weight::from_parts(614_464, 0).saturating_mul(r.into())) + // Estimated: `14024` + // Minimum execution time: 30_249_000 picoseconds. + Weight::from_parts(32_702_502, 14024) + // Standard Error: 26_725 + .saturating_add(Weight::from_parts(651_139, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -149,10 +152,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn vote() -> Weight { // Proof Size summary in bytes: - // Measured: `626` - // Estimated: `226856` - // Minimum execution time: 41_121 nanoseconds. - Weight::from_parts(41_606_000, 226856) + // Measured: `595` + // Estimated: `230816` + // Minimum execution time: 46_972_000 picoseconds. + Weight::from_parts(47_617_000, 230816) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -160,19 +163,21 @@ impl WeightInfo for SubstrateWeight { /// Proof: RankedPolls ReferendumInfoFor (max_values: None, max_size: Some(330), added: 2805, mode: MaxEncodedLen) /// Storage: RankedCollective VotingCleanup (r:1 w:0) /// Proof: RankedCollective VotingCleanup (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) - /// Storage: RankedCollective Voting (r:0 w:100) + /// Storage: RankedCollective Voting (r:100 w:100) /// Proof: RankedCollective Voting (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) /// The range of component `n` is `[0, 100]`. fn cleanup_poll(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `461 + n * (50 ±0)` - // Estimated: `5394` - // Minimum execution time: 13_245 nanoseconds. - Weight::from_parts(17_420_271, 5394) - // Standard Error: 1_503 - .saturating_add(Weight::from_parts(952_500, 0).saturating_mul(n.into())) + // Measured: `429 + n * (50 ±0)` + // Estimated: `8364 + n * (2540 ±0)` + // Minimum execution time: 15_301_000 picoseconds. + Weight::from_parts(19_308_613, 8364) + // Standard Error: 1_792 + .saturating_add(Weight::from_parts(1_015_251, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) } } @@ -189,9 +194,9 @@ impl WeightInfo for () { fn add_member() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `5006` - // Minimum execution time: 16_334 nanoseconds. - Weight::from_parts(16_784_000, 5006) + // Estimated: `6986` + // Minimum execution time: 19_174_000 picoseconds. + Weight::from_parts(19_391_000, 6986) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -207,11 +212,11 @@ impl WeightInfo for () { fn remove_member(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `583 + r * (281 ±0)` - // Estimated: `10064 + r * (7547 ±0)` - // Minimum execution time: 26_177 nanoseconds. - Weight::from_parts(29_245_248, 10064) - // Standard Error: 18_611 - .saturating_add(Weight::from_parts(10_916_516, 0).saturating_mul(r.into())) + // Estimated: `14024 + r * (7547 ±0)` + // Minimum execution time: 30_972_000 picoseconds. + Weight::from_parts(35_526_205, 14024) + // Standard Error: 47_832 + .saturating_add(Weight::from_parts(12_838_739, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) @@ -230,11 +235,11 @@ impl WeightInfo for () { fn promote_member(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `281 + r * (17 ±0)` - // Estimated: `5006` - // Minimum execution time: 18_953 nanoseconds. - Weight::from_parts(19_570_567, 5006) - // Standard Error: 4_156 - .saturating_add(Weight::from_parts(263_843, 0).saturating_mul(r.into())) + // Estimated: `6986` + // Minimum execution time: 21_573_000 picoseconds. + Weight::from_parts(22_184_210, 6986) + // Standard Error: 10_584 + .saturating_add(Weight::from_parts(289_535, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -250,11 +255,11 @@ impl WeightInfo for () { fn demote_member(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `599 + r * (72 ±0)` - // Estimated: `10064` - // Minimum execution time: 26_243 nanoseconds. - Weight::from_parts(28_532_816, 10064) - // Standard Error: 22_689 - .saturating_add(Weight::from_parts(614_464, 0).saturating_mul(r.into())) + // Estimated: `14024` + // Minimum execution time: 30_249_000 picoseconds. + Weight::from_parts(32_702_502, 14024) + // Standard Error: 26_725 + .saturating_add(Weight::from_parts(651_139, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -268,10 +273,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn vote() -> Weight { // Proof Size summary in bytes: - // Measured: `626` - // Estimated: `226856` - // Minimum execution time: 41_121 nanoseconds. - Weight::from_parts(41_606_000, 226856) + // Measured: `595` + // Estimated: `230816` + // Minimum execution time: 46_972_000 picoseconds. + Weight::from_parts(47_617_000, 230816) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -279,18 +284,20 @@ impl WeightInfo for () { /// Proof: RankedPolls ReferendumInfoFor (max_values: None, max_size: Some(330), added: 2805, mode: MaxEncodedLen) /// Storage: RankedCollective VotingCleanup (r:1 w:0) /// Proof: RankedCollective VotingCleanup (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) - /// Storage: RankedCollective Voting (r:0 w:100) + /// Storage: RankedCollective Voting (r:100 w:100) /// Proof: RankedCollective Voting (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) /// The range of component `n` is `[0, 100]`. fn cleanup_poll(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `461 + n * (50 ±0)` - // Estimated: `5394` - // Minimum execution time: 13_245 nanoseconds. - Weight::from_parts(17_420_271, 5394) - // Standard Error: 1_503 - .saturating_add(Weight::from_parts(952_500, 0).saturating_mul(n.into())) + // Measured: `429 + n * (50 ±0)` + // Estimated: `8364 + n * (2540 ±0)` + // Minimum execution time: 15_301_000 picoseconds. + Weight::from_parts(19_308_613, 8364) + // Standard Error: 1_792 + .saturating_add(Weight::from_parts(1_015_251, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) } } diff --git a/frame/recovery/src/weights.rs b/frame/recovery/src/weights.rs index 6f8818f819bad..8245b9606deee 100644 --- a/frame/recovery/src/weights.rs +++ b/frame/recovery/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_recovery //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_recovery +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -67,9 +70,9 @@ impl WeightInfo for SubstrateWeight { fn as_recovered() -> Weight { // Proof Size summary in bytes: // Measured: `281` - // Estimated: `2555` - // Minimum execution time: 8_866 nanoseconds. - Weight::from_parts(9_065_000, 2555) + // Estimated: `3545` + // Minimum execution time: 9_937_000 picoseconds. + Weight::from_parts(10_213_000, 3545) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Recovery Proxy (r:0 w:1) @@ -78,8 +81,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_893 nanoseconds. - Weight::from_parts(9_177_000, 0) + // Minimum execution time: 9_704_000 picoseconds. + Weight::from_parts(9_997_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Recovery Recoverable (r:1 w:1) @@ -88,11 +91,11 @@ impl WeightInfo for SubstrateWeight { fn create_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `175` - // Estimated: `2826` - // Minimum execution time: 20_662 nanoseconds. - Weight::from_parts(21_378_064, 2826) - // Standard Error: 3_350 - .saturating_add(Weight::from_parts(83_738, 0).saturating_mul(n.into())) + // Estimated: `3816` + // Minimum execution time: 23_260_000 picoseconds. + Weight::from_parts(24_408_081, 3816) + // Standard Error: 3_086 + .saturating_add(Weight::from_parts(41_628, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -103,9 +106,9 @@ impl WeightInfo for SubstrateWeight { fn initiate_recovery() -> Weight { // Proof Size summary in bytes: // Measured: `272` - // Estimated: `5690` - // Minimum execution time: 24_805 nanoseconds. - Weight::from_parts(25_273_000, 5690) + // Estimated: `7670` + // Minimum execution time: 28_148_000 picoseconds. + Weight::from_parts(28_577_000, 7670) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -116,12 +119,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[1, 9]`. fn vouch_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `423 + n * (64 ±0)` - // Estimated: `5690` - // Minimum execution time: 17_837 nanoseconds. - Weight::from_parts(18_429_664, 5690) - // Standard Error: 3_187 - .saturating_add(Weight::from_parts(143_648, 0).saturating_mul(n.into())) + // Measured: `360 + n * (64 ±0)` + // Estimated: `7670` + // Minimum execution time: 20_395_000 picoseconds. + Weight::from_parts(21_287_972, 7670) + // Standard Error: 4_464 + .saturating_add(Weight::from_parts(170_214, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -134,12 +137,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[1, 9]`. fn claim_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `455 + n * (64 ±0)` - // Estimated: `8245` - // Minimum execution time: 21_960 nanoseconds. - Weight::from_parts(22_529_644, 8245) - // Standard Error: 2_945 - .saturating_add(Weight::from_parts(85_604, 0).saturating_mul(n.into())) + // Measured: `392 + n * (64 ±0)` + // Estimated: `11215` + // Minimum execution time: 24_902_000 picoseconds. + Weight::from_parts(25_662_621, 11215) + // Standard Error: 3_101 + .saturating_add(Weight::from_parts(60_748, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -150,12 +153,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[1, 9]`. fn close_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `576 + n * (32 ±0)` - // Estimated: `5467` - // Minimum execution time: 26_054 nanoseconds. - Weight::from_parts(26_724_866, 5467) - // Standard Error: 2_645 - .saturating_add(Weight::from_parts(104_301, 0).saturating_mul(n.into())) + // Measured: `513 + n * (32 ±0)` + // Estimated: `7447` + // Minimum execution time: 30_071_000 picoseconds. + Weight::from_parts(30_727_760, 7447) + // Standard Error: 4_442 + .saturating_add(Weight::from_parts(98_153, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -164,14 +167,12 @@ impl WeightInfo for SubstrateWeight { /// Storage: Recovery Recoverable (r:1 w:1) /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) /// The range of component `n` is `[1, 9]`. - fn remove_recovery(n: u32, ) -> Weight { + fn remove_recovery(_n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `302 + n * (32 ±0)` - // Estimated: `5690` - // Minimum execution time: 25_110 nanoseconds. - Weight::from_parts(25_805_837, 5690) - // Standard Error: 2_732 - .saturating_add(Weight::from_parts(73_458, 0).saturating_mul(n.into())) + // Measured: `270 + n * (32 ±0)` + // Estimated: `7670` + // Minimum execution time: 29_088_000 picoseconds. + Weight::from_parts(30_535_744, 7670) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -180,9 +181,9 @@ impl WeightInfo for SubstrateWeight { fn cancel_recovered() -> Weight { // Proof Size summary in bytes: // Measured: `281` - // Estimated: `2555` - // Minimum execution time: 11_061 nanoseconds. - Weight::from_parts(11_291_000, 2555) + // Estimated: `3545` + // Minimum execution time: 12_712_000 picoseconds. + Weight::from_parts(12_980_000, 3545) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -195,9 +196,9 @@ impl WeightInfo for () { fn as_recovered() -> Weight { // Proof Size summary in bytes: // Measured: `281` - // Estimated: `2555` - // Minimum execution time: 8_866 nanoseconds. - Weight::from_parts(9_065_000, 2555) + // Estimated: `3545` + // Minimum execution time: 9_937_000 picoseconds. + Weight::from_parts(10_213_000, 3545) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Recovery Proxy (r:0 w:1) @@ -206,8 +207,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_893 nanoseconds. - Weight::from_parts(9_177_000, 0) + // Minimum execution time: 9_704_000 picoseconds. + Weight::from_parts(9_997_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Recovery Recoverable (r:1 w:1) @@ -216,11 +217,11 @@ impl WeightInfo for () { fn create_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `175` - // Estimated: `2826` - // Minimum execution time: 20_662 nanoseconds. - Weight::from_parts(21_378_064, 2826) - // Standard Error: 3_350 - .saturating_add(Weight::from_parts(83_738, 0).saturating_mul(n.into())) + // Estimated: `3816` + // Minimum execution time: 23_260_000 picoseconds. + Weight::from_parts(24_408_081, 3816) + // Standard Error: 3_086 + .saturating_add(Weight::from_parts(41_628, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -231,9 +232,9 @@ impl WeightInfo for () { fn initiate_recovery() -> Weight { // Proof Size summary in bytes: // Measured: `272` - // Estimated: `5690` - // Minimum execution time: 24_805 nanoseconds. - Weight::from_parts(25_273_000, 5690) + // Estimated: `7670` + // Minimum execution time: 28_148_000 picoseconds. + Weight::from_parts(28_577_000, 7670) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -244,12 +245,12 @@ impl WeightInfo for () { /// The range of component `n` is `[1, 9]`. fn vouch_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `423 + n * (64 ±0)` - // Estimated: `5690` - // Minimum execution time: 17_837 nanoseconds. - Weight::from_parts(18_429_664, 5690) - // Standard Error: 3_187 - .saturating_add(Weight::from_parts(143_648, 0).saturating_mul(n.into())) + // Measured: `360 + n * (64 ±0)` + // Estimated: `7670` + // Minimum execution time: 20_395_000 picoseconds. + Weight::from_parts(21_287_972, 7670) + // Standard Error: 4_464 + .saturating_add(Weight::from_parts(170_214, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -262,12 +263,12 @@ impl WeightInfo for () { /// The range of component `n` is `[1, 9]`. fn claim_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `455 + n * (64 ±0)` - // Estimated: `8245` - // Minimum execution time: 21_960 nanoseconds. - Weight::from_parts(22_529_644, 8245) - // Standard Error: 2_945 - .saturating_add(Weight::from_parts(85_604, 0).saturating_mul(n.into())) + // Measured: `392 + n * (64 ±0)` + // Estimated: `11215` + // Minimum execution time: 24_902_000 picoseconds. + Weight::from_parts(25_662_621, 11215) + // Standard Error: 3_101 + .saturating_add(Weight::from_parts(60_748, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -278,12 +279,12 @@ impl WeightInfo for () { /// The range of component `n` is `[1, 9]`. fn close_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `576 + n * (32 ±0)` - // Estimated: `5467` - // Minimum execution time: 26_054 nanoseconds. - Weight::from_parts(26_724_866, 5467) - // Standard Error: 2_645 - .saturating_add(Weight::from_parts(104_301, 0).saturating_mul(n.into())) + // Measured: `513 + n * (32 ±0)` + // Estimated: `7447` + // Minimum execution time: 30_071_000 picoseconds. + Weight::from_parts(30_727_760, 7447) + // Standard Error: 4_442 + .saturating_add(Weight::from_parts(98_153, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -292,14 +293,12 @@ impl WeightInfo for () { /// Storage: Recovery Recoverable (r:1 w:1) /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) /// The range of component `n` is `[1, 9]`. - fn remove_recovery(n: u32, ) -> Weight { + fn remove_recovery(_n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `302 + n * (32 ±0)` - // Estimated: `5690` - // Minimum execution time: 25_110 nanoseconds. - Weight::from_parts(25_805_837, 5690) - // Standard Error: 2_732 - .saturating_add(Weight::from_parts(73_458, 0).saturating_mul(n.into())) + // Measured: `270 + n * (32 ±0)` + // Estimated: `7670` + // Minimum execution time: 29_088_000 picoseconds. + Weight::from_parts(30_535_744, 7670) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -308,9 +307,9 @@ impl WeightInfo for () { fn cancel_recovered() -> Weight { // Proof Size summary in bytes: // Measured: `281` - // Estimated: `2555` - // Minimum execution time: 11_061 nanoseconds. - Weight::from_parts(11_291_000, 2555) + // Estimated: `3545` + // Minimum execution time: 12_712_000 picoseconds. + Weight::from_parts(12_980_000, 3545) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/referenda/src/weights.rs b/frame/referenda/src/weights.rs index 817e0d88d329d..3ac0f54ed8307 100644 --- a/frame/referenda/src/weights.rs +++ b/frame/referenda/src/weights.rs @@ -18,26 +18,28 @@ //! Autogenerated weights for pallet_referenda //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-b3zmxxc-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_referenda +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_referenda -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/referenda/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -92,10 +94,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn submit() -> Weight { // Proof Size summary in bytes: - // Measured: `251` - // Estimated: `109996` - // Minimum execution time: 34_540 nanoseconds. - Weight::from_parts(36_144_000, 109996) + // Measured: `220` + // Estimated: `111976` + // Minimum execution time: 36_851_000 picoseconds. + Weight::from_parts(37_183_000, 111976) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -105,10 +107,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn place_decision_deposit_preparing() -> Weight { // Proof Size summary in bytes: - // Measured: `536` - // Estimated: `221835` - // Minimum execution time: 46_963 nanoseconds. - Weight::from_parts(48_459_000, 221835) + // Measured: `473` + // Estimated: `223815` + // Minimum execution time: 49_435_000 picoseconds. + Weight::from_parts(50_056_000, 223815) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -120,10 +122,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) fn place_decision_deposit_queued() -> Weight { // Proof Size summary in bytes: - // Measured: `3203` - // Estimated: `9817` - // Minimum execution time: 55_798 nanoseconds. - Weight::from_parts(58_260_000, 9817) + // Measured: `3107` + // Estimated: `12787` + // Minimum execution time: 47_061_000 picoseconds. + Weight::from_parts(47_579_000, 12787) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -135,10 +137,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) fn place_decision_deposit_not_queued() -> Weight { // Proof Size summary in bytes: - // Measured: `3223` - // Estimated: `9817` - // Minimum execution time: 53_888 nanoseconds. - Weight::from_parts(57_919_000, 9817) + // Measured: `3127` + // Estimated: `12787` + // Minimum execution time: 46_513_000 picoseconds. + Weight::from_parts(47_212_000, 12787) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -150,10 +152,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn place_decision_deposit_passing() -> Weight { // Proof Size summary in bytes: - // Measured: `536` - // Estimated: `224324` - // Minimum execution time: 56_121 nanoseconds. - Weight::from_parts(58_301_000, 224324) + // Measured: `473` + // Estimated: `227294` + // Minimum execution time: 59_255_000 picoseconds. + Weight::from_parts(60_114_000, 227294) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -165,10 +167,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn place_decision_deposit_failing() -> Weight { // Proof Size summary in bytes: - // Measured: `536` - // Estimated: `224324` - // Minimum execution time: 54_237 nanoseconds. - Weight::from_parts(55_681_000, 224324) + // Measured: `473` + // Estimated: `227294` + // Minimum execution time: 57_927_000 picoseconds. + Weight::from_parts(58_625_000, 227294) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -176,10 +178,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn refund_decision_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `415` - // Estimated: `2841` - // Minimum execution time: 25_734 nanoseconds. - Weight::from_parts(26_429_000, 2841) + // Measured: `351` + // Estimated: `3831` + // Minimum execution time: 27_186_000 picoseconds. + Weight::from_parts(27_551_000, 3831) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -187,10 +189,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn refund_submission_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `405` - // Estimated: `2841` - // Minimum execution time: 26_000 nanoseconds. - Weight::from_parts(26_786_000, 2841) + // Measured: `341` + // Estimated: `3831` + // Minimum execution time: 27_339_000 picoseconds. + Weight::from_parts(27_828_000, 3831) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -200,10 +202,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn cancel() -> Weight { // Proof Size summary in bytes: - // Measured: `412` - // Estimated: `221835` - // Minimum execution time: 34_567 nanoseconds. - Weight::from_parts(35_939_000, 221835) + // Measured: `381` + // Estimated: `223815` + // Minimum execution time: 37_081_000 picoseconds. + Weight::from_parts(38_110_000, 223815) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -215,10 +217,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn kill() -> Weight { // Proof Size summary in bytes: - // Measured: `717` - // Estimated: `224362` - // Minimum execution time: 67_744 nanoseconds. - Weight::from_parts(70_047_000, 224362) + // Measured: `622` + // Estimated: `227332` + // Minimum execution time: 70_195_000 picoseconds. + Weight::from_parts(71_451_000, 227332) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -229,9 +231,9 @@ impl WeightInfo for SubstrateWeight { fn one_fewer_deciding_queue_empty() -> Weight { // Proof Size summary in bytes: // Measured: `174` - // Estimated: `6976` - // Minimum execution time: 9_886 nanoseconds. - Weight::from_parts(10_406_000, 6976) + // Estimated: `8956` + // Minimum execution time: 10_748_000 picoseconds. + Weight::from_parts(10_912_000, 8956) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -243,10 +245,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn one_fewer_deciding_failing() -> Weight { // Proof Size summary in bytes: - // Measured: `4661` - // Estimated: `226322` - // Minimum execution time: 100_449 nanoseconds. - Weight::from_parts(101_812_000, 226322) + // Measured: `4567` + // Estimated: `229292` + // Minimum execution time: 89_144_000 picoseconds. + Weight::from_parts(90_552_000, 229292) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -258,10 +260,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn one_fewer_deciding_passing() -> Weight { // Proof Size summary in bytes: - // Measured: `4661` - // Estimated: `226322` - // Minimum execution time: 101_430 nanoseconds. - Weight::from_parts(103_704_000, 226322) + // Measured: `4567` + // Estimated: `229292` + // Minimum execution time: 92_164_000 picoseconds. + Weight::from_parts(92_947_000, 229292) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -273,10 +275,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_requeued_insertion() -> Weight { // Proof Size summary in bytes: - // Measured: `4682` - // Estimated: `116825` - // Minimum execution time: 67_224 nanoseconds. - Weight::from_parts(70_596_000, 116825) + // Measured: `4588` + // Estimated: `119795` + // Minimum execution time: 59_212_000 picoseconds. + Weight::from_parts(59_843_000, 119795) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -288,10 +290,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_requeued_slide() -> Weight { // Proof Size summary in bytes: - // Measured: `4668` - // Estimated: `116825` - // Minimum execution time: 65_461 nanoseconds. - Weight::from_parts(69_624_000, 116825) + // Measured: `4574` + // Estimated: `119795` + // Minimum execution time: 59_049_000 picoseconds. + Weight::from_parts(59_760_000, 119795) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -305,10 +307,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_queued() -> Weight { // Proof Size summary in bytes: - // Measured: `4642` - // Estimated: `119314` - // Minimum execution time: 69_848 nanoseconds. - Weight::from_parts(74_480_000, 119314) + // Measured: `4548` + // Estimated: `123274` + // Minimum execution time: 61_774_000 picoseconds. + Weight::from_parts(62_480_000, 123274) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -322,10 +324,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_not_queued() -> Weight { // Proof Size summary in bytes: - // Measured: `4676` - // Estimated: `119314` - // Minimum execution time: 70_042 nanoseconds. - Weight::from_parts(72_912_000, 119314) + // Measured: `4582` + // Estimated: `123274` + // Minimum execution time: 61_605_000 picoseconds. + Weight::from_parts(62_385_000, 123274) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -335,10 +337,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_no_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `364` - // Estimated: `112338` - // Minimum execution time: 23_008 nanoseconds. - Weight::from_parts(23_767_000, 112338) + // Measured: `333` + // Estimated: `114318` + // Minimum execution time: 24_423_000 picoseconds. + Weight::from_parts(24_747_000, 114318) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -348,10 +350,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_preparing() -> Weight { // Proof Size summary in bytes: - // Measured: `412` - // Estimated: `112338` - // Minimum execution time: 23_550 nanoseconds. - Weight::from_parts(24_081_000, 112338) + // Measured: `381` + // Estimated: `114318` + // Minimum execution time: 24_487_000 picoseconds. + Weight::from_parts(24_941_000, 114318) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -359,10 +361,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn nudge_referendum_timed_out() -> Weight { // Proof Size summary in bytes: - // Measured: `310` - // Estimated: `2841` - // Minimum execution time: 15_850 nanoseconds. - Weight::from_parts(16_773_000, 2841) + // Measured: `278` + // Estimated: `3831` + // Minimum execution time: 17_454_000 picoseconds. + Weight::from_parts(17_697_000, 3831) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -374,10 +376,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_begin_deciding_failing() -> Weight { // Proof Size summary in bytes: - // Measured: `412` - // Estimated: `114827` - // Minimum execution time: 32_126 nanoseconds. - Weight::from_parts(33_313_000, 114827) + // Measured: `381` + // Estimated: `117797` + // Minimum execution time: 34_721_000 picoseconds. + Weight::from_parts(35_295_000, 117797) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -389,10 +391,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_begin_deciding_passing() -> Weight { // Proof Size summary in bytes: - // Measured: `412` - // Estimated: `114827` - // Minimum execution time: 34_698 nanoseconds. - Weight::from_parts(35_802_000, 114827) + // Measured: `381` + // Estimated: `117797` + // Minimum execution time: 36_587_000 picoseconds. + Weight::from_parts(37_095_000, 117797) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -402,10 +404,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_begin_confirming() -> Weight { // Proof Size summary in bytes: - // Measured: `465` - // Estimated: `112338` - // Minimum execution time: 28_710 nanoseconds. - Weight::from_parts(29_574_000, 112338) + // Measured: `434` + // Estimated: `114318` + // Minimum execution time: 30_003_000 picoseconds. + Weight::from_parts(30_541_000, 114318) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -415,10 +417,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_end_confirming() -> Weight { // Proof Size summary in bytes: - // Measured: `448` - // Estimated: `112338` - // Minimum execution time: 29_030 nanoseconds. - Weight::from_parts(30_308_000, 112338) + // Measured: `417` + // Estimated: `114318` + // Minimum execution time: 30_479_000 picoseconds. + Weight::from_parts(30_900_000, 114318) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -428,10 +430,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_continue_not_confirming() -> Weight { // Proof Size summary in bytes: - // Measured: `465` - // Estimated: `112338` - // Minimum execution time: 26_382 nanoseconds. - Weight::from_parts(27_219_000, 112338) + // Measured: `434` + // Estimated: `114318` + // Minimum execution time: 27_657_000 picoseconds. + Weight::from_parts(28_054_000, 114318) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -441,10 +443,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_continue_confirming() -> Weight { // Proof Size summary in bytes: - // Measured: `469` - // Estimated: `112338` - // Minimum execution time: 25_445 nanoseconds. - Weight::from_parts(26_010_000, 112338) + // Measured: `438` + // Estimated: `114318` + // Minimum execution time: 26_713_000 picoseconds. + Weight::from_parts(27_284_000, 114318) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -456,10 +458,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn nudge_referendum_approved() -> Weight { // Proof Size summary in bytes: - // Measured: `469` - // Estimated: `224358` - // Minimum execution time: 41_064 nanoseconds. - Weight::from_parts(42_895_000, 224358) + // Measured: `438` + // Estimated: `227328` + // Minimum execution time: 42_374_000 picoseconds. + Weight::from_parts(43_142_000, 227328) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -469,10 +471,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_rejected() -> Weight { // Proof Size summary in bytes: - // Measured: `465` - // Estimated: `112338` - // Minimum execution time: 29_472 nanoseconds. - Weight::from_parts(30_011_000, 112338) + // Measured: `434` + // Estimated: `114318` + // Minimum execution time: 30_213_000 picoseconds. + Weight::from_parts(30_633_000, 114318) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -484,10 +486,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn set_some_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `454` - // Estimated: `5407` - // Minimum execution time: 19_389 nanoseconds. - Weight::from_parts(20_490_000, 5407) + // Measured: `422` + // Estimated: `7387` + // Minimum execution time: 20_887_000 picoseconds. + Weight::from_parts(21_242_000, 7387) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -497,10 +499,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `387` - // Estimated: `5368` - // Minimum execution time: 18_195 nanoseconds. - Weight::from_parts(19_917_000, 5368) + // Measured: `355` + // Estimated: `7348` + // Minimum execution time: 18_702_000 picoseconds. + Weight::from_parts(18_880_000, 7348) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -516,10 +518,10 @@ impl WeightInfo for () { /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn submit() -> Weight { // Proof Size summary in bytes: - // Measured: `251` - // Estimated: `109996` - // Minimum execution time: 34_540 nanoseconds. - Weight::from_parts(36_144_000, 109996) + // Measured: `220` + // Estimated: `111976` + // Minimum execution time: 36_851_000 picoseconds. + Weight::from_parts(37_183_000, 111976) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -529,10 +531,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn place_decision_deposit_preparing() -> Weight { // Proof Size summary in bytes: - // Measured: `536` - // Estimated: `221835` - // Minimum execution time: 46_963 nanoseconds. - Weight::from_parts(48_459_000, 221835) + // Measured: `473` + // Estimated: `223815` + // Minimum execution time: 49_435_000 picoseconds. + Weight::from_parts(50_056_000, 223815) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -544,10 +546,10 @@ impl WeightInfo for () { /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) fn place_decision_deposit_queued() -> Weight { // Proof Size summary in bytes: - // Measured: `3203` - // Estimated: `9817` - // Minimum execution time: 55_798 nanoseconds. - Weight::from_parts(58_260_000, 9817) + // Measured: `3107` + // Estimated: `12787` + // Minimum execution time: 47_061_000 picoseconds. + Weight::from_parts(47_579_000, 12787) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -559,10 +561,10 @@ impl WeightInfo for () { /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) fn place_decision_deposit_not_queued() -> Weight { // Proof Size summary in bytes: - // Measured: `3223` - // Estimated: `9817` - // Minimum execution time: 53_888 nanoseconds. - Weight::from_parts(57_919_000, 9817) + // Measured: `3127` + // Estimated: `12787` + // Minimum execution time: 46_513_000 picoseconds. + Weight::from_parts(47_212_000, 12787) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -574,10 +576,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn place_decision_deposit_passing() -> Weight { // Proof Size summary in bytes: - // Measured: `536` - // Estimated: `224324` - // Minimum execution time: 56_121 nanoseconds. - Weight::from_parts(58_301_000, 224324) + // Measured: `473` + // Estimated: `227294` + // Minimum execution time: 59_255_000 picoseconds. + Weight::from_parts(60_114_000, 227294) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -589,10 +591,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn place_decision_deposit_failing() -> Weight { // Proof Size summary in bytes: - // Measured: `536` - // Estimated: `224324` - // Minimum execution time: 54_237 nanoseconds. - Weight::from_parts(55_681_000, 224324) + // Measured: `473` + // Estimated: `227294` + // Minimum execution time: 57_927_000 picoseconds. + Weight::from_parts(58_625_000, 227294) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -600,10 +602,10 @@ impl WeightInfo for () { /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn refund_decision_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `415` - // Estimated: `2841` - // Minimum execution time: 25_734 nanoseconds. - Weight::from_parts(26_429_000, 2841) + // Measured: `351` + // Estimated: `3831` + // Minimum execution time: 27_186_000 picoseconds. + Weight::from_parts(27_551_000, 3831) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -611,10 +613,10 @@ impl WeightInfo for () { /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn refund_submission_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `405` - // Estimated: `2841` - // Minimum execution time: 26_000 nanoseconds. - Weight::from_parts(26_786_000, 2841) + // Measured: `341` + // Estimated: `3831` + // Minimum execution time: 27_339_000 picoseconds. + Weight::from_parts(27_828_000, 3831) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -624,10 +626,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn cancel() -> Weight { // Proof Size summary in bytes: - // Measured: `412` - // Estimated: `221835` - // Minimum execution time: 34_567 nanoseconds. - Weight::from_parts(35_939_000, 221835) + // Measured: `381` + // Estimated: `223815` + // Minimum execution time: 37_081_000 picoseconds. + Weight::from_parts(38_110_000, 223815) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -639,10 +641,10 @@ impl WeightInfo for () { /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn kill() -> Weight { // Proof Size summary in bytes: - // Measured: `717` - // Estimated: `224362` - // Minimum execution time: 67_744 nanoseconds. - Weight::from_parts(70_047_000, 224362) + // Measured: `622` + // Estimated: `227332` + // Minimum execution time: 70_195_000 picoseconds. + Weight::from_parts(71_451_000, 227332) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -653,9 +655,9 @@ impl WeightInfo for () { fn one_fewer_deciding_queue_empty() -> Weight { // Proof Size summary in bytes: // Measured: `174` - // Estimated: `6976` - // Minimum execution time: 9_886 nanoseconds. - Weight::from_parts(10_406_000, 6976) + // Estimated: `8956` + // Minimum execution time: 10_748_000 picoseconds. + Weight::from_parts(10_912_000, 8956) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -667,10 +669,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn one_fewer_deciding_failing() -> Weight { // Proof Size summary in bytes: - // Measured: `4661` - // Estimated: `226322` - // Minimum execution time: 100_449 nanoseconds. - Weight::from_parts(101_812_000, 226322) + // Measured: `4567` + // Estimated: `229292` + // Minimum execution time: 89_144_000 picoseconds. + Weight::from_parts(90_552_000, 229292) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -682,10 +684,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn one_fewer_deciding_passing() -> Weight { // Proof Size summary in bytes: - // Measured: `4661` - // Estimated: `226322` - // Minimum execution time: 101_430 nanoseconds. - Weight::from_parts(103_704_000, 226322) + // Measured: `4567` + // Estimated: `229292` + // Minimum execution time: 92_164_000 picoseconds. + Weight::from_parts(92_947_000, 229292) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -697,10 +699,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_requeued_insertion() -> Weight { // Proof Size summary in bytes: - // Measured: `4682` - // Estimated: `116825` - // Minimum execution time: 67_224 nanoseconds. - Weight::from_parts(70_596_000, 116825) + // Measured: `4588` + // Estimated: `119795` + // Minimum execution time: 59_212_000 picoseconds. + Weight::from_parts(59_843_000, 119795) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -712,10 +714,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_requeued_slide() -> Weight { // Proof Size summary in bytes: - // Measured: `4668` - // Estimated: `116825` - // Minimum execution time: 65_461 nanoseconds. - Weight::from_parts(69_624_000, 116825) + // Measured: `4574` + // Estimated: `119795` + // Minimum execution time: 59_049_000 picoseconds. + Weight::from_parts(59_760_000, 119795) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -729,10 +731,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_queued() -> Weight { // Proof Size summary in bytes: - // Measured: `4642` - // Estimated: `119314` - // Minimum execution time: 69_848 nanoseconds. - Weight::from_parts(74_480_000, 119314) + // Measured: `4548` + // Estimated: `123274` + // Minimum execution time: 61_774_000 picoseconds. + Weight::from_parts(62_480_000, 123274) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -746,10 +748,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_not_queued() -> Weight { // Proof Size summary in bytes: - // Measured: `4676` - // Estimated: `119314` - // Minimum execution time: 70_042 nanoseconds. - Weight::from_parts(72_912_000, 119314) + // Measured: `4582` + // Estimated: `123274` + // Minimum execution time: 61_605_000 picoseconds. + Weight::from_parts(62_385_000, 123274) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -759,10 +761,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_no_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `364` - // Estimated: `112338` - // Minimum execution time: 23_008 nanoseconds. - Weight::from_parts(23_767_000, 112338) + // Measured: `333` + // Estimated: `114318` + // Minimum execution time: 24_423_000 picoseconds. + Weight::from_parts(24_747_000, 114318) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -772,10 +774,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_preparing() -> Weight { // Proof Size summary in bytes: - // Measured: `412` - // Estimated: `112338` - // Minimum execution time: 23_550 nanoseconds. - Weight::from_parts(24_081_000, 112338) + // Measured: `381` + // Estimated: `114318` + // Minimum execution time: 24_487_000 picoseconds. + Weight::from_parts(24_941_000, 114318) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -783,10 +785,10 @@ impl WeightInfo for () { /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn nudge_referendum_timed_out() -> Weight { // Proof Size summary in bytes: - // Measured: `310` - // Estimated: `2841` - // Minimum execution time: 15_850 nanoseconds. - Weight::from_parts(16_773_000, 2841) + // Measured: `278` + // Estimated: `3831` + // Minimum execution time: 17_454_000 picoseconds. + Weight::from_parts(17_697_000, 3831) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -798,10 +800,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_begin_deciding_failing() -> Weight { // Proof Size summary in bytes: - // Measured: `412` - // Estimated: `114827` - // Minimum execution time: 32_126 nanoseconds. - Weight::from_parts(33_313_000, 114827) + // Measured: `381` + // Estimated: `117797` + // Minimum execution time: 34_721_000 picoseconds. + Weight::from_parts(35_295_000, 117797) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -813,10 +815,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_begin_deciding_passing() -> Weight { // Proof Size summary in bytes: - // Measured: `412` - // Estimated: `114827` - // Minimum execution time: 34_698 nanoseconds. - Weight::from_parts(35_802_000, 114827) + // Measured: `381` + // Estimated: `117797` + // Minimum execution time: 36_587_000 picoseconds. + Weight::from_parts(37_095_000, 117797) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -826,10 +828,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_begin_confirming() -> Weight { // Proof Size summary in bytes: - // Measured: `465` - // Estimated: `112338` - // Minimum execution time: 28_710 nanoseconds. - Weight::from_parts(29_574_000, 112338) + // Measured: `434` + // Estimated: `114318` + // Minimum execution time: 30_003_000 picoseconds. + Weight::from_parts(30_541_000, 114318) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -839,10 +841,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_end_confirming() -> Weight { // Proof Size summary in bytes: - // Measured: `448` - // Estimated: `112338` - // Minimum execution time: 29_030 nanoseconds. - Weight::from_parts(30_308_000, 112338) + // Measured: `417` + // Estimated: `114318` + // Minimum execution time: 30_479_000 picoseconds. + Weight::from_parts(30_900_000, 114318) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -852,10 +854,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_continue_not_confirming() -> Weight { // Proof Size summary in bytes: - // Measured: `465` - // Estimated: `112338` - // Minimum execution time: 26_382 nanoseconds. - Weight::from_parts(27_219_000, 112338) + // Measured: `434` + // Estimated: `114318` + // Minimum execution time: 27_657_000 picoseconds. + Weight::from_parts(28_054_000, 114318) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -865,10 +867,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_continue_confirming() -> Weight { // Proof Size summary in bytes: - // Measured: `469` - // Estimated: `112338` - // Minimum execution time: 25_445 nanoseconds. - Weight::from_parts(26_010_000, 112338) + // Measured: `438` + // Estimated: `114318` + // Minimum execution time: 26_713_000 picoseconds. + Weight::from_parts(27_284_000, 114318) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -880,10 +882,10 @@ impl WeightInfo for () { /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn nudge_referendum_approved() -> Weight { // Proof Size summary in bytes: - // Measured: `469` - // Estimated: `224358` - // Minimum execution time: 41_064 nanoseconds. - Weight::from_parts(42_895_000, 224358) + // Measured: `438` + // Estimated: `227328` + // Minimum execution time: 42_374_000 picoseconds. + Weight::from_parts(43_142_000, 227328) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -893,10 +895,10 @@ impl WeightInfo for () { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_rejected() -> Weight { // Proof Size summary in bytes: - // Measured: `465` - // Estimated: `112338` - // Minimum execution time: 29_472 nanoseconds. - Weight::from_parts(30_011_000, 112338) + // Measured: `434` + // Estimated: `114318` + // Minimum execution time: 30_213_000 picoseconds. + Weight::from_parts(30_633_000, 114318) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -908,10 +910,10 @@ impl WeightInfo for () { /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn set_some_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `454` - // Estimated: `5407` - // Minimum execution time: 19_389 nanoseconds. - Weight::from_parts(20_490_000, 5407) + // Measured: `422` + // Estimated: `7387` + // Minimum execution time: 20_887_000 picoseconds. + Weight::from_parts(21_242_000, 7387) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -921,10 +923,10 @@ impl WeightInfo for () { /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `387` - // Estimated: `5368` - // Minimum execution time: 18_195 nanoseconds. - Weight::from_parts(19_917_000, 5368) + // Measured: `355` + // Estimated: `7348` + // Minimum execution time: 18_702_000 picoseconds. + Weight::from_parts(18_880_000, 7348) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/remark/src/weights.rs b/frame/remark/src/weights.rs index f9fcb73803716..bb2e91b5dfbd0 100644 --- a/frame/remark/src/weights.rs +++ b/frame/remark/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_remark //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_remark +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -59,10 +62,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_404 nanoseconds. - Weight::from_parts(343_031, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(1_404, 0).saturating_mul(l.into())) + // Minimum execution time: 9_284_000 picoseconds. + Weight::from_parts(4_054_843, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(1_094, 0).saturating_mul(l.into())) } } @@ -73,9 +76,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_404 nanoseconds. - Weight::from_parts(343_031, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(1_404, 0).saturating_mul(l.into())) + // Minimum execution time: 9_284_000 picoseconds. + Weight::from_parts(4_054_843, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(1_094, 0).saturating_mul(l.into())) } } diff --git a/frame/salary/src/weights.rs b/frame/salary/src/weights.rs index 6b43c58b6038c..7195a144a65a3 100644 --- a/frame/salary/src/weights.rs +++ b/frame/salary/src/weights.rs @@ -18,26 +18,29 @@ //! Autogenerated weights for pallet_salary //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: // ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 -// --extrinsic=* // --pallet=pallet_salary +// --no-storage-info +// --no-median-slopes +// --no-min-squares +// --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --chain=dev -// --header=HEADER-APACHE2 -// --output=frame/salary/src/weights.rs -// --template=.maintain/frame-weight-template.hbs +// --output=./frame/salary/src/weights.rs +// --header=./HEADER-APACHE2 +// --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -66,8 +69,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4` // Estimated: `1541` - // Minimum execution time: 11_793_000 picoseconds. - Weight::from_parts(12_080_000, 1541) + // Minimum execution time: 11_732_000 picoseconds. + Weight::from_parts(12_162_000, 1541) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -75,10 +78,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Salary Status (max_values: Some(1), max_size: Some(56), added: 551, mode: MaxEncodedLen) fn bump() -> Weight { // Proof Size summary in bytes: - // Measured: `118` + // Measured: `86` // Estimated: `1541` - // Minimum execution time: 12_799_000 picoseconds. - Weight::from_parts(13_343_000, 1541) + // Minimum execution time: 12_966_000 picoseconds. + Weight::from_parts(13_443_000, 1541) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -90,10 +93,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Salary Claimant (max_values: None, max_size: Some(78), added: 2553, mode: MaxEncodedLen) fn induct() -> Weight { // Proof Size summary in bytes: - // Measured: `394` + // Measured: `362` // Estimated: `8591` - // Minimum execution time: 20_299_000 picoseconds. - Weight::from_parts(20_664_000, 8591) + // Minimum execution time: 20_467_000 picoseconds. + Weight::from_parts(20_782_000, 8591) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -105,10 +108,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Salary Claimant (max_values: None, max_size: Some(78), added: 2553, mode: MaxEncodedLen) fn register() -> Weight { // Proof Size summary in bytes: - // Measured: `461` + // Measured: `429` // Estimated: `8591` - // Minimum execution time: 24_195_000 picoseconds. - Weight::from_parts(24_528_000, 8591) + // Minimum execution time: 23_547_000 picoseconds. + Weight::from_parts(23_911_000, 8591) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -120,10 +123,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) fn payout() -> Weight { // Proof Size summary in bytes: - // Measured: `461` + // Measured: `429` // Estimated: `8591` - // Minimum execution time: 47_609_000 picoseconds. - Weight::from_parts(48_462_000, 8591) + // Minimum execution time: 47_145_000 picoseconds. + Weight::from_parts(47_778_000, 8591) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -137,10 +140,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn payout_other() -> Weight { // Proof Size summary in bytes: - // Measured: `461` + // Measured: `429` // Estimated: `12184` - // Minimum execution time: 48_513_000 picoseconds. - Weight::from_parts(49_053_000, 12184) + // Minimum execution time: 48_763_000 picoseconds. + Weight::from_parts(49_853_000, 12184) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -150,10 +153,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Salary Claimant (max_values: None, max_size: Some(78), added: 2553, mode: MaxEncodedLen) fn check_payment() -> Weight { // Proof Size summary in bytes: - // Measured: `202` + // Measured: `170` // Estimated: `5084` - // Minimum execution time: 12_663_000 picoseconds. - Weight::from_parts(12_858_000, 5084) + // Minimum execution time: 12_825_000 picoseconds. + Weight::from_parts(13_143_000, 5084) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -167,8 +170,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4` // Estimated: `1541` - // Minimum execution time: 11_793_000 picoseconds. - Weight::from_parts(12_080_000, 1541) + // Minimum execution time: 11_732_000 picoseconds. + Weight::from_parts(12_162_000, 1541) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -176,10 +179,10 @@ impl WeightInfo for () { /// Proof: Salary Status (max_values: Some(1), max_size: Some(56), added: 551, mode: MaxEncodedLen) fn bump() -> Weight { // Proof Size summary in bytes: - // Measured: `118` + // Measured: `86` // Estimated: `1541` - // Minimum execution time: 12_799_000 picoseconds. - Weight::from_parts(13_343_000, 1541) + // Minimum execution time: 12_966_000 picoseconds. + Weight::from_parts(13_443_000, 1541) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -191,10 +194,10 @@ impl WeightInfo for () { /// Proof: Salary Claimant (max_values: None, max_size: Some(78), added: 2553, mode: MaxEncodedLen) fn induct() -> Weight { // Proof Size summary in bytes: - // Measured: `394` + // Measured: `362` // Estimated: `8591` - // Minimum execution time: 20_299_000 picoseconds. - Weight::from_parts(20_664_000, 8591) + // Minimum execution time: 20_467_000 picoseconds. + Weight::from_parts(20_782_000, 8591) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -206,10 +209,10 @@ impl WeightInfo for () { /// Proof: Salary Claimant (max_values: None, max_size: Some(78), added: 2553, mode: MaxEncodedLen) fn register() -> Weight { // Proof Size summary in bytes: - // Measured: `461` + // Measured: `429` // Estimated: `8591` - // Minimum execution time: 24_195_000 picoseconds. - Weight::from_parts(24_528_000, 8591) + // Minimum execution time: 23_547_000 picoseconds. + Weight::from_parts(23_911_000, 8591) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -221,10 +224,10 @@ impl WeightInfo for () { /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) fn payout() -> Weight { // Proof Size summary in bytes: - // Measured: `461` + // Measured: `429` // Estimated: `8591` - // Minimum execution time: 47_609_000 picoseconds. - Weight::from_parts(48_462_000, 8591) + // Minimum execution time: 47_145_000 picoseconds. + Weight::from_parts(47_778_000, 8591) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -238,10 +241,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn payout_other() -> Weight { // Proof Size summary in bytes: - // Measured: `461` + // Measured: `429` // Estimated: `12184` - // Minimum execution time: 48_513_000 picoseconds. - Weight::from_parts(49_053_000, 12184) + // Minimum execution time: 48_763_000 picoseconds. + Weight::from_parts(49_853_000, 12184) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -251,10 +254,10 @@ impl WeightInfo for () { /// Proof: Salary Claimant (max_values: None, max_size: Some(78), added: 2553, mode: MaxEncodedLen) fn check_payment() -> Weight { // Proof Size summary in bytes: - // Measured: `202` + // Measured: `170` // Estimated: `5084` - // Minimum execution time: 12_663_000 picoseconds. - Weight::from_parts(12_858_000, 5084) + // Minimum execution time: 12_825_000 picoseconds. + Weight::from_parts(13_143_000, 5084) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } diff --git a/frame/scheduler/src/weights.rs b/frame/scheduler/src/weights.rs index 577e5b0bc4b2d..bccb502656a72 100644 --- a/frame/scheduler/src/weights.rs +++ b/frame/scheduler/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_scheduler //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_scheduler +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -69,10 +72,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Scheduler IncompleteSince (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn service_agendas_base() -> Weight { // Proof Size summary in bytes: - // Measured: `30` - // Estimated: `499` - // Minimum execution time: 3_670 nanoseconds. - Weight::from_parts(3_838_000, 499) + // Measured: `31` + // Estimated: `1489` + // Minimum execution time: 3_965_000 picoseconds. + Weight::from_parts(4_126_000, 1489) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -81,12 +84,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 512]`. fn service_agenda_base(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `112 + s * (177 ±0)` - // Estimated: `109497` - // Minimum execution time: 3_079 nanoseconds. - Weight::from_parts(7_087_647, 109497) - // Standard Error: 658 - .saturating_add(Weight::from_parts(279_320, 0).saturating_mul(s.into())) + // Measured: `81 + s * (177 ±0)` + // Estimated: `110487` + // Minimum execution time: 3_662_000 picoseconds. + Weight::from_parts(8_746_597, 110487) + // Standard Error: 754 + .saturating_add(Weight::from_parts(309_350, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -94,8 +97,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_192 nanoseconds. - Weight::from_parts(5_528_000, 0) + // Minimum execution time: 5_807_000 picoseconds. + Weight::from_parts(5_963_000, 0) } /// Storage: Preimage PreimageFor (r:1 w:1) /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: Measured) @@ -104,12 +107,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[128, 4194304]`. fn service_task_fetched(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `211 + s * (1 ±0)` - // Estimated: `5252 + s * (1 ±0)` - // Minimum execution time: 17_284 nanoseconds. - Weight::from_parts(17_574_000, 5252) - // Standard Error: 0 - .saturating_add(Weight::from_parts(1_126, 0).saturating_mul(s.into())) + // Measured: `179 + s * (1 ±0)` + // Estimated: `7200 + s * (1 ±0)` + // Minimum execution time: 20_188_000 picoseconds. + Weight::from_parts(20_422_000, 7200) + // Standard Error: 1 + .saturating_add(Weight::from_parts(1_143, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(s.into())) @@ -120,42 +123,42 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_020 nanoseconds. - Weight::from_parts(7_262_000, 0) + // Minimum execution time: 7_787_000 picoseconds. + Weight::from_parts(8_046_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } fn service_task_periodic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_187 nanoseconds. - Weight::from_parts(5_368_000, 0) + // Minimum execution time: 5_730_000 picoseconds. + Weight::from_parts(5_901_000, 0) } fn execute_dispatch_signed() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_313 nanoseconds. - Weight::from_parts(2_404_000, 0) + // Minimum execution time: 2_569_000 picoseconds. + Weight::from_parts(2_710_000, 0) } fn execute_dispatch_unsigned() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_187 nanoseconds. - Weight::from_parts(2_362_000, 0) + // Minimum execution time: 2_611_000 picoseconds. + Weight::from_parts(2_765_000, 0) } /// Storage: Scheduler Agenda (r:1 w:1) /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) /// The range of component `s` is `[0, 511]`. fn schedule(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `112 + s * (177 ±0)` - // Estimated: `109497` - // Minimum execution time: 11_971 nanoseconds. - Weight::from_parts(16_060_361, 109497) - // Standard Error: 665 - .saturating_add(Weight::from_parts(286_324, 0).saturating_mul(s.into())) + // Measured: `81 + s * (177 ±0)` + // Estimated: `110487` + // Minimum execution time: 14_237_000 picoseconds. + Weight::from_parts(18_553_929, 110487) + // Standard Error: 757 + .saturating_add(Weight::from_parts(327_347, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -166,12 +169,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 512]`. fn cancel(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `112 + s * (177 ±0)` - // Estimated: `109497` - // Minimum execution time: 15_594 nanoseconds. - Weight::from_parts(17_191_501, 109497) - // Standard Error: 626 - .saturating_add(Weight::from_parts(425_572, 0).saturating_mul(s.into())) + // Measured: `81 + s * (177 ±0)` + // Estimated: `110487` + // Minimum execution time: 18_003_000 picoseconds. + Weight::from_parts(19_521_283, 110487) + // Standard Error: 901 + .saturating_add(Weight::from_parts(496_401, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -182,12 +185,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 511]`. fn schedule_named(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `627 + s * (178 ±0)` - // Estimated: `112020` - // Minimum execution time: 15_127 nanoseconds. - Weight::from_parts(20_932_642, 112020) - // Standard Error: 692 - .saturating_add(Weight::from_parts(288_344, 0).saturating_mul(s.into())) + // Measured: `596 + s * (178 ±0)` + // Estimated: `114000` + // Minimum execution time: 17_713_000 picoseconds. + Weight::from_parts(24_442_945, 114000) + // Standard Error: 764 + .saturating_add(Weight::from_parts(330_307, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -198,12 +201,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 512]`. fn cancel_named(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `740 + s * (177 ±0)` - // Estimated: `112020` - // Minimum execution time: 16_859 nanoseconds. - Weight::from_parts(19_736_937, 112020) - // Standard Error: 676 - .saturating_add(Weight::from_parts(429_770, 0).saturating_mul(s.into())) + // Measured: `709 + s * (177 ±0)` + // Estimated: `114000` + // Minimum execution time: 19_808_000 picoseconds. + Weight::from_parts(22_601_896, 114000) + // Standard Error: 991 + .saturating_add(Weight::from_parts(496_702, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -215,10 +218,10 @@ impl WeightInfo for () { /// Proof: Scheduler IncompleteSince (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn service_agendas_base() -> Weight { // Proof Size summary in bytes: - // Measured: `30` - // Estimated: `499` - // Minimum execution time: 3_670 nanoseconds. - Weight::from_parts(3_838_000, 499) + // Measured: `31` + // Estimated: `1489` + // Minimum execution time: 3_965_000 picoseconds. + Weight::from_parts(4_126_000, 1489) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -227,12 +230,12 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 512]`. fn service_agenda_base(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `112 + s * (177 ±0)` - // Estimated: `109497` - // Minimum execution time: 3_079 nanoseconds. - Weight::from_parts(7_087_647, 109497) - // Standard Error: 658 - .saturating_add(Weight::from_parts(279_320, 0).saturating_mul(s.into())) + // Measured: `81 + s * (177 ±0)` + // Estimated: `110487` + // Minimum execution time: 3_662_000 picoseconds. + Weight::from_parts(8_746_597, 110487) + // Standard Error: 754 + .saturating_add(Weight::from_parts(309_350, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -240,8 +243,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_192 nanoseconds. - Weight::from_parts(5_528_000, 0) + // Minimum execution time: 5_807_000 picoseconds. + Weight::from_parts(5_963_000, 0) } /// Storage: Preimage PreimageFor (r:1 w:1) /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: Measured) @@ -250,12 +253,12 @@ impl WeightInfo for () { /// The range of component `s` is `[128, 4194304]`. fn service_task_fetched(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `211 + s * (1 ±0)` - // Estimated: `5252 + s * (1 ±0)` - // Minimum execution time: 17_284 nanoseconds. - Weight::from_parts(17_574_000, 5252) - // Standard Error: 0 - .saturating_add(Weight::from_parts(1_126, 0).saturating_mul(s.into())) + // Measured: `179 + s * (1 ±0)` + // Estimated: `7200 + s * (1 ±0)` + // Minimum execution time: 20_188_000 picoseconds. + Weight::from_parts(20_422_000, 7200) + // Standard Error: 1 + .saturating_add(Weight::from_parts(1_143, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(s.into())) @@ -266,42 +269,42 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_020 nanoseconds. - Weight::from_parts(7_262_000, 0) + // Minimum execution time: 7_787_000 picoseconds. + Weight::from_parts(8_046_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn service_task_periodic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_187 nanoseconds. - Weight::from_parts(5_368_000, 0) + // Minimum execution time: 5_730_000 picoseconds. + Weight::from_parts(5_901_000, 0) } fn execute_dispatch_signed() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_313 nanoseconds. - Weight::from_parts(2_404_000, 0) + // Minimum execution time: 2_569_000 picoseconds. + Weight::from_parts(2_710_000, 0) } fn execute_dispatch_unsigned() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_187 nanoseconds. - Weight::from_parts(2_362_000, 0) + // Minimum execution time: 2_611_000 picoseconds. + Weight::from_parts(2_765_000, 0) } /// Storage: Scheduler Agenda (r:1 w:1) /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) /// The range of component `s` is `[0, 511]`. fn schedule(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `112 + s * (177 ±0)` - // Estimated: `109497` - // Minimum execution time: 11_971 nanoseconds. - Weight::from_parts(16_060_361, 109497) - // Standard Error: 665 - .saturating_add(Weight::from_parts(286_324, 0).saturating_mul(s.into())) + // Measured: `81 + s * (177 ±0)` + // Estimated: `110487` + // Minimum execution time: 14_237_000 picoseconds. + Weight::from_parts(18_553_929, 110487) + // Standard Error: 757 + .saturating_add(Weight::from_parts(327_347, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -312,12 +315,12 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 512]`. fn cancel(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `112 + s * (177 ±0)` - // Estimated: `109497` - // Minimum execution time: 15_594 nanoseconds. - Weight::from_parts(17_191_501, 109497) - // Standard Error: 626 - .saturating_add(Weight::from_parts(425_572, 0).saturating_mul(s.into())) + // Measured: `81 + s * (177 ±0)` + // Estimated: `110487` + // Minimum execution time: 18_003_000 picoseconds. + Weight::from_parts(19_521_283, 110487) + // Standard Error: 901 + .saturating_add(Weight::from_parts(496_401, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -328,12 +331,12 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 511]`. fn schedule_named(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `627 + s * (178 ±0)` - // Estimated: `112020` - // Minimum execution time: 15_127 nanoseconds. - Weight::from_parts(20_932_642, 112020) - // Standard Error: 692 - .saturating_add(Weight::from_parts(288_344, 0).saturating_mul(s.into())) + // Measured: `596 + s * (178 ±0)` + // Estimated: `114000` + // Minimum execution time: 17_713_000 picoseconds. + Weight::from_parts(24_442_945, 114000) + // Standard Error: 764 + .saturating_add(Weight::from_parts(330_307, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -344,12 +347,12 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 512]`. fn cancel_named(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `740 + s * (177 ±0)` - // Estimated: `112020` - // Minimum execution time: 16_859 nanoseconds. - Weight::from_parts(19_736_937, 112020) - // Standard Error: 676 - .saturating_add(Weight::from_parts(429_770, 0).saturating_mul(s.into())) + // Measured: `709 + s * (177 ±0)` + // Estimated: `114000` + // Minimum execution time: 19_808_000 picoseconds. + Weight::from_parts(22_601_896, 114000) + // Standard Error: 991 + .saturating_add(Weight::from_parts(496_702, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } diff --git a/frame/session/src/weights.rs b/frame/session/src/weights.rs index c01799ce53050..3515ff4464a3a 100644 --- a/frame/session/src/weights.rs +++ b/frame/session/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_session //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_session +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -63,10 +66,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn set_keys() -> Weight { // Proof Size summary in bytes: - // Measured: `1955` - // Estimated: `19851` - // Minimum execution time: 40_867 nanoseconds. - Weight::from_parts(41_319_000, 19851) + // Measured: `1891` + // Estimated: `22693` + // Minimum execution time: 48_165_000 picoseconds. + Weight::from_parts(48_967_000, 22693) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -78,10 +81,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn purge_keys() -> Weight { // Proof Size summary in bytes: - // Measured: `1854` - // Estimated: `9749` - // Minimum execution time: 30_286 nanoseconds. - Weight::from_parts(30_620_000, 9749) + // Measured: `1758` + // Estimated: `11537` + // Minimum execution time: 35_824_000 picoseconds. + Weight::from_parts(36_267_000, 11537) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -97,10 +100,10 @@ impl WeightInfo for () { /// Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn set_keys() -> Weight { // Proof Size summary in bytes: - // Measured: `1955` - // Estimated: `19851` - // Minimum execution time: 40_867 nanoseconds. - Weight::from_parts(41_319_000, 19851) + // Measured: `1891` + // Estimated: `22693` + // Minimum execution time: 48_165_000 picoseconds. + Weight::from_parts(48_967_000, 22693) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -112,10 +115,10 @@ impl WeightInfo for () { /// Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn purge_keys() -> Weight { // Proof Size summary in bytes: - // Measured: `1854` - // Estimated: `9749` - // Minimum execution time: 30_286 nanoseconds. - Weight::from_parts(30_620_000, 9749) + // Measured: `1758` + // Estimated: `11537` + // Minimum execution time: 35_824_000 picoseconds. + Weight::from_parts(36_267_000, 11537) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index d1814d89d4d89..01d874d55660b 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_staking +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -95,10 +98,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn bond() -> Weight { // Proof Size summary in bytes: - // Measured: `1079` - // Estimated: `10386` - // Minimum execution time: 40_015 nanoseconds. - Weight::from_parts(40_601_000, 10386) + // Measured: `1047` + // Estimated: `14346` + // Minimum execution time: 46_401_000 picoseconds. + Weight::from_parts(46_987_000, 14346) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -114,10 +117,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra() -> Weight { // Proof Size summary in bytes: - // Measured: `2252` - // Estimated: `22888` - // Minimum execution time: 74_781 nanoseconds. - Weight::from_parts(75_188_000, 22888) + // Measured: `2028` + // Estimated: `27838` + // Minimum execution time: 87_755_000 picoseconds. + Weight::from_parts(88_802_000, 27838) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -141,10 +144,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn unbond() -> Weight { // Proof Size summary in bytes: - // Measured: `2457` - // Estimated: `29534` - // Minimum execution time: 81_299 nanoseconds. - Weight::from_parts(82_242_000, 29534) + // Measured: `2233` + // Estimated: `38444` + // Minimum execution time: 95_698_000 picoseconds. + Weight::from_parts(96_971_000, 38444) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } @@ -159,12 +162,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1085` - // Estimated: `10442` - // Minimum execution time: 31_479 nanoseconds. - Weight::from_parts(32_410_035, 10442) - // Standard Error: 313 - .saturating_add(Weight::from_parts(9_090, 0).saturating_mul(s.into())) + // Measured: `1021` + // Estimated: `14402` + // Minimum execution time: 38_239_000 picoseconds. + Weight::from_parts(39_615_452, 14402) + // Standard Error: 447 + .saturating_add(Weight::from_parts(9_199, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -199,12 +202,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_kill(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2486 + s * (4 ±0)` - // Estimated: `32303 + s * (4 ±0)` - // Minimum execution time: 71_968 nanoseconds. - Weight::from_parts(76_631_804, 32303) - // Standard Error: 1_613 - .saturating_add(Weight::from_parts(1_058_968, 0).saturating_mul(s.into())) + // Measured: `2294 + s * (4 ±0)` + // Estimated: `43999 + s * (4 ±0)` + // Minimum execution time: 84_251_000 picoseconds. + Weight::from_parts(90_113_319, 43999) + // Standard Error: 2_177 + .saturating_add(Weight::from_parts(1_278_840, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(12_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -234,10 +237,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Staking CounterForValidators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn validate() -> Weight { // Proof Size summary in bytes: - // Measured: `1446` - // Estimated: `19359` - // Minimum execution time: 51_963 nanoseconds. - Weight::from_parts(52_418_000, 19359) + // Measured: `1414` + // Estimated: `30249` + // Minimum execution time: 60_509_000 picoseconds. + Weight::from_parts(61_305_000, 30249) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -248,12 +251,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `k` is `[1, 128]`. fn kick(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1292 + k * (601 ±0)` - // Estimated: `3566 + k * (3033 ±0)` - // Minimum execution time: 25_685 nanoseconds. - Weight::from_parts(25_290_286, 3566) - // Standard Error: 5_164 - .saturating_add(Weight::from_parts(6_445_608, 0).saturating_mul(k.into())) + // Measured: `1260 + k * (569 ±0)` + // Estimated: `5546 + k * (3033 ±0)` + // Minimum execution time: 30_063_000 picoseconds. + Weight::from_parts(31_774_698, 5546) + // Standard Error: 11_088 + .saturating_add(Weight::from_parts(7_869_325, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -284,12 +287,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1984 + n * (105 ±0)` - // Estimated: `21988 + n * (2520 ±0)` - // Minimum execution time: 59_542 nanoseconds. - Weight::from_parts(57_558_678, 21988) - // Standard Error: 10_364 - .saturating_add(Weight::from_parts(2_759_713, 0).saturating_mul(n.into())) + // Measured: `1888 + n * (105 ±0)` + // Estimated: `32878 + n * (2520 ±0)` + // Minimum execution time: 70_091_000 picoseconds. + Weight::from_parts(67_744_973, 32878) + // Standard Error: 12_799 + .saturating_add(Weight::from_parts(3_238_224, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) @@ -311,10 +314,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill() -> Weight { // Proof Size summary in bytes: - // Measured: `1876` - // Estimated: `17932` - // Minimum execution time: 52_132 nanoseconds. - Weight::from_parts(52_648_000, 17932) + // Measured: `1748` + // Estimated: `24862` + // Minimum execution time: 60_582_000 picoseconds. + Weight::from_parts(61_208_000, 24862) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -324,10 +327,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn set_payee() -> Weight { // Proof Size summary in bytes: - // Measured: `840` - // Estimated: `3566` - // Minimum execution time: 13_399 nanoseconds. - Weight::from_parts(13_567_000, 3566) + // Measured: `808` + // Estimated: `4556` + // Minimum execution time: 15_630_000 picoseconds. + Weight::from_parts(16_018_000, 4556) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -337,10 +340,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) fn set_controller() -> Weight { // Proof Size summary in bytes: - // Measured: `939` - // Estimated: `9679` - // Minimum execution time: 20_425 nanoseconds. - Weight::from_parts(20_713_000, 9679) + // Measured: `907` + // Estimated: `11659` + // Minimum execution time: 23_895_000 picoseconds. + Weight::from_parts(24_306_000, 11659) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -350,8 +353,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_069 nanoseconds. - Weight::from_parts(3_176_000, 0) + // Minimum execution time: 3_694_000 picoseconds. + Weight::from_parts(3_820_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Staking ForceEra (r:0 w:1) @@ -360,8 +363,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_386 nanoseconds. - Weight::from_parts(11_672_000, 0) + // Minimum execution time: 10_729_000 picoseconds. + Weight::from_parts(11_086_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Staking ForceEra (r:0 w:1) @@ -370,8 +373,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_591 nanoseconds. - Weight::from_parts(11_799_000, 0) + // Minimum execution time: 10_959_000 picoseconds. + Weight::from_parts(11_371_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Staking ForceEra (r:0 w:1) @@ -380,8 +383,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_553 nanoseconds. - Weight::from_parts(11_871_000, 0) + // Minimum execution time: 11_101_000 picoseconds. + Weight::from_parts(11_506_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Staking Invulnerables (r:0 w:1) @@ -391,10 +394,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_292 nanoseconds. - Weight::from_parts(3_754_352, 0) - // Standard Error: 40 - .saturating_add(Weight::from_parts(9_838, 0).saturating_mul(v.into())) + // Minimum execution time: 4_016_000 picoseconds. + Weight::from_parts(4_454_020, 0) + // Standard Error: 82 + .saturating_add(Weight::from_parts(10_703, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Staking Bonded (r:1 w:1) @@ -426,12 +429,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 100]`. fn force_unstake(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2178 + s * (4 ±0)` - // Estimated: `27930 + s * (4 ±0)` - // Minimum execution time: 65_307 nanoseconds. - Weight::from_parts(70_227_980, 27930) - // Standard Error: 2_113 - .saturating_add(Weight::from_parts(1_059_856, 0).saturating_mul(s.into())) + // Measured: `2018 + s * (4 ±0)` + // Estimated: `37678 + s * (4 ±0)` + // Minimum execution time: 76_338_000 picoseconds. + Weight::from_parts(82_426_098, 37678) + // Standard Error: 3_761 + .saturating_add(Weight::from_parts(1_279_343, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(12_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -442,12 +445,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 1000]`. fn cancel_deferred_slash(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `66671` - // Estimated: `69146` - // Minimum execution time: 89_123 nanoseconds. - Weight::from_parts(890_989_741, 69146) - // Standard Error: 58_282 - .saturating_add(Weight::from_parts(4_920_413, 0).saturating_mul(s.into())) + // Measured: `66639` + // Estimated: `70104` + // Minimum execution time: 91_160_000 picoseconds. + Weight::from_parts(794_662_495, 70104) + // Standard Error: 51_479 + .saturating_add(Weight::from_parts(4_346_694, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -472,12 +475,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 256]`. fn payout_stakers_dead_controller(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `20345 + n * (143 ±0)` - // Estimated: `54756 + n * (8024 ±1)` - // Minimum execution time: 73_652 nanoseconds. - Weight::from_parts(127_839_483, 54756) - // Standard Error: 14_195 - .saturating_add(Weight::from_parts(21_932_079, 0).saturating_mul(n.into())) + // Measured: `20217 + n * (143 ±0)` + // Estimated: `63416 + n * (8024 ±1)` + // Minimum execution time: 77_845_000 picoseconds. + Weight::from_parts(86_178_186, 63416) + // Standard Error: 21_971 + .saturating_add(Weight::from_parts(26_966_654, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -507,17 +510,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 256]`. fn payout_stakers_alive_staked(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `35099 + n * (465 ±0)` - // Estimated: `83594 + n * (16026 ±0)` - // Minimum execution time: 94_560 nanoseconds. - Weight::from_parts(154_033_219, 83594) - // Standard Error: 26_663 - .saturating_add(Weight::from_parts(31_269_223, 0).saturating_mul(n.into())) + // Measured: `34971 + n * (401 ±0)` + // Estimated: `93244 + n * (15898 ±0)` + // Minimum execution time: 98_209_000 picoseconds. + Weight::from_parts(102_121_432, 93244) + // Standard Error: 25_633 + .saturating_add(Weight::from_parts(39_244_200, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 16026).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 15898).saturating_mul(n.into())) } /// Storage: Staking Ledger (r:1 w:1) /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) @@ -534,12 +537,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `l` is `[1, 32]`. fn rebond(l: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2253 + l * (7 ±0)` - // Estimated: `25491` - // Minimum execution time: 74_764 nanoseconds. - Weight::from_parts(75_814_067, 25491) - // Standard Error: 1_217 - .saturating_add(Weight::from_parts(64_725, 0).saturating_mul(l.into())) + // Measured: `2029 + l * (7 ±0)` + // Estimated: `31431` + // Minimum execution time: 87_067_000 picoseconds. + Weight::from_parts(87_971_483, 31431) + // Standard Error: 1_668 + .saturating_add(Weight::from_parts(56_024, 0).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } @@ -572,12 +575,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 100]`. fn reap_stash(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2486 + s * (4 ±0)` - // Estimated: `31810 + s * (4 ±0)` - // Minimum execution time: 77_611 nanoseconds. - Weight::from_parts(79_760_034, 31810) - // Standard Error: 1_597 - .saturating_add(Weight::from_parts(1_039_268, 0).saturating_mul(s.into())) + // Measured: `2294 + s * (4 ±0)` + // Estimated: `42515 + s * (4 ±0)` + // Minimum execution time: 90_421_000 picoseconds. + Weight::from_parts(91_873_866, 42515) + // Standard Error: 1_867 + .saturating_add(Weight::from_parts(1_275_581, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(12_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -621,21 +624,21 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 100]`. fn new_era(v: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + v * (3662 ±0) + n * (816 ±0)` - // Estimated: `528203 + v * (16743 ±0) + n * (12947 ±0)` - // Minimum execution time: 489_824 nanoseconds. - Weight::from_parts(491_687_000, 528203) - // Standard Error: 1_787_577 - .saturating_add(Weight::from_parts(58_719_498, 0).saturating_mul(v.into())) - // Standard Error: 178_122 - .saturating_add(Weight::from_parts(13_273_555, 0).saturating_mul(n.into())) + // Measured: `0 + v * (3598 ±0) + n * (720 ±0)` + // Estimated: `537749 + v * (16699 ±39) + n * (12763 ±3)` + // Minimum execution time: 552_452_000 picoseconds. + Weight::from_parts(555_250_000, 537749) + // Standard Error: 1_893_951 + .saturating_add(Weight::from_parts(61_059_451, 0).saturating_mul(v.into())) + // Standard Error: 188_721 + .saturating_add(Weight::from_parts(17_220_679, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(206_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(v.into()))) - .saturating_add(Weight::from_parts(0, 16743).saturating_mul(v.into())) - .saturating_add(Weight::from_parts(0, 12947).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 16699).saturating_mul(v.into())) + .saturating_add(Weight::from_parts(0, 12763).saturating_mul(n.into())) } /// Storage: VoterList CounterForListNodes (r:1 w:0) /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -657,14 +660,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[500, 1000]`. fn get_npos_voters(v: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3167 + v * (459 ±0) + n * (1007 ±0)` - // Estimated: `511899 + v * (14295 ±0) + n * (11775 ±0)` - // Minimum execution time: 23_373_467 nanoseconds. - Weight::from_parts(23_497_257_000, 511899) - // Standard Error: 299_205 - .saturating_add(Weight::from_parts(3_434_000, 0).saturating_mul(v.into())) - // Standard Error: 299_205 - .saturating_add(Weight::from_parts(2_568_954, 0).saturating_mul(n.into())) + // Measured: `3135 + v * (395 ±0) + n * (911 ±0)` + // Estimated: `518829 + v * (14295 ±0) + n * (11775 ±0)` + // Minimum execution time: 32_870_065_000 picoseconds. + Weight::from_parts(33_295_716_000, 518829) + // Standard Error: 371_824 + .saturating_add(Weight::from_parts(5_148_979, 0).saturating_mul(v.into())) + // Standard Error: 371_824 + .saturating_add(Weight::from_parts(3_376_262, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(201_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -680,11 +683,11 @@ impl WeightInfo for SubstrateWeight { fn get_npos_targets(v: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `983 + v * (50 ±0)` - // Estimated: `3019 + v * (2520 ±0)` - // Minimum execution time: 3_882_120 nanoseconds. - Weight::from_parts(3_951_993_000, 3019) - // Standard Error: 46_729 - .saturating_add(Weight::from_parts(2_856_043, 0).saturating_mul(v.into())) + // Estimated: `4999 + v * (2520 ±0)` + // Minimum execution time: 2_321_389_000 picoseconds. + Weight::from_parts(70_122_933, 4999) + // Standard Error: 7_249 + .saturating_add(Weight::from_parts(4_632_666, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(v.into())) @@ -705,8 +708,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_427 nanoseconds. - Weight::from_parts(8_794_000, 0) + // Minimum execution time: 9_581_000 picoseconds. + Weight::from_parts(9_802_000, 0) .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: Staking MinCommission (r:0 w:1) @@ -725,8 +728,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_620 nanoseconds. - Weight::from_parts(7_901_000, 0) + // Minimum execution time: 8_883_000 picoseconds. + Weight::from_parts(9_151_000, 0) .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: Staking Ledger (r:1 w:0) @@ -751,10 +754,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill_other() -> Weight { // Proof Size summary in bytes: - // Measured: `2031` - // Estimated: `19438` - // Minimum execution time: 66_188 nanoseconds. - Weight::from_parts(66_767_000, 19438) + // Measured: `1871` + // Estimated: `29338` + // Minimum execution time: 77_916_000 picoseconds. + Weight::from_parts(78_877_000, 29338) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -765,9 +768,9 @@ impl WeightInfo for SubstrateWeight { fn force_apply_min_commission() -> Weight { // Proof Size summary in bytes: // Measured: `694` - // Estimated: `3019` - // Minimum execution time: 14_703 nanoseconds. - Weight::from_parts(15_031_000, 3019) + // Estimated: `4999` + // Minimum execution time: 16_658_000 picoseconds. + Weight::from_parts(16_968_000, 4999) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -777,8 +780,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_518 nanoseconds. - Weight::from_parts(4_656_000, 0) + // Minimum execution time: 4_982_000 picoseconds. + Weight::from_parts(5_232_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -797,10 +800,10 @@ impl WeightInfo for () { /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn bond() -> Weight { // Proof Size summary in bytes: - // Measured: `1079` - // Estimated: `10386` - // Minimum execution time: 40_015 nanoseconds. - Weight::from_parts(40_601_000, 10386) + // Measured: `1047` + // Estimated: `14346` + // Minimum execution time: 46_401_000 picoseconds. + Weight::from_parts(46_987_000, 14346) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -816,10 +819,10 @@ impl WeightInfo for () { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra() -> Weight { // Proof Size summary in bytes: - // Measured: `2252` - // Estimated: `22888` - // Minimum execution time: 74_781 nanoseconds. - Weight::from_parts(75_188_000, 22888) + // Measured: `2028` + // Estimated: `27838` + // Minimum execution time: 87_755_000 picoseconds. + Weight::from_parts(88_802_000, 27838) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -843,10 +846,10 @@ impl WeightInfo for () { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn unbond() -> Weight { // Proof Size summary in bytes: - // Measured: `2457` - // Estimated: `29534` - // Minimum execution time: 81_299 nanoseconds. - Weight::from_parts(82_242_000, 29534) + // Measured: `2233` + // Estimated: `38444` + // Minimum execution time: 95_698_000 picoseconds. + Weight::from_parts(96_971_000, 38444) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().writes(8_u64)) } @@ -861,12 +864,12 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1085` - // Estimated: `10442` - // Minimum execution time: 31_479 nanoseconds. - Weight::from_parts(32_410_035, 10442) - // Standard Error: 313 - .saturating_add(Weight::from_parts(9_090, 0).saturating_mul(s.into())) + // Measured: `1021` + // Estimated: `14402` + // Minimum execution time: 38_239_000 picoseconds. + Weight::from_parts(39_615_452, 14402) + // Standard Error: 447 + .saturating_add(Weight::from_parts(9_199, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -901,12 +904,12 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_kill(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2486 + s * (4 ±0)` - // Estimated: `32303 + s * (4 ±0)` - // Minimum execution time: 71_968 nanoseconds. - Weight::from_parts(76_631_804, 32303) - // Standard Error: 1_613 - .saturating_add(Weight::from_parts(1_058_968, 0).saturating_mul(s.into())) + // Measured: `2294 + s * (4 ±0)` + // Estimated: `43999 + s * (4 ±0)` + // Minimum execution time: 84_251_000 picoseconds. + Weight::from_parts(90_113_319, 43999) + // Standard Error: 2_177 + .saturating_add(Weight::from_parts(1_278_840, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().writes(12_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -936,10 +939,10 @@ impl WeightInfo for () { /// Proof: Staking CounterForValidators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn validate() -> Weight { // Proof Size summary in bytes: - // Measured: `1446` - // Estimated: `19359` - // Minimum execution time: 51_963 nanoseconds. - Weight::from_parts(52_418_000, 19359) + // Measured: `1414` + // Estimated: `30249` + // Minimum execution time: 60_509_000 picoseconds. + Weight::from_parts(61_305_000, 30249) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -950,12 +953,12 @@ impl WeightInfo for () { /// The range of component `k` is `[1, 128]`. fn kick(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1292 + k * (601 ±0)` - // Estimated: `3566 + k * (3033 ±0)` - // Minimum execution time: 25_685 nanoseconds. - Weight::from_parts(25_290_286, 3566) - // Standard Error: 5_164 - .saturating_add(Weight::from_parts(6_445_608, 0).saturating_mul(k.into())) + // Measured: `1260 + k * (569 ±0)` + // Estimated: `5546 + k * (3033 ±0)` + // Minimum execution time: 30_063_000 picoseconds. + Weight::from_parts(31_774_698, 5546) + // Standard Error: 11_088 + .saturating_add(Weight::from_parts(7_869_325, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -986,12 +989,12 @@ impl WeightInfo for () { /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1984 + n * (105 ±0)` - // Estimated: `21988 + n * (2520 ±0)` - // Minimum execution time: 59_542 nanoseconds. - Weight::from_parts(57_558_678, 21988) - // Standard Error: 10_364 - .saturating_add(Weight::from_parts(2_759_713, 0).saturating_mul(n.into())) + // Measured: `1888 + n * (105 ±0)` + // Estimated: `32878 + n * (2520 ±0)` + // Minimum execution time: 70_091_000 picoseconds. + Weight::from_parts(67_744_973, 32878) + // Standard Error: 12_799 + .saturating_add(Weight::from_parts(3_238_224, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) @@ -1013,10 +1016,10 @@ impl WeightInfo for () { /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill() -> Weight { // Proof Size summary in bytes: - // Measured: `1876` - // Estimated: `17932` - // Minimum execution time: 52_132 nanoseconds. - Weight::from_parts(52_648_000, 17932) + // Measured: `1748` + // Estimated: `24862` + // Minimum execution time: 60_582_000 picoseconds. + Weight::from_parts(61_208_000, 24862) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1026,10 +1029,10 @@ impl WeightInfo for () { /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn set_payee() -> Weight { // Proof Size summary in bytes: - // Measured: `840` - // Estimated: `3566` - // Minimum execution time: 13_399 nanoseconds. - Weight::from_parts(13_567_000, 3566) + // Measured: `808` + // Estimated: `4556` + // Minimum execution time: 15_630_000 picoseconds. + Weight::from_parts(16_018_000, 4556) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1039,10 +1042,10 @@ impl WeightInfo for () { /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) fn set_controller() -> Weight { // Proof Size summary in bytes: - // Measured: `939` - // Estimated: `9679` - // Minimum execution time: 20_425 nanoseconds. - Weight::from_parts(20_713_000, 9679) + // Measured: `907` + // Estimated: `11659` + // Minimum execution time: 23_895_000 picoseconds. + Weight::from_parts(24_306_000, 11659) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1052,8 +1055,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_069 nanoseconds. - Weight::from_parts(3_176_000, 0) + // Minimum execution time: 3_694_000 picoseconds. + Weight::from_parts(3_820_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Staking ForceEra (r:0 w:1) @@ -1062,8 +1065,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_386 nanoseconds. - Weight::from_parts(11_672_000, 0) + // Minimum execution time: 10_729_000 picoseconds. + Weight::from_parts(11_086_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Staking ForceEra (r:0 w:1) @@ -1072,8 +1075,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_591 nanoseconds. - Weight::from_parts(11_799_000, 0) + // Minimum execution time: 10_959_000 picoseconds. + Weight::from_parts(11_371_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Staking ForceEra (r:0 w:1) @@ -1082,8 +1085,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_553 nanoseconds. - Weight::from_parts(11_871_000, 0) + // Minimum execution time: 11_101_000 picoseconds. + Weight::from_parts(11_506_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Staking Invulnerables (r:0 w:1) @@ -1093,10 +1096,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_292 nanoseconds. - Weight::from_parts(3_754_352, 0) - // Standard Error: 40 - .saturating_add(Weight::from_parts(9_838, 0).saturating_mul(v.into())) + // Minimum execution time: 4_016_000 picoseconds. + Weight::from_parts(4_454_020, 0) + // Standard Error: 82 + .saturating_add(Weight::from_parts(10_703, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Staking Bonded (r:1 w:1) @@ -1128,12 +1131,12 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 100]`. fn force_unstake(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2178 + s * (4 ±0)` - // Estimated: `27930 + s * (4 ±0)` - // Minimum execution time: 65_307 nanoseconds. - Weight::from_parts(70_227_980, 27930) - // Standard Error: 2_113 - .saturating_add(Weight::from_parts(1_059_856, 0).saturating_mul(s.into())) + // Measured: `2018 + s * (4 ±0)` + // Estimated: `37678 + s * (4 ±0)` + // Minimum execution time: 76_338_000 picoseconds. + Weight::from_parts(82_426_098, 37678) + // Standard Error: 3_761 + .saturating_add(Weight::from_parts(1_279_343, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(12_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -1144,12 +1147,12 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 1000]`. fn cancel_deferred_slash(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `66671` - // Estimated: `69146` - // Minimum execution time: 89_123 nanoseconds. - Weight::from_parts(890_989_741, 69146) - // Standard Error: 58_282 - .saturating_add(Weight::from_parts(4_920_413, 0).saturating_mul(s.into())) + // Measured: `66639` + // Estimated: `70104` + // Minimum execution time: 91_160_000 picoseconds. + Weight::from_parts(794_662_495, 70104) + // Standard Error: 51_479 + .saturating_add(Weight::from_parts(4_346_694, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1174,12 +1177,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 256]`. fn payout_stakers_dead_controller(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `20345 + n * (143 ±0)` - // Estimated: `54756 + n * (8024 ±1)` - // Minimum execution time: 73_652 nanoseconds. - Weight::from_parts(127_839_483, 54756) - // Standard Error: 14_195 - .saturating_add(Weight::from_parts(21_932_079, 0).saturating_mul(n.into())) + // Measured: `20217 + n * (143 ±0)` + // Estimated: `63416 + n * (8024 ±1)` + // Minimum execution time: 77_845_000 picoseconds. + Weight::from_parts(86_178_186, 63416) + // Standard Error: 21_971 + .saturating_add(Weight::from_parts(26_966_654, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -1209,17 +1212,17 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 256]`. fn payout_stakers_alive_staked(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `35099 + n * (465 ±0)` - // Estimated: `83594 + n * (16026 ±0)` - // Minimum execution time: 94_560 nanoseconds. - Weight::from_parts(154_033_219, 83594) - // Standard Error: 26_663 - .saturating_add(Weight::from_parts(31_269_223, 0).saturating_mul(n.into())) + // Measured: `34971 + n * (401 ±0)` + // Estimated: `93244 + n * (15898 ±0)` + // Minimum execution time: 98_209_000 picoseconds. + Weight::from_parts(102_121_432, 93244) + // Standard Error: 25_633 + .saturating_add(Weight::from_parts(39_244_200, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 16026).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 15898).saturating_mul(n.into())) } /// Storage: Staking Ledger (r:1 w:1) /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) @@ -1236,12 +1239,12 @@ impl WeightInfo for () { /// The range of component `l` is `[1, 32]`. fn rebond(l: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2253 + l * (7 ±0)` - // Estimated: `25491` - // Minimum execution time: 74_764 nanoseconds. - Weight::from_parts(75_814_067, 25491) - // Standard Error: 1_217 - .saturating_add(Weight::from_parts(64_725, 0).saturating_mul(l.into())) + // Measured: `2029 + l * (7 ±0)` + // Estimated: `31431` + // Minimum execution time: 87_067_000 picoseconds. + Weight::from_parts(87_971_483, 31431) + // Standard Error: 1_668 + .saturating_add(Weight::from_parts(56_024, 0).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(8_u64)) } @@ -1274,12 +1277,12 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 100]`. fn reap_stash(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2486 + s * (4 ±0)` - // Estimated: `31810 + s * (4 ±0)` - // Minimum execution time: 77_611 nanoseconds. - Weight::from_parts(79_760_034, 31810) - // Standard Error: 1_597 - .saturating_add(Weight::from_parts(1_039_268, 0).saturating_mul(s.into())) + // Measured: `2294 + s * (4 ±0)` + // Estimated: `42515 + s * (4 ±0)` + // Minimum execution time: 90_421_000 picoseconds. + Weight::from_parts(91_873_866, 42515) + // Standard Error: 1_867 + .saturating_add(Weight::from_parts(1_275_581, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().writes(12_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -1323,21 +1326,21 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 100]`. fn new_era(v: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + v * (3662 ±0) + n * (816 ±0)` - // Estimated: `528203 + v * (16743 ±0) + n * (12947 ±0)` - // Minimum execution time: 489_824 nanoseconds. - Weight::from_parts(491_687_000, 528203) - // Standard Error: 1_787_577 - .saturating_add(Weight::from_parts(58_719_498, 0).saturating_mul(v.into())) - // Standard Error: 178_122 - .saturating_add(Weight::from_parts(13_273_555, 0).saturating_mul(n.into())) + // Measured: `0 + v * (3598 ±0) + n * (720 ±0)` + // Estimated: `537749 + v * (16699 ±39) + n * (12763 ±3)` + // Minimum execution time: 552_452_000 picoseconds. + Weight::from_parts(555_250_000, 537749) + // Standard Error: 1_893_951 + .saturating_add(Weight::from_parts(61_059_451, 0).saturating_mul(v.into())) + // Standard Error: 188_721 + .saturating_add(Weight::from_parts(17_220_679, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(206_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(v.into()))) - .saturating_add(Weight::from_parts(0, 16743).saturating_mul(v.into())) - .saturating_add(Weight::from_parts(0, 12947).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 16699).saturating_mul(v.into())) + .saturating_add(Weight::from_parts(0, 12763).saturating_mul(n.into())) } /// Storage: VoterList CounterForListNodes (r:1 w:0) /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -1359,14 +1362,14 @@ impl WeightInfo for () { /// The range of component `n` is `[500, 1000]`. fn get_npos_voters(v: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3167 + v * (459 ±0) + n * (1007 ±0)` - // Estimated: `511899 + v * (14295 ±0) + n * (11775 ±0)` - // Minimum execution time: 23_373_467 nanoseconds. - Weight::from_parts(23_497_257_000, 511899) - // Standard Error: 299_205 - .saturating_add(Weight::from_parts(3_434_000, 0).saturating_mul(v.into())) - // Standard Error: 299_205 - .saturating_add(Weight::from_parts(2_568_954, 0).saturating_mul(n.into())) + // Measured: `3135 + v * (395 ±0) + n * (911 ±0)` + // Estimated: `518829 + v * (14295 ±0) + n * (11775 ±0)` + // Minimum execution time: 32_870_065_000 picoseconds. + Weight::from_parts(33_295_716_000, 518829) + // Standard Error: 371_824 + .saturating_add(Weight::from_parts(5_148_979, 0).saturating_mul(v.into())) + // Standard Error: 371_824 + .saturating_add(Weight::from_parts(3_376_262, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(201_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -1382,11 +1385,11 @@ impl WeightInfo for () { fn get_npos_targets(v: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `983 + v * (50 ±0)` - // Estimated: `3019 + v * (2520 ±0)` - // Minimum execution time: 3_882_120 nanoseconds. - Weight::from_parts(3_951_993_000, 3019) - // Standard Error: 46_729 - .saturating_add(Weight::from_parts(2_856_043, 0).saturating_mul(v.into())) + // Estimated: `4999 + v * (2520 ±0)` + // Minimum execution time: 2_321_389_000 picoseconds. + Weight::from_parts(70_122_933, 4999) + // Standard Error: 7_249 + .saturating_add(Weight::from_parts(4_632_666, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(v.into())) @@ -1407,8 +1410,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_427 nanoseconds. - Weight::from_parts(8_794_000, 0) + // Minimum execution time: 9_581_000 picoseconds. + Weight::from_parts(9_802_000, 0) .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: Staking MinCommission (r:0 w:1) @@ -1427,8 +1430,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_620 nanoseconds. - Weight::from_parts(7_901_000, 0) + // Minimum execution time: 8_883_000 picoseconds. + Weight::from_parts(9_151_000, 0) .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: Staking Ledger (r:1 w:0) @@ -1453,10 +1456,10 @@ impl WeightInfo for () { /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill_other() -> Weight { // Proof Size summary in bytes: - // Measured: `2031` - // Estimated: `19438` - // Minimum execution time: 66_188 nanoseconds. - Weight::from_parts(66_767_000, 19438) + // Measured: `1871` + // Estimated: `29338` + // Minimum execution time: 77_916_000 picoseconds. + Weight::from_parts(78_877_000, 29338) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1467,9 +1470,9 @@ impl WeightInfo for () { fn force_apply_min_commission() -> Weight { // Proof Size summary in bytes: // Measured: `694` - // Estimated: `3019` - // Minimum execution time: 14_703 nanoseconds. - Weight::from_parts(15_031_000, 3019) + // Estimated: `4999` + // Minimum execution time: 16_658_000 picoseconds. + Weight::from_parts(16_968_000, 4999) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1479,8 +1482,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_518 nanoseconds. - Weight::from_parts(4_656_000, 0) + // Minimum execution time: 4_982_000 picoseconds. + Weight::from_parts(5_232_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/state-trie-migration/src/weights.rs b/frame/state-trie-migration/src/weights.rs index e087ba185994f..961cec7bcfa51 100644 --- a/frame/state-trie-migration/src/weights.rs +++ b/frame/state-trie-migration/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_state_trie_migration //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_state_trie_migration +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -67,9 +70,9 @@ impl WeightInfo for SubstrateWeight { fn continue_migrate() -> Weight { // Proof Size summary in bytes: // Measured: `108` - // Estimated: `2040` - // Minimum execution time: 15_563 nanoseconds. - Weight::from_parts(15_783_000, 2040) + // Estimated: `4020` + // Minimum execution time: 15_449_000 picoseconds. + Weight::from_parts(16_040_000, 4020) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -78,26 +81,26 @@ impl WeightInfo for SubstrateWeight { fn continue_migrate_wrong_witness() -> Weight { // Proof Size summary in bytes: // Measured: `76` - // Estimated: `503` - // Minimum execution time: 4_347 nanoseconds. - Weight::from_parts(4_558_000, 503) + // Estimated: `1493` + // Minimum execution time: 4_632_000 picoseconds. + Weight::from_parts(4_768_000, 1493) .saturating_add(T::DbWeight::get().reads(1_u64)) } fn migrate_custom_top_success() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_817 nanoseconds. - Weight::from_parts(9_027_000, 0) + // Minimum execution time: 9_596_000 picoseconds. + Weight::from_parts(9_866_000, 0) } /// Storage: unknown `0x666f6f` (r:1 w:1) /// Proof Skipped: unknown `0x666f6f` (r:1 w:1) fn migrate_custom_top_fail() -> Weight { // Proof Size summary in bytes: - // Measured: `144` - // Estimated: `2619` - // Minimum execution time: 23_854 nanoseconds. - Weight::from_parts(24_850_000, 2619) + // Measured: `113` + // Estimated: `3578` + // Minimum execution time: 27_352_000 picoseconds. + Weight::from_parts(28_089_000, 3578) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -105,17 +108,17 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_020 nanoseconds. - Weight::from_parts(9_234_000, 0) + // Minimum execution time: 10_286_000 picoseconds. + Weight::from_parts(10_761_000, 0) } /// Storage: unknown `0x666f6f` (r:1 w:1) /// Proof Skipped: unknown `0x666f6f` (r:1 w:1) fn migrate_custom_child_fail() -> Weight { // Proof Size summary in bytes: - // Measured: `136` - // Estimated: `2611` - // Minimum execution time: 24_136 nanoseconds. - Weight::from_parts(24_810_000, 2611) + // Measured: `105` + // Estimated: `3570` + // Minimum execution time: 27_355_000 picoseconds. + Weight::from_parts(28_092_000, 3570) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -124,12 +127,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[1, 4194304]`. fn process_top_key(v: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `228 + v * (1 ±0)` - // Estimated: `2700 + v * (1 ±0)` - // Minimum execution time: 5_279 nanoseconds. - Weight::from_parts(5_517_000, 2700) + // Measured: `197 + v * (1 ±0)` + // Estimated: `3662 + v * (1 ±0)` + // Minimum execution time: 6_004_000 picoseconds. + Weight::from_parts(6_188_000, 3662) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_230, 0).saturating_mul(v.into())) + .saturating_add(Weight::from_parts(1_073, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(v.into())) @@ -145,9 +148,9 @@ impl WeightInfo for () { fn continue_migrate() -> Weight { // Proof Size summary in bytes: // Measured: `108` - // Estimated: `2040` - // Minimum execution time: 15_563 nanoseconds. - Weight::from_parts(15_783_000, 2040) + // Estimated: `4020` + // Minimum execution time: 15_449_000 picoseconds. + Weight::from_parts(16_040_000, 4020) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -156,26 +159,26 @@ impl WeightInfo for () { fn continue_migrate_wrong_witness() -> Weight { // Proof Size summary in bytes: // Measured: `76` - // Estimated: `503` - // Minimum execution time: 4_347 nanoseconds. - Weight::from_parts(4_558_000, 503) + // Estimated: `1493` + // Minimum execution time: 4_632_000 picoseconds. + Weight::from_parts(4_768_000, 1493) .saturating_add(RocksDbWeight::get().reads(1_u64)) } fn migrate_custom_top_success() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_817 nanoseconds. - Weight::from_parts(9_027_000, 0) + // Minimum execution time: 9_596_000 picoseconds. + Weight::from_parts(9_866_000, 0) } /// Storage: unknown `0x666f6f` (r:1 w:1) /// Proof Skipped: unknown `0x666f6f` (r:1 w:1) fn migrate_custom_top_fail() -> Weight { // Proof Size summary in bytes: - // Measured: `144` - // Estimated: `2619` - // Minimum execution time: 23_854 nanoseconds. - Weight::from_parts(24_850_000, 2619) + // Measured: `113` + // Estimated: `3578` + // Minimum execution time: 27_352_000 picoseconds. + Weight::from_parts(28_089_000, 3578) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -183,17 +186,17 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_020 nanoseconds. - Weight::from_parts(9_234_000, 0) + // Minimum execution time: 10_286_000 picoseconds. + Weight::from_parts(10_761_000, 0) } /// Storage: unknown `0x666f6f` (r:1 w:1) /// Proof Skipped: unknown `0x666f6f` (r:1 w:1) fn migrate_custom_child_fail() -> Weight { // Proof Size summary in bytes: - // Measured: `136` - // Estimated: `2611` - // Minimum execution time: 24_136 nanoseconds. - Weight::from_parts(24_810_000, 2611) + // Measured: `105` + // Estimated: `3570` + // Minimum execution time: 27_355_000 picoseconds. + Weight::from_parts(28_092_000, 3570) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -202,12 +205,12 @@ impl WeightInfo for () { /// The range of component `v` is `[1, 4194304]`. fn process_top_key(v: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `228 + v * (1 ±0)` - // Estimated: `2700 + v * (1 ±0)` - // Minimum execution time: 5_279 nanoseconds. - Weight::from_parts(5_517_000, 2700) + // Measured: `197 + v * (1 ±0)` + // Estimated: `3662 + v * (1 ±0)` + // Minimum execution time: 6_004_000 picoseconds. + Weight::from_parts(6_188_000, 3662) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_230, 0).saturating_mul(v.into())) + .saturating_add(Weight::from_parts(1_073, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(v.into())) diff --git a/frame/support/src/weights/block_weights.rs b/frame/support/src/weights/block_weights.rs index 2389c51d9de9c..b8ac9a0383dee 100644 --- a/frame/support/src/weights/block_weights.rs +++ b/frame/support/src/weights/block_weights.rs @@ -16,8 +16,8 @@ // limitations under the License. //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25 (Y/M/D) -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-03-15 (Y/M/D) +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! //! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Development` //! WARMUPS: `10`, REPEAT: `100` @@ -44,17 +44,17 @@ parameter_types! { /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 377_722, 414_752 - /// Average: 381_015 - /// Median: 379_751 - /// Std-Dev: 5462.64 + /// Min, Max: 402_748, 458_228 + /// Average: 412_772 + /// Median: 406_151 + /// Std-Dev: 13480.33 /// /// Percentiles nanoseconds: - /// 99th: 413_074 - /// 95th: 384_876 - /// 75th: 380_642 + /// 99th: 450_080 + /// 95th: 445_111 + /// 75th: 414_170 pub const BlockExecutionWeight: Weight = - Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(381_015), 0); + Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(412_772), 0); } #[cfg(test)] diff --git a/frame/support/src/weights/extrinsic_weights.rs b/frame/support/src/weights/extrinsic_weights.rs index 78798d2e3a277..44b1b94aeb8ba 100644 --- a/frame/support/src/weights/extrinsic_weights.rs +++ b/frame/support/src/weights/extrinsic_weights.rs @@ -16,8 +16,8 @@ // limitations under the License. //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25 (Y/M/D) -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-03-15 (Y/M/D) +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! //! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Development` //! WARMUPS: `10`, REPEAT: `100` @@ -44,17 +44,17 @@ parameter_types! { /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 99_481, 103_304 - /// Average: 99_840 - /// Median: 99_795 - /// Std-Dev: 376.17 + /// Min, Max: 109_595, 114_170 + /// Average: 110_536 + /// Median: 110_233 + /// Std-Dev: 933.39 /// /// Percentiles nanoseconds: - /// 99th: 100_078 - /// 95th: 100_051 - /// 75th: 99_916 + /// 99th: 114_120 + /// 95th: 112_680 + /// 75th: 110_858 pub const ExtrinsicBaseWeight: Weight = - Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(99_840), 0); + Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(110_536), 0); } #[cfg(test)] diff --git a/frame/system/src/weights.rs b/frame/system/src/weights.rs index 812f2d091fcfe..34c0b62dcdd2f 100644 --- a/frame/system/src/weights.rs +++ b/frame/system/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for frame_system //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=frame_system +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -64,20 +67,20 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_018 nanoseconds. - Weight::from_parts(2_091_000, 0) + // Minimum execution time: 2_519_000 picoseconds. + Weight::from_parts(2_576_000, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(362, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(365, 0).saturating_mul(b.into())) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_449 nanoseconds. - Weight::from_parts(7_748_000, 0) + // Minimum execution time: 8_687_000 picoseconds. + Weight::from_parts(8_875_000, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_423, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(1_121, 0).saturating_mul(b.into())) } /// Storage: System Digest (r:1 w:1) /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) @@ -86,9 +89,9 @@ impl WeightInfo for SubstrateWeight { fn set_heap_pages() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `495` - // Minimum execution time: 4_440 nanoseconds. - Weight::from_parts(4_605_000, 495) + // Estimated: `1485` + // Minimum execution time: 5_281_000 picoseconds. + Weight::from_parts(5_383_000, 1485) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -99,10 +102,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_981 nanoseconds. - Weight::from_parts(2_114_000, 0) - // Standard Error: 804 - .saturating_add(Weight::from_parts(631_438, 0).saturating_mul(i.into())) + // Minimum execution time: 2_346_000 picoseconds. + Weight::from_parts(2_491_000, 0) + // Standard Error: 815 + .saturating_add(Weight::from_parts(731_217, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -112,10 +115,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_061 nanoseconds. - Weight::from_parts(2_153_000, 0) - // Standard Error: 952 - .saturating_add(Weight::from_parts(502_629, 0).saturating_mul(i.into())) + // Minimum execution time: 2_394_000 picoseconds. + Weight::from_parts(2_567_000, 0) + // Standard Error: 935 + .saturating_add(Weight::from_parts(554_023, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -125,10 +128,11 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `116 + p * (69 ±0)` // Estimated: `121 + p * (70 ±0)` - // Minimum execution time: 4_026 nanoseconds. - Weight::from_parts(4_174_000, 121) - // Standard Error: 1_148 - .saturating_add(Weight::from_parts(1_093_099, 0).saturating_mul(p.into())) + // Minimum execution time: 4_706_000 picoseconds. + Weight::from_parts(4_858_000, 121) + // Standard Error: 1_291 + .saturating_add(Weight::from_parts(1_142_198, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) } @@ -141,20 +145,20 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_018 nanoseconds. - Weight::from_parts(2_091_000, 0) + // Minimum execution time: 2_519_000 picoseconds. + Weight::from_parts(2_576_000, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(362, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(365, 0).saturating_mul(b.into())) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_449 nanoseconds. - Weight::from_parts(7_748_000, 0) + // Minimum execution time: 8_687_000 picoseconds. + Weight::from_parts(8_875_000, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_423, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(1_121, 0).saturating_mul(b.into())) } /// Storage: System Digest (r:1 w:1) /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) @@ -163,9 +167,9 @@ impl WeightInfo for () { fn set_heap_pages() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `495` - // Minimum execution time: 4_440 nanoseconds. - Weight::from_parts(4_605_000, 495) + // Estimated: `1485` + // Minimum execution time: 5_281_000 picoseconds. + Weight::from_parts(5_383_000, 1485) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -176,10 +180,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_981 nanoseconds. - Weight::from_parts(2_114_000, 0) - // Standard Error: 804 - .saturating_add(Weight::from_parts(631_438, 0).saturating_mul(i.into())) + // Minimum execution time: 2_346_000 picoseconds. + Weight::from_parts(2_491_000, 0) + // Standard Error: 815 + .saturating_add(Weight::from_parts(731_217, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -189,10 +193,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_061 nanoseconds. - Weight::from_parts(2_153_000, 0) - // Standard Error: 952 - .saturating_add(Weight::from_parts(502_629, 0).saturating_mul(i.into())) + // Minimum execution time: 2_394_000 picoseconds. + Weight::from_parts(2_567_000, 0) + // Standard Error: 935 + .saturating_add(Weight::from_parts(554_023, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -202,10 +206,11 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `116 + p * (69 ±0)` // Estimated: `121 + p * (70 ±0)` - // Minimum execution time: 4_026 nanoseconds. - Weight::from_parts(4_174_000, 121) - // Standard Error: 1_148 - .saturating_add(Weight::from_parts(1_093_099, 0).saturating_mul(p.into())) + // Minimum execution time: 4_706_000 picoseconds. + Weight::from_parts(4_858_000, 121) + // Standard Error: 1_291 + .saturating_add(Weight::from_parts(1_142_198, 0).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(p.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) } diff --git a/frame/timestamp/src/weights.rs b/frame/timestamp/src/weights.rs index 943f941d55305..e1ada6f63c961 100644 --- a/frame/timestamp/src/weights.rs +++ b/frame/timestamp/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_timestamp //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_timestamp +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -62,9 +65,9 @@ impl WeightInfo for SubstrateWeight { fn set() -> Weight { // Proof Size summary in bytes: // Measured: `312` - // Estimated: `1006` - // Minimum execution time: 9_106 nanoseconds. - Weight::from_parts(9_258_000, 1006) + // Estimated: `2986` + // Minimum execution time: 10_913_000 picoseconds. + Weight::from_parts(11_453_000, 2986) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -72,8 +75,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `161` // Estimated: `0` - // Minimum execution time: 3_927 nanoseconds. - Weight::from_parts(4_078_000, 0) + // Minimum execution time: 4_400_000 picoseconds. + Weight::from_parts(4_550_000, 0) } } @@ -86,9 +89,9 @@ impl WeightInfo for () { fn set() -> Weight { // Proof Size summary in bytes: // Measured: `312` - // Estimated: `1006` - // Minimum execution time: 9_106 nanoseconds. - Weight::from_parts(9_258_000, 1006) + // Estimated: `2986` + // Minimum execution time: 10_913_000 picoseconds. + Weight::from_parts(11_453_000, 2986) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -96,7 +99,7 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `161` // Estimated: `0` - // Minimum execution time: 3_927 nanoseconds. - Weight::from_parts(4_078_000, 0) + // Minimum execution time: 4_400_000 picoseconds. + Weight::from_parts(4_550_000, 0) } } diff --git a/frame/tips/src/weights.rs b/frame/tips/src/weights.rs index 2b265d7879712..205413d52d7ff 100644 --- a/frame/tips/src/weights.rs +++ b/frame/tips/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_tips //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_tips +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -67,11 +70,11 @@ impl WeightInfo for SubstrateWeight { fn report_awesome(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `4` - // Estimated: `4958` - // Minimum execution time: 23_262 nanoseconds. - Weight::from_parts(24_104_224, 4958) - // Standard Error: 148 - .saturating_add(Weight::from_parts(1_963, 0).saturating_mul(r.into())) + // Estimated: `6938` + // Minimum execution time: 26_789_000 picoseconds. + Weight::from_parts(27_619_925, 6938) + // Standard Error: 168 + .saturating_add(Weight::from_parts(1_352, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -81,10 +84,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) fn retract_tip() -> Weight { // Proof Size summary in bytes: - // Measured: `253` - // Estimated: `2981` - // Minimum execution time: 22_282 nanoseconds. - Weight::from_parts(22_737_000, 2981) + // Measured: `221` + // Estimated: `3907` + // Minimum execution time: 25_322_000 picoseconds. + Weight::from_parts(26_107_000, 3907) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -96,16 +99,14 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 300]`. /// The range of component `t` is `[1, 13]`. - fn tip_new(r: u32, t: u32, ) -> Weight { + fn tip_new(_r: u32, t: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `558 + t * (64 ±0)` - // Estimated: `4644 + t * (192 ±0)` - // Minimum execution time: 18_382 nanoseconds. - Weight::from_parts(18_195_288, 4644) - // Standard Error: 103 - .saturating_add(Weight::from_parts(2_096, 0).saturating_mul(r.into())) - // Standard Error: 2_469 - .saturating_add(Weight::from_parts(97_092, 0).saturating_mul(t.into())) + // Measured: `526 + t * (64 ±0)` + // Estimated: `6528 + t * (192 ±0)` + // Minimum execution time: 21_112_000 picoseconds. + Weight::from_parts(21_825_317, 6528) + // Standard Error: 11_230 + .saturating_add(Weight::from_parts(86_081, 0).saturating_mul(t.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 192).saturating_mul(t.into())) @@ -117,12 +118,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `t` is `[1, 13]`. fn tip(t: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `811 + t * (112 ±0)` - // Estimated: `4592 + t * (224 ±0)` - // Minimum execution time: 13_564 nanoseconds. - Weight::from_parts(13_867_280, 4592) - // Standard Error: 4_245 - .saturating_add(Weight::from_parts(206_587, 0).saturating_mul(t.into())) + // Measured: `747 + t * (112 ±0)` + // Estimated: `6444 + t * (224 ±0)` + // Minimum execution time: 16_703_000 picoseconds. + Weight::from_parts(16_679_429, 6444) + // Standard Error: 18_088 + .saturating_add(Weight::from_parts(281_667, 0).saturating_mul(t.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 224).saturating_mul(t.into())) @@ -138,12 +139,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `t` is `[1, 13]`. fn close_tip(t: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `850 + t * (112 ±0)` - // Estimated: `8096 + t * (336 ±0)` - // Minimum execution time: 39_902 nanoseconds. - Weight::from_parts(40_747_650, 8096) - // Standard Error: 5_322 - .saturating_add(Weight::from_parts(144_298, 0).saturating_mul(t.into())) + // Measured: `786 + t * (112 ±0)` + // Estimated: `10874 + t * (336 ±0)` + // Minimum execution time: 46_106_000 picoseconds. + Weight::from_parts(47_844_269, 10874) + // Standard Error: 9_247 + .saturating_add(Weight::from_parts(87_804, 0).saturating_mul(t.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 336).saturating_mul(t.into())) @@ -153,14 +154,12 @@ impl WeightInfo for SubstrateWeight { /// Storage: Tips Reasons (r:0 w:1) /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[1, 13]`. - fn slash_tip(t: u32, ) -> Weight { + fn slash_tip(_t: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `301` - // Estimated: `3077` - // Minimum execution time: 13_511 nanoseconds. - Weight::from_parts(14_114_101, 3077) - // Standard Error: 1_815 - .saturating_add(Weight::from_parts(7_825, 0).saturating_mul(t.into())) + // Measured: `269` + // Estimated: `4003` + // Minimum execution time: 15_508_000 picoseconds. + Weight::from_parts(16_207_284, 4003) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -176,11 +175,11 @@ impl WeightInfo for () { fn report_awesome(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `4` - // Estimated: `4958` - // Minimum execution time: 23_262 nanoseconds. - Weight::from_parts(24_104_224, 4958) - // Standard Error: 148 - .saturating_add(Weight::from_parts(1_963, 0).saturating_mul(r.into())) + // Estimated: `6938` + // Minimum execution time: 26_789_000 picoseconds. + Weight::from_parts(27_619_925, 6938) + // Standard Error: 168 + .saturating_add(Weight::from_parts(1_352, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -190,10 +189,10 @@ impl WeightInfo for () { /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) fn retract_tip() -> Weight { // Proof Size summary in bytes: - // Measured: `253` - // Estimated: `2981` - // Minimum execution time: 22_282 nanoseconds. - Weight::from_parts(22_737_000, 2981) + // Measured: `221` + // Estimated: `3907` + // Minimum execution time: 25_322_000 picoseconds. + Weight::from_parts(26_107_000, 3907) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -205,16 +204,14 @@ impl WeightInfo for () { /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 300]`. /// The range of component `t` is `[1, 13]`. - fn tip_new(r: u32, t: u32, ) -> Weight { + fn tip_new(_r: u32, t: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `558 + t * (64 ±0)` - // Estimated: `4644 + t * (192 ±0)` - // Minimum execution time: 18_382 nanoseconds. - Weight::from_parts(18_195_288, 4644) - // Standard Error: 103 - .saturating_add(Weight::from_parts(2_096, 0).saturating_mul(r.into())) - // Standard Error: 2_469 - .saturating_add(Weight::from_parts(97_092, 0).saturating_mul(t.into())) + // Measured: `526 + t * (64 ±0)` + // Estimated: `6528 + t * (192 ±0)` + // Minimum execution time: 21_112_000 picoseconds. + Weight::from_parts(21_825_317, 6528) + // Standard Error: 11_230 + .saturating_add(Weight::from_parts(86_081, 0).saturating_mul(t.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 192).saturating_mul(t.into())) @@ -226,12 +223,12 @@ impl WeightInfo for () { /// The range of component `t` is `[1, 13]`. fn tip(t: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `811 + t * (112 ±0)` - // Estimated: `4592 + t * (224 ±0)` - // Minimum execution time: 13_564 nanoseconds. - Weight::from_parts(13_867_280, 4592) - // Standard Error: 4_245 - .saturating_add(Weight::from_parts(206_587, 0).saturating_mul(t.into())) + // Measured: `747 + t * (112 ±0)` + // Estimated: `6444 + t * (224 ±0)` + // Minimum execution time: 16_703_000 picoseconds. + Weight::from_parts(16_679_429, 6444) + // Standard Error: 18_088 + .saturating_add(Weight::from_parts(281_667, 0).saturating_mul(t.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 224).saturating_mul(t.into())) @@ -247,12 +244,12 @@ impl WeightInfo for () { /// The range of component `t` is `[1, 13]`. fn close_tip(t: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `850 + t * (112 ±0)` - // Estimated: `8096 + t * (336 ±0)` - // Minimum execution time: 39_902 nanoseconds. - Weight::from_parts(40_747_650, 8096) - // Standard Error: 5_322 - .saturating_add(Weight::from_parts(144_298, 0).saturating_mul(t.into())) + // Measured: `786 + t * (112 ±0)` + // Estimated: `10874 + t * (336 ±0)` + // Minimum execution time: 46_106_000 picoseconds. + Weight::from_parts(47_844_269, 10874) + // Standard Error: 9_247 + .saturating_add(Weight::from_parts(87_804, 0).saturating_mul(t.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 336).saturating_mul(t.into())) @@ -262,14 +259,12 @@ impl WeightInfo for () { /// Storage: Tips Reasons (r:0 w:1) /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[1, 13]`. - fn slash_tip(t: u32, ) -> Weight { + fn slash_tip(_t: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `301` - // Estimated: `3077` - // Minimum execution time: 13_511 nanoseconds. - Weight::from_parts(14_114_101, 3077) - // Standard Error: 1_815 - .saturating_add(Weight::from_parts(7_825, 0).saturating_mul(t.into())) + // Measured: `269` + // Estimated: `4003` + // Minimum execution time: 15_508_000 picoseconds. + Weight::from_parts(16_207_284, 4003) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } diff --git a/frame/transaction-storage/src/weights.rs b/frame/transaction-storage/src/weights.rs index 896e1ebab43aa..2845136b7d2a9 100644 --- a/frame/transaction-storage/src/weights.rs +++ b/frame/transaction-storage/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_transaction_storage //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_transaction_storage +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -66,11 +69,11 @@ impl WeightInfo for SubstrateWeight { fn store(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `176` - // Estimated: `38383` - // Minimum execution time: 28_702 nanoseconds. - Weight::from_parts(29_164_000, 38383) + // Estimated: `41353` + // Minimum execution time: 33_286_000 picoseconds. + Weight::from_parts(33_596_000, 41353) // Standard Error: 2 - .saturating_add(Weight::from_parts(5_601, 0).saturating_mul(l.into())) + .saturating_add(Weight::from_parts(4_954, 0).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -84,10 +87,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: TransactionStorage BlockTransactions (max_values: Some(1), max_size: Some(36866), added: 37361, mode: MaxEncodedLen) fn renew() -> Weight { // Proof Size summary in bytes: - // Measured: `358` - // Estimated: `77744` - // Minimum execution time: 36_219 nanoseconds. - Weight::from_parts(36_979_000, 77744) + // Measured: `326` + // Estimated: `81704` + // Minimum execution time: 41_892_000 picoseconds. + Weight::from_parts(42_802_000, 81704) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -103,10 +106,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: TransactionStorage Transactions (max_values: None, max_size: Some(36886), added: 39361, mode: MaxEncodedLen) fn check_proof_max() -> Weight { // Proof Size summary in bytes: - // Measured: `37177` - // Estimated: `43382` - // Minimum execution time: 55_793 nanoseconds. - Weight::from_parts(57_128_000, 43382) + // Measured: `37145` + // Estimated: `48332` + // Minimum execution time: 63_799_000 picoseconds. + Weight::from_parts(66_145_000, 48332) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -124,11 +127,11 @@ impl WeightInfo for () { fn store(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `176` - // Estimated: `38383` - // Minimum execution time: 28_702 nanoseconds. - Weight::from_parts(29_164_000, 38383) + // Estimated: `41353` + // Minimum execution time: 33_286_000 picoseconds. + Weight::from_parts(33_596_000, 41353) // Standard Error: 2 - .saturating_add(Weight::from_parts(5_601, 0).saturating_mul(l.into())) + .saturating_add(Weight::from_parts(4_954, 0).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -142,10 +145,10 @@ impl WeightInfo for () { /// Proof: TransactionStorage BlockTransactions (max_values: Some(1), max_size: Some(36866), added: 37361, mode: MaxEncodedLen) fn renew() -> Weight { // Proof Size summary in bytes: - // Measured: `358` - // Estimated: `77744` - // Minimum execution time: 36_219 nanoseconds. - Weight::from_parts(36_979_000, 77744) + // Measured: `326` + // Estimated: `81704` + // Minimum execution time: 41_892_000 picoseconds. + Weight::from_parts(42_802_000, 81704) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -161,10 +164,10 @@ impl WeightInfo for () { /// Proof: TransactionStorage Transactions (max_values: None, max_size: Some(36886), added: 39361, mode: MaxEncodedLen) fn check_proof_max() -> Weight { // Proof Size summary in bytes: - // Measured: `37177` - // Estimated: `43382` - // Minimum execution time: 55_793 nanoseconds. - Weight::from_parts(57_128_000, 43382) + // Measured: `37145` + // Estimated: `48332` + // Minimum execution time: 63_799_000 picoseconds. + Weight::from_parts(66_145_000, 48332) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index abf461c622a0f..a7c093a8001ec 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_treasury //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_treasury +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -68,9 +71,9 @@ impl WeightInfo for SubstrateWeight { fn spend() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `1396` - // Minimum execution time: 14_277 nanoseconds. - Weight::from_parts(14_749_000, 1396) + // Estimated: `3376` + // Minimum execution time: 17_010_000 picoseconds. + Weight::from_parts(17_247_000, 3376) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -80,10 +83,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn propose_spend() -> Weight { // Proof Size summary in bytes: - // Measured: `175` - // Estimated: `499` - // Minimum execution time: 23_297 nanoseconds. - Weight::from_parts(23_585_000, 499) + // Measured: `143` + // Estimated: `1489` + // Minimum execution time: 25_780_000 picoseconds. + Weight::from_parts(41_064_000, 1489) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -93,10 +96,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn reject_proposal() -> Weight { // Proof Size summary in bytes: - // Measured: `365` - // Estimated: `5186` - // Minimum execution time: 23_996 nanoseconds. - Weight::from_parts(24_548_000, 5186) + // Measured: `301` + // Estimated: `7166` + // Minimum execution time: 27_805_000 picoseconds. + Weight::from_parts(28_322_000, 7166) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -107,12 +110,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[0, 99]`. fn approve_proposal(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `501 + p * (8 ±0)` - // Estimated: `3480` - // Minimum execution time: 9_366 nanoseconds. - Weight::from_parts(11_731_455, 3480) - // Standard Error: 761 - .saturating_add(Weight::from_parts(21_665, 0).saturating_mul(p.into())) + // Measured: `470 + p * (8 ±0)` + // Estimated: `5460` + // Minimum execution time: 10_939_000 picoseconds. + Weight::from_parts(13_667_341, 5460) + // Standard Error: 907 + .saturating_add(Weight::from_parts(26_648, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -121,9 +124,9 @@ impl WeightInfo for SubstrateWeight { fn remove_approval() -> Weight { // Proof Size summary in bytes: // Measured: `127` - // Estimated: `897` - // Minimum execution time: 7_012 nanoseconds. - Weight::from_parts(7_270_000, 897) + // Estimated: `1887` + // Minimum execution time: 8_261_000 picoseconds. + Weight::from_parts(8_399_000, 1887) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -140,12 +143,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[0, 100]`. fn on_initialize_proposals(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `415 + p * (314 ±0)` - // Estimated: `2305 + p * (7789 ±0)` - // Minimum execution time: 37_834 nanoseconds. - Weight::from_parts(47_496_917, 2305) - // Standard Error: 12_505 - .saturating_add(Weight::from_parts(26_902_474, 0).saturating_mul(p.into())) + // Measured: `387 + p * (251 ±0)` + // Estimated: `7255 + p * (7789 ±0)` + // Minimum execution time: 43_781_000 picoseconds. + Weight::from_parts(68_521_487, 7255) + // Standard Error: 58_804 + .saturating_add(Weight::from_parts(33_271_211, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -165,9 +168,9 @@ impl WeightInfo for () { fn spend() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `1396` - // Minimum execution time: 14_277 nanoseconds. - Weight::from_parts(14_749_000, 1396) + // Estimated: `3376` + // Minimum execution time: 17_010_000 picoseconds. + Weight::from_parts(17_247_000, 3376) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -177,10 +180,10 @@ impl WeightInfo for () { /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn propose_spend() -> Weight { // Proof Size summary in bytes: - // Measured: `175` - // Estimated: `499` - // Minimum execution time: 23_297 nanoseconds. - Weight::from_parts(23_585_000, 499) + // Measured: `143` + // Estimated: `1489` + // Minimum execution time: 25_780_000 picoseconds. + Weight::from_parts(41_064_000, 1489) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -190,10 +193,10 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn reject_proposal() -> Weight { // Proof Size summary in bytes: - // Measured: `365` - // Estimated: `5186` - // Minimum execution time: 23_996 nanoseconds. - Weight::from_parts(24_548_000, 5186) + // Measured: `301` + // Estimated: `7166` + // Minimum execution time: 27_805_000 picoseconds. + Weight::from_parts(28_322_000, 7166) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -204,12 +207,12 @@ impl WeightInfo for () { /// The range of component `p` is `[0, 99]`. fn approve_proposal(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `501 + p * (8 ±0)` - // Estimated: `3480` - // Minimum execution time: 9_366 nanoseconds. - Weight::from_parts(11_731_455, 3480) - // Standard Error: 761 - .saturating_add(Weight::from_parts(21_665, 0).saturating_mul(p.into())) + // Measured: `470 + p * (8 ±0)` + // Estimated: `5460` + // Minimum execution time: 10_939_000 picoseconds. + Weight::from_parts(13_667_341, 5460) + // Standard Error: 907 + .saturating_add(Weight::from_parts(26_648, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -218,9 +221,9 @@ impl WeightInfo for () { fn remove_approval() -> Weight { // Proof Size summary in bytes: // Measured: `127` - // Estimated: `897` - // Minimum execution time: 7_012 nanoseconds. - Weight::from_parts(7_270_000, 897) + // Estimated: `1887` + // Minimum execution time: 8_261_000 picoseconds. + Weight::from_parts(8_399_000, 1887) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -237,12 +240,12 @@ impl WeightInfo for () { /// The range of component `p` is `[0, 100]`. fn on_initialize_proposals(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `415 + p * (314 ±0)` - // Estimated: `2305 + p * (7789 ±0)` - // Minimum execution time: 37_834 nanoseconds. - Weight::from_parts(47_496_917, 2305) - // Standard Error: 12_505 - .saturating_add(Weight::from_parts(26_902_474, 0).saturating_mul(p.into())) + // Measured: `387 + p * (251 ±0)` + // Estimated: `7255 + p * (7789 ±0)` + // Minimum execution time: 43_781_000 picoseconds. + Weight::from_parts(68_521_487, 7255) + // Standard Error: 58_804 + .saturating_add(Weight::from_parts(33_271_211, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(p.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) diff --git a/frame/uniques/src/weights.rs b/frame/uniques/src/weights.rs index edf3bd35dcef0..1f0e3772696f7 100644 --- a/frame/uniques/src/weights.rs +++ b/frame/uniques/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_uniques //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_uniques +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -85,10 +88,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn create() -> Weight { // Proof Size summary in bytes: - // Measured: `281` - // Estimated: `2653` - // Minimum execution time: 24_242 nanoseconds. - Weight::from_parts(24_682_000, 2653) + // Measured: `249` + // Estimated: `3643` + // Minimum execution time: 27_805_000 picoseconds. + Weight::from_parts(28_303_000, 3643) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -99,9 +102,9 @@ impl WeightInfo for SubstrateWeight { fn force_create() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `2653` - // Minimum execution time: 14_145 nanoseconds. - Weight::from_parts(14_598_000, 2653) + // Estimated: `3643` + // Minimum execution time: 16_257_000 picoseconds. + Weight::from_parts(16_626_000, 3643) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -109,14 +112,14 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) /// Storage: Uniques Asset (r:1001 w:1000) /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques InstanceMetadataOf (r:1000 w:1000) + /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: Uniques Attribute (r:1000 w:1000) + /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) /// Storage: Uniques ClassAccount (r:0 w:1) /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) - /// Storage: Uniques Attribute (r:0 w:1000) - /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) /// Storage: Uniques ClassMetadataOf (r:0 w:1) /// Proof: Uniques ClassMetadataOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) - /// Storage: Uniques InstanceMetadataOf (r:0 w:1000) - /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) /// Storage: Uniques Account (r:0 w:1000) /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) /// Storage: Uniques CollectionMaxSupply (r:0 w:1) @@ -126,23 +129,27 @@ impl WeightInfo for SubstrateWeight { /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `450 + n * (108 ±0) + m * (56 ±0) + a * (107 ±0)` - // Estimated: `5250 + n * (2597 ±0)` - // Minimum execution time: 2_404_081 nanoseconds. - Weight::from_parts(2_419_004_000, 5250) - // Standard Error: 27_175 - .saturating_add(Weight::from_parts(8_616_904, 0).saturating_mul(n.into())) - // Standard Error: 27_175 - .saturating_add(Weight::from_parts(334_249, 0).saturating_mul(m.into())) - // Standard Error: 27_175 - .saturating_add(Weight::from_parts(213_038, 0).saturating_mul(a.into())) + // Measured: `418 + n * (76 ±0) + m * (56 ±0) + a * (107 ±0)` + // Estimated: `9210 + n * (2597 ±0) + a * (2839 ±0) + m * (2583 ±0)` + // Minimum execution time: 2_510_772_000 picoseconds. + Weight::from_parts(2_522_511_000, 9210) + // Standard Error: 27_455 + .saturating_add(Weight::from_parts(6_708_827, 0).saturating_mul(n.into())) + // Standard Error: 27_455 + .saturating_add(Weight::from_parts(375_591, 0).saturating_mul(m.into())) + // Standard Error: 27_455 + .saturating_add(Weight::from_parts(251_697, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(m.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) .saturating_add(Weight::from_parts(0, 2597).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(a.into())) + .saturating_add(Weight::from_parts(0, 2583).saturating_mul(m.into())) } /// Storage: Uniques Asset (r:1 w:1) /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) @@ -154,10 +161,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `7749` - // Minimum execution time: 29_326 nanoseconds. - Weight::from_parts(29_671_000, 7749) + // Measured: `349` + // Estimated: `10719` + // Minimum execution time: 33_959_000 picoseconds. + Weight::from_parts(34_380_000, 10719) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -171,10 +178,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn burn() -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `5250` - // Minimum execution time: 30_497 nanoseconds. - Weight::from_parts(30_714_000, 5250) + // Measured: `495` + // Estimated: `7230` + // Minimum execution time: 34_194_000 picoseconds. + Weight::from_parts(34_808_000, 7230) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -188,10 +195,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `5250` - // Minimum execution time: 24_212 nanoseconds. - Weight::from_parts(24_681_000, 5250) + // Measured: `495` + // Estimated: `7230` + // Minimum execution time: 27_841_000 picoseconds. + Weight::from_parts(28_263_000, 7230) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -202,12 +209,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `837 + i * (108 ±0)` - // Estimated: `2653 + i * (2597 ±0)` - // Minimum execution time: 13_633 nanoseconds. - Weight::from_parts(13_797_000, 2653) - // Standard Error: 9_293 - .saturating_add(Weight::from_parts(11_163_914, 0).saturating_mul(i.into())) + // Measured: `805 + i * (76 ±0)` + // Estimated: `4633 + i * (2597 ±0)` + // Minimum execution time: 15_577_000 picoseconds. + Weight::from_parts(15_706_000, 4633) + // Standard Error: 17_679 + .saturating_add(Weight::from_parts(14_173_779, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -220,10 +227,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn freeze() -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `5250` - // Minimum execution time: 17_126 nanoseconds. - Weight::from_parts(17_572_000, 5250) + // Measured: `495` + // Estimated: `7230` + // Minimum execution time: 19_474_000 picoseconds. + Weight::from_parts(19_807_000, 7230) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -233,10 +240,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn thaw() -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `5250` - // Minimum execution time: 17_209 nanoseconds. - Weight::from_parts(17_411_000, 5250) + // Measured: `495` + // Estimated: `7230` + // Minimum execution time: 19_526_000 picoseconds. + Weight::from_parts(19_818_000, 7230) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -244,10 +251,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn freeze_collection() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `2653` - // Minimum execution time: 13_048 nanoseconds. - Weight::from_parts(13_589_000, 2653) + // Measured: `349` + // Estimated: `3643` + // Minimum execution time: 15_324_000 picoseconds. + Weight::from_parts(15_599_000, 3643) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -255,10 +262,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn thaw_collection() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `2653` - // Minimum execution time: 12_908 nanoseconds. - Weight::from_parts(13_098_000, 2653) + // Measured: `349` + // Estimated: `3643` + // Minimum execution time: 15_294_000 picoseconds. + Weight::from_parts(15_504_000, 3643) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -270,10 +277,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { // Proof Size summary in bytes: - // Measured: `455` - // Estimated: `5180` - // Minimum execution time: 20_629 nanoseconds. - Weight::from_parts(21_448_000, 5180) + // Measured: `423` + // Estimated: `7160` + // Minimum execution time: 24_007_000 picoseconds. + Weight::from_parts(24_555_000, 7160) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -281,10 +288,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn set_team() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `2653` - // Minimum execution time: 13_740 nanoseconds. - Weight::from_parts(14_020_000, 2653) + // Measured: `349` + // Estimated: `3643` + // Minimum execution time: 15_616_000 picoseconds. + Weight::from_parts(15_897_000, 3643) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -294,10 +301,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_item_status() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `2653` - // Minimum execution time: 16_293 nanoseconds. - Weight::from_parts(16_509_000, 2653) + // Measured: `349` + // Estimated: `3643` + // Minimum execution time: 18_459_000 picoseconds. + Weight::from_parts(18_705_000, 3643) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -309,10 +316,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) fn set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `611` - // Estimated: `8075` - // Minimum execution time: 33_560 nanoseconds. - Weight::from_parts(34_263_000, 8075) + // Measured: `547` + // Estimated: `11045` + // Minimum execution time: 39_056_000 picoseconds. + Weight::from_parts(39_513_000, 11045) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -324,10 +331,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) fn clear_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `1031` - // Estimated: `8075` - // Minimum execution time: 31_955 nanoseconds. - Weight::from_parts(32_447_000, 8075) + // Measured: `936` + // Estimated: `11045` + // Minimum execution time: 37_441_000 picoseconds. + Weight::from_parts(37_859_000, 11045) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -337,10 +344,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn set_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `447` - // Estimated: `5236` - // Minimum execution time: 25_520 nanoseconds. - Weight::from_parts(25_843_000, 5236) + // Measured: `415` + // Estimated: `7216` + // Minimum execution time: 29_456_000 picoseconds. + Weight::from_parts(29_930_000, 7216) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -350,10 +357,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `611` - // Estimated: `5236` - // Minimum execution time: 25_812 nanoseconds. - Weight::from_parts(26_141_000, 5236) + // Measured: `547` + // Estimated: `7216` + // Minimum execution time: 29_817_000 picoseconds. + Weight::from_parts(30_364_000, 7216) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -363,10 +370,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques ClassMetadataOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `5216` - // Minimum execution time: 25_055 nanoseconds. - Weight::from_parts(25_244_000, 5216) + // Measured: `349` + // Estimated: `7196` + // Minimum execution time: 29_392_000 picoseconds. + Weight::from_parts(29_878_000, 7196) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -376,10 +383,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques ClassMetadataOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `525` - // Estimated: `5216` - // Minimum execution time: 23_311 nanoseconds. - Weight::from_parts(23_682_000, 5216) + // Measured: `461` + // Estimated: `7196` + // Minimum execution time: 27_234_000 picoseconds. + Weight::from_parts(27_664_000, 7196) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -389,10 +396,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) fn approve_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `5250` - // Minimum execution time: 17_709 nanoseconds. - Weight::from_parts(18_308_000, 5250) + // Measured: `495` + // Estimated: `7230` + // Minimum execution time: 20_447_000 picoseconds. + Weight::from_parts(20_886_000, 7230) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -402,10 +409,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) fn cancel_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `592` - // Estimated: `5250` - // Minimum execution time: 17_656 nanoseconds. - Weight::from_parts(18_039_000, 5250) + // Measured: `528` + // Estimated: `7230` + // Minimum execution time: 20_934_000 picoseconds. + Weight::from_parts(21_271_000, 7230) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -414,9 +421,9 @@ impl WeightInfo for SubstrateWeight { fn set_accept_ownership() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `2527` - // Minimum execution time: 14_615 nanoseconds. - Weight::from_parts(14_931_000, 2527) + // Estimated: `3517` + // Minimum execution time: 17_004_000 picoseconds. + Weight::from_parts(17_401_000, 3517) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -426,10 +433,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `5152` - // Minimum execution time: 14_974 nanoseconds. - Weight::from_parts(15_314_000, 5152) + // Measured: `349` + // Estimated: `7132` + // Minimum execution time: 17_371_000 picoseconds. + Weight::from_parts(18_103_000, 7132) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -439,10 +446,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn set_price() -> Weight { // Proof Size summary in bytes: - // Measured: `358` - // Estimated: `2597` - // Minimum execution time: 15_444 nanoseconds. - Weight::from_parts(15_886_000, 2597) + // Measured: `326` + // Estimated: `3587` + // Minimum execution time: 17_624_000 picoseconds. + Weight::from_parts(17_866_000, 3587) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -456,10 +463,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn buy_item() -> Weight { // Proof Size summary in bytes: - // Measured: `703` - // Estimated: `7814` - // Minimum execution time: 35_628 nanoseconds. - Weight::from_parts(35_886_000, 7814) + // Measured: `607` + // Estimated: `10784` + // Minimum execution time: 39_736_000 picoseconds. + Weight::from_parts(40_855_000, 10784) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -473,10 +480,10 @@ impl WeightInfo for () { /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn create() -> Weight { // Proof Size summary in bytes: - // Measured: `281` - // Estimated: `2653` - // Minimum execution time: 24_242 nanoseconds. - Weight::from_parts(24_682_000, 2653) + // Measured: `249` + // Estimated: `3643` + // Minimum execution time: 27_805_000 picoseconds. + Weight::from_parts(28_303_000, 3643) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -487,9 +494,9 @@ impl WeightInfo for () { fn force_create() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `2653` - // Minimum execution time: 14_145 nanoseconds. - Weight::from_parts(14_598_000, 2653) + // Estimated: `3643` + // Minimum execution time: 16_257_000 picoseconds. + Weight::from_parts(16_626_000, 3643) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -497,14 +504,14 @@ impl WeightInfo for () { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) /// Storage: Uniques Asset (r:1001 w:1000) /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques InstanceMetadataOf (r:1000 w:1000) + /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: Uniques Attribute (r:1000 w:1000) + /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) /// Storage: Uniques ClassAccount (r:0 w:1) /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) - /// Storage: Uniques Attribute (r:0 w:1000) - /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) /// Storage: Uniques ClassMetadataOf (r:0 w:1) /// Proof: Uniques ClassMetadataOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) - /// Storage: Uniques InstanceMetadataOf (r:0 w:1000) - /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) /// Storage: Uniques Account (r:0 w:1000) /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) /// Storage: Uniques CollectionMaxSupply (r:0 w:1) @@ -514,23 +521,27 @@ impl WeightInfo for () { /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `450 + n * (108 ±0) + m * (56 ±0) + a * (107 ±0)` - // Estimated: `5250 + n * (2597 ±0)` - // Minimum execution time: 2_404_081 nanoseconds. - Weight::from_parts(2_419_004_000, 5250) - // Standard Error: 27_175 - .saturating_add(Weight::from_parts(8_616_904, 0).saturating_mul(n.into())) - // Standard Error: 27_175 - .saturating_add(Weight::from_parts(334_249, 0).saturating_mul(m.into())) - // Standard Error: 27_175 - .saturating_add(Weight::from_parts(213_038, 0).saturating_mul(a.into())) + // Measured: `418 + n * (76 ±0) + m * (56 ±0) + a * (107 ±0)` + // Estimated: `9210 + n * (2597 ±0) + a * (2839 ±0) + m * (2583 ±0)` + // Minimum execution time: 2_510_772_000 picoseconds. + Weight::from_parts(2_522_511_000, 9210) + // Standard Error: 27_455 + .saturating_add(Weight::from_parts(6_708_827, 0).saturating_mul(n.into())) + // Standard Error: 27_455 + .saturating_add(Weight::from_parts(375_591, 0).saturating_mul(m.into())) + // Standard Error: 27_455 + .saturating_add(Weight::from_parts(251_697, 0).saturating_mul(a.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(m.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(m.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) .saturating_add(Weight::from_parts(0, 2597).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(a.into())) + .saturating_add(Weight::from_parts(0, 2583).saturating_mul(m.into())) } /// Storage: Uniques Asset (r:1 w:1) /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) @@ -542,10 +553,10 @@ impl WeightInfo for () { /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `7749` - // Minimum execution time: 29_326 nanoseconds. - Weight::from_parts(29_671_000, 7749) + // Measured: `349` + // Estimated: `10719` + // Minimum execution time: 33_959_000 picoseconds. + Weight::from_parts(34_380_000, 10719) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -559,10 +570,10 @@ impl WeightInfo for () { /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn burn() -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `5250` - // Minimum execution time: 30_497 nanoseconds. - Weight::from_parts(30_714_000, 5250) + // Measured: `495` + // Estimated: `7230` + // Minimum execution time: 34_194_000 picoseconds. + Weight::from_parts(34_808_000, 7230) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -576,10 +587,10 @@ impl WeightInfo for () { /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `5250` - // Minimum execution time: 24_212 nanoseconds. - Weight::from_parts(24_681_000, 5250) + // Measured: `495` + // Estimated: `7230` + // Minimum execution time: 27_841_000 picoseconds. + Weight::from_parts(28_263_000, 7230) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -590,12 +601,12 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `837 + i * (108 ±0)` - // Estimated: `2653 + i * (2597 ±0)` - // Minimum execution time: 13_633 nanoseconds. - Weight::from_parts(13_797_000, 2653) - // Standard Error: 9_293 - .saturating_add(Weight::from_parts(11_163_914, 0).saturating_mul(i.into())) + // Measured: `805 + i * (76 ±0)` + // Estimated: `4633 + i * (2597 ±0)` + // Minimum execution time: 15_577_000 picoseconds. + Weight::from_parts(15_706_000, 4633) + // Standard Error: 17_679 + .saturating_add(Weight::from_parts(14_173_779, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -608,10 +619,10 @@ impl WeightInfo for () { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn freeze() -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `5250` - // Minimum execution time: 17_126 nanoseconds. - Weight::from_parts(17_572_000, 5250) + // Measured: `495` + // Estimated: `7230` + // Minimum execution time: 19_474_000 picoseconds. + Weight::from_parts(19_807_000, 7230) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -621,10 +632,10 @@ impl WeightInfo for () { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn thaw() -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `5250` - // Minimum execution time: 17_209 nanoseconds. - Weight::from_parts(17_411_000, 5250) + // Measured: `495` + // Estimated: `7230` + // Minimum execution time: 19_526_000 picoseconds. + Weight::from_parts(19_818_000, 7230) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -632,10 +643,10 @@ impl WeightInfo for () { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn freeze_collection() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `2653` - // Minimum execution time: 13_048 nanoseconds. - Weight::from_parts(13_589_000, 2653) + // Measured: `349` + // Estimated: `3643` + // Minimum execution time: 15_324_000 picoseconds. + Weight::from_parts(15_599_000, 3643) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -643,10 +654,10 @@ impl WeightInfo for () { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn thaw_collection() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `2653` - // Minimum execution time: 12_908 nanoseconds. - Weight::from_parts(13_098_000, 2653) + // Measured: `349` + // Estimated: `3643` + // Minimum execution time: 15_294_000 picoseconds. + Weight::from_parts(15_504_000, 3643) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -658,10 +669,10 @@ impl WeightInfo for () { /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { // Proof Size summary in bytes: - // Measured: `455` - // Estimated: `5180` - // Minimum execution time: 20_629 nanoseconds. - Weight::from_parts(21_448_000, 5180) + // Measured: `423` + // Estimated: `7160` + // Minimum execution time: 24_007_000 picoseconds. + Weight::from_parts(24_555_000, 7160) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -669,10 +680,10 @@ impl WeightInfo for () { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn set_team() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `2653` - // Minimum execution time: 13_740 nanoseconds. - Weight::from_parts(14_020_000, 2653) + // Measured: `349` + // Estimated: `3643` + // Minimum execution time: 15_616_000 picoseconds. + Weight::from_parts(15_897_000, 3643) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -682,10 +693,10 @@ impl WeightInfo for () { /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_item_status() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `2653` - // Minimum execution time: 16_293 nanoseconds. - Weight::from_parts(16_509_000, 2653) + // Measured: `349` + // Estimated: `3643` + // Minimum execution time: 18_459_000 picoseconds. + Weight::from_parts(18_705_000, 3643) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -697,10 +708,10 @@ impl WeightInfo for () { /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) fn set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `611` - // Estimated: `8075` - // Minimum execution time: 33_560 nanoseconds. - Weight::from_parts(34_263_000, 8075) + // Measured: `547` + // Estimated: `11045` + // Minimum execution time: 39_056_000 picoseconds. + Weight::from_parts(39_513_000, 11045) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -712,10 +723,10 @@ impl WeightInfo for () { /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) fn clear_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `1031` - // Estimated: `8075` - // Minimum execution time: 31_955 nanoseconds. - Weight::from_parts(32_447_000, 8075) + // Measured: `936` + // Estimated: `11045` + // Minimum execution time: 37_441_000 picoseconds. + Weight::from_parts(37_859_000, 11045) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -725,10 +736,10 @@ impl WeightInfo for () { /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn set_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `447` - // Estimated: `5236` - // Minimum execution time: 25_520 nanoseconds. - Weight::from_parts(25_843_000, 5236) + // Measured: `415` + // Estimated: `7216` + // Minimum execution time: 29_456_000 picoseconds. + Weight::from_parts(29_930_000, 7216) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -738,10 +749,10 @@ impl WeightInfo for () { /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `611` - // Estimated: `5236` - // Minimum execution time: 25_812 nanoseconds. - Weight::from_parts(26_141_000, 5236) + // Measured: `547` + // Estimated: `7216` + // Minimum execution time: 29_817_000 picoseconds. + Weight::from_parts(30_364_000, 7216) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -751,10 +762,10 @@ impl WeightInfo for () { /// Proof: Uniques ClassMetadataOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `5216` - // Minimum execution time: 25_055 nanoseconds. - Weight::from_parts(25_244_000, 5216) + // Measured: `349` + // Estimated: `7196` + // Minimum execution time: 29_392_000 picoseconds. + Weight::from_parts(29_878_000, 7196) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -764,10 +775,10 @@ impl WeightInfo for () { /// Proof: Uniques ClassMetadataOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `525` - // Estimated: `5216` - // Minimum execution time: 23_311 nanoseconds. - Weight::from_parts(23_682_000, 5216) + // Measured: `461` + // Estimated: `7196` + // Minimum execution time: 27_234_000 picoseconds. + Weight::from_parts(27_664_000, 7196) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -777,10 +788,10 @@ impl WeightInfo for () { /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) fn approve_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `559` - // Estimated: `5250` - // Minimum execution time: 17_709 nanoseconds. - Weight::from_parts(18_308_000, 5250) + // Measured: `495` + // Estimated: `7230` + // Minimum execution time: 20_447_000 picoseconds. + Weight::from_parts(20_886_000, 7230) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -790,10 +801,10 @@ impl WeightInfo for () { /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) fn cancel_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `592` - // Estimated: `5250` - // Minimum execution time: 17_656 nanoseconds. - Weight::from_parts(18_039_000, 5250) + // Measured: `528` + // Estimated: `7230` + // Minimum execution time: 20_934_000 picoseconds. + Weight::from_parts(21_271_000, 7230) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -802,9 +813,9 @@ impl WeightInfo for () { fn set_accept_ownership() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `2527` - // Minimum execution time: 14_615 nanoseconds. - Weight::from_parts(14_931_000, 2527) + // Estimated: `3517` + // Minimum execution time: 17_004_000 picoseconds. + Weight::from_parts(17_401_000, 3517) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -814,10 +825,10 @@ impl WeightInfo for () { /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: - // Measured: `381` - // Estimated: `5152` - // Minimum execution time: 14_974 nanoseconds. - Weight::from_parts(15_314_000, 5152) + // Measured: `349` + // Estimated: `7132` + // Minimum execution time: 17_371_000 picoseconds. + Weight::from_parts(18_103_000, 7132) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -827,10 +838,10 @@ impl WeightInfo for () { /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn set_price() -> Weight { // Proof Size summary in bytes: - // Measured: `358` - // Estimated: `2597` - // Minimum execution time: 15_444 nanoseconds. - Weight::from_parts(15_886_000, 2597) + // Measured: `326` + // Estimated: `3587` + // Minimum execution time: 17_624_000 picoseconds. + Weight::from_parts(17_866_000, 3587) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -844,10 +855,10 @@ impl WeightInfo for () { /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn buy_item() -> Weight { // Proof Size summary in bytes: - // Measured: `703` - // Estimated: `7814` - // Minimum execution time: 35_628 nanoseconds. - Weight::from_parts(35_886_000, 7814) + // Measured: `607` + // Estimated: `10784` + // Minimum execution time: 39_736_000 picoseconds. + Weight::from_parts(40_855_000, 10784) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } diff --git a/frame/utility/src/weights.rs b/frame/utility/src/weights.rs index c680c9ff00f9f..0c50de4f5df88 100644 --- a/frame/utility/src/weights.rs +++ b/frame/utility/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_utility //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_utility +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -63,44 +66,44 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_742 nanoseconds. - Weight::from_parts(16_087_635, 0) - // Standard Error: 2_411 - .saturating_add(Weight::from_parts(3_665_506, 0).saturating_mul(c.into())) + // Minimum execution time: 7_828_000 picoseconds. + Weight::from_parts(13_806_712, 0) + // Standard Error: 2_750 + .saturating_add(Weight::from_parts(4_169_287, 0).saturating_mul(c.into())) } fn as_derivative() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_802 nanoseconds. - Weight::from_parts(5_269_000, 0) + // Minimum execution time: 5_835_000 picoseconds. + Weight::from_parts(6_305_000, 0) } /// The range of component `c` is `[0, 1000]`. fn batch_all(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_100 nanoseconds. - Weight::from_parts(14_090_381, 0) - // Standard Error: 1_917 - .saturating_add(Weight::from_parts(3_744_891, 0).saturating_mul(c.into())) + // Minimum execution time: 8_010_000 picoseconds. + Weight::from_parts(10_539_696, 0) + // Standard Error: 2_681 + .saturating_add(Weight::from_parts(4_368_716, 0).saturating_mul(c.into())) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_840 nanoseconds. - Weight::from_parts(9_280_000, 0) + // Minimum execution time: 10_139_000 picoseconds. + Weight::from_parts(10_679_000, 0) } /// The range of component `c` is `[0, 1000]`. fn force_batch(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_245 nanoseconds. - Weight::from_parts(14_292_923, 0) - // Standard Error: 1_803 - .saturating_add(Weight::from_parts(3_645_950, 0).saturating_mul(c.into())) + // Minimum execution time: 7_960_000 picoseconds. + Weight::from_parts(16_874_350, 0) + // Standard Error: 3_040 + .saturating_add(Weight::from_parts(4_151_507, 0).saturating_mul(c.into())) } } @@ -111,43 +114,43 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_742 nanoseconds. - Weight::from_parts(16_087_635, 0) - // Standard Error: 2_411 - .saturating_add(Weight::from_parts(3_665_506, 0).saturating_mul(c.into())) + // Minimum execution time: 7_828_000 picoseconds. + Weight::from_parts(13_806_712, 0) + // Standard Error: 2_750 + .saturating_add(Weight::from_parts(4_169_287, 0).saturating_mul(c.into())) } fn as_derivative() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_802 nanoseconds. - Weight::from_parts(5_269_000, 0) + // Minimum execution time: 5_835_000 picoseconds. + Weight::from_parts(6_305_000, 0) } /// The range of component `c` is `[0, 1000]`. fn batch_all(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_100 nanoseconds. - Weight::from_parts(14_090_381, 0) - // Standard Error: 1_917 - .saturating_add(Weight::from_parts(3_744_891, 0).saturating_mul(c.into())) + // Minimum execution time: 8_010_000 picoseconds. + Weight::from_parts(10_539_696, 0) + // Standard Error: 2_681 + .saturating_add(Weight::from_parts(4_368_716, 0).saturating_mul(c.into())) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_840 nanoseconds. - Weight::from_parts(9_280_000, 0) + // Minimum execution time: 10_139_000 picoseconds. + Weight::from_parts(10_679_000, 0) } /// The range of component `c` is `[0, 1000]`. fn force_batch(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_245 nanoseconds. - Weight::from_parts(14_292_923, 0) - // Standard Error: 1_803 - .saturating_add(Weight::from_parts(3_645_950, 0).saturating_mul(c.into())) + // Minimum execution time: 7_960_000 picoseconds. + Weight::from_parts(16_874_350, 0) + // Standard Error: 3_040 + .saturating_add(Weight::from_parts(4_151_507, 0).saturating_mul(c.into())) } } diff --git a/frame/vesting/src/weights.rs b/frame/vesting/src/weights.rs index de3260fa1e6a6..400984f06823d 100644 --- a/frame/vesting/src/weights.rs +++ b/frame/vesting/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_vesting //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_vesting +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -69,14 +72,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 28]`. fn vest_locked(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `444 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `7306` - // Minimum execution time: 28_062 nanoseconds. - Weight::from_parts(26_857_563, 7306) - // Standard Error: 623 - .saturating_add(Weight::from_parts(55_988, 0).saturating_mul(l.into())) - // Standard Error: 1_109 - .saturating_add(Weight::from_parts(59_714, 0).saturating_mul(s.into())) + // Measured: `381 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9286` + // Minimum execution time: 31_657_000 picoseconds. + Weight::from_parts(30_569_947, 9286) + // Standard Error: 794 + .saturating_add(Weight::from_parts(63_114, 0).saturating_mul(l.into())) + // Standard Error: 1_413 + .saturating_add(Weight::from_parts(58_636, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -88,14 +91,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 28]`. fn vest_unlocked(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `444 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `7306` - // Minimum execution time: 27_027 nanoseconds. - Weight::from_parts(26_509_364, 7306) - // Standard Error: 815 - .saturating_add(Weight::from_parts(54_711, 0).saturating_mul(l.into())) - // Standard Error: 1_451 - .saturating_add(Weight::from_parts(32_792, 0).saturating_mul(s.into())) + // Measured: `381 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9286` + // Minimum execution time: 30_474_000 picoseconds. + Weight::from_parts(30_227_344, 9286) + // Standard Error: 1_005 + .saturating_add(Weight::from_parts(56_742, 0).saturating_mul(l.into())) + // Standard Error: 1_788 + .saturating_add(Weight::from_parts(33_890, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -109,14 +112,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 28]`. fn vest_other_locked(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `579 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `9909` - // Minimum execution time: 29_554 nanoseconds. - Weight::from_parts(28_269_203, 9909) - // Standard Error: 623 - .saturating_add(Weight::from_parts(59_058, 0).saturating_mul(l.into())) - // Standard Error: 1_108 - .saturating_add(Weight::from_parts(63_429, 0).saturating_mul(s.into())) + // Measured: `484 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `12879` + // Minimum execution time: 33_681_000 picoseconds. + Weight::from_parts(32_540_534, 12879) + // Standard Error: 2_642 + .saturating_add(Weight::from_parts(62_200, 0).saturating_mul(l.into())) + // Standard Error: 4_701 + .saturating_add(Weight::from_parts(69_703, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -130,14 +133,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 28]`. fn vest_other_unlocked(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `579 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `9909` - // Minimum execution time: 28_546 nanoseconds. - Weight::from_parts(28_299_251, 9909) - // Standard Error: 786 - .saturating_add(Weight::from_parts(53_401, 0).saturating_mul(l.into())) - // Standard Error: 1_399 - .saturating_add(Weight::from_parts(29_713, 0).saturating_mul(s.into())) + // Measured: `484 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `12879` + // Minimum execution time: 32_255_000 picoseconds. + Weight::from_parts(31_637_918, 12879) + // Standard Error: 3_135 + .saturating_add(Weight::from_parts(62_121, 0).saturating_mul(l.into())) + // Standard Error: 5_579 + .saturating_add(Weight::from_parts(61_055, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -151,14 +154,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 27]`. fn vested_transfer(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `650 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `9909` - // Minimum execution time: 43_436 nanoseconds. - Weight::from_parts(44_885_707, 9909) - // Standard Error: 1_516 - .saturating_add(Weight::from_parts(59_066, 0).saturating_mul(l.into())) - // Standard Error: 2_698 - .saturating_add(Weight::from_parts(32_053, 0).saturating_mul(s.into())) + // Measured: `555 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `12879` + // Minimum execution time: 51_697_000 picoseconds. + Weight::from_parts(52_048_055, 12879) + // Standard Error: 1_598 + .saturating_add(Weight::from_parts(60_508, 0).saturating_mul(l.into())) + // Standard Error: 2_843 + .saturating_add(Weight::from_parts(37_870, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -172,14 +175,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 27]`. fn force_vested_transfer(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `785 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `12512` - // Minimum execution time: 45_805 nanoseconds. - Weight::from_parts(46_869_490, 12512) - // Standard Error: 1_445 - .saturating_add(Weight::from_parts(52_654, 0).saturating_mul(l.into())) - // Standard Error: 2_571 - .saturating_add(Weight::from_parts(34_202, 0).saturating_mul(s.into())) + // Measured: `658 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `15482` + // Minimum execution time: 54_585_000 picoseconds. + Weight::from_parts(54_492_070, 15482) + // Standard Error: 1_694 + .saturating_add(Weight::from_parts(52_633, 0).saturating_mul(l.into())) + // Standard Error: 3_014 + .saturating_add(Weight::from_parts(45_485, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -193,14 +196,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[2, 28]`. fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `577 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `9909` - // Minimum execution time: 30_460 nanoseconds. - Weight::from_parts(29_407_637, 9909) - // Standard Error: 794 - .saturating_add(Weight::from_parts(63_757, 0).saturating_mul(l.into())) - // Standard Error: 1_466 - .saturating_add(Weight::from_parts(56_032, 0).saturating_mul(s.into())) + // Measured: `482 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `12879` + // Minimum execution time: 34_312_000 picoseconds. + Weight::from_parts(33_740_101, 12879) + // Standard Error: 996 + .saturating_add(Weight::from_parts(62_123, 0).saturating_mul(l.into())) + // Standard Error: 1_841 + .saturating_add(Weight::from_parts(56_463, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -214,14 +217,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[2, 28]`. fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `577 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `9909` - // Minimum execution time: 30_413 nanoseconds. - Weight::from_parts(29_350_467, 9909) - // Standard Error: 724 - .saturating_add(Weight::from_parts(65_366, 0).saturating_mul(l.into())) - // Standard Error: 1_337 - .saturating_add(Weight::from_parts(53_799, 0).saturating_mul(s.into())) + // Measured: `482 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `12879` + // Minimum execution time: 34_965_000 picoseconds. + Weight::from_parts(33_831_484, 12879) + // Standard Error: 1_530 + .saturating_add(Weight::from_parts(59_136, 0).saturating_mul(l.into())) + // Standard Error: 2_827 + .saturating_add(Weight::from_parts(58_493, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -237,14 +240,14 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 28]`. fn vest_locked(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `444 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `7306` - // Minimum execution time: 28_062 nanoseconds. - Weight::from_parts(26_857_563, 7306) - // Standard Error: 623 - .saturating_add(Weight::from_parts(55_988, 0).saturating_mul(l.into())) - // Standard Error: 1_109 - .saturating_add(Weight::from_parts(59_714, 0).saturating_mul(s.into())) + // Measured: `381 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9286` + // Minimum execution time: 31_657_000 picoseconds. + Weight::from_parts(30_569_947, 9286) + // Standard Error: 794 + .saturating_add(Weight::from_parts(63_114, 0).saturating_mul(l.into())) + // Standard Error: 1_413 + .saturating_add(Weight::from_parts(58_636, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -256,14 +259,14 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 28]`. fn vest_unlocked(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `444 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `7306` - // Minimum execution time: 27_027 nanoseconds. - Weight::from_parts(26_509_364, 7306) - // Standard Error: 815 - .saturating_add(Weight::from_parts(54_711, 0).saturating_mul(l.into())) - // Standard Error: 1_451 - .saturating_add(Weight::from_parts(32_792, 0).saturating_mul(s.into())) + // Measured: `381 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9286` + // Minimum execution time: 30_474_000 picoseconds. + Weight::from_parts(30_227_344, 9286) + // Standard Error: 1_005 + .saturating_add(Weight::from_parts(56_742, 0).saturating_mul(l.into())) + // Standard Error: 1_788 + .saturating_add(Weight::from_parts(33_890, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -277,14 +280,14 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 28]`. fn vest_other_locked(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `579 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `9909` - // Minimum execution time: 29_554 nanoseconds. - Weight::from_parts(28_269_203, 9909) - // Standard Error: 623 - .saturating_add(Weight::from_parts(59_058, 0).saturating_mul(l.into())) - // Standard Error: 1_108 - .saturating_add(Weight::from_parts(63_429, 0).saturating_mul(s.into())) + // Measured: `484 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `12879` + // Minimum execution time: 33_681_000 picoseconds. + Weight::from_parts(32_540_534, 12879) + // Standard Error: 2_642 + .saturating_add(Weight::from_parts(62_200, 0).saturating_mul(l.into())) + // Standard Error: 4_701 + .saturating_add(Weight::from_parts(69_703, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -298,14 +301,14 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 28]`. fn vest_other_unlocked(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `579 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `9909` - // Minimum execution time: 28_546 nanoseconds. - Weight::from_parts(28_299_251, 9909) - // Standard Error: 786 - .saturating_add(Weight::from_parts(53_401, 0).saturating_mul(l.into())) - // Standard Error: 1_399 - .saturating_add(Weight::from_parts(29_713, 0).saturating_mul(s.into())) + // Measured: `484 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `12879` + // Minimum execution time: 32_255_000 picoseconds. + Weight::from_parts(31_637_918, 12879) + // Standard Error: 3_135 + .saturating_add(Weight::from_parts(62_121, 0).saturating_mul(l.into())) + // Standard Error: 5_579 + .saturating_add(Weight::from_parts(61_055, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -319,14 +322,14 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 27]`. fn vested_transfer(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `650 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `9909` - // Minimum execution time: 43_436 nanoseconds. - Weight::from_parts(44_885_707, 9909) - // Standard Error: 1_516 - .saturating_add(Weight::from_parts(59_066, 0).saturating_mul(l.into())) - // Standard Error: 2_698 - .saturating_add(Weight::from_parts(32_053, 0).saturating_mul(s.into())) + // Measured: `555 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `12879` + // Minimum execution time: 51_697_000 picoseconds. + Weight::from_parts(52_048_055, 12879) + // Standard Error: 1_598 + .saturating_add(Weight::from_parts(60_508, 0).saturating_mul(l.into())) + // Standard Error: 2_843 + .saturating_add(Weight::from_parts(37_870, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -340,14 +343,14 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 27]`. fn force_vested_transfer(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `785 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `12512` - // Minimum execution time: 45_805 nanoseconds. - Weight::from_parts(46_869_490, 12512) - // Standard Error: 1_445 - .saturating_add(Weight::from_parts(52_654, 0).saturating_mul(l.into())) - // Standard Error: 2_571 - .saturating_add(Weight::from_parts(34_202, 0).saturating_mul(s.into())) + // Measured: `658 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `15482` + // Minimum execution time: 54_585_000 picoseconds. + Weight::from_parts(54_492_070, 15482) + // Standard Error: 1_694 + .saturating_add(Weight::from_parts(52_633, 0).saturating_mul(l.into())) + // Standard Error: 3_014 + .saturating_add(Weight::from_parts(45_485, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -361,14 +364,14 @@ impl WeightInfo for () { /// The range of component `s` is `[2, 28]`. fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `577 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `9909` - // Minimum execution time: 30_460 nanoseconds. - Weight::from_parts(29_407_637, 9909) - // Standard Error: 794 - .saturating_add(Weight::from_parts(63_757, 0).saturating_mul(l.into())) - // Standard Error: 1_466 - .saturating_add(Weight::from_parts(56_032, 0).saturating_mul(s.into())) + // Measured: `482 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `12879` + // Minimum execution time: 34_312_000 picoseconds. + Weight::from_parts(33_740_101, 12879) + // Standard Error: 996 + .saturating_add(Weight::from_parts(62_123, 0).saturating_mul(l.into())) + // Standard Error: 1_841 + .saturating_add(Weight::from_parts(56_463, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -382,14 +385,14 @@ impl WeightInfo for () { /// The range of component `s` is `[2, 28]`. fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `577 + l * (25 ±0) + s * (36 ±0)` - // Estimated: `9909` - // Minimum execution time: 30_413 nanoseconds. - Weight::from_parts(29_350_467, 9909) - // Standard Error: 724 - .saturating_add(Weight::from_parts(65_366, 0).saturating_mul(l.into())) - // Standard Error: 1_337 - .saturating_add(Weight::from_parts(53_799, 0).saturating_mul(s.into())) + // Measured: `482 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `12879` + // Minimum execution time: 34_965_000 picoseconds. + Weight::from_parts(33_831_484, 12879) + // Standard Error: 1_530 + .saturating_add(Weight::from_parts(59_136, 0).saturating_mul(l.into())) + // Standard Error: 2_827 + .saturating_add(Weight::from_parts(58_493, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } diff --git a/frame/whitelist/src/weights.rs b/frame/whitelist/src/weights.rs index 667d602a3c0ba..536cd188761b1 100644 --- a/frame/whitelist/src/weights.rs +++ b/frame/whitelist/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_whitelist //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_whitelist +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -64,9 +67,9 @@ impl WeightInfo for SubstrateWeight { fn whitelist_call() -> Weight { // Proof Size summary in bytes: // Measured: `217` - // Estimated: `5081` - // Minimum execution time: 18_618 nanoseconds. - Weight::from_parts(19_133_000, 5081) + // Estimated: `7061` + // Minimum execution time: 21_530_000 picoseconds. + Weight::from_parts(21_986_000, 7061) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -77,9 +80,9 @@ impl WeightInfo for SubstrateWeight { fn remove_whitelisted_call() -> Weight { // Proof Size summary in bytes: // Measured: `346` - // Estimated: `5081` - // Minimum execution time: 16_685 nanoseconds. - Weight::from_parts(17_325_000, 5081) + // Estimated: `7061` + // Minimum execution time: 18_980_000 picoseconds. + Weight::from_parts(19_474_000, 7061) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -92,12 +95,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[1, 4194294]`. fn dispatch_whitelisted_call(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `454 + n * (1 ±0)` - // Estimated: `8007 + n * (1 ±0)` - // Minimum execution time: 27_539 nanoseconds. - Weight::from_parts(27_950_000, 8007) + // Measured: `422 + n * (1 ±0)` + // Estimated: `10947 + n * (1 ±0)` + // Minimum execution time: 32_377_000 picoseconds. + Weight::from_parts(32_643_000, 10947) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_134, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_147, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -110,11 +113,11 @@ impl WeightInfo for SubstrateWeight { fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `346` - // Estimated: `5081` - // Minimum execution time: 20_581 nanoseconds. - Weight::from_parts(21_762_318, 5081) - // Standard Error: 4 - .saturating_add(Weight::from_parts(1_480, 0).saturating_mul(n.into())) + // Estimated: `7061` + // Minimum execution time: 23_421_000 picoseconds. + Weight::from_parts(24_488_523, 7061) + // Standard Error: 5 + .saturating_add(Weight::from_parts(1_217, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -129,9 +132,9 @@ impl WeightInfo for () { fn whitelist_call() -> Weight { // Proof Size summary in bytes: // Measured: `217` - // Estimated: `5081` - // Minimum execution time: 18_618 nanoseconds. - Weight::from_parts(19_133_000, 5081) + // Estimated: `7061` + // Minimum execution time: 21_530_000 picoseconds. + Weight::from_parts(21_986_000, 7061) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -142,9 +145,9 @@ impl WeightInfo for () { fn remove_whitelisted_call() -> Weight { // Proof Size summary in bytes: // Measured: `346` - // Estimated: `5081` - // Minimum execution time: 16_685 nanoseconds. - Weight::from_parts(17_325_000, 5081) + // Estimated: `7061` + // Minimum execution time: 18_980_000 picoseconds. + Weight::from_parts(19_474_000, 7061) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -157,12 +160,12 @@ impl WeightInfo for () { /// The range of component `n` is `[1, 4194294]`. fn dispatch_whitelisted_call(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `454 + n * (1 ±0)` - // Estimated: `8007 + n * (1 ±0)` - // Minimum execution time: 27_539 nanoseconds. - Weight::from_parts(27_950_000, 8007) + // Measured: `422 + n * (1 ±0)` + // Estimated: `10947 + n * (1 ±0)` + // Minimum execution time: 32_377_000 picoseconds. + Weight::from_parts(32_643_000, 10947) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_134, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_147, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -175,11 +178,11 @@ impl WeightInfo for () { fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `346` - // Estimated: `5081` - // Minimum execution time: 20_581 nanoseconds. - Weight::from_parts(21_762_318, 5081) - // Standard Error: 4 - .saturating_add(Weight::from_parts(1_480, 0).saturating_mul(n.into())) + // Estimated: `7061` + // Minimum execution time: 23_421_000 picoseconds. + Weight::from_parts(24_488_523, 7061) + // Standard Error: 5 + .saturating_add(Weight::from_parts(1_217, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } From aaa9a3631d29f757552ffcc8b97aa7091c0b27b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Thu, 16 Mar 2023 20:19:48 +0100 Subject: [PATCH 29/80] contracts: Simplify benchmarks (#13595) * Remove batching * Benchmark in bytes not kilobytes * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * Add rationale for picking batch numbers --------- Co-authored-by: command-bot <> --- frame/contracts/src/benchmarking/code.rs | 2 +- frame/contracts/src/benchmarking/mod.rs | 789 +++-- frame/contracts/src/schedule.rs | 222 +- frame/contracts/src/wasm/prepare.rs | 2 +- frame/contracts/src/weights.rs | 3383 +++++++++++----------- 5 files changed, 2092 insertions(+), 2306 deletions(-) diff --git a/frame/contracts/src/benchmarking/code.rs b/frame/contracts/src/benchmarking/code.rs index aa44cc3976a2c..96eb5e501d068 100644 --- a/frame/contracts/src/benchmarking/code.rs +++ b/frame/contracts/src/benchmarking/code.rs @@ -512,7 +512,7 @@ pub fn max_pages() -> u32 { fn inject_gas_metering(module: Module) -> Module { let schedule = T::Schedule::get(); - let gas_rules = schedule.rules(&module, Determinism::Deterministic); + let gas_rules = schedule.rules(Determinism::Deterministic); let backend = gas_metering::host_function::Injector::new("seal0", "gas"); gas_metering::inject(module, backend, &gas_rules).unwrap() } diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index c18d9ffb4b584..873314981b7ed 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -31,7 +31,6 @@ use self::{ }; use crate::{ exec::{AccountIdOf, FixSizedKey, VarSizedKey}, - schedule::{API_BENCHMARK_BATCH_SIZE, INSTR_BENCHMARK_BATCH_SIZE}, wasm::CallFlags, Pallet as Contracts, *, }; @@ -47,10 +46,17 @@ use sp_std::prelude::*; use wasm_instrument::parity_wasm::elements::{BlockType, BrTableData, Instruction, ValueType}; /// How many batches we do per API benchmark. -const API_BENCHMARK_BATCHES: u32 = 20; +/// +/// This is picked more or less arbitrary. We experimented with different numbers until +/// the results appeared to be stable. Reducing the number would speed up the benchmarks +/// but might make the results less precise. +const API_BENCHMARK_BATCHES: u32 = 1600; -/// How many batches we do per Instruction benchmark. -const INSTR_BENCHMARK_BATCHES: u32 = 50; +/// How many batches we do per instruction benchmark. +/// +/// Same rationale as for [`API_BENCHMARK_BATCHES`]. The number is bigger because instruction +/// benchmarks are faster. +const INSTR_BENCHMARK_BATCHES: u32 = 5000; /// An instantiated and deployed contract. struct Contract { @@ -244,7 +250,7 @@ benchmarks! { // the sandbox. This does **not** include the actual execution for which the gas meter // is responsible. This is achieved by generating all code to the `deploy` function // which is in the wasm module but not executed on `call`. - // The results are supposed to be used as `call_with_code_kb(c) - call_with_code_kb(0)`. + // The results are supposed to be used as `call_with_code_per_byte(c) - call_with_code_per_byte(0)`. #[pov_mode = Measured] call_with_code_per_byte { let c in 0 .. T::MaxCodeLen::get(); @@ -263,9 +269,9 @@ benchmarks! { // we don't benchmark the actual execution of this code but merely what it takes to load // a code of that size into the sandbox. // - // `c`: Size of the code in kilobytes. - // `i`: Size of the input in kilobytes. - // `s`: Size of the salt in kilobytes. + // `c`: Size of the code in bytes. + // `i`: Size of the input in bytes. + // `s`: Size of the salt in bytes. // // # Note // @@ -299,8 +305,8 @@ benchmarks! { } // Instantiate uses a dummy contract constructor to measure the overhead of the instantiate. - // `i`: Size of the input in kilobytes. - // `s`: Size of the salt in kilobytes. + // `i`: Size of the input in bytes. + // `s`: Size of the salt in bytes. #[pov_mode = Measured] instantiate { let i in 0 .. code::max_pages::() * 64 * 1024; @@ -333,7 +339,7 @@ benchmarks! { // The dummy contract used here does not do this. The costs for the data copy is billed as // part of `seal_input`. The costs for invoking a contract of a specific size are not part // of this benchmark because we cannot know the size of the contract when issuing a call - // transaction. See `invoke_per_code_kb` for this. + // transaction. See `call_with_code_per_byte` for this. #[pov_mode = Measured] call { let data = vec![42u8; 1024]; @@ -362,7 +368,7 @@ benchmarks! { // This constructs a contract that is maximal expensive to instrument. // It creates a maximum number of metering blocks per byte. - // `c`: Size of the code in kilobytes. + // `c`: Size of the code in bytes. // // # Note // @@ -421,7 +427,7 @@ benchmarks! { seal_caller { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( - "seal0", "seal_caller", r * API_BENCHMARK_BATCH_SIZE + "seal0", "seal_caller", r ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -429,7 +435,7 @@ benchmarks! { #[pov_mode = Measured] seal_is_contract { let r in 0 .. API_BENCHMARK_BATCHES; - let accounts = (0 .. r * API_BENCHMARK_BATCH_SIZE) + let accounts = (0 .. r) .map(|n| account::("account", n, 0)) .collect::>(); let account_len = accounts.get(0).map(|i| i.encode().len()).unwrap_or(0); @@ -448,7 +454,7 @@ benchmarks! { value: accounts_bytes }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(0, account_len as u32), // address_ptr Regular(Instruction::Call(0)), Regular(Instruction::Drop), @@ -467,7 +473,7 @@ benchmarks! { #[pov_mode = Measured] seal_code_hash { let r in 0 .. API_BENCHMARK_BATCHES; - let accounts = (0 .. r * API_BENCHMARK_BATCH_SIZE) + let accounts = (0 .. r) .map(|n| account::("account", n, 0)) .collect::>(); let account_len = accounts.get(0).map(|i| i.encode().len()).unwrap_or(0); @@ -492,7 +498,7 @@ benchmarks! { value: accounts_bytes, }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(36, account_len as u32), // address_ptr Regular(Instruction::I32Const(4)), // ptr to output data Regular(Instruction::I32Const(0)), // ptr to output length @@ -514,7 +520,7 @@ benchmarks! { seal_own_code_hash { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( - "seal0", "seal_own_code_hash", r * API_BENCHMARK_BATCH_SIZE + "seal0", "seal_own_code_hash", r ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -530,7 +536,7 @@ benchmarks! { params: vec![], return_type: Some(ValueType::I32), }], - call_body: Some(body::repeated(r * API_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::repeated(r, &[ Instruction::Call(0), Instruction::Drop, ])), @@ -544,7 +550,7 @@ benchmarks! { seal_address { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( - "seal0", "seal_address", r * API_BENCHMARK_BATCH_SIZE + "seal0", "seal_address", r ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -553,7 +559,7 @@ benchmarks! { seal_gas_left { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( - "seal0", "seal_gas_left", r * API_BENCHMARK_BATCH_SIZE + "seal0", "seal_gas_left", r ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -562,7 +568,7 @@ benchmarks! { seal_balance { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( - "seal0", "seal_balance", r * API_BENCHMARK_BATCH_SIZE + "seal0", "seal_balance", r ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -571,7 +577,7 @@ benchmarks! { seal_value_transferred { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( - "seal0", "seal_value_transferred", r * API_BENCHMARK_BATCH_SIZE + "seal0", "seal_value_transferred", r ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -580,7 +586,7 @@ benchmarks! { seal_minimum_balance { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( - "seal0", "seal_minimum_balance", r * API_BENCHMARK_BATCH_SIZE + "seal0", "seal_minimum_balance", r ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -589,7 +595,7 @@ benchmarks! { seal_block_number { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( - "seal0", "seal_block_number", r * API_BENCHMARK_BATCH_SIZE + "seal0", "seal_block_number", r ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -598,7 +604,7 @@ benchmarks! { seal_now { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( - "seal0", "seal_now", r * API_BENCHMARK_BATCH_SIZE + "seal0", "seal_now", r ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -619,7 +625,7 @@ benchmarks! { offset: 0, value: (pages * 64 * 1024 - 4).to_le_bytes().to_vec(), }], - call_body: Some(body::repeated(r * API_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::repeated(r, &[ Instruction::I64Const(500_000), Instruction::I32Const(4), Instruction::I32Const(0), @@ -641,7 +647,7 @@ benchmarks! { params: vec![ValueType::I64], return_type: None, }], - call_body: Some(body::repeated(r * API_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::repeated(r, &[ Instruction::I64Const(42), Instruction::Call(0), ])), @@ -669,7 +675,7 @@ benchmarks! { value: 0u32.to_le_bytes().to_vec(), }, ], - call_body: Some(body::repeated(r * API_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::repeated(r, &[ Instruction::I32Const(4), // ptr where to store output Instruction::I32Const(0), // ptr to length Instruction::Call(0), @@ -681,10 +687,9 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) #[pov_mode = Measured] - seal_input_per_kb { - let n in 0 .. code::max_pages::() * 64; - let pages = code::max_pages::(); - let buffer_size = pages * 64 * 1024 - 4; + seal_input_per_byte { + let n in 0 .. code::max_pages::() * 64 * 1024; + let buffer_size = code::max_pages::() * 64 * 1024 - 4; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -699,15 +704,16 @@ benchmarks! { value: buffer_size.to_le_bytes().to_vec(), }, ], - call_body: Some(body::repeated(API_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::plain(vec![ Instruction::I32Const(4), // ptr where to store output Instruction::I32Const(0), // ptr to length Instruction::Call(0), + Instruction::End, ])), .. Default::default() }); let instance = Contract::::new(code, vec![])?; - let data = vec![42u8; (n * 1024).min(buffer_size) as usize]; + let data = vec![42u8; n.min(buffer_size) as usize]; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, data) @@ -738,8 +744,8 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) #[pov_mode = Measured] - seal_return_per_kb { - let n in 0 .. code::max_pages::() * 64; + seal_return_per_byte { + let n in 0 .. code::max_pages::() * 64 * 1024; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -751,7 +757,7 @@ benchmarks! { call_body: Some(body::plain(vec![ Instruction::I32Const(0), // flags Instruction::I32Const(0), // data_ptr - Instruction::I32Const((n * 1024) as i32), // data_len + Instruction::I32Const(n as i32), // data_len Instruction::Call(0), Instruction::End, ])), @@ -827,7 +833,7 @@ benchmarks! { value: (pages * 64 * 1024 - subject_len - 4).to_le_bytes().to_vec(), }, ], - call_body: Some(body::repeated(r * API_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::repeated(r, &[ Instruction::I32Const(4), // subject_ptr Instruction::I32Const(subject_len as i32), // subject_len Instruction::I32Const((subject_len + 4) as i32), // out_ptr @@ -853,7 +859,7 @@ benchmarks! { params: vec![ValueType::I32, ValueType::I32, ValueType::I32, ValueType::I32], return_type: None, }], - call_body: Some(body::repeated(r * API_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::repeated(r, &[ Instruction::I32Const(0), // topics_ptr Instruction::I32Const(0), // topics_len Instruction::I32Const(0), // data_ptr @@ -868,16 +874,13 @@ benchmarks! { // Benchmark the overhead that topics generate. // `t`: Number of topics - // `n`: Size of event payload in kb + // `n`: Size of event payload in bytes #[pov_mode = Measured] - seal_deposit_event_per_topic_and_kb { + seal_deposit_event_per_topic_and_byte { let t in 0 .. T::Schedule::get().limits.event_topics; - let n in 0 .. T::Schedule::get().limits.payload_len / 1024; - let mut topics = (0..API_BENCHMARK_BATCH_SIZE) - .map(|n| (n * t..n * t + t).map(|i| T::Hashing::hash_of(&i)).collect::>().encode()) - .peekable(); - let topics_len = topics.peek().map(|i| i.len()).unwrap_or(0); - let topics = topics.flatten().collect(); + let n in 0 .. T::Schedule::get().limits.payload_len; + let topics = (0..t).map(|i| T::Hashing::hash_of(&i)).collect::>().encode(); + let topics_len = topics.len(); let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -892,12 +895,13 @@ benchmarks! { value: topics, }, ], - call_body: Some(body::repeated_dyn(API_BENCHMARK_BATCH_SIZE, vec![ - Counter(0, topics_len as u32), // topics_ptr - Regular(Instruction::I32Const(topics_len as i32)), // topics_len - Regular(Instruction::I32Const(0)), // data_ptr - Regular(Instruction::I32Const((n * 1024) as i32)), // data_len - Regular(Instruction::Call(0)), + call_body: Some(body::plain(vec![ + Instruction::I32Const(0), // topics_ptr + Instruction::I32Const(topics_len as i32), // topics_len + Instruction::I32Const(0), // data_ptr + Instruction::I32Const(n as i32), // data_len + Instruction::Call(0), + Instruction::End, ])), .. Default::default() }); @@ -919,7 +923,7 @@ benchmarks! { params: vec![ValueType::I32, ValueType::I32], return_type: Some(ValueType::I32), }], - call_body: Some(body::repeated(r * API_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::repeated(r, &[ Instruction::I32Const(0), // value_ptr Instruction::I32Const(0), // value_len Instruction::Call(0), @@ -942,10 +946,10 @@ benchmarks! { .result?; } - seal_debug_message_per_kb { - // Vary size of input in kilobytes up to maximum allowed contract memory + seal_debug_message_per_byte { + // Vary size of input in bytes up to maximum allowed contract memory // or maximum allowed debug buffer size, whichever is less. - let i in 0 .. (T::Schedule::get().limits.memory_pages * 64).min(T::MaxDebugBufferLen::get() / 1024); + let i in 0 .. (T::Schedule::get().limits.memory_pages * 64 * 1024).min(T::MaxDebugBufferLen::get()); // We benchmark versus messages containing printable ASCII codes. // About 1Kb goes to the instrumented contract code instructions, // whereas all the space left we use for the initialization of the debug messages data. @@ -969,7 +973,7 @@ benchmarks! { ], call_body: Some(body::plain(vec![ Instruction::I32Const(0), // value_ptr - Instruction::I32Const((i * 1024) as i32), // value_len increments by i Kb + Instruction::I32Const(i as i32), // value_len Instruction::Call(0), Instruction::Drop, Instruction::End, @@ -994,15 +998,20 @@ benchmarks! { // Only the overhead of calling the function itself with minimal arguments. // The contract is a bit more complex because it needs to use different keys in order // to generate unique storage accesses. However, it is still dominated by the storage - // accesses. We store all the keys that we are about to write at beforehand + // accesses. We store something at all the keys that we are about to write to // because re-writing at an existing key is always more expensive than writing - // it at a virgin key. + // to an key with no data behind it. + // + // # Note + // + // We need to use a smaller `r` because the keys are big and writing them all into the wasm + // might exceed the code size. #[skip_meta] #[pov_mode = Measured] seal_set_storage { let r in 0 .. API_BENCHMARK_BATCHES/2; let max_key_len = T::MaxStorageKeyLen::get(); - let keys = (0 .. r * API_BENCHMARK_BATCH_SIZE) + let keys = (0 .. r) .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); h.resize(max_key_len.try_into().unwrap(), n.to_le_bytes()[0]); h }) .collect::>(); @@ -1021,7 +1030,7 @@ benchmarks! { value: keys_bytes, }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(0, max_key_len as u32), // key_ptr Regular(Instruction::I32Const(max_key_len as i32)), // key_len Regular(Instruction::I32Const(0)), // value_ptr @@ -1047,14 +1056,10 @@ benchmarks! { #[skip_meta] #[pov_mode = Measured] - seal_set_storage_per_new_kb { - let n in 0 .. T::Schedule::get().limits.payload_len / 2048; // half of the max payload_len in kb + seal_set_storage_per_new_byte { + let n in 0 .. T::Schedule::get().limits.payload_len; let max_key_len = T::MaxStorageKeyLen::get(); - let keys = (0 .. n * API_BENCHMARK_BATCH_SIZE) - .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); - h.resize(max_key_len.try_into().unwrap(), n.to_le_bytes()[0]); h }) - .collect::>(); - let key_bytes = keys.iter().flatten().cloned().collect::>(); + let key = vec![0u8; max_key_len as usize]; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -1066,43 +1071,38 @@ benchmarks! { data_segments: vec![ DataSegment { offset: 0, - value: key_bytes, + value: key.clone(), }, ], - call_body: Some(body::repeated_dyn(API_BENCHMARK_BATCH_SIZE, vec![ - Counter(0, max_key_len as u32), // key_ptr - Regular(Instruction::I32Const(max_key_len as i32)), // key_len - Regular(Instruction::I32Const(0)), // value_ptr - Regular(Instruction::I32Const((n * 2048) as i32)), // value_len increments by 2kb up to max payload_len - Regular(Instruction::Call(0)), - Regular(Instruction::Drop), + call_body: Some(body::plain(vec![ + Instruction::I32Const(0), // key_ptr + Instruction::I32Const(max_key_len as i32), // key_len + Instruction::I32Const(0), // value_ptr + Instruction::I32Const(n as i32), // value_len + Instruction::Call(0), + Instruction::Drop, + Instruction::End, ])), .. Default::default() }); let instance = Contract::::new(code, vec![])?; let info = instance.info()?; - for key in keys { - info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, - Some(vec![]), - None, - false, - ) - .map_err(|_| "Failed to write to storage during setup.")?; - } + info.write( + &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + Some(vec![]), + None, + false, + ) + .map_err(|_| "Failed to write to storage during setup.")?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) #[skip_meta] #[pov_mode = Measured] - seal_set_storage_per_old_kb { - let n in 0 .. T::Schedule::get().limits.payload_len / 2048; // half of the max payload_len in kb + seal_set_storage_per_old_byte { + let n in 0 .. T::Schedule::get().limits.payload_len; let max_key_len = T::MaxStorageKeyLen::get(); - let keys = (0 .. n * API_BENCHMARK_BATCH_SIZE) - .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); - h.resize(max_key_len.try_into().unwrap(), n.to_le_bytes()[0]); h }) - .collect::>(); - let key_bytes = keys.iter().flatten().cloned().collect::>(); + let key = vec![0u8; max_key_len as usize]; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -1114,30 +1114,29 @@ benchmarks! { data_segments: vec![ DataSegment { offset: 0, - value: key_bytes, + value: key.clone(), }, ], - call_body: Some(body::repeated_dyn(API_BENCHMARK_BATCH_SIZE, vec![ - Counter(0, max_key_len as u32), // key_ptr - Regular(Instruction::I32Const(max_key_len as i32)), // key_len - Regular(Instruction::I32Const(0)), // value_ptr - Regular(Instruction::I32Const(0)), // value_len is 0 as testing vs pre-existing value len - Regular(Instruction::Call(0)), - Regular(Instruction::Drop), + call_body: Some(body::plain(vec![ + Instruction::I32Const(0), // key_ptr + Instruction::I32Const(max_key_len as i32), // key_len + Instruction::I32Const(0), // value_ptr + Instruction::I32Const(0), // value_len is 0 as testing vs pre-existing value len + Instruction::Call(0), + Instruction::Drop, + Instruction::End, ])), .. Default::default() }); let instance = Contract::::new(code, vec![])?; let info = instance.info()?; - for key in keys { - info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, - Some(vec![42u8; (n * 2048) as usize]), // value_len increments by 2kb up to max payload_len - None, - false, - ) - .map_err(|_| "Failed to write to storage during setup.")?; - } + info.write( + &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + Some(vec![42u8; n as usize]), + None, + false, + ) + .map_err(|_| "Failed to write to storage during setup.")?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -1150,7 +1149,7 @@ benchmarks! { seal_clear_storage { let r in 0 .. API_BENCHMARK_BATCHES/2; let max_key_len = T::MaxStorageKeyLen::get(); - let keys = (0 .. r * API_BENCHMARK_BATCH_SIZE) + let keys = (0 .. r) .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); h.resize(max_key_len.try_into().unwrap(), n.to_le_bytes()[0]); h }) .collect::>(); @@ -1169,7 +1168,7 @@ benchmarks! { value: key_bytes, }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(0, max_key_len as u32), // key_ptr Regular(Instruction::I32Const(max_key_len as i32)), // key_len Regular(Instruction::Call(0)), @@ -1194,14 +1193,10 @@ benchmarks! { #[skip_meta] #[pov_mode = Measured] - seal_clear_storage_per_kb { - let n in 0 .. T::Schedule::get().limits.payload_len / 2048; // half of the max payload_len in kb + seal_clear_storage_per_byte { + let n in 0 .. T::Schedule::get().limits.payload_len; let max_key_len = T::MaxStorageKeyLen::get(); - let keys = (0 .. n * API_BENCHMARK_BATCH_SIZE) - .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); - h.resize(max_key_len.try_into().unwrap(), n.to_le_bytes()[0]); h }) - .collect::>(); - let key_bytes = keys.iter().flatten().cloned().collect::>(); + let key = vec![0u8; max_key_len as usize]; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -1213,28 +1208,27 @@ benchmarks! { data_segments: vec![ DataSegment { offset: 0, - value: key_bytes, + value: key.clone(), }, ], - call_body: Some(body::repeated_dyn(API_BENCHMARK_BATCH_SIZE, vec![ - Counter(0, max_key_len as u32), // key_ptr - Regular(Instruction::I32Const(max_key_len as i32)), // key_len - Regular(Instruction::Call(0)), - Regular(Instruction::Drop), + call_body: Some(body::plain(vec![ + Instruction::I32Const(0), // key_ptr + Instruction::I32Const(max_key_len as i32), // key_len + Instruction::Call(0), + Instruction::Drop, + Instruction::End, ])), .. Default::default() }); let instance = Contract::::new(code, vec![])?; let info = instance.info()?; - for key in keys { - info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, - Some(vec![42u8; (n * 2048) as usize]), // value_len increments by 2kb up to max payload_len - None, - false, - ) - .map_err(|_| "Failed to write to storage during setup.")?; - } + info.write( + &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + Some(vec![42u8; n as usize]), + None, + false, + ) + .map_err(|_| "Failed to write to storage during setup.")?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -1244,7 +1238,7 @@ benchmarks! { seal_get_storage { let r in 0 .. API_BENCHMARK_BATCHES/2; let max_key_len = T::MaxStorageKeyLen::get(); - let keys = (0 .. r * API_BENCHMARK_BATCH_SIZE) + let keys = (0 .. r) .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); h.resize(max_key_len.try_into().unwrap(), n.to_le_bytes()[0]); h }) .collect::>(); @@ -1268,8 +1262,8 @@ benchmarks! { value: T::Schedule::get().limits.payload_len.to_le_bytes().into(), }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ - Counter(0, max_key_len as u32), // key_ptr + call_body: Some(body::repeated_dyn(r, vec![ + Counter(0, max_key_len), // key_ptr Regular(Instruction::I32Const(max_key_len as i32)), // key_len Regular(Instruction::I32Const((key_bytes_len + 4) as i32)), // out_ptr Regular(Instruction::I32Const(key_bytes_len as i32)), // out_len_ptr @@ -1295,15 +1289,10 @@ benchmarks! { #[skip_meta] #[pov_mode = Measured] - seal_get_storage_per_kb { - let n in 0 .. T::Schedule::get().limits.payload_len / 2048; // half of the max payload_len in kb + seal_get_storage_per_byte { + let n in 0 .. T::Schedule::get().limits.payload_len; let max_key_len = T::MaxStorageKeyLen::get(); - let keys = (0 .. n * API_BENCHMARK_BATCH_SIZE) - .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); - h.resize(max_key_len.try_into().unwrap(), n.to_le_bytes()[0]); h }) - .collect::>(); - let key_bytes = keys.iter().flatten().cloned().collect::>(); - let key_bytes_len = key_bytes.len(); + let key = vec![0u8; max_key_len as usize]; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -1315,34 +1304,33 @@ benchmarks! { data_segments: vec![ DataSegment { offset: 0, - value: key_bytes, + value: key.clone(), }, DataSegment { - offset: key_bytes_len as u32, + offset: max_key_len, value: T::Schedule::get().limits.payload_len.to_le_bytes().into(), }, ], - call_body: Some(body::repeated_dyn(API_BENCHMARK_BATCH_SIZE, vec![ - Counter(0, max_key_len as u32), // key_ptr - Regular(Instruction::I32Const(max_key_len as i32)), // key_len - Regular(Instruction::I32Const((key_bytes_len + 4) as i32)), // out_ptr - Regular(Instruction::I32Const(key_bytes_len as i32)), // out_len_ptr - Regular(Instruction::Call(0)), - Regular(Instruction::Drop), + call_body: Some(body::plain(vec![ + Instruction::I32Const(0), // key_ptr + Instruction::I32Const(max_key_len as i32), // key_len + Instruction::I32Const((max_key_len + 4) as i32), // out_ptr + Instruction::I32Const(max_key_len as i32), // out_len_ptr + Instruction::Call(0), + Instruction::Drop, + Instruction::End, ])), .. Default::default() }); let instance = Contract::::new(code, vec![])?; let info = instance.info()?; - for key in keys { - info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, - Some(vec![42u8; (n * 2048) as usize]), // value_len increments by 2kb up to max payload_len - None, - false, - ) - .map_err(|_| "Failed to write to storage during setup.")?; - } + info.write( + &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + Some(vec![42u8; n as usize]), + None, + false, + ) + .map_err(|_| "Failed to write to storage during setup.")?; >::insert(&instance.account_id, info); let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -1353,7 +1341,7 @@ benchmarks! { seal_contains_storage { let r in 0 .. API_BENCHMARK_BATCHES/2; let max_key_len = T::MaxStorageKeyLen::get(); - let keys = (0 .. r * API_BENCHMARK_BATCH_SIZE) + let keys = (0 .. r) .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); h.resize(max_key_len.try_into().unwrap(), n.to_le_bytes()[0]); h }) .collect::>(); @@ -1373,7 +1361,7 @@ benchmarks! { value: key_bytes, }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(0, max_key_len as u32), // key_ptr Regular(Instruction::I32Const(max_key_len as i32)), // key_len Regular(Instruction::Call(0)), @@ -1398,14 +1386,10 @@ benchmarks! { #[skip_meta] #[pov_mode = Measured] - seal_contains_storage_per_kb { - let n in 0 .. T::Schedule::get().limits.payload_len / 2048; // half of the max payload_len in kb + seal_contains_storage_per_byte { + let n in 0 .. T::Schedule::get().limits.payload_len; let max_key_len = T::MaxStorageKeyLen::get(); - let keys = (0 .. n * API_BENCHMARK_BATCH_SIZE) - .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); - h.resize(max_key_len.try_into().unwrap(), n.to_le_bytes()[0]); h }) - .collect::>(); - let key_bytes = keys.iter().flatten().cloned().collect::>(); + let key = vec![0u8; max_key_len as usize]; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -1417,28 +1401,27 @@ benchmarks! { data_segments: vec![ DataSegment { offset: 0, - value: key_bytes, + value: key.clone(), }, ], - call_body: Some(body::repeated_dyn(API_BENCHMARK_BATCH_SIZE, vec![ - Counter(0, max_key_len as u32), // key_ptr - Regular(Instruction::I32Const(max_key_len as i32)), // key_len - Regular(Instruction::Call(0)), - Regular(Instruction::Drop), + call_body: Some(body::plain(vec![ + Instruction::I32Const(0), // key_ptr + Instruction::I32Const(max_key_len as i32), // key_len + Instruction::Call(0), + Instruction::Drop, + Instruction::End, ])), .. Default::default() }); let instance = Contract::::new(code, vec![])?; let info = instance.info()?; - for key in keys { - info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, - Some(vec![42u8; (n * 2048) as usize]), // value_len increments by 2kb up to max payload_len - None, - false, - ) - .map_err(|_| "Failed to write to storage during setup.")?; - } + info.write( + &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + Some(vec![42u8; n as usize]), + None, + false, + ) + .map_err(|_| "Failed to write to storage during setup.")?; >::insert(&instance.account_id, info); let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -1448,7 +1431,7 @@ benchmarks! { seal_take_storage { let r in 0 .. API_BENCHMARK_BATCHES/2; let max_key_len = T::MaxStorageKeyLen::get(); - let keys = (0 .. r * API_BENCHMARK_BATCH_SIZE) + let keys = (0 .. r) .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); h.resize(max_key_len.try_into().unwrap(), n.to_le_bytes()[0]); h }) .collect::>(); @@ -1472,7 +1455,7 @@ benchmarks! { value: T::Schedule::get().limits.payload_len.to_le_bytes().into(), }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(0, max_key_len as u32), // key_ptr Regular(Instruction::I32Const(max_key_len as i32)), // key_len Regular(Instruction::I32Const((key_bytes_len + 4) as i32)), // out_ptr @@ -1499,15 +1482,10 @@ benchmarks! { #[skip_meta] #[pov_mode = Measured] - seal_take_storage_per_kb { - let n in 0 .. T::Schedule::get().limits.payload_len / 2048; // half of the max payload_len in kb + seal_take_storage_per_byte { + let n in 0 .. T::Schedule::get().limits.payload_len; let max_key_len = T::MaxStorageKeyLen::get(); - let keys = (0 .. n * API_BENCHMARK_BATCH_SIZE) - .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); - h.resize(max_key_len.try_into().unwrap(), n.to_le_bytes()[0]); h }) - .collect::>(); - let key_bytes = keys.iter().flatten().cloned().collect::>(); - let key_bytes_len = key_bytes.len(); + let key = vec![0u8; max_key_len as usize]; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -1519,34 +1497,33 @@ benchmarks! { data_segments: vec![ DataSegment { offset: 0, - value: key_bytes, + value: key.clone(), }, DataSegment { - offset: key_bytes_len as u32, + offset: max_key_len, value: T::Schedule::get().limits.payload_len.to_le_bytes().into(), }, ], - call_body: Some(body::repeated_dyn(API_BENCHMARK_BATCH_SIZE, vec![ - Counter(0, max_key_len as u32), // key_ptr - Regular(Instruction::I32Const(max_key_len as i32)), // key_len - Regular(Instruction::I32Const((key_bytes_len + 4) as i32)), // out_ptr - Regular(Instruction::I32Const(key_bytes_len as i32)), // out_len_ptr - Regular(Instruction::Call(0)), - Regular(Instruction::Drop), + call_body: Some(body::plain(vec![ + Instruction::I32Const(0), // key_ptr + Instruction::I32Const(max_key_len as i32), // key_len + Instruction::I32Const((max_key_len + 4) as i32), // out_ptr + Instruction::I32Const(max_key_len as i32), // out_len_ptr + Instruction::Call(0), + Instruction::Drop, + Instruction::End, ])), .. Default::default() }); let instance = Contract::::new(code, vec![])?; let info = instance.info()?; - for key in keys { - info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, - Some(vec![42u8; (n * 2048) as usize]), // value_len increments by 2kb up to max payload_len - None, - false, - ) - .map_err(|_| "Failed to write to storage during setup.")?; - } + info.write( + &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + Some(vec![42u8; n as usize]), + None, + false, + ) + .map_err(|_| "Failed to write to storage during setup.")?; >::insert(&instance.account_id, info); let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -1555,7 +1532,7 @@ benchmarks! { #[pov_mode = Measured] seal_transfer { let r in 0 .. API_BENCHMARK_BATCHES; - let accounts = (0..r * API_BENCHMARK_BATCH_SIZE) + let accounts = (0..r) .map(|i| account::("receiver", i, 0)) .collect::>(); let account_len = accounts.get(0).map(|i| i.encode().len()).unwrap_or(0); @@ -1582,7 +1559,7 @@ benchmarks! { value: account_bytes, }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(value_len as u32, account_len as u32), // account_ptr Regular(Instruction::I32Const(account_len as i32)), // account_len Regular(Instruction::I32Const(0)), // value_ptr @@ -1593,7 +1570,7 @@ benchmarks! { .. Default::default() }); let instance = Contract::::new(code, vec![])?; - instance.set_balance(value * (r * API_BENCHMARK_BATCH_SIZE + 1).into()); + instance.set_balance(value * (r + 1).into()); let origin = RawOrigin::Signed(instance.caller.clone()); for account in &accounts { assert_eq!(T::Currency::total_balance(account), 0u32.into()); @@ -1610,7 +1587,7 @@ benchmarks! { seal_call { let r in 0 .. API_BENCHMARK_BATCHES; let dummy_code = WasmModule::::dummy_with_bytes(0); - let callees = (0..r * API_BENCHMARK_BATCH_SIZE) + let callees = (0..r) .map(|i| Contract::with_index(i + 1, dummy_code.clone(), vec![])) .collect::, _>>()?; let callee_len = callees.get(0).map(|i| i.account_id.encode().len()).unwrap_or(0); @@ -1646,7 +1623,7 @@ benchmarks! { value: callee_bytes, }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(value_len as u32, callee_len as u32), // callee_ptr Regular(Instruction::I32Const(callee_len as i32)), // callee_len Regular(Instruction::I64Const(0)), // gas @@ -1668,7 +1645,7 @@ benchmarks! { #[pov_mode = Measured] seal_delegate_call { let r in 0 .. API_BENCHMARK_BATCHES; - let hashes = (0..r * API_BENCHMARK_BATCH_SIZE) + let hashes = (0..r) .map(|i| { let code = WasmModule::::dummy_with_bytes(i); Contracts::::store_code_raw(code.code, whitelisted_caller())?; @@ -1701,7 +1678,7 @@ benchmarks! { value: hashes_bytes, }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Regular(Instruction::I32Const(0)), // flags Counter(hashes_offset as u32, hash_len as u32), // code_hash_ptr Regular(Instruction::I32Const(0)), // input_data_ptr @@ -1719,14 +1696,10 @@ benchmarks! { }: call(origin, callee, 0u32.into(), Weight::MAX, None, vec![]) #[pov_mode = Measured] - seal_call_per_transfer_clone_kb { + seal_call_per_transfer_clone_byte { let t in 0 .. 1; - let c in 0 .. code::max_pages::() * 64; - let callees = (0..API_BENCHMARK_BATCH_SIZE) - .map(|i| Contract::with_index(i + 1, >::dummy(), vec![])) - .collect::, _>>()?; - let callee_len = callees.get(0).map(|i| i.account_id.encode().len()).unwrap_or(0); - let callee_bytes = callees.iter().flat_map(|x| x.account_id.encode()).collect::>(); + let c in 0 .. code::max_pages::() * 64 * 1024; + let callee = Contract::with_index(5, >::dummy(), vec![])?; let value: BalanceOf = t.into(); let value_bytes = value.encode(); let value_len = value_bytes.len(); @@ -1754,33 +1727,34 @@ benchmarks! { }, DataSegment { offset: value_len as u32, - value: callee_bytes, + value: callee.account_id.encode(), }, ], - call_body: Some(body::repeated_dyn(API_BENCHMARK_BATCH_SIZE, vec![ - Regular(Instruction::I32Const(CallFlags::CLONE_INPUT.bits() as i32)), // flags - Counter(value_len as u32, callee_len as u32), // callee_ptr - Regular(Instruction::I64Const(0)), // gas - Regular(Instruction::I32Const(0)), // value_ptr - Regular(Instruction::I32Const(0)), // input_data_ptr - Regular(Instruction::I32Const(0)), // input_data_len - Regular(Instruction::I32Const(SENTINEL as i32)), // output_ptr - Regular(Instruction::I32Const(0)), // output_len_ptr - Regular(Instruction::Call(0)), - Regular(Instruction::Drop), + call_body: Some(body::plain(vec![ + Instruction::I32Const(CallFlags::CLONE_INPUT.bits() as i32), // flags + Instruction::I32Const(value_len as i32), // callee_ptr + Instruction::I64Const(0), // gas + Instruction::I32Const(0), // value_ptr + Instruction::I32Const(0), // input_data_ptr + Instruction::I32Const(0), // input_data_len + Instruction::I32Const(SENTINEL as i32), // output_ptr + Instruction::I32Const(0), // output_len_ptr + Instruction::Call(0), + Instruction::Drop, + Instruction::End, ])), .. Default::default() }); let instance = Contract::::new(code, vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); - let bytes = vec![42; (c * 1024) as usize]; + let bytes = vec![42; c as usize]; }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, bytes) // We assume that every instantiate sends at least the minimum balance. #[pov_mode = Measured] seal_instantiate { let r in 0 .. API_BENCHMARK_BATCHES; - let hashes = (0..r * API_BENCHMARK_BATCH_SIZE) + let hashes = (0..r) .map(|i| { let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), @@ -1848,7 +1822,7 @@ benchmarks! { value: addr_len.to_le_bytes().into(), }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(hashes_offset as u32, hash_len as u32), // code_hash_ptr Regular(Instruction::I32Const(hash_len as i32)), // code_hash_len Regular(Instruction::I64Const(0)), // gas @@ -1868,7 +1842,7 @@ benchmarks! { .. Default::default() }); let instance = Contract::::new(code, vec![])?; - instance.set_balance((value + Pallet::::min_balance()) * (r * API_BENCHMARK_BATCH_SIZE + 1).into()); + instance.set_balance((value + Pallet::::min_balance()) * (r + 1).into()); let origin = RawOrigin::Signed(instance.caller.clone()); let callee = instance.addr.clone(); let addresses = hashes @@ -1892,37 +1866,24 @@ benchmarks! { } #[pov_mode = Measured] - seal_instantiate_per_transfer_input_salt_kb { + seal_instantiate_per_transfer_input_salt_byte { let t in 0 .. 1; - let i in 0 .. (code::max_pages::() - 1) * 64; - let s in 0 .. (code::max_pages::() - 1) * 64; + let i in 0 .. (code::max_pages::() - 1) * 64 * 1024; + let s in 0 .. (code::max_pages::() - 1) * 64 * 1024; let callee_code = WasmModule::::dummy(); let hash = callee_code.hash; let hash_bytes = callee_code.hash.encode(); let hash_len = hash_bytes.len(); Contracts::::store_code_raw(callee_code.code, whitelisted_caller())?; - let salts = (0..API_BENCHMARK_BATCH_SIZE).map(|x| x.encode()).collect::>(); - let salt_len = salts.get(0).map(|x| x.len()).unwrap_or(0); - let salt_bytes = salts.iter().cloned().flatten().collect::>(); - let salts_len = salt_bytes.len(); - let value: BalanceOf = t.into(); + let value: BalanceOf = t.into(); let value_bytes = value.encode(); - let value_len = value_bytes.len(); - let addr_len = T::AccountId::max_encoded_len(); - - // offsets where to place static data in contract memory - let salt_offset = 0; - let value_offset = salts_len; - let hash_offset = value_offset + value_len; - let addr_len_offset = hash_offset + hash_len; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { - module: "seal0", + module: "seal1", name: "seal_instantiate", params: vec![ - ValueType::I32, ValueType::I32, ValueType::I64, ValueType::I32, @@ -1934,73 +1895,63 @@ benchmarks! { ValueType::I32, ValueType::I32, ValueType::I32, - ValueType::I32, ], return_type: Some(ValueType::I32), }], data_segments: vec![ DataSegment { - offset: salt_offset as u32, - value: salt_bytes, - }, - DataSegment { - offset: value_offset as u32, - value: value_bytes, - }, - DataSegment { - offset: hash_offset as u32, + offset: 0, value: hash_bytes, }, DataSegment { - offset: addr_len_offset as u32, - value: (addr_len as u32).to_le_bytes().into(), + offset: hash_len as u32, + value: value_bytes, }, ], - call_body: Some(body::repeated_dyn(API_BENCHMARK_BATCH_SIZE, vec![ - Regular(Instruction::I32Const(hash_offset as i32)), // code_hash_ptr - Regular(Instruction::I32Const(hash_len as i32)), // code_hash_len - Regular(Instruction::I64Const(0)), // gas - Regular(Instruction::I32Const(value_offset as i32)), // value_ptr - Regular(Instruction::I32Const(value_len as i32)), // value_len - Counter(salt_offset as u32, salt_len as u32), // input_data_ptr - Regular(Instruction::I32Const((i * 1024) as i32)), // input_data_len - Regular(Instruction::I32Const((addr_len_offset + addr_len) as i32)), // address_ptr - Regular(Instruction::I32Const(addr_len_offset as i32)), // address_len_ptr - Regular(Instruction::I32Const(SENTINEL as i32)), // output_ptr - Regular(Instruction::I32Const(0)), // output_len_ptr - Counter(salt_offset as u32, salt_len as u32), // salt_ptr - Regular(Instruction::I32Const((s * 1024) as i32)), // salt_len - Regular(Instruction::Call(0)), - Regular(Instruction::I32Eqz), - Regular(Instruction::If(BlockType::NoResult)), - Regular(Instruction::Nop), - Regular(Instruction::Else), - Regular(Instruction::Unreachable), - Regular(Instruction::End), + call_body: Some(body::plain(vec![ + Instruction::I32Const(0 as i32), // code_hash_ptr + Instruction::I64Const(0), // gas + Instruction::I32Const(hash_len as i32), // value_ptr + Instruction::I32Const(0 as i32), // input_data_ptr + Instruction::I32Const(i as i32), // input_data_len + Instruction::I32Const(SENTINEL as i32), // address_ptr + Instruction::I32Const(0), // address_len_ptr + Instruction::I32Const(SENTINEL as i32), // output_ptr + Instruction::I32Const(0), // output_len_ptr + Instruction::I32Const(0 as i32), // salt_ptr + Instruction::I32Const(s as i32), // salt_len + Instruction::Call(0), + Instruction::I32Eqz, + Instruction::If(BlockType::NoResult), + Instruction::Nop, + Instruction::Else, + Instruction::Unreachable, + Instruction::End, + Instruction::End, ])), .. Default::default() }); let instance = Contract::::new(code, vec![])?; - instance.set_balance((value + Pallet::::min_balance()) * (API_BENCHMARK_BATCH_SIZE + 1).into()); + instance.set_balance(value + (Pallet::::min_balance() * 2u32.into())); let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) // Only the overhead of calling the function itself with minimal arguments. #[pov_mode = Measured] seal_hash_sha2_256 { - let r in 0 .. 1; + let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::hasher( - "seal_hash_sha2_256", r * API_BENCHMARK_BATCH_SIZE, 0, + "seal_hash_sha2_256", r, 0, ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) - // `n`: Input to hash in kilobytes + // `n`: Input to hash in bytes #[pov_mode = Measured] - seal_hash_sha2_256_per_kb { - let n in 0 .. code::max_pages::() * 64; + seal_hash_sha2_256_per_byte { + let n in 0 .. code::max_pages::() * 64 * 1024; let instance = Contract::::new(WasmModule::hasher( - "seal_hash_sha2_256", API_BENCHMARK_BATCH_SIZE, n * 1024, + "seal_hash_sha2_256", 1, n, ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -2008,19 +1959,19 @@ benchmarks! { // Only the overhead of calling the function itself with minimal arguments. #[pov_mode = Measured] seal_hash_keccak_256 { - let r in 0 .. 1; + let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::hasher( - "seal_hash_keccak_256", r * API_BENCHMARK_BATCH_SIZE, 0, + "seal_hash_keccak_256", r, 0, ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) - // `n`: Input to hash in kilobytes + // `n`: Input to hash in bytes #[pov_mode = Measured] - seal_hash_keccak_256_per_kb { - let n in 0 .. code::max_pages::() * 64; + seal_hash_keccak_256_per_byte { + let n in 0 .. code::max_pages::() * 64 * 1024; let instance = Contract::::new(WasmModule::hasher( - "seal_hash_keccak_256", API_BENCHMARK_BATCH_SIZE, n * 1024, + "seal_hash_keccak_256", 1, n, ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -2028,19 +1979,19 @@ benchmarks! { // Only the overhead of calling the function itself with minimal arguments. #[pov_mode = Measured] seal_hash_blake2_256 { - let r in 0 .. 1; + let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::hasher( - "seal_hash_blake2_256", r * API_BENCHMARK_BATCH_SIZE, 0, + "seal_hash_blake2_256", r, 0, ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) - // `n`: Input to hash in kilobytes + // `n`: Input to hash in bytes #[pov_mode = Measured] - seal_hash_blake2_256_per_kb { - let n in 0 .. code::max_pages::() * 64; + seal_hash_blake2_256_per_byte { + let n in 0 .. code::max_pages::() * 64 * 1024; let instance = Contract::::new(WasmModule::hasher( - "seal_hash_blake2_256", API_BENCHMARK_BATCH_SIZE, n * 1024, + "seal_hash_blake2_256", 1, n, ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -2048,19 +1999,19 @@ benchmarks! { // Only the overhead of calling the function itself with minimal arguments. #[pov_mode = Measured] seal_hash_blake2_128 { - let r in 0 .. 1; + let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::hasher( - "seal_hash_blake2_128", r * API_BENCHMARK_BATCH_SIZE, 0, + "seal_hash_blake2_128", r, 0, ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) - // `n`: Input to hash in kilobytes + // `n`: Input to hash in bytes #[pov_mode = Measured] - seal_hash_blake2_128_per_kb { - let n in 0 .. code::max_pages::() * 64; + seal_hash_blake2_128_per_byte { + let n in 0 .. code::max_pages::() * 64 * 1024; let instance = Contract::::new(WasmModule::hasher( - "seal_hash_blake2_128", API_BENCHMARK_BATCH_SIZE, n * 1024, + "seal_hash_blake2_128", 1, n, ), vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) @@ -2069,11 +2020,11 @@ benchmarks! { // It generates different private keys and signatures for the message "Hello world". #[pov_mode = Measured] seal_ecdsa_recover { - let r in 0 .. 1; + let r in 0 .. API_BENCHMARK_BATCHES; let message_hash = sp_io::hashing::blake2_256("Hello world".as_bytes()); let key_type = sp_core::crypto::KeyTypeId(*b"code"); - let signatures = (0..r * API_BENCHMARK_BATCH_SIZE) + let signatures = (0..r) .map(|i| { let pub_key = sp_io::crypto::ecdsa_generate(key_type, None); let sig = sp_io::crypto::ecdsa_sign_prehashed(key_type, &pub_key, &message_hash).expect("Generates signature"); @@ -2101,7 +2052,7 @@ benchmarks! { value: signatures, }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(32, 65), // signature_ptr Regular(Instruction::I32Const(0)), // message_hash_ptr Regular(Instruction::I32Const(signatures_bytes_len + 32)), // output_len_ptr @@ -2118,9 +2069,9 @@ benchmarks! { // generated different ECDSA keys. #[pov_mode = Measured] seal_ecdsa_to_eth_address { - let r in 0 .. 1; + let r in 0 .. API_BENCHMARK_BATCHES; let key_type = sp_core::crypto::KeyTypeId(*b"code"); - let pub_keys_bytes = (0..r * API_BENCHMARK_BATCH_SIZE) + let pub_keys_bytes = (0..r) .flat_map(|_| { sp_io::crypto::ecdsa_generate(key_type, None).0 }) @@ -2140,7 +2091,7 @@ benchmarks! { value: pub_keys_bytes, }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(0, 33), // pub_key_ptr Regular(Instruction::I32Const(pub_keys_bytes_len)), // out_ptr Regular(Instruction::Call(0)), @@ -2155,7 +2106,7 @@ benchmarks! { #[pov_mode = Measured] seal_set_code_hash { let r in 0 .. API_BENCHMARK_BATCHES; - let code_hashes = (0..r * API_BENCHMARK_BATCH_SIZE) + let code_hashes = (0..r) .map(|i| { let new_code = WasmModule::::dummy_with_bytes(i); Contracts::::store_code_raw(new_code.code, whitelisted_caller())?; @@ -2182,7 +2133,7 @@ benchmarks! { value: code_hashes_bytes, }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(0, code_hash_len as u32), // code_hash_ptr Regular(Instruction::Call(0)), Regular(Instruction::Drop), @@ -2204,7 +2155,7 @@ benchmarks! { params: vec![], return_type: Some(ValueType::I32), }], - call_body: Some(body::repeated(r * API_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::repeated(r, &[ Instruction::Call(0), Instruction::Drop, ])), @@ -2218,7 +2169,7 @@ benchmarks! { seal_account_reentrance_count { let r in 0 .. API_BENCHMARK_BATCHES; let dummy_code = WasmModule::::dummy_with_bytes(0); - let accounts = (0..r * API_BENCHMARK_BATCH_SIZE) + let accounts = (0..r) .map(|i| Contract::with_index(i + 1, dummy_code.clone(), vec![])) .collect::, _>>()?; let account_id_len = accounts.get(0).map(|i| i.account_id.encode().len()).unwrap_or(0); @@ -2237,7 +2188,7 @@ benchmarks! { value: account_id_bytes, }, ], - call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Counter(0, account_id_len as u32), // account_ptr Regular(Instruction::Call(0)), Regular(Instruction::Drop), @@ -2259,7 +2210,7 @@ benchmarks! { params: vec![], return_type: Some(ValueType::I64), }], - call_body: Some(body::repeated(r * API_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::repeated(r, &[ Instruction::Call(0), Instruction::Drop, ])), @@ -2283,7 +2234,7 @@ benchmarks! { instr_i64const { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ RandomI64Repeated(1), Regular(Instruction::Drop), ])), @@ -2299,7 +2250,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ RandomUnaligned(0, code::max_pages::() * 64 * 1024 - 8), Regular(Instruction::I64Load(3, 0)), Regular(Instruction::Drop), @@ -2316,7 +2267,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ RandomUnaligned(0, code::max_pages::() * 64 * 1024 - 8), RandomI64Repeated(1), Regular(Instruction::I64Store(3, 0)), @@ -2332,7 +2283,7 @@ benchmarks! { instr_select { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ RandomI64Repeated(1), RandomI64Repeated(1), RandomI32(0, 2), @@ -2350,7 +2301,7 @@ benchmarks! { instr_if { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ RandomI32(0, 2), Regular(Instruction::If(BlockType::Value(ValueType::I64))), RandomI64Repeated(1), @@ -2371,7 +2322,7 @@ benchmarks! { instr_br { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Regular(Instruction::Block(BlockType::NoResult)), Regular(Instruction::Block(BlockType::NoResult)), Regular(Instruction::Block(BlockType::NoResult)), @@ -2398,7 +2349,7 @@ benchmarks! { instr_br_if { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Regular(Instruction::Block(BlockType::NoResult)), Regular(Instruction::Block(BlockType::NoResult)), Regular(Instruction::Block(BlockType::NoResult)), @@ -2430,7 +2381,7 @@ benchmarks! { default: 1, }); let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ Regular(Instruction::Block(BlockType::NoResult)), Regular(Instruction::Block(BlockType::NoResult)), Regular(Instruction::Block(BlockType::NoResult)), @@ -2465,21 +2416,22 @@ benchmarks! { default: 0, }); let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { - call_body: Some(body::repeated_dyn(INSTR_BENCHMARK_BATCH_SIZE, vec![ - Regular(Instruction::Block(BlockType::NoResult)), - Regular(Instruction::Block(BlockType::NoResult)), - Regular(Instruction::Block(BlockType::NoResult)), - RandomI32(0, (e + 1) as i32), // Make sure the default entry is also used - Regular(Instruction::BrTable(table)), - RandomI64Repeated(1), - Regular(Instruction::Drop), - Regular(Instruction::End), - RandomI64Repeated(1), - Regular(Instruction::Drop), - Regular(Instruction::End), - RandomI64Repeated(1), - Regular(Instruction::Drop), - Regular(Instruction::End), + call_body: Some(body::plain(vec![ + Instruction::Block(BlockType::NoResult), + Instruction::Block(BlockType::NoResult), + Instruction::Block(BlockType::NoResult), + Instruction::I32Const((e / 2) as i32), + Instruction::BrTable(table), + Instruction::I64Const(42), + Instruction::Drop, + Instruction::End, + Instruction::I64Const(42), + Instruction::Drop, + Instruction::End, + Instruction::I64Const(42), + Instruction::Drop, + Instruction::End, + Instruction::End, ])), .. Default::default() })); @@ -2499,7 +2451,7 @@ benchmarks! { Instruction::Drop, Instruction::End, ])), - call_body: Some(body::repeated(r * INSTR_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::repeated(r, &[ Instruction::Call(2), // call aux ])), .. Default::default() @@ -2522,7 +2474,7 @@ benchmarks! { Instruction::Drop, Instruction::End, ])), - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ RandomI32(0, num_elements as i32), Regular(Instruction::CallIndirect(0, 0)), // we only have one sig: 0 ])), @@ -2536,39 +2488,6 @@ benchmarks! { sbox.invoke(); } - // w_instr_call_indirect_per_param = w_bench - 1 * w_param - // Calling a function indirectly causes it to go through a thunk function whose runtime - // linearly depend on the amount of parameters to this function. - // Please note that this is not necessary with a direct call. - #[pov_mode = Ignored] - instr_call_indirect_per_param { - let p in 0 .. T::Schedule::get().limits.parameters; - let num_elements = T::Schedule::get().limits.table_size; - use self::code::TableSegment; - let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { - // We need to make use of the stack here in order to trigger stack height - // instrumentation. - aux_body: Some(body::plain(vec![ - Instruction::I64Const(42), - Instruction::Drop, - Instruction::End, - ])), - aux_arg_num: p, - call_body: Some(body::repeated_dyn(INSTR_BENCHMARK_BATCH_SIZE, vec![ - RandomI64Repeated(p as usize), - RandomI32(0, num_elements as i32), - Regular(Instruction::CallIndirect(p.min(1), 0)), // aux signature: 1 or 0 - ])), - table: Some(TableSegment { - num_elements, - function_index: 2, // aux - }), - .. Default::default() - })); - }: { - sbox.invoke(); - } - // w_per_local = w_bench #[pov_mode = Ignored] instr_call_per_local { @@ -2579,8 +2498,9 @@ benchmarks! { body::inject_locals(&mut aux_body, l); let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { aux_body: Some(aux_body), - call_body: Some(body::repeated(INSTR_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::plain(vec![ Instruction::Call(2), // call aux + Instruction::End, ])), .. Default::default() })); @@ -2593,7 +2513,7 @@ benchmarks! { instr_local_get { let r in 0 .. INSTR_BENCHMARK_BATCHES; let max_locals = T::Schedule::get().limits.locals; - let mut call_body = body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + let mut call_body = body::repeated_dyn(r, vec![ RandomGetLocal(0, max_locals), Regular(Instruction::Drop), ]); @@ -2611,7 +2531,7 @@ benchmarks! { instr_local_set { let r in 0 .. INSTR_BENCHMARK_BATCHES; let max_locals = T::Schedule::get().limits.locals; - let mut call_body = body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + let mut call_body = body::repeated_dyn(r, vec![ RandomI64Repeated(1), RandomSetLocal(0, max_locals), ]); @@ -2629,7 +2549,7 @@ benchmarks! { instr_local_tee { let r in 0 .. INSTR_BENCHMARK_BATCHES; let max_locals = T::Schedule::get().limits.locals; - let mut call_body = body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + let mut call_body = body::repeated_dyn(r, vec![ RandomI64Repeated(1), RandomTeeLocal(0, max_locals), Regular(Instruction::Drop), @@ -2649,7 +2569,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let max_globals = T::Schedule::get().limits.globals; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ RandomGetGlobal(0, max_globals), Regular(Instruction::Drop), ])), @@ -2666,7 +2586,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let max_globals = T::Schedule::get().limits.globals; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ RandomI64Repeated(1), RandomSetGlobal(0, max_globals), ])), @@ -2683,7 +2603,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), - call_body: Some(body::repeated(r * INSTR_BENCHMARK_BATCH_SIZE, &[ + call_body: Some(body::repeated(r, &[ Instruction::CurrentMemory(0), Instruction::Drop ])), @@ -2700,14 +2620,13 @@ benchmarks! { // depends on how much memory is already allocated. #[pov_mode = Ignored] instr_memory_grow { - let r in 0 .. 1; - let max_pages = ImportedMemory::max::().max_pages; + let r in 0 .. ImportedMemory::max::().max_pages; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory { min_pages: 0, - max_pages, + max_pages: ImportedMemory::max::().max_pages, }), - call_body: Some(body::repeated(r * max_pages, &[ + call_body: Some(body::repeated(r, &[ Instruction::I32Const(1), Instruction::GrowMemory(0), Instruction::Drop, @@ -2726,7 +2645,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( Instruction::I64Clz, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2737,7 +2656,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( Instruction::I64Ctz, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2748,7 +2667,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( Instruction::I64Popcnt, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2759,7 +2678,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( Instruction::I64Eqz, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2769,7 +2688,7 @@ benchmarks! { instr_i64extendsi32 { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ RandomI32Repeated(1), Regular(Instruction::I64ExtendSI32), Regular(Instruction::Drop), @@ -2784,7 +2703,7 @@ benchmarks! { instr_i64extendui32 { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { - call_body: Some(body::repeated_dyn(r * INSTR_BENCHMARK_BATCH_SIZE, vec![ + call_body: Some(body::repeated_dyn(r, vec![ RandomI32Repeated(1), Regular(Instruction::I64ExtendUI32), Regular(Instruction::Drop), @@ -2800,7 +2719,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( Instruction::I32WrapI64, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2814,7 +2733,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Eq, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2825,7 +2744,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Ne, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2836,7 +2755,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64LtS, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2847,7 +2766,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64LtU, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2858,7 +2777,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64GtS, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2869,7 +2788,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64GtU, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2880,7 +2799,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64LeS, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2891,7 +2810,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64LeU, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2902,7 +2821,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64GeS, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2913,7 +2832,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64GeU, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2924,7 +2843,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Add, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2935,7 +2854,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Sub, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2946,7 +2865,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Mul, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2957,7 +2876,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64DivS, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2968,7 +2887,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64DivU, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2979,7 +2898,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64RemS, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -2990,7 +2909,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64RemU, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -3001,7 +2920,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64And, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -3012,7 +2931,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Or, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -3023,7 +2942,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Xor, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -3034,7 +2953,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Shl, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -3045,7 +2964,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64ShrS, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -3056,7 +2975,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64ShrU, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -3067,7 +2986,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Rotl, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); @@ -3078,7 +2997,7 @@ benchmarks! { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Rotr, - r * INSTR_BENCHMARK_BATCH_SIZE, + r, )); }: { sbox.invoke(); diff --git a/frame/contracts/src/schedule.rs b/frame/contracts/src/schedule.rs index 71faf08c23d6a..796a7f6d3718d 100644 --- a/frame/contracts/src/schedule.rs +++ b/frame/contracts/src/schedule.rs @@ -27,18 +27,9 @@ use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_runtime::RuntimeDebug; -use sp_std::{marker::PhantomData, vec::Vec}; +use sp_std::marker::PhantomData; use wasm_instrument::{gas_metering, parity_wasm::elements}; -/// How many API calls are executed in a single batch. The reason for increasing the amount -/// of API calls in batches (per benchmark component increase) is so that the linear regression -/// has an easier time determining the contribution of that component. -pub const API_BENCHMARK_BATCH_SIZE: u32 = 80; - -/// How many instructions are executed in a single batch. The reasoning is the same -/// as for `API_BENCHMARK_BATCH_SIZE`. -pub const INSTR_BENCHMARK_BATCH_SIZE: u32 = 100; - /// Definition of the cost schedule and other parameterizations for the wasm vm. /// /// Its [`Default`] implementation is the designated way to initialize this type. It uses @@ -200,7 +191,6 @@ pub struct InstructionWeights { pub br_table_per_entry: u32, pub call: u32, pub call_indirect: u32, - pub call_indirect_per_param: u32, pub call_per_local: u32, pub local_get: u32, pub local_set: u32, @@ -451,66 +441,22 @@ macro_rules! cost_args { } } -macro_rules! cost_batched_args { - ($name:ident, $( $arg: expr ),+) => { - cost_args!($name, $( $arg ),+) / u64::from(API_BENCHMARK_BATCH_SIZE) - } -} - -macro_rules! cost_instr_no_params_with_batch_size { - ($name:ident, $batch_size:expr) => { - (cost_args!($name, 1).ref_time() / u64::from($batch_size)) as u32 - }; -} - -macro_rules! cost_instr_with_batch_size { - ($name:ident, $num_params:expr, $batch_size:expr) => { - cost_instr_no_params_with_batch_size!($name, $batch_size).saturating_sub( - (cost_instr_no_params_with_batch_size!(instr_i64const, $batch_size) / 2) - .saturating_mul($num_params), - ) - }; -} - -macro_rules! cost_instr { - ($name:ident, $num_params:expr) => { - cost_instr_with_batch_size!($name, $num_params, INSTR_BENCHMARK_BATCH_SIZE) +macro_rules! cost_instr_no_params { + ($name:ident) => { + cost_args!($name, 1).ref_time() as u32 }; } -macro_rules! cost_byte_args { - ($name:ident, $( $arg: expr ),+) => { - cost_args!($name, $( $arg ),+) / 1024 - } -} - -macro_rules! cost_byte_batched_args { - ($name:ident, $( $arg: expr ),+) => { - cost_batched_args!($name, $( $arg ),+) / 1024 - } -} - macro_rules! cost { ($name:ident) => { cost_args!($name, 1) }; } -macro_rules! cost_batched { - ($name:ident) => { - cost_batched_args!($name, 1) - }; -} - -macro_rules! cost_byte { - ($name:ident) => { - cost_byte_args!($name, 1) - }; -} - -macro_rules! cost_byte_batched { - ($name:ident) => { - cost_byte_batched_args!($name, 1) +macro_rules! cost_instr { + ($name:ident, $num_params:expr) => { + cost_instr_no_params!($name) + .saturating_sub((cost_instr_no_params!(instr_i64const) / 2).saturating_mul($num_params)) }; } @@ -533,7 +479,6 @@ impl Default for Limits { impl Default for InstructionWeights { fn default() -> Self { - let max_pages = Limits::default().memory_pages; Self { version: 4, fallback: 0, @@ -548,7 +493,6 @@ impl Default for InstructionWeights { br_table_per_entry: cost_instr!(instr_br_table_per_entry, 0), call: cost_instr!(instr_call, 2), call_indirect: cost_instr!(instr_call_indirect, 3), - call_indirect_per_param: cost_instr!(instr_call_indirect_per_param, 0), call_per_local: cost_instr!(instr_call_per_local, 0), local_get: cost_instr!(instr_local_get, 1), local_set: cost_instr!(instr_local_set, 1), @@ -556,7 +500,7 @@ impl Default for InstructionWeights { global_get: cost_instr!(instr_global_get, 1), global_set: cost_instr!(instr_global_set, 1), memory_current: cost_instr!(instr_memory_current, 1), - memory_grow: cost_instr_with_batch_size!(instr_memory_grow, 1, max_pages), + memory_grow: cost_instr!(instr_memory_grow, 1), i64clz: cost_instr!(instr_i64clz, 2), i64ctz: cost_instr!(instr_i64ctz, 2), i64popcnt: cost_instr!(instr_i64popcnt, 2), @@ -597,89 +541,85 @@ impl Default for InstructionWeights { impl Default for HostFnWeights { fn default() -> Self { Self { - caller: cost_batched!(seal_caller), - is_contract: cost_batched!(seal_is_contract), - code_hash: cost_batched!(seal_code_hash), - own_code_hash: cost_batched!(seal_own_code_hash), - caller_is_origin: cost_batched!(seal_caller_is_origin), - address: cost_batched!(seal_address), - gas_left: cost_batched!(seal_gas_left), - balance: cost_batched!(seal_balance), - value_transferred: cost_batched!(seal_value_transferred), - minimum_balance: cost_batched!(seal_minimum_balance), - block_number: cost_batched!(seal_block_number), - now: cost_batched!(seal_now), - weight_to_fee: cost_batched!(seal_weight_to_fee), + caller: cost!(seal_caller), + is_contract: cost!(seal_is_contract), + code_hash: cost!(seal_code_hash), + own_code_hash: cost!(seal_own_code_hash), + caller_is_origin: cost!(seal_caller_is_origin), + address: cost!(seal_address), + gas_left: cost!(seal_gas_left), + balance: cost!(seal_balance), + value_transferred: cost!(seal_value_transferred), + minimum_balance: cost!(seal_minimum_balance), + block_number: cost!(seal_block_number), + now: cost!(seal_now), + weight_to_fee: cost!(seal_weight_to_fee), // Manually remove proof size from basic block cost. // // Due to imperfect benchmarking some host functions incur a small // amount of proof size. Usually this is ok. However, charging a basic block is such // a frequent operation that this would be a vast overestimation. - gas: cost_batched!(seal_gas).set_proof_size(0), - input: cost_batched!(seal_input), - input_per_byte: cost_byte_batched!(seal_input_per_kb), + gas: cost!(seal_gas).set_proof_size(0), + input: cost!(seal_input), + input_per_byte: cost!(seal_input_per_byte), r#return: cost!(seal_return), - return_per_byte: cost_byte!(seal_return_per_kb), + return_per_byte: cost!(seal_return_per_byte), terminate: cost!(seal_terminate), - random: cost_batched!(seal_random), - deposit_event: cost_batched!(seal_deposit_event), - deposit_event_per_topic: cost_batched_args!(seal_deposit_event_per_topic_and_kb, 1, 0), - deposit_event_per_byte: cost_byte_batched_args!( - seal_deposit_event_per_topic_and_kb, - 0, - 1 - ), - debug_message: cost_batched!(seal_debug_message), - debug_message_per_byte: cost_byte!(seal_debug_message_per_kb), - set_storage: cost_batched!(seal_set_storage), - set_code_hash: cost_batched!(seal_set_code_hash), - set_storage_per_new_byte: cost_byte_batched!(seal_set_storage_per_new_kb), - set_storage_per_old_byte: cost_byte_batched!(seal_set_storage_per_old_kb), - clear_storage: cost_batched!(seal_clear_storage), - clear_storage_per_byte: cost_byte_batched!(seal_clear_storage_per_kb), - contains_storage: cost_batched!(seal_contains_storage), - contains_storage_per_byte: cost_byte_batched!(seal_contains_storage_per_kb), - get_storage: cost_batched!(seal_get_storage), - get_storage_per_byte: cost_byte_batched!(seal_get_storage_per_kb), - take_storage: cost_batched!(seal_take_storage), - take_storage_per_byte: cost_byte_batched!(seal_take_storage_per_kb), - transfer: cost_batched!(seal_transfer), - call: cost_batched!(seal_call), - delegate_call: cost_batched!(seal_delegate_call), - call_transfer_surcharge: cost_batched_args!(seal_call_per_transfer_clone_kb, 1, 0), - call_per_cloned_byte: cost_byte_batched_args!(seal_call_per_transfer_clone_kb, 0, 1), - instantiate: cost_batched!(seal_instantiate), - instantiate_transfer_surcharge: cost_batched_args!( - seal_instantiate_per_transfer_input_salt_kb, + random: cost!(seal_random), + deposit_event: cost!(seal_deposit_event), + deposit_event_per_topic: cost_args!(seal_deposit_event_per_topic_and_byte, 1, 0), + deposit_event_per_byte: cost_args!(seal_deposit_event_per_topic_and_byte, 0, 1), + debug_message: cost!(seal_debug_message), + debug_message_per_byte: cost!(seal_debug_message_per_byte), + set_storage: cost!(seal_set_storage), + set_code_hash: cost!(seal_set_code_hash), + set_storage_per_new_byte: cost!(seal_set_storage_per_new_byte), + set_storage_per_old_byte: cost!(seal_set_storage_per_old_byte), + clear_storage: cost!(seal_clear_storage), + clear_storage_per_byte: cost!(seal_clear_storage_per_byte), + contains_storage: cost!(seal_contains_storage), + contains_storage_per_byte: cost!(seal_contains_storage_per_byte), + get_storage: cost!(seal_get_storage), + get_storage_per_byte: cost!(seal_get_storage_per_byte), + take_storage: cost!(seal_take_storage), + take_storage_per_byte: cost!(seal_take_storage_per_byte), + transfer: cost!(seal_transfer), + call: cost!(seal_call), + delegate_call: cost!(seal_delegate_call), + call_transfer_surcharge: cost_args!(seal_call_per_transfer_clone_byte, 1, 0), + call_per_cloned_byte: cost_args!(seal_call_per_transfer_clone_byte, 0, 1), + instantiate: cost!(seal_instantiate), + instantiate_transfer_surcharge: cost_args!( + seal_instantiate_per_transfer_input_salt_byte, 1, 0, 0 ), - instantiate_per_input_byte: cost_byte_batched_args!( - seal_instantiate_per_transfer_input_salt_kb, + instantiate_per_input_byte: cost_args!( + seal_instantiate_per_transfer_input_salt_byte, 0, 1, 0 ), - instantiate_per_salt_byte: cost_byte_batched_args!( - seal_instantiate_per_transfer_input_salt_kb, + instantiate_per_salt_byte: cost_args!( + seal_instantiate_per_transfer_input_salt_byte, 0, 0, 1 ), - hash_sha2_256: cost_batched!(seal_hash_sha2_256), - hash_sha2_256_per_byte: cost_byte_batched!(seal_hash_sha2_256_per_kb), - hash_keccak_256: cost_batched!(seal_hash_keccak_256), - hash_keccak_256_per_byte: cost_byte_batched!(seal_hash_keccak_256_per_kb), - hash_blake2_256: cost_batched!(seal_hash_blake2_256), - hash_blake2_256_per_byte: cost_byte_batched!(seal_hash_blake2_256_per_kb), - hash_blake2_128: cost_batched!(seal_hash_blake2_128), - hash_blake2_128_per_byte: cost_byte_batched!(seal_hash_blake2_128_per_kb), - ecdsa_recover: cost_batched!(seal_ecdsa_recover), - ecdsa_to_eth_address: cost_batched!(seal_ecdsa_to_eth_address), - reentrance_count: cost_batched!(seal_reentrance_count), - account_reentrance_count: cost_batched!(seal_account_reentrance_count), - instantiation_nonce: cost_batched!(seal_instantiation_nonce), + hash_sha2_256: cost!(seal_hash_sha2_256), + hash_sha2_256_per_byte: cost!(seal_hash_sha2_256_per_byte), + hash_keccak_256: cost!(seal_hash_keccak_256), + hash_keccak_256_per_byte: cost!(seal_hash_keccak_256_per_byte), + hash_blake2_256: cost!(seal_hash_blake2_256), + hash_blake2_256_per_byte: cost!(seal_hash_blake2_256_per_byte), + hash_blake2_128: cost!(seal_hash_blake2_128), + hash_blake2_128_per_byte: cost!(seal_hash_blake2_128_per_byte), + ecdsa_recover: cost!(seal_ecdsa_recover), + ecdsa_to_eth_address: cost!(seal_ecdsa_to_eth_address), + reentrance_count: cost!(seal_reentrance_count), + account_reentrance_count: cost!(seal_account_reentrance_count), + instantiation_nonce: cost!(seal_instantiation_nonce), _phantom: PhantomData, } } @@ -687,29 +627,12 @@ impl Default for HostFnWeights { struct ScheduleRules<'a, T: Config> { schedule: &'a Schedule, - params: Vec, determinism: Determinism, } impl Schedule { - pub(crate) fn rules( - &self, - module: &elements::Module, - determinism: Determinism, - ) -> impl gas_metering::Rules + '_ { - ScheduleRules { - schedule: self, - params: module - .type_section() - .iter() - .flat_map(|section| section.types()) - .map(|func| { - let elements::Type::Function(func) = func; - func.params().len() as u32 - }) - .collect(), - determinism, - } + pub(crate) fn rules(&self, determinism: Determinism) -> impl gas_metering::Rules + '_ { + ScheduleRules { schedule: self, determinism } } } @@ -717,7 +640,6 @@ impl<'a, T: Config> gas_metering::Rules for ScheduleRules<'a, T> { fn instruction_cost(&self, instruction: &elements::Instruction) -> Option { use self::elements::Instruction::*; let w = &self.schedule.instruction_weights; - let max_params = self.schedule.limits.parameters; let weight = match *instruction { End | Unreachable | Return | Else => 0, @@ -753,7 +675,7 @@ impl<'a, T: Config> gas_metering::Rules for ScheduleRules<'a, T> { SetGlobal(_) => w.global_set, CurrentMemory(_) => w.memory_current, GrowMemory(_) => w.memory_grow, - CallIndirect(idx, _) => *self.params.get(idx as usize).unwrap_or(&max_params), + CallIndirect(_, _) => w.call_indirect, BrTable(ref data) => w .br_table .saturating_add(w.br_table_per_entry.saturating_mul(data.table.len() as u32)), diff --git a/frame/contracts/src/wasm/prepare.rs b/frame/contracts/src/wasm/prepare.rs index 3c69fc2a7940f..eed60891d66f4 100644 --- a/frame/contracts/src/wasm/prepare.rs +++ b/frame/contracts/src/wasm/prepare.rs @@ -219,7 +219,7 @@ impl<'a, T: Config> ContractModule<'a, T> { } fn inject_gas_metering(self, determinism: Determinism) -> Result { - let gas_rules = self.schedule.rules(&self.module, determinism); + let gas_rules = self.schedule.rules(determinism); let backend = gas_metering::host_function::Injector::new("seal0", "gas"); let contract_module = gas_metering::inject(self.module, backend, &gas_rules) .map_err(|_| "gas instrumentation failed")?; diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index ae8638eb73431..b16f11eb7f50a 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -18,28 +18,26 @@ //! Autogenerated weights for pallet_contracts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/substrate +// target/production/substrate // benchmark // pallet -// --chain=dev // --steps=50 // --repeat=20 -// --pallet=pallet_contracts -// --no-storage-info -// --no-median-slopes -// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./frame/contracts/src/weights.rs +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json +// --pallet=pallet_contracts +// --chain=dev // --header=./HEADER-APACHE2 +// --output=./frame/contracts/src/weights.rs // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -77,40 +75,40 @@ pub trait WeightInfo { fn seal_weight_to_fee(r: u32, ) -> Weight; fn seal_gas(r: u32, ) -> Weight; fn seal_input(r: u32, ) -> Weight; - fn seal_input_per_kb(n: u32, ) -> Weight; + fn seal_input_per_byte(n: u32, ) -> Weight; fn seal_return(r: u32, ) -> Weight; - fn seal_return_per_kb(n: u32, ) -> Weight; + fn seal_return_per_byte(n: u32, ) -> Weight; fn seal_terminate(r: u32, ) -> Weight; fn seal_random(r: u32, ) -> Weight; fn seal_deposit_event(r: u32, ) -> Weight; - fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight; + fn seal_deposit_event_per_topic_and_byte(t: u32, n: u32, ) -> Weight; fn seal_debug_message(r: u32, ) -> Weight; - fn seal_debug_message_per_kb(i: u32, ) -> Weight; + fn seal_debug_message_per_byte(i: u32, ) -> Weight; fn seal_set_storage(r: u32, ) -> Weight; - fn seal_set_storage_per_new_kb(n: u32, ) -> Weight; - fn seal_set_storage_per_old_kb(n: u32, ) -> Weight; + fn seal_set_storage_per_new_byte(n: u32, ) -> Weight; + fn seal_set_storage_per_old_byte(n: u32, ) -> Weight; fn seal_clear_storage(r: u32, ) -> Weight; - fn seal_clear_storage_per_kb(n: u32, ) -> Weight; + fn seal_clear_storage_per_byte(n: u32, ) -> Weight; fn seal_get_storage(r: u32, ) -> Weight; - fn seal_get_storage_per_kb(n: u32, ) -> Weight; + fn seal_get_storage_per_byte(n: u32, ) -> Weight; fn seal_contains_storage(r: u32, ) -> Weight; - fn seal_contains_storage_per_kb(n: u32, ) -> Weight; + fn seal_contains_storage_per_byte(n: u32, ) -> Weight; fn seal_take_storage(r: u32, ) -> Weight; - fn seal_take_storage_per_kb(n: u32, ) -> Weight; + fn seal_take_storage_per_byte(n: u32, ) -> Weight; fn seal_transfer(r: u32, ) -> Weight; fn seal_call(r: u32, ) -> Weight; fn seal_delegate_call(r: u32, ) -> Weight; - fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight; + fn seal_call_per_transfer_clone_byte(t: u32, c: u32, ) -> Weight; fn seal_instantiate(r: u32, ) -> Weight; - fn seal_instantiate_per_transfer_input_salt_kb(t: u32, i: u32, s: u32, ) -> Weight; + fn seal_instantiate_per_transfer_input_salt_byte(t: u32, i: u32, s: u32, ) -> Weight; fn seal_hash_sha2_256(r: u32, ) -> Weight; - fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight; + fn seal_hash_sha2_256_per_byte(n: u32, ) -> Weight; fn seal_hash_keccak_256(r: u32, ) -> Weight; - fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight; + fn seal_hash_keccak_256_per_byte(n: u32, ) -> Weight; fn seal_hash_blake2_256(r: u32, ) -> Weight; - fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight; + fn seal_hash_blake2_256_per_byte(n: u32, ) -> Weight; fn seal_hash_blake2_128(r: u32, ) -> Weight; - fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight; + fn seal_hash_blake2_128_per_byte(n: u32, ) -> Weight; fn seal_ecdsa_recover(r: u32, ) -> Weight; fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight; fn seal_set_code_hash(r: u32, ) -> Weight; @@ -128,7 +126,6 @@ pub trait WeightInfo { fn instr_br_table_per_entry(e: u32, ) -> Weight; fn instr_call(r: u32, ) -> Weight; fn instr_call_indirect(r: u32, ) -> Weight; - fn instr_call_indirect_per_param(p: u32, ) -> Weight; fn instr_call_per_local(l: u32, ) -> Weight; fn instr_local_get(r: u32, ) -> Weight; fn instr_local_set(r: u32, ) -> Weight; @@ -180,8 +177,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `109` // Estimated: `1594` - // Minimum execution time: 2_679_000 picoseconds. - Weight::from_parts(2_907_000, 1594) + // Minimum execution time: 2_736_000 picoseconds. + Weight::from_parts(2_931_000, 1594) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Skipped Metadata (r:0 w:0) @@ -189,12 +186,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `450 + k * (69 ±0)` - // Estimated: `440 + k * (70 ±0)` - // Minimum execution time: 11_162_000 picoseconds. - Weight::from_parts(5_734_923, 440) - // Standard Error: 1_097 - .saturating_add(Weight::from_parts(976_647, 0).saturating_mul(k.into())) + // Measured: `481 + k * (69 ±0)` + // Estimated: `471 + k * (70 ±0)` + // Minimum execution time: 10_759_000 picoseconds. + Weight::from_parts(6_965_683, 471) + // Standard Error: 1_019 + .saturating_add(Weight::from_parts(961_947, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -206,12 +203,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `q` is `[0, 128]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `250 + q * (33 ±0)` - // Estimated: `1725 + q * (33 ±0)` - // Minimum execution time: 2_626_000 picoseconds. - Weight::from_parts(10_626_314, 1725) - // Standard Error: 4_006 - .saturating_add(Weight::from_parts(1_298_864, 0).saturating_mul(q.into())) + // Measured: `281 + q * (33 ±0)` + // Estimated: `1753 + q * (33 ±0)` + // Minimum execution time: 2_633_000 picoseconds. + Weight::from_parts(10_668_837, 1753) + // Standard Error: 3_538 + .saturating_add(Weight::from_parts(1_277_168, 0).saturating_mul(q.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 33).saturating_mul(q.into())) @@ -223,12 +220,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 61717]`. fn reinstrument(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `238 + c * (1 ±0)` - // Estimated: `3951 + c * (2 ±0)` - // Minimum execution time: 31_434_000 picoseconds. - Weight::from_parts(29_558_961, 3951) - // Standard Error: 55 - .saturating_add(Weight::from_parts(50_774, 0).saturating_mul(c.into())) + // Measured: `270 + c * (1 ±0)` + // Estimated: `4015 + c * (2 ±0)` + // Minimum execution time: 30_264_000 picoseconds. + Weight::from_parts(27_106_554, 4015) + // Standard Error: 53 + .saturating_add(Weight::from_parts(49_705, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 2).saturating_mul(c.into())) @@ -246,12 +243,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `707` - // Estimated: `21400 + c * (5 ±0)` - // Minimum execution time: 309_015_000 picoseconds. - Weight::from_parts(318_740_885, 21400) - // Standard Error: 29 - .saturating_add(Weight::from_parts(30_993, 0).saturating_mul(c.into())) + // Measured: `803` + // Estimated: `21880 + c * (5 ±0)` + // Minimum execution time: 309_249_000 picoseconds. + Weight::from_parts(323_353_590, 21880) + // Standard Error: 25 + .saturating_add(Weight::from_parts(31_359, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(c.into())) @@ -279,14 +276,14 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `270` // Estimated: `26207` - // Minimum execution time: 3_126_495_000 picoseconds. - Weight::from_parts(636_857_878, 26207) - // Standard Error: 294 - .saturating_add(Weight::from_parts(92_930, 0).saturating_mul(c.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(1_128, 0).saturating_mul(i.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(1_415, 0).saturating_mul(s.into())) + // Minimum execution time: 3_136_707_000 picoseconds. + Weight::from_parts(564_055_378, 26207) + // Standard Error: 286 + .saturating_add(Weight::from_parts(93_308, 0).saturating_mul(c.into())) + // Standard Error: 16 + .saturating_add(Weight::from_parts(1_165, 0).saturating_mul(i.into())) + // Standard Error: 16 + .saturating_add(Weight::from_parts(1_435, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } @@ -308,14 +305,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `482` - // Estimated: `28521` - // Minimum execution time: 1_591_415_000 picoseconds. - Weight::from_parts(228_633_516, 28521) + // Measured: `546` + // Estimated: `28969` + // Minimum execution time: 1_631_314_000 picoseconds. + Weight::from_parts(236_693_159, 28969) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_449, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_434, 0).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_444, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_445, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -331,10 +328,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) fn call() -> Weight { // Proof Size summary in bytes: - // Measured: `759` - // Estimated: `21615` - // Minimum execution time: 167_905_000 picoseconds. - Weight::from_parts(169_247_000, 21615) + // Measured: `855` + // Estimated: `22095` + // Minimum execution time: 167_139_000 picoseconds. + Weight::from_parts(168_034_000, 22095) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -351,10 +348,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `109` // Estimated: `7366` - // Minimum execution time: 305_128_000 picoseconds. - Weight::from_parts(310_911_395, 7366) - // Standard Error: 70 - .saturating_add(Weight::from_parts(94_067, 0).saturating_mul(c.into())) + // Minimum execution time: 306_518_000 picoseconds. + Weight::from_parts(325_652_407, 7366) + // Standard Error: 134 + .saturating_add(Weight::from_parts(93_502, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -368,10 +365,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `255` - // Estimated: `7950` - // Minimum execution time: 29_605_000 picoseconds. - Weight::from_parts(29_986_000, 7950) + // Measured: `287` + // Estimated: `8078` + // Minimum execution time: 29_084_000 picoseconds. + Weight::from_parts(29_350_000, 8078) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -383,10 +380,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `570` - // Estimated: `19530` - // Minimum execution time: 33_824_000 picoseconds. - Weight::from_parts(34_388_000, 19530) + // Measured: `666` + // Estimated: `19818` + // Minimum execution time: 32_996_000 picoseconds. + Weight::from_parts(33_365_000, 19818) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -400,18 +397,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_caller(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `781 + r * (480 ±0)` - // Estimated: `21765 + r * (2400 ±0)` - // Minimum execution time: 295_283_000 picoseconds. - Weight::from_parts(295_895_211, 21765) - // Standard Error: 44_860 - .saturating_add(Weight::from_parts(22_913_078, 0).saturating_mul(r.into())) + // Measured: `877 + r * (6 ±0)` + // Estimated: `22210 + r * (30 ±0)` + // Minimum execution time: 298_315_000 picoseconds. + Weight::from_parts(304_612_433, 22210) + // Standard Error: 904 + .saturating_add(Weight::from_parts(285_473, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -423,19 +420,19 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_is_contract(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `821 + r * (19218 ±0)` - // Estimated: `21765 + r * (294095 ±0)` - // Minimum execution time: 295_760_000 picoseconds. - Weight::from_parts(151_512_811, 21765) - // Standard Error: 522_974 - .saturating_add(Weight::from_parts(263_028_353, 0).saturating_mul(r.into())) + // Measured: `935 + r * (272 ±0)` + // Estimated: `22315 + r * (3835 ±0)` + // Minimum execution time: 299_169_000 picoseconds. + Weight::from_parts(138_157_704, 22315) + // Standard Error: 6_115 + .saturating_add(Weight::from_parts(3_244_482, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 294095).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 3835).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -447,19 +444,19 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `825 + r * (19539 ±0)` - // Estimated: `21810 + r * (295700 ±0)` - // Minimum execution time: 295_950_000 picoseconds. - Weight::from_parts(164_516_076, 21810) - // Standard Error: 469_540 - .saturating_add(Weight::from_parts(321_138_601, 0).saturating_mul(r.into())) + // Measured: `927 + r * (276 ±0)` + // Estimated: `22335 + r * (3855 ±0)` + // Minimum execution time: 299_262_000 picoseconds. + Weight::from_parts(157_105_627, 22335) + // Standard Error: 5_634 + .saturating_add(Weight::from_parts(3_995_666, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 295700).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 3855).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -471,18 +468,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_own_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `788 + r * (480 ±0)` - // Estimated: `21800 + r * (2400 ±0)` - // Minimum execution time: 295_916_000 picoseconds. - Weight::from_parts(299_964_913, 21800) - // Standard Error: 78_211 - .saturating_add(Weight::from_parts(28_933_603, 0).saturating_mul(r.into())) + // Measured: `884 + r * (6 ±0)` + // Estimated: `22250 + r * (30 ±0)` + // Minimum execution time: 298_259_000 picoseconds. + Weight::from_parts(303_498_245, 22250) + // Standard Error: 874 + .saturating_add(Weight::from_parts(352_839, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -494,18 +491,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_origin(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `778 + r * (240 ±0)` - // Estimated: `21735 + r * (1200 ±0)` - // Minimum execution time: 293_588_000 picoseconds. - Weight::from_parts(297_568_984, 21735) - // Standard Error: 35_513 - .saturating_add(Weight::from_parts(11_074_880, 0).saturating_mul(r.into())) + // Measured: `874 + r * (3 ±0)` + // Estimated: `22215 + r * (15 ±0)` + // Minimum execution time: 295_689_000 picoseconds. + Weight::from_parts(314_004_541, 22215) + // Standard Error: 1_803 + .saturating_add(Weight::from_parts(131_102, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 1200).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -517,18 +514,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `782 + r * (480 ±0)` - // Estimated: `21730 + r * (2400 ±0)` - // Minimum execution time: 294_929_000 picoseconds. - Weight::from_parts(295_916_817, 21730) - // Standard Error: 64_902 - .saturating_add(Weight::from_parts(22_944_018, 0).saturating_mul(r.into())) + // Measured: `878 + r * (6 ±0)` + // Estimated: `22220 + r * (30 ±0)` + // Minimum execution time: 297_579_000 picoseconds. + Weight::from_parts(299_326_920, 22220) + // Standard Error: 990 + .saturating_add(Weight::from_parts(284_789, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -540,18 +537,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_gas_left(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `783 + r * (480 ±0)` - // Estimated: `21720 + r * (2405 ±0)` - // Minimum execution time: 296_783_000 picoseconds. - Weight::from_parts(299_399_332, 21720) - // Standard Error: 50_982 - .saturating_add(Weight::from_parts(22_173_249, 0).saturating_mul(r.into())) + // Measured: `879 + r * (6 ±0)` + // Estimated: `22205 + r * (30 ±0)` + // Minimum execution time: 297_651_000 picoseconds. + Weight::from_parts(304_465_467, 22205) + // Standard Error: 736 + .saturating_add(Weight::from_parts(272_149, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2405).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:2 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -563,18 +560,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `921 + r * (480 ±0)` - // Estimated: `24193 + r * (2451 ±0)` - // Minimum execution time: 294_120_000 picoseconds. - Weight::from_parts(305_889_989, 24193) - // Standard Error: 116_244 - .saturating_add(Weight::from_parts(114_781_094, 0).saturating_mul(r.into())) + // Measured: `1050 + r * (6 ±0)` + // Estimated: `25258 + r * (30 ±0)` + // Minimum execution time: 296_957_000 picoseconds. + Weight::from_parts(308_680_068, 25258) + // Standard Error: 1_377 + .saturating_add(Weight::from_parts(1_419_294, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2451).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -586,18 +583,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_value_transferred(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `792 + r * (480 ±0)` - // Estimated: `21830 + r * (2400 ±0)` - // Minimum execution time: 295_569_000 picoseconds. - Weight::from_parts(299_774_774, 21830) - // Standard Error: 46_252 - .saturating_add(Weight::from_parts(21_753_842, 0).saturating_mul(r.into())) + // Measured: `888 + r * (6 ±0)` + // Estimated: `22305 + r * (30 ±0)` + // Minimum execution time: 297_735_000 picoseconds. + Weight::from_parts(301_533_807, 22305) + // Standard Error: 1_119 + .saturating_add(Weight::from_parts(277_289, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -609,18 +606,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_minimum_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `790 + r * (480 ±0)` - // Estimated: `21760 + r * (2400 ±0)` - // Minimum execution time: 295_400_000 picoseconds. - Weight::from_parts(300_637_266, 21760) - // Standard Error: 41_263 - .saturating_add(Weight::from_parts(21_565_466, 0).saturating_mul(r.into())) + // Measured: `886 + r * (6 ±0)` + // Estimated: `22295 + r * (30 ±0)` + // Minimum execution time: 299_599_000 picoseconds. + Weight::from_parts(303_664_496, 22295) + // Standard Error: 1_009 + .saturating_add(Weight::from_parts(280_353, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -632,18 +629,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_block_number(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `787 + r * (480 ±0)` - // Estimated: `21785 + r * (2400 ±0)` - // Minimum execution time: 294_696_000 picoseconds. - Weight::from_parts(297_196_796, 21785) - // Standard Error: 61_173 - .saturating_add(Weight::from_parts(21_903_191, 0).saturating_mul(r.into())) + // Measured: `883 + r * (6 ±0)` + // Estimated: `22285 + r * (30 ±0)` + // Minimum execution time: 297_641_000 picoseconds. + Weight::from_parts(302_437_979, 22285) + // Standard Error: 669 + .saturating_add(Weight::from_parts(270_403, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -655,18 +652,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_now(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `778 + r * (480 ±0)` - // Estimated: `21715 + r * (2400 ±0)` - // Minimum execution time: 297_714_000 picoseconds. - Weight::from_parts(306_030_237, 21715) - // Standard Error: 69_984 - .saturating_add(Weight::from_parts(21_744_413, 0).saturating_mul(r.into())) + // Measured: `874 + r * (6 ±0)` + // Estimated: `22215 + r * (30 ±0)` + // Minimum execution time: 297_217_000 picoseconds. + Weight::from_parts(299_538_157, 22215) + // Standard Error: 732 + .saturating_add(Weight::from_parts(280_800, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -680,18 +677,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: TransactionPayment NextFeeMultiplier (max_values: Some(1), max_size: Some(16), added: 511, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_weight_to_fee(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `856 + r * (800 ±0)` - // Estimated: `24416 + r * (4805 ±0)` - // Minimum execution time: 295_180_000 picoseconds. - Weight::from_parts(308_851_025, 24416) - // Standard Error: 115_126 - .saturating_add(Weight::from_parts(98_678_404, 0).saturating_mul(r.into())) + // Measured: `952 + r * (10 ±0)` + // Estimated: `25022 + r * (60 ±0)` + // Minimum execution time: 297_286_000 picoseconds. + Weight::from_parts(311_436_352, 25022) + // Standard Error: 6_811 + .saturating_add(Weight::from_parts(1_291_941, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 4805).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -703,18 +700,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_gas(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `745 + r * (320 ±0)` - // Estimated: `21590 + r * (1600 ±0)` - // Minimum execution time: 151_587_000 picoseconds. - Weight::from_parts(155_713_096, 21590) - // Standard Error: 32_464 - .saturating_add(Weight::from_parts(8_332_778, 0).saturating_mul(r.into())) + // Measured: `841 + r * (4 ±0)` + // Estimated: `22035 + r * (20 ±0)` + // Minimum execution time: 154_772_000 picoseconds. + Weight::from_parts(159_224_457, 22035) + // Standard Error: 212 + .saturating_add(Weight::from_parts(102_264, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 1600).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 20).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -726,18 +723,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_input(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `780 + r * (480 ±0)` - // Estimated: `21715 + r * (2400 ±0)` - // Minimum execution time: 295_008_000 picoseconds. - Weight::from_parts(297_982_800, 21715) - // Standard Error: 37_480 - .saturating_add(Weight::from_parts(17_970_520, 0).saturating_mul(r.into())) + // Measured: `876 + r * (6 ±0)` + // Estimated: `22220 + r * (30 ±0)` + // Minimum execution time: 297_248_000 picoseconds. + Weight::from_parts(303_805_584, 22220) + // Standard Error: 858 + .saturating_add(Weight::from_parts(223_587, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -749,15 +746,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 1024]`. - fn seal_input_per_kb(n: u32, ) -> Weight { + /// The range of component `n` is `[0, 1048576]`. + fn seal_input_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1260` - // Estimated: `24120` - // Minimum execution time: 314_970_000 picoseconds. - Weight::from_parts(345_339_508, 24120) - // Standard Error: 4_112 - .saturating_add(Weight::from_parts(9_746_966, 0).saturating_mul(n.into())) + // Measured: `880` + // Estimated: `22220` + // Minimum execution time: 298_464_000 picoseconds. + Weight::from_parts(300_996_431, 22220) + // Standard Error: 1 + .saturating_add(Weight::from_parts(600, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -774,12 +771,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `768 + r * (45 ±0)` - // Estimated: `21660 + r * (225 ±0)` - // Minimum execution time: 293_072_000 picoseconds. - Weight::from_parts(295_694_824, 21660) - // Standard Error: 219_523 - .saturating_add(Weight::from_parts(783_975, 0).saturating_mul(r.into())) + // Measured: `864 + r * (45 ±0)` + // Estimated: `22140 + r * (225 ±0)` + // Minimum execution time: 294_347_000 picoseconds. + Weight::from_parts(296_793_034, 22140) + // Standard Error: 277_251 + .saturating_add(Weight::from_parts(1_711_665, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 225).saturating_mul(r.into())) @@ -794,15 +791,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 1024]`. - fn seal_return_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `778` - // Estimated: `21755` - // Minimum execution time: 295_959_000 picoseconds. - Weight::from_parts(299_004_761, 21755) - // Standard Error: 3_988 - .saturating_add(Weight::from_parts(194_268, 0).saturating_mul(n.into())) + /// The range of component `n` is `[0, 1048576]`. + fn seal_return_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `874` + // Estimated: `22255` + // Minimum execution time: 297_257_000 picoseconds. + Weight::from_parts(300_088_288, 22255) + // Standard Error: 1 + .saturating_add(Weight::from_parts(181, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -823,17 +820,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `810 + r * (356 ±0)` - // Estimated: `25511 + r * (15321 ±0)` - // Minimum execution time: 294_626_000 picoseconds. - Weight::from_parts(297_839_179, 25511) - // Standard Error: 707_428 - .saturating_add(Weight::from_parts(81_507_620, 0).saturating_mul(r.into())) + // Measured: `906 + r * (452 ±0)` + // Estimated: `26183 + r * (15994 ±0)` + // Minimum execution time: 296_510_000 picoseconds. + Weight::from_parts(299_169_757, 26183) + // Standard Error: 205_313 + .saturating_add(Weight::from_parts(78_059_642, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 15321).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 15994).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -847,18 +844,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_random(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `825 + r * (800 ±0)` - // Estimated: `24199 + r * (4805 ±0)` - // Minimum execution time: 295_431_000 picoseconds. - Weight::from_parts(310_428_531, 24199) - // Standard Error: 143_501 - .saturating_add(Weight::from_parts(136_529_376, 0).saturating_mul(r.into())) + // Measured: `921 + r * (10 ±0)` + // Estimated: `24859 + r * (60 ±0)` + // Minimum execution time: 299_299_000 picoseconds. + Weight::from_parts(314_487_015, 24859) + // Standard Error: 1_552 + .saturating_add(Weight::from_parts(1_753_960, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 4805).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -870,18 +867,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_deposit_event(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `778 + r * (800 ±0)` - // Estimated: `21720 + r * (4000 ±0)` - // Minimum execution time: 293_778_000 picoseconds. - Weight::from_parts(323_404_081, 21720) - // Standard Error: 243_095 - .saturating_add(Weight::from_parts(269_012_482, 0).saturating_mul(r.into())) + // Measured: `874 + r * (10 ±0)` + // Estimated: `22215 + r * (50 ±0)` + // Minimum execution time: 296_188_000 picoseconds. + Weight::from_parts(305_901_539, 22215) + // Standard Error: 2_782 + .saturating_add(Weight::from_parts(3_456_054, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 4000).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 50).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -891,26 +888,25 @@ impl WeightInfo for SubstrateWeight { /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:322 w:322) + /// Storage: System EventTopics (r:6 w:6) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[0, 4]`. - /// The range of component `n` is `[0, 16]`. - fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1725 + t * (2608 ±0) + n * (7 ±0)` - // Estimated: `26340 + t * (211030 ±0) + n * (50 ±0)` - // Minimum execution time: 1_317_129_000 picoseconds. - Weight::from_parts(566_722_295, 26340) - // Standard Error: 619_390 - .saturating_add(Weight::from_parts(194_334_643, 0).saturating_mul(t.into())) - // Standard Error: 170_114 - .saturating_add(Weight::from_parts(67_458_751, 0).saturating_mul(n.into())) + /// The range of component `n` is `[0, 16384]`. + fn seal_deposit_event_per_topic_and_byte(t: u32, n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `893 + t * (32 ±0)` + // Estimated: `22320 + t * (2640 ±0)` + // Minimum execution time: 313_860_000 picoseconds. + Weight::from_parts(312_473_092, 22320) + // Standard Error: 250_852 + .saturating_add(Weight::from_parts(2_258_502, 0).saturating_mul(t.into())) + // Standard Error: 70 + .saturating_add(Weight::from_parts(312, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(t.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 211030).saturating_mul(t.into())) - .saturating_add(Weight::from_parts(0, 50).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) + .saturating_add(Weight::from_parts(0, 2640).saturating_mul(t.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -922,18 +918,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_debug_message(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `777 + r * (560 ±0)` - // Estimated: `21710 + r * (2800 ±0)` - // Minimum execution time: 159_087_000 picoseconds. - Weight::from_parts(163_703_981, 21710) - // Standard Error: 26_067 - .saturating_add(Weight::from_parts(14_810_256, 0).saturating_mul(r.into())) + // Measured: `873 + r * (7 ±0)` + // Estimated: `22205 + r * (35 ±0)` + // Minimum execution time: 162_043_000 picoseconds. + Weight::from_parts(166_132_332, 22205) + // Standard Error: 716 + .saturating_add(Weight::from_parts(184_981, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2800).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 35).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) @@ -945,200 +941,187 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `i` is `[0, 1024]`. - fn seal_debug_message_per_kb(i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `125728` - // Estimated: `269982` - // Minimum execution time: 413_391_000 picoseconds. - Weight::from_parts(414_927_640, 269982) - // Standard Error: 1_740 - .saturating_add(Weight::from_parts(763_359, 0).saturating_mul(i.into())) + /// The range of component `i` is `[0, 1048576]`. + fn seal_debug_message_per_byte(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `125824` + // Estimated: `270073` + // Minimum execution time: 414_433_000 picoseconds. + Weight::from_parts(417_483_627, 270073) + // Standard Error: 1 + .saturating_add(Weight::from_parts(748, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 10]`. + /// The range of component `r` is `[0, 800]`. fn seal_set_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `815 + r * (23420 ±0)` - // Estimated: `815 + r * (23418 ±0)` - // Minimum execution time: 296_108_000 picoseconds. - Weight::from_parts(208_214_040, 815) - // Standard Error: 860_573 - .saturating_add(Weight::from_parts(480_342_550, 0).saturating_mul(r.into())) + // Measured: `941 + r * (292 ±0)` + // Estimated: `939 + r * (293 ±0)` + // Minimum execution time: 299_500_000 picoseconds. + Weight::from_parts(194_466_413, 939) + // Standard Error: 9_986 + .saturating_add(Weight::from_parts(6_010_112, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 23418).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 293).saturating_mul(r.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 8]`. - fn seal_set_storage_per_new_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `12544 + n * (11945 ±0)` - // Estimated: `8401 + n * (12814 ±61)` - // Minimum execution time: 442_286_000 picoseconds. - Weight::from_parts(620_395_299, 8401) - // Standard Error: 1_661_554 - .saturating_add(Weight::from_parts(89_393_169, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(52_u64)) - .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(50_u64)) - .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 12814).saturating_mul(n.into())) + /// The range of component `n` is `[0, 16384]`. + fn seal_set_storage_per_new_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1432` + // Estimated: `1405` + // Minimum execution time: 314_171_000 picoseconds. + Weight::from_parts(335_595_397, 1405) + // Standard Error: 67 + .saturating_add(Weight::from_parts(90, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 8]`. - fn seal_set_storage_per_old_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `12532 + n * (175784 ±0)` - // Estimated: `8396 + n * (176649 ±61)` - // Minimum execution time: 440_882_000 picoseconds. - Weight::from_parts(587_317_981, 8396) - // Standard Error: 1_374_991 - .saturating_add(Weight::from_parts(66_271_084, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(51_u64)) - .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(49_u64)) - .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 176649).saturating_mul(n.into())) + /// The range of component `n` is `[0, 16384]`. + fn seal_set_storage_per_old_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1295 + n * (1 ±0)` + // Estimated: `1292 + n * (1 ±0)` + // Minimum execution time: 313_479_000 picoseconds. + Weight::from_parts(317_435_100, 1292) + // Standard Error: 41 + .saturating_add(Weight::from_parts(106, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 10]`. + /// The range of component `r` is `[0, 800]`. fn seal_clear_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `807 + r * (23099 ±0)` - // Estimated: `812 + r * (23099 ±0)` - // Minimum execution time: 296_023_000 picoseconds. - Weight::from_parts(221_471_559, 812) - // Standard Error: 814_503 - .saturating_add(Weight::from_parts(465_928_089, 0).saturating_mul(r.into())) + // Measured: `937 + r * (288 ±0)` + // Estimated: `941 + r * (289 ±0)` + // Minimum execution time: 297_831_000 picoseconds. + Weight::from_parts(196_983_778, 941) + // Standard Error: 9_899 + .saturating_add(Weight::from_parts(5_904_642, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 23099).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 289).saturating_mul(r.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 8]`. - fn seal_clear_storage_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `12256 + n * (175776 ±0)` - // Estimated: `8047 + n * (176655 ±62)` - // Minimum execution time: 412_212_000 picoseconds. - Weight::from_parts(569_213_147, 8047) - // Standard Error: 1_463_771 - .saturating_add(Weight::from_parts(67_932_081, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(51_u64)) - .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(48_u64)) - .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 176655).saturating_mul(n.into())) + /// The range of component `n` is `[0, 16384]`. + fn seal_clear_storage_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1291 + n * (1 ±0)` + // Estimated: `1288 + n * (1 ±0)` + // Minimum execution time: 320_156_000 picoseconds. + Weight::from_parts(327_504_368, 1288) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 10]`. + /// The range of component `r` is `[0, 800]`. fn seal_get_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `800 + r * (23744 ±0)` - // Estimated: `813 + r * (23740 ±0)` - // Minimum execution time: 296_007_000 picoseconds. - Weight::from_parts(229_100_700, 813) - // Standard Error: 684_970 - .saturating_add(Weight::from_parts(394_982_991, 0).saturating_mul(r.into())) + // Measured: `931 + r * (296 ±0)` + // Estimated: `936 + r * (297 ±0)` + // Minimum execution time: 305_849_000 picoseconds. + Weight::from_parts(219_649_351, 936) + // Standard Error: 9_157 + .saturating_add(Weight::from_parts(4_846_108, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 23740).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 297).saturating_mul(r.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 8]`. - fn seal_get_storage_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `12863 + n * (175784 ±0)` - // Estimated: `8538 + n * (176688 ±63)` - // Minimum execution time: 392_306_000 picoseconds. - Weight::from_parts(539_188_004, 8538) - // Standard Error: 1_371_839 - .saturating_add(Weight::from_parts(155_130_373, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(51_u64)) - .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) + /// The range of component `n` is `[0, 16384]`. + fn seal_get_storage_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1307 + n * (1 ±0)` + // Estimated: `1304 + n * (1 ±0)` + // Minimum execution time: 312_106_000 picoseconds. + Weight::from_parts(315_905_779, 1304) + // Standard Error: 44 + .saturating_add(Weight::from_parts(674, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 176688).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 10]`. + /// The range of component `r` is `[0, 800]`. fn seal_contains_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `818 + r * (23098 ±0)` - // Estimated: `824 + r * (23098 ±0)` - // Minimum execution time: 296_038_000 picoseconds. - Weight::from_parts(229_462_798, 824) - // Standard Error: 655_463 - .saturating_add(Weight::from_parts(372_593_685, 0).saturating_mul(r.into())) + // Measured: `952 + r * (288 ±0)` + // Estimated: `953 + r * (289 ±0)` + // Minimum execution time: 299_372_000 picoseconds. + Weight::from_parts(211_293_493, 953) + // Standard Error: 8_509 + .saturating_add(Weight::from_parts(4_688_993, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 23098).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 289).saturating_mul(r.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 8]`. - fn seal_contains_storage_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `12200 + n * (175798 ±0)` - // Estimated: `8028 + n * (176661 ±62)` - // Minimum execution time: 386_782_000 picoseconds. - Weight::from_parts(512_965_975, 8028) - // Standard Error: 1_168_132 - .saturating_add(Weight::from_parts(63_307_325, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(51_u64)) - .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) + /// The range of component `n` is `[0, 16384]`. + fn seal_contains_storage_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1294 + n * (1 ±0)` + // Estimated: `1291 + n * (1 ±0)` + // Minimum execution time: 311_605_000 picoseconds. + Weight::from_parts(315_473_850, 1291) + // Standard Error: 37 + .saturating_add(Weight::from_parts(3, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 176661).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 10]`. + /// The range of component `r` is `[0, 800]`. fn seal_take_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `815 + r * (23740 ±0)` - // Estimated: `817 + r * (23739 ±0)` - // Minimum execution time: 296_352_000 picoseconds. - Weight::from_parts(212_661_296, 817) - // Standard Error: 879_297 - .saturating_add(Weight::from_parts(494_182_672, 0).saturating_mul(r.into())) + // Measured: `925 + r * (296 ±0)` + // Estimated: `932 + r * (297 ±0)` + // Minimum execution time: 298_231_000 picoseconds. + Weight::from_parts(200_178_698, 932) + // Standard Error: 10_452 + .saturating_add(Weight::from_parts(6_107_653, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 23739).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 297).saturating_mul(r.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 8]`. - fn seal_take_storage_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `12864 + n * (175784 ±0)` - // Estimated: `8539 + n * (176686 ±63)` - // Minimum execution time: 414_693_000 picoseconds. - Weight::from_parts(595_693_859, 8539) - // Standard Error: 1_673_819 - .saturating_add(Weight::from_parts(163_090_316, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(51_u64)) - .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(48_u64)) - .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 176686).saturating_mul(n.into())) + /// The range of component `n` is `[0, 16384]`. + fn seal_take_storage_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1308 + n * (1 ±0)` + // Estimated: `1305 + n * (1 ±0)` + // Minimum execution time: 314_970_000 picoseconds. + Weight::from_parts(318_135_821, 1305) + // Standard Error: 26 + .saturating_add(Weight::from_parts(630, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: System Account (r:1602 w:1601) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1150,20 +1133,20 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_transfer(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1329 + r * (3604 ±0)` - // Estimated: `25928 + r * (216096 ±4)` - // Minimum execution time: 299_205_000 picoseconds. - Weight::from_parts(221_142_217, 25928) - // Standard Error: 1_369_909 - .saturating_add(Weight::from_parts(1_665_917_241, 0).saturating_mul(r.into())) + // Measured: `1501 + r * (45 ±0)` + // Estimated: `27383 + r * (2700 ±0)` + // Minimum execution time: 299_629_000 picoseconds. + Weight::from_parts(150_915_187, 27383) + // Standard Error: 25_604 + .saturating_add(Weight::from_parts(20_859_844, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) - .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 216096).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 2700).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1175,20 +1158,20 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:1602 w:1602) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1479 + r * (20514 ±0)` - // Estimated: `26429 + r * (498656 ±1)` - // Minimum execution time: 297_501_000 picoseconds. - Weight::from_parts(298_400_000, 26429) - // Standard Error: 9_372_890 - .saturating_add(Weight::from_parts(22_507_984_433, 0).saturating_mul(r.into())) + // Measured: `1670 + r * (288 ±0)` + // Estimated: `27813 + r * (6391 ±0)` + // Minimum execution time: 299_578_000 picoseconds. + Weight::from_parts(300_036_000, 27813) + // Standard Error: 102_709 + .saturating_add(Weight::from_parts(283_767_316, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().reads((160_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(T::DbWeight::get().writes((160_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 498656).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 6391).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1200,48 +1183,48 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:1537 w:1537) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (69030 ±0)` - // Estimated: `21755 + r * (647542 ±560)` - // Minimum execution time: 297_432_000 picoseconds. - Weight::from_parts(298_220_000, 21755) - // Standard Error: 9_420_834 - .saturating_add(Weight::from_parts(22_261_152_353, 0).saturating_mul(r.into())) + // Measured: `0 + r * (935 ±0)` + // Estimated: `22235 + r * (8322 ±10)` + // Minimum execution time: 298_943_000 picoseconds. + Weight::from_parts(299_619_000, 22235) + // Standard Error: 117_493 + .saturating_add(Weight::from_parts(280_555_517, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().reads((150_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(T::DbWeight::get().writes((75_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 647542).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 8322).saturating_mul(r.into())) } - /// Storage: System Account (r:82 w:81) + /// Storage: System Account (r:3 w:2) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:81 w:81) + /// Storage: Contracts ContractInfoOf (r:2 w:2) /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) /// Storage: Contracts CodeStorage (r:2 w:0) /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:82 w:82) + /// Storage: System EventTopics (r:3 w:3) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[0, 1]`. - /// The range of component `c` is `[0, 1024]`. - fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `21581 + t * (14318 ±0)` - // Estimated: `524200 + t * (272065 ±0)` - // Minimum execution time: 11_799_802_000 picoseconds. - Weight::from_parts(10_575_328_547, 524200) - // Standard Error: 11_952_810 - .saturating_add(Weight::from_parts(1_603_077_083, 0).saturating_mul(t.into())) - // Standard Error: 17_922 - .saturating_add(Weight::from_parts(9_876_752, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(167_u64)) - .saturating_add(T::DbWeight::get().reads((81_u64).saturating_mul(t.into()))) - .saturating_add(T::DbWeight::get().writes(163_u64)) - .saturating_add(T::DbWeight::get().writes((81_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 272065).saturating_mul(t.into())) + /// The range of component `c` is `[0, 1048576]`. + fn seal_call_per_transfer_clone_byte(t: u32, c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1314 + t * (268 ±0)` + // Estimated: `31815 + t * (6290 ±0)` + // Minimum execution time: 453_013_000 picoseconds. + Weight::from_parts(442_536_283, 31815) + // Standard Error: 1_339_541 + .saturating_add(Weight::from_parts(17_062_445, 0).saturating_mul(t.into())) + // Standard Error: 1 + .saturating_add(Weight::from_parts(604, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(t.into()))) + .saturating_add(T::DbWeight::get().writes(5_u64)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(t.into()))) + .saturating_add(Weight::from_parts(0, 6290).saturating_mul(t.into())) } /// Storage: System Account (r:3202 w:3202) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1257,24 +1240,24 @@ impl WeightInfo for SubstrateWeight { /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) /// Storage: System EventTopics (r:1602 w:1602) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_instantiate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1646 + r * (20288 ±0)` - // Estimated: `32625 + r * (1330150 ±2)` - // Minimum execution time: 298_155_000 picoseconds. - Weight::from_parts(299_212_000, 32625) - // Standard Error: 32_410_313 - .saturating_add(Weight::from_parts(30_417_025_178, 0).saturating_mul(r.into())) + // Measured: `1988 + r * (319 ±0)` + // Estimated: `34745 + r * (17090 ±0)` + // Minimum execution time: 300_123_000 picoseconds. + Weight::from_parts(300_406_000, 34745) + // Standard Error: 420_997 + .saturating_add(Weight::from_parts(382_704_025, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().reads((480_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(5_u64)) - .saturating_add(T::DbWeight::get().writes((400_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 1330150).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(6_u64)) + .saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 17090).saturating_mul(r.into())) } - /// Storage: System Account (r:162 w:162) + /// Storage: System Account (r:4 w:4) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:81 w:81) + /// Storage: Contracts ContractInfoOf (r:2 w:2) /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) /// Storage: Contracts CodeStorage (r:2 w:0) /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) @@ -1284,28 +1267,28 @@ impl WeightInfo for SubstrateWeight { /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: Contracts OwnerInfoOf (r:1 w:1) /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) - /// Storage: System EventTopics (r:82 w:82) + /// Storage: System EventTopics (r:3 w:3) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[0, 1]`. - /// The range of component `i` is `[0, 960]`. - /// The range of component `s` is `[0, 960]`. - fn seal_instantiate_per_transfer_input_salt_kb(t: u32, i: u32, s: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `5625 + t * (1 ±0)` - // Estimated: `856795 + t * (2471 ±3)` - // Minimum execution time: 105_914_928_000 picoseconds. - Weight::from_parts(13_229_760_432, 856795) - // Standard Error: 96_394_437 - .saturating_add(Weight::from_parts(398_413_888, 0).saturating_mul(t.into())) - // Standard Error: 157_192 - .saturating_add(Weight::from_parts(97_104_978, 0).saturating_mul(i.into())) - // Standard Error: 157_192 - .saturating_add(Weight::from_parts(97_146_130, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(329_u64)) + /// The range of component `i` is `[0, 983040]`. + /// The range of component `s` is `[0, 983040]`. + fn seal_instantiate_per_transfer_input_salt_byte(t: u32, i: u32, s: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1231 + t * (219 ±0)` + // Estimated: `43797 + t * (3812 ±2)` + // Minimum execution time: 1_636_322_000 picoseconds. + Weight::from_parts(360_859_331, 43797) + // Standard Error: 4_816_923 + .saturating_add(Weight::from_parts(109_179_023, 0).saturating_mul(t.into())) + // Standard Error: 7 + .saturating_add(Weight::from_parts(1_180, 0).saturating_mul(i.into())) + // Standard Error: 7 + .saturating_add(Weight::from_parts(1_344, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) - .saturating_add(T::DbWeight::get().writes(326_u64)) + .saturating_add(T::DbWeight::get().writes(10_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 2471).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 3812).saturating_mul(t.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1317,18 +1300,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 1600]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `775 + r * (642 ±0)` - // Estimated: `21695 + r * (3210 ±0)` - // Minimum execution time: 294_309_000 picoseconds. - Weight::from_parts(296_241_318, 21695) - // Standard Error: 127_872 - .saturating_add(Weight::from_parts(45_806_281, 0).saturating_mul(r.into())) + // Measured: `873 + r * (8 ±0)` + // Estimated: `22190 + r * (40 ±0)` + // Minimum execution time: 297_521_000 picoseconds. + Weight::from_parts(303_523_260, 22190) + // Standard Error: 1_162 + .saturating_add(Weight::from_parts(542_201, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 3210).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1340,15 +1323,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 1024]`. - fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1577` - // Estimated: `25630` - // Minimum execution time: 341_248_000 picoseconds. - Weight::from_parts(341_607_000, 25630) - // Standard Error: 66_687 - .saturating_add(Weight::from_parts(322_250_398, 0).saturating_mul(n.into())) + /// The range of component `n` is `[0, 1048576]`. + fn seal_hash_sha2_256_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `881` + // Estimated: `22225` + // Minimum execution time: 299_877_000 picoseconds. + Weight::from_parts(293_538_014, 22225) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_967, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1362,18 +1345,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 1600]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `777 + r * (642 ±0)` - // Estimated: `21705 + r * (3210 ±0)` - // Minimum execution time: 293_810_000 picoseconds. - Weight::from_parts(296_719_171, 21705) - // Standard Error: 450_807 - .saturating_add(Weight::from_parts(61_627_228, 0).saturating_mul(r.into())) + // Measured: `875 + r * (8 ±0)` + // Estimated: `22205 + r * (40 ±0)` + // Minimum execution time: 297_672_000 picoseconds. + Weight::from_parts(299_933_312, 22205) + // Standard Error: 1_138 + .saturating_add(Weight::from_parts(713_189, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 3210).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1385,15 +1368,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 1024]`. - fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1579` - // Estimated: `25675` - // Minimum execution time: 354_550_000 picoseconds. - Weight::from_parts(355_136_000, 25675) - // Standard Error: 61_761 - .saturating_add(Weight::from_parts(257_021_566, 0).saturating_mul(n.into())) + /// The range of component `n` is `[0, 1048576]`. + fn seal_hash_keccak_256_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `883` + // Estimated: `22245` + // Minimum execution time: 299_048_000 picoseconds. + Weight::from_parts(293_055_982, 22245) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_179, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1407,18 +1390,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `777 + r * (642 ±0)` - // Estimated: `21705 + r * (3210 ±0)` - // Minimum execution time: 293_369_000 picoseconds. - Weight::from_parts(295_990_893, 21705) - // Standard Error: 431_269 - .saturating_add(Weight::from_parts(32_213_406, 0).saturating_mul(r.into())) + // Measured: `875 + r * (8 ±0)` + // Estimated: `22220 + r * (40 ±0)` + // Minimum execution time: 301_991_000 picoseconds. + Weight::from_parts(300_027_441, 22220) + // Standard Error: 981 + .saturating_add(Weight::from_parts(391_319, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 3210).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1430,15 +1413,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 1024]`. - fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1579` - // Estimated: `25650` - // Minimum execution time: 326_595_000 picoseconds. - Weight::from_parts(327_188_000, 25650) - // Standard Error: 53_385 - .saturating_add(Weight::from_parts(74_046_074, 0).saturating_mul(n.into())) + /// The range of component `n` is `[0, 1048576]`. + fn seal_hash_blake2_256_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `883` + // Estimated: `22265` + // Minimum execution time: 296_522_000 picoseconds. + Weight::from_parts(296_121_638, 22265) + // Standard Error: 2 + .saturating_add(Weight::from_parts(916, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1452,18 +1435,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `777 + r * (679 ±0)` - // Estimated: `21705 + r * (3395 ±0)` - // Minimum execution time: 292_388_000 picoseconds. - Weight::from_parts(295_090_179, 21705) - // Standard Error: 170_487 - .saturating_add(Weight::from_parts(32_577_820, 0).saturating_mul(r.into())) + // Measured: `875 + r * (8 ±0)` + // Estimated: `22225 + r * (40 ±0)` + // Minimum execution time: 296_228_000 picoseconds. + Weight::from_parts(301_472_299, 22225) + // Standard Error: 875 + .saturating_add(Weight::from_parts(381_027, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 3395).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1475,15 +1458,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 1024]`. - fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1579` - // Estimated: `25695` - // Minimum execution time: 326_862_000 picoseconds. - Weight::from_parts(327_449_000, 25695) - // Standard Error: 54_539 - .saturating_add(Weight::from_parts(74_042_337, 0).saturating_mul(n.into())) + /// The range of component `n` is `[0, 1048576]`. + fn seal_hash_blake2_128_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `883` + // Estimated: `22235` + // Minimum execution time: 296_644_000 picoseconds. + Weight::from_parts(289_879_744, 22235) + // Standard Error: 2 + .saturating_add(Weight::from_parts(925, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1497,18 +1480,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 1600]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `821 + r * (6083 ±0)` - // Estimated: `21925 + r * (30415 ±0)` - // Minimum execution time: 295_597_000 picoseconds. - Weight::from_parts(298_267_200, 21925) - // Standard Error: 699_824 - .saturating_add(Weight::from_parts(3_021_734_700, 0).saturating_mul(r.into())) + // Measured: `800 + r * (78 ±0)` + // Estimated: `21845 + r * (390 ±0)` + // Minimum execution time: 297_804_000 picoseconds. + Weight::from_parts(471_994_534, 21845) + // Standard Error: 9_479 + .saturating_add(Weight::from_parts(36_886_028, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 30415).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 390).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1520,18 +1503,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 1600]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `790 + r * (3362 ±0)` - // Estimated: `21770 + r * (16810 ±0)` - // Minimum execution time: 295_539_000 picoseconds. - Weight::from_parts(297_844_822, 21770) - // Standard Error: 490_532 - .saturating_add(Weight::from_parts(747_592_977, 0).saturating_mul(r.into())) + // Measured: `645 + r * (44 ±0)` + // Estimated: `21110 + r * (220 ±0)` + // Minimum execution time: 298_623_000 picoseconds. + Weight::from_parts(322_192_102, 21110) + // Standard Error: 3_207 + .saturating_add(Weight::from_parts(9_243_653, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 16810).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 220).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1545,20 +1528,20 @@ impl WeightInfo for SubstrateWeight { /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) /// Storage: System EventTopics (r:1538 w:1538) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (74020 ±0)` - // Estimated: `69192 + r * (913289 ±821)` - // Minimum execution time: 295_164_000 picoseconds. - Weight::from_parts(296_597_000, 69192) - // Standard Error: 3_646_577 - .saturating_add(Weight::from_parts(1_725_796_807, 0).saturating_mul(r.into())) + // Measured: `0 + r * (1030 ±0)` + // Estimated: `30592 + r * (11919 ±7)` + // Minimum execution time: 298_574_000 picoseconds. + Weight::from_parts(299_383_000, 30592) + // Standard Error: 44_061 + .saturating_add(Weight::from_parts(21_625_366, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().reads((225_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(T::DbWeight::get().writes((150_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 913289).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 11919).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1570,18 +1553,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `773 + r * (240 ±0)` - // Estimated: `21685 + r * (1200 ±0)` - // Minimum execution time: 296_287_000 picoseconds. - Weight::from_parts(300_696_694, 21685) - // Standard Error: 27_891 - .saturating_add(Weight::from_parts(10_943_994, 0).saturating_mul(r.into())) + // Measured: `869 + r * (3 ±0)` + // Estimated: `22215 + r * (15 ±0)` + // Minimum execution time: 297_014_000 picoseconds. + Weight::from_parts(301_226_615, 22215) + // Standard Error: 439 + .saturating_add(Weight::from_parts(143_017, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 1200).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1593,18 +1576,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2006 + r * (3154 ±0)` - // Estimated: `26435 + r * (15875 ±2)` - // Minimum execution time: 298_000_000 picoseconds. - Weight::from_parts(328_282_119, 26435) - // Standard Error: 104_874 - .saturating_add(Weight::from_parts(18_428_267, 0).saturating_mul(r.into())) + // Measured: `2072 + r * (39 ±0)` + // Estimated: `27645 + r * (200 ±0)` + // Minimum execution time: 299_074_000 picoseconds. + Weight::from_parts(336_979_016, 27645) + // Standard Error: 1_163 + .saturating_add(Weight::from_parts(227_998, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 15875).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 200).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1618,538 +1601,526 @@ impl WeightInfo for SubstrateWeight { /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `776 + r * (240 ±0)` - // Estimated: `23962 + r * (1440 ±0)` - // Minimum execution time: 295_104_000 picoseconds. - Weight::from_parts(299_334_585, 23962) - // Standard Error: 25_840 - .saturating_add(Weight::from_parts(9_744_866, 0).saturating_mul(r.into())) + // Measured: `872 + r * (3 ±0)` + // Estimated: `24580 + r * (18 ±0)` + // Minimum execution time: 296_959_000 picoseconds. + Weight::from_parts(303_796_839, 24580) + // Standard Error: 534 + .saturating_add(Weight::from_parts(118_978, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) - .saturating_add(Weight::from_parts(0, 1440).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 18).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64const(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_132_000 picoseconds. - Weight::from_parts(1_100_159, 0) - // Standard Error: 10_131 - .saturating_add(Weight::from_parts(436_462, 0).saturating_mul(r.into())) + // Minimum execution time: 1_020_000 picoseconds. + Weight::from_parts(1_355_107, 0) + // Standard Error: 1 + .saturating_add(Weight::from_parts(4_110, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64load(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_368_000 picoseconds. - Weight::from_parts(1_974_308, 0) - // Standard Error: 811 - .saturating_add(Weight::from_parts(1_079_620, 0).saturating_mul(r.into())) + // Minimum execution time: 1_224_000 picoseconds. + Weight::from_parts(1_819_284, 0) + // Standard Error: 10 + .saturating_add(Weight::from_parts(10_803, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64store(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_354_000 picoseconds. - Weight::from_parts(2_057_834, 0) - // Standard Error: 4_277 - .saturating_add(Weight::from_parts(1_008_797, 0).saturating_mul(r.into())) + // Minimum execution time: 1_216_000 picoseconds. + Weight::from_parts(1_795_011, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(10_000, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_select(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_218_000 picoseconds. - Weight::from_parts(1_594_528, 0) - // Standard Error: 723 - .saturating_add(Weight::from_parts(1_147_486, 0).saturating_mul(r.into())) + // Minimum execution time: 1_127_000 picoseconds. + Weight::from_parts(1_491_730, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(11_471, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_156_000 picoseconds. - Weight::from_parts(1_460_611, 0) - // Standard Error: 419 - .saturating_add(Weight::from_parts(1_314_741, 0).saturating_mul(r.into())) + // Minimum execution time: 1_044_000 picoseconds. + Weight::from_parts(2_330_852, 0) + // Standard Error: 69 + .saturating_add(Weight::from_parts(12_866, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_br(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_166_000 picoseconds. - Weight::from_parts(1_454_460, 0) - // Standard Error: 493 - .saturating_add(Weight::from_parts(642_481, 0).saturating_mul(r.into())) + // Minimum execution time: 1_067_000 picoseconds. + Weight::from_parts(1_399_626, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(6_430, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_br_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_144_000 picoseconds. - Weight::from_parts(1_410_515, 0) - // Standard Error: 894 - .saturating_add(Weight::from_parts(958_765, 0).saturating_mul(r.into())) + // Minimum execution time: 1_087_000 picoseconds. + Weight::from_parts(1_463_592, 0) + // Standard Error: 12 + .saturating_add(Weight::from_parts(9_707, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_br_table(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_190_000 picoseconds. - Weight::from_parts(1_143_236, 0) - // Standard Error: 2_773 - .saturating_add(Weight::from_parts(1_164_764, 0).saturating_mul(r.into())) + // Minimum execution time: 1_110_000 picoseconds. + Weight::from_parts(1_058_258, 0) + // Standard Error: 22 + .saturating_add(Weight::from_parts(11_713, 0).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. - fn instr_br_table_per_entry(e: u32, ) -> Weight { + fn instr_br_table_per_entry(_e: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_993_000 picoseconds. - Weight::from_parts(3_270_525, 0) - // Standard Error: 65 - .saturating_add(Weight::from_parts(4_418, 0).saturating_mul(e.into())) + // Minimum execution time: 1_189_000 picoseconds. + Weight::from_parts(1_416_188, 0) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_163_000 picoseconds. - Weight::from_parts(1_999_458, 0) - // Standard Error: 1_418 - .saturating_add(Weight::from_parts(2_371_979, 0).saturating_mul(r.into())) + // Minimum execution time: 2_201_000 picoseconds. + Weight::from_parts(3_375_851, 0) + // Standard Error: 96 + .saturating_add(Weight::from_parts(22_970, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_call_indirect(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_288_000 picoseconds. - Weight::from_parts(2_340_227, 0) - // Standard Error: 3_234 - .saturating_add(Weight::from_parts(3_038_523, 0).saturating_mul(r.into())) - } - /// The range of component `p` is `[0, 128]`. - fn instr_call_indirect_per_param(p: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 5_270_000 picoseconds. - Weight::from_parts(6_360_011, 0) - // Standard Error: 2_585 - .saturating_add(Weight::from_parts(226_149, 0).saturating_mul(p.into())) + // Minimum execution time: 1_286_000 picoseconds. + Weight::from_parts(2_817_725, 0) + // Standard Error: 55 + .saturating_add(Weight::from_parts(29_437, 0).saturating_mul(r.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_580_000 picoseconds. - Weight::from_parts(5_183_658, 0) - // Standard Error: 80 - .saturating_add(Weight::from_parts(46_038, 0).saturating_mul(l.into())) + // Minimum execution time: 1_319_000 picoseconds. + Weight::from_parts(1_636_286, 0) + // Standard Error: 31 + .saturating_add(Weight::from_parts(1_240, 0).saturating_mul(l.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_local_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_559_000 picoseconds. - Weight::from_parts(2_846_350, 0) - // Standard Error: 2_809 - .saturating_add(Weight::from_parts(462_084, 0).saturating_mul(r.into())) + // Minimum execution time: 2_507_000 picoseconds. + Weight::from_parts(2_785_119, 0) + // Standard Error: 1 + .saturating_add(Weight::from_parts(4_601, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_local_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_530_000 picoseconds. - Weight::from_parts(2_835_072, 0) - // Standard Error: 479 - .saturating_add(Weight::from_parts(483_451, 0).saturating_mul(r.into())) + // Minimum execution time: 2_494_000 picoseconds. + Weight::from_parts(2_948_015, 0) + // Standard Error: 14 + .saturating_add(Weight::from_parts(4_788, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_local_tee(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_510_000 picoseconds. - Weight::from_parts(2_740_081, 0) - // Standard Error: 901 - .saturating_add(Weight::from_parts(664_354, 0).saturating_mul(r.into())) + // Minimum execution time: 2_443_000 picoseconds. + Weight::from_parts(3_065_273, 0) + // Standard Error: 15 + .saturating_add(Weight::from_parts(6_489, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_global_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_295_000 picoseconds. - Weight::from_parts(1_798_174, 0) - // Standard Error: 464 - .saturating_add(Weight::from_parts(896_289, 0).saturating_mul(r.into())) + // Minimum execution time: 1_214_000 picoseconds. + Weight::from_parts(1_634_049, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(8_960, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_global_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_287_000 picoseconds. - Weight::from_parts(1_636_548, 0) - // Standard Error: 658 - .saturating_add(Weight::from_parts(923_295, 0).saturating_mul(r.into())) + // Minimum execution time: 1_180_000 picoseconds. + Weight::from_parts(1_555_599, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_205, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_memory_current(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_353_000 picoseconds. - Weight::from_parts(1_672_309, 0) - // Standard Error: 403 - .saturating_add(Weight::from_parts(818_273, 0).saturating_mul(r.into())) + // Minimum execution time: 1_223_000 picoseconds. + Weight::from_parts(1_626_002, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(8_181, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 16]`. fn instr_memory_grow(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_180_000 picoseconds. - Weight::from_parts(1_304_714, 0) - // Standard Error: 88_180 - .saturating_add(Weight::from_parts(183_952_985, 0).saturating_mul(r.into())) + // Minimum execution time: 1_148_000 picoseconds. + Weight::from_parts(307_155, 0) + // Standard Error: 138_541 + .saturating_add(Weight::from_parts(13_291_570, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64clz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_158_000 picoseconds. - Weight::from_parts(1_800_065, 0) - // Standard Error: 2_104 - .saturating_add(Weight::from_parts(625_410, 0).saturating_mul(r.into())) + // Minimum execution time: 1_079_000 picoseconds. + Weight::from_parts(1_372_409, 0) + // Standard Error: 50 + .saturating_add(Weight::from_parts(6_427, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64ctz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_208_000 picoseconds. - Weight::from_parts(1_483_908, 0) - // Standard Error: 319 - .saturating_add(Weight::from_parts(635_095, 0).saturating_mul(r.into())) + // Minimum execution time: 1_116_000 picoseconds. + Weight::from_parts(1_415_180, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_353, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64popcnt(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_164_000 picoseconds. - Weight::from_parts(1_506_871, 0) - // Standard Error: 264 - .saturating_add(Weight::from_parts(633_660, 0).saturating_mul(r.into())) + // Minimum execution time: 1_058_000 picoseconds. + Weight::from_parts(1_314_206, 0) + // Standard Error: 35 + .saturating_add(Weight::from_parts(6_431, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64eqz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_141_000 picoseconds. - Weight::from_parts(1_467_219, 0) - // Standard Error: 191 - .saturating_add(Weight::from_parts(651_156, 0).saturating_mul(r.into())) + // Minimum execution time: 1_059_000 picoseconds. + Weight::from_parts(1_455_331, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_507, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64extendsi32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_170_000 picoseconds. - Weight::from_parts(1_474_718, 0) - // Standard Error: 224 - .saturating_add(Weight::from_parts(617_317, 0).saturating_mul(r.into())) + // Minimum execution time: 1_057_000 picoseconds. + Weight::from_parts(1_421_085, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_177, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64extendui32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_195_000 picoseconds. - Weight::from_parts(1_501_421, 0) - // Standard Error: 221 - .saturating_add(Weight::from_parts(616_559, 0).saturating_mul(r.into())) + // Minimum execution time: 1_079_000 picoseconds. + Weight::from_parts(1_429_275, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_175, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i32wrapi64(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_172_000 picoseconds. - Weight::from_parts(1_482_402, 0) - // Standard Error: 2_163 - .saturating_add(Weight::from_parts(619_230, 0).saturating_mul(r.into())) + // Minimum execution time: 1_065_000 picoseconds. + Weight::from_parts(1_403_813, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(6_192, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64eq(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_149_000 picoseconds. - Weight::from_parts(2_021_801, 0) - // Standard Error: 20_804 - .saturating_add(Weight::from_parts(913_888, 0).saturating_mul(r.into())) + // Minimum execution time: 1_061_000 picoseconds. + Weight::from_parts(1_421_984, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_094, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64ne(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_187_000 picoseconds. - Weight::from_parts(1_358_437, 0) - // Standard Error: 1_946 - .saturating_add(Weight::from_parts(916_378, 0).saturating_mul(r.into())) + // Minimum execution time: 1_075_000 picoseconds. + Weight::from_parts(1_431_453, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(9_084, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64lts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_175_000 picoseconds. - Weight::from_parts(1_527_336, 0) - // Standard Error: 243 - .saturating_add(Weight::from_parts(907_580, 0).saturating_mul(r.into())) + // Minimum execution time: 1_100_000 picoseconds. + Weight::from_parts(1_452_384, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(9_081, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64ltu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_220_000 picoseconds. - Weight::from_parts(1_530_715, 0) - // Standard Error: 224 - .saturating_add(Weight::from_parts(906_096, 0).saturating_mul(r.into())) + // Minimum execution time: 1_090_000 picoseconds. + Weight::from_parts(1_466_416, 0) + // Standard Error: 17 + .saturating_add(Weight::from_parts(9_091, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64gts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_107_000 picoseconds. - Weight::from_parts(1_496_553, 0) - // Standard Error: 299 - .saturating_add(Weight::from_parts(907_963, 0).saturating_mul(r.into())) + // Minimum execution time: 1_056_000 picoseconds. + Weight::from_parts(1_676_091, 0) + // Standard Error: 47 + .saturating_add(Weight::from_parts(9_082, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64gtu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_153_000 picoseconds. - Weight::from_parts(1_482_710, 0) - // Standard Error: 182 - .saturating_add(Weight::from_parts(918_439, 0).saturating_mul(r.into())) + // Minimum execution time: 1_053_000 picoseconds. + Weight::from_parts(1_232_790, 0) + // Standard Error: 43 + .saturating_add(Weight::from_parts(9_329, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64les(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_142_000 picoseconds. - Weight::from_parts(1_522_114, 0) - // Standard Error: 297 - .saturating_add(Weight::from_parts(906_633, 0).saturating_mul(r.into())) + // Minimum execution time: 1_091_000 picoseconds. + Weight::from_parts(1_476_212, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_074, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64leu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_119_000 picoseconds. - Weight::from_parts(2_199_831, 0) - // Standard Error: 4_234 - .saturating_add(Weight::from_parts(898_161, 0).saturating_mul(r.into())) + // Minimum execution time: 1_083_000 picoseconds. + Weight::from_parts(1_484_966, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(9_184, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64ges(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_163_000 picoseconds. - Weight::from_parts(1_489_404, 0) - // Standard Error: 416 - .saturating_add(Weight::from_parts(908_450, 0).saturating_mul(r.into())) + // Minimum execution time: 1_089_000 picoseconds. + Weight::from_parts(1_516_766, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_063, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64geu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_204_000 picoseconds. - Weight::from_parts(2_266_296, 0) - // Standard Error: 13_013 - .saturating_add(Weight::from_parts(899_225, 0).saturating_mul(r.into())) + // Minimum execution time: 996_000 picoseconds. + Weight::from_parts(1_460_638, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(9_076, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64add(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_160_000 picoseconds. - Weight::from_parts(1_470_799, 0) - // Standard Error: 422 - .saturating_add(Weight::from_parts(897_325, 0).saturating_mul(r.into())) + // Minimum execution time: 1_095_000 picoseconds. + Weight::from_parts(1_448_412, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(8_977, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64sub(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_125_000 picoseconds. - Weight::from_parts(1_521_508, 0) - // Standard Error: 594 - .saturating_add(Weight::from_parts(886_145, 0).saturating_mul(r.into())) + // Minimum execution time: 1_071_000 picoseconds. + Weight::from_parts(1_459_165, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(8_852, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64mul(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_139_000 picoseconds. - Weight::from_parts(1_490_535, 0) - // Standard Error: 211 - .saturating_add(Weight::from_parts(884_929, 0).saturating_mul(r.into())) + // Minimum execution time: 1_082_000 picoseconds. + Weight::from_parts(1_450_718, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(8_860, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64divs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_180_000 picoseconds. - Weight::from_parts(2_221_481, 0) - // Standard Error: 9_884 - .saturating_add(Weight::from_parts(1_507_511, 0).saturating_mul(r.into())) + // Minimum execution time: 1_065_000 picoseconds. + Weight::from_parts(1_436_871, 0) + // Standard Error: 9 + .saturating_add(Weight::from_parts(15_241, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64divu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_131_000 picoseconds. - Weight::from_parts(1_498_652, 0) - // Standard Error: 531 - .saturating_add(Weight::from_parts(1_451_498, 0).saturating_mul(r.into())) + // Minimum execution time: 1_065_000 picoseconds. + Weight::from_parts(1_423_806, 0) + // Standard Error: 17 + .saturating_add(Weight::from_parts(14_706, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64rems(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_145_000 picoseconds. - Weight::from_parts(1_504_118, 0) - // Standard Error: 439 - .saturating_add(Weight::from_parts(1_521_895, 0).saturating_mul(r.into())) + // Minimum execution time: 1_059_000 picoseconds. + Weight::from_parts(1_735_816, 0) + // Standard Error: 66 + .saturating_add(Weight::from_parts(15_230, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64remu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_124_000 picoseconds. - Weight::from_parts(1_497_209, 0) - // Standard Error: 198 - .saturating_add(Weight::from_parts(1_449_843, 0).saturating_mul(r.into())) + // Minimum execution time: 1_076_000 picoseconds. + Weight::from_parts(1_451_290, 0) + // Standard Error: 6 + .saturating_add(Weight::from_parts(14_530, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64and(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_169_000 picoseconds. - Weight::from_parts(1_534_491, 0) - // Standard Error: 283 - .saturating_add(Weight::from_parts(894_703, 0).saturating_mul(r.into())) + // Minimum execution time: 1_079_000 picoseconds. + Weight::from_parts(1_457_537, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(8_963, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64or(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_178_000 picoseconds. - Weight::from_parts(1_485_473, 0) - // Standard Error: 552 - .saturating_add(Weight::from_parts(897_878, 0).saturating_mul(r.into())) + // Minimum execution time: 1_032_000 picoseconds. + Weight::from_parts(1_475_315, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(8_956, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64xor(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_214_000 picoseconds. - Weight::from_parts(1_580_999, 0) - // Standard Error: 358 - .saturating_add(Weight::from_parts(894_207, 0).saturating_mul(r.into())) + // Minimum execution time: 1_056_000 picoseconds. + Weight::from_parts(1_450_071, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(8_960, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64shl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_176_000 picoseconds. - Weight::from_parts(1_490_470, 0) - // Standard Error: 738 - .saturating_add(Weight::from_parts(904_900, 0).saturating_mul(r.into())) + // Minimum execution time: 1_116_000 picoseconds. + Weight::from_parts(1_429_705, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(9_027, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64shrs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_197_000 picoseconds. - Weight::from_parts(1_519_703, 0) - // Standard Error: 336 - .saturating_add(Weight::from_parts(901_277, 0).saturating_mul(r.into())) + // Minimum execution time: 1_059_000 picoseconds. + Weight::from_parts(1_429_307, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_048, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64shru(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_166_000 picoseconds. - Weight::from_parts(1_507_499, 0) - // Standard Error: 298 - .saturating_add(Weight::from_parts(901_153, 0).saturating_mul(r.into())) + // Minimum execution time: 1_093_000 picoseconds. + Weight::from_parts(1_411_827, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_528, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64rotl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_158_000 picoseconds. - Weight::from_parts(1_491_176, 0) - // Standard Error: 341 - .saturating_add(Weight::from_parts(901_880, 0).saturating_mul(r.into())) + // Minimum execution time: 1_115_000 picoseconds. + Weight::from_parts(1_441_025, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_043, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64rotr(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_207_000 picoseconds. - Weight::from_parts(1_477_261, 0) - // Standard Error: 287 - .saturating_add(Weight::from_parts(902_622, 0).saturating_mul(r.into())) + // Minimum execution time: 1_077_000 picoseconds. + Weight::from_parts(1_480_666, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_031, 0).saturating_mul(r.into())) } } @@ -2161,8 +2132,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `109` // Estimated: `1594` - // Minimum execution time: 2_679_000 picoseconds. - Weight::from_parts(2_907_000, 1594) + // Minimum execution time: 2_736_000 picoseconds. + Weight::from_parts(2_931_000, 1594) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Skipped Metadata (r:0 w:0) @@ -2170,12 +2141,12 @@ impl WeightInfo for () { /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `450 + k * (69 ±0)` - // Estimated: `440 + k * (70 ±0)` - // Minimum execution time: 11_162_000 picoseconds. - Weight::from_parts(5_734_923, 440) - // Standard Error: 1_097 - .saturating_add(Weight::from_parts(976_647, 0).saturating_mul(k.into())) + // Measured: `481 + k * (69 ±0)` + // Estimated: `471 + k * (70 ±0)` + // Minimum execution time: 10_759_000 picoseconds. + Weight::from_parts(6_965_683, 471) + // Standard Error: 1_019 + .saturating_add(Weight::from_parts(961_947, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -2187,12 +2158,12 @@ impl WeightInfo for () { /// The range of component `q` is `[0, 128]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `250 + q * (33 ±0)` - // Estimated: `1725 + q * (33 ±0)` - // Minimum execution time: 2_626_000 picoseconds. - Weight::from_parts(10_626_314, 1725) - // Standard Error: 4_006 - .saturating_add(Weight::from_parts(1_298_864, 0).saturating_mul(q.into())) + // Measured: `281 + q * (33 ±0)` + // Estimated: `1753 + q * (33 ±0)` + // Minimum execution time: 2_633_000 picoseconds. + Weight::from_parts(10_668_837, 1753) + // Standard Error: 3_538 + .saturating_add(Weight::from_parts(1_277_168, 0).saturating_mul(q.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 33).saturating_mul(q.into())) @@ -2204,12 +2175,12 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 61717]`. fn reinstrument(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `238 + c * (1 ±0)` - // Estimated: `3951 + c * (2 ±0)` - // Minimum execution time: 31_434_000 picoseconds. - Weight::from_parts(29_558_961, 3951) - // Standard Error: 55 - .saturating_add(Weight::from_parts(50_774, 0).saturating_mul(c.into())) + // Measured: `270 + c * (1 ±0)` + // Estimated: `4015 + c * (2 ±0)` + // Minimum execution time: 30_264_000 picoseconds. + Weight::from_parts(27_106_554, 4015) + // Standard Error: 53 + .saturating_add(Weight::from_parts(49_705, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 2).saturating_mul(c.into())) @@ -2227,12 +2198,12 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `707` - // Estimated: `21400 + c * (5 ±0)` - // Minimum execution time: 309_015_000 picoseconds. - Weight::from_parts(318_740_885, 21400) - // Standard Error: 29 - .saturating_add(Weight::from_parts(30_993, 0).saturating_mul(c.into())) + // Measured: `803` + // Estimated: `21880 + c * (5 ±0)` + // Minimum execution time: 309_249_000 picoseconds. + Weight::from_parts(323_353_590, 21880) + // Standard Error: 25 + .saturating_add(Weight::from_parts(31_359, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(c.into())) @@ -2260,14 +2231,14 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `270` // Estimated: `26207` - // Minimum execution time: 3_126_495_000 picoseconds. - Weight::from_parts(636_857_878, 26207) - // Standard Error: 294 - .saturating_add(Weight::from_parts(92_930, 0).saturating_mul(c.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(1_128, 0).saturating_mul(i.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(1_415, 0).saturating_mul(s.into())) + // Minimum execution time: 3_136_707_000 picoseconds. + Weight::from_parts(564_055_378, 26207) + // Standard Error: 286 + .saturating_add(Weight::from_parts(93_308, 0).saturating_mul(c.into())) + // Standard Error: 16 + .saturating_add(Weight::from_parts(1_165, 0).saturating_mul(i.into())) + // Standard Error: 16 + .saturating_add(Weight::from_parts(1_435, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(10_u64)) } @@ -2289,14 +2260,14 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `482` - // Estimated: `28521` - // Minimum execution time: 1_591_415_000 picoseconds. - Weight::from_parts(228_633_516, 28521) + // Measured: `546` + // Estimated: `28969` + // Minimum execution time: 1_631_314_000 picoseconds. + Weight::from_parts(236_693_159, 28969) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_449, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_434, 0).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_444, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_445, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -2312,10 +2283,10 @@ impl WeightInfo for () { /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) fn call() -> Weight { // Proof Size summary in bytes: - // Measured: `759` - // Estimated: `21615` - // Minimum execution time: 167_905_000 picoseconds. - Weight::from_parts(169_247_000, 21615) + // Measured: `855` + // Estimated: `22095` + // Minimum execution time: 167_139_000 picoseconds. + Weight::from_parts(168_034_000, 22095) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2332,10 +2303,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `109` // Estimated: `7366` - // Minimum execution time: 305_128_000 picoseconds. - Weight::from_parts(310_911_395, 7366) - // Standard Error: 70 - .saturating_add(Weight::from_parts(94_067, 0).saturating_mul(c.into())) + // Minimum execution time: 306_518_000 picoseconds. + Weight::from_parts(325_652_407, 7366) + // Standard Error: 134 + .saturating_add(Weight::from_parts(93_502, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2349,10 +2320,10 @@ impl WeightInfo for () { /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `255` - // Estimated: `7950` - // Minimum execution time: 29_605_000 picoseconds. - Weight::from_parts(29_986_000, 7950) + // Measured: `287` + // Estimated: `8078` + // Minimum execution time: 29_084_000 picoseconds. + Weight::from_parts(29_350_000, 8078) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2364,10 +2335,10 @@ impl WeightInfo for () { /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `570` - // Estimated: `19530` - // Minimum execution time: 33_824_000 picoseconds. - Weight::from_parts(34_388_000, 19530) + // Measured: `666` + // Estimated: `19818` + // Minimum execution time: 32_996_000 picoseconds. + Weight::from_parts(33_365_000, 19818) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -2381,18 +2352,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_caller(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `781 + r * (480 ±0)` - // Estimated: `21765 + r * (2400 ±0)` - // Minimum execution time: 295_283_000 picoseconds. - Weight::from_parts(295_895_211, 21765) - // Standard Error: 44_860 - .saturating_add(Weight::from_parts(22_913_078, 0).saturating_mul(r.into())) + // Measured: `877 + r * (6 ±0)` + // Estimated: `22210 + r * (30 ±0)` + // Minimum execution time: 298_315_000 picoseconds. + Weight::from_parts(304_612_433, 22210) + // Standard Error: 904 + .saturating_add(Weight::from_parts(285_473, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2404,19 +2375,19 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_is_contract(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `821 + r * (19218 ±0)` - // Estimated: `21765 + r * (294095 ±0)` - // Minimum execution time: 295_760_000 picoseconds. - Weight::from_parts(151_512_811, 21765) - // Standard Error: 522_974 - .saturating_add(Weight::from_parts(263_028_353, 0).saturating_mul(r.into())) + // Measured: `935 + r * (272 ±0)` + // Estimated: `22315 + r * (3835 ±0)` + // Minimum execution time: 299_169_000 picoseconds. + Weight::from_parts(138_157_704, 22315) + // Standard Error: 6_115 + .saturating_add(Weight::from_parts(3_244_482, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 294095).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 3835).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2428,19 +2399,19 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `825 + r * (19539 ±0)` - // Estimated: `21810 + r * (295700 ±0)` - // Minimum execution time: 295_950_000 picoseconds. - Weight::from_parts(164_516_076, 21810) - // Standard Error: 469_540 - .saturating_add(Weight::from_parts(321_138_601, 0).saturating_mul(r.into())) + // Measured: `927 + r * (276 ±0)` + // Estimated: `22335 + r * (3855 ±0)` + // Minimum execution time: 299_262_000 picoseconds. + Weight::from_parts(157_105_627, 22335) + // Standard Error: 5_634 + .saturating_add(Weight::from_parts(3_995_666, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 295700).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 3855).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2452,18 +2423,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_own_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `788 + r * (480 ±0)` - // Estimated: `21800 + r * (2400 ±0)` - // Minimum execution time: 295_916_000 picoseconds. - Weight::from_parts(299_964_913, 21800) - // Standard Error: 78_211 - .saturating_add(Weight::from_parts(28_933_603, 0).saturating_mul(r.into())) + // Measured: `884 + r * (6 ±0)` + // Estimated: `22250 + r * (30 ±0)` + // Minimum execution time: 298_259_000 picoseconds. + Weight::from_parts(303_498_245, 22250) + // Standard Error: 874 + .saturating_add(Weight::from_parts(352_839, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2475,18 +2446,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_origin(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `778 + r * (240 ±0)` - // Estimated: `21735 + r * (1200 ±0)` - // Minimum execution time: 293_588_000 picoseconds. - Weight::from_parts(297_568_984, 21735) - // Standard Error: 35_513 - .saturating_add(Weight::from_parts(11_074_880, 0).saturating_mul(r.into())) + // Measured: `874 + r * (3 ±0)` + // Estimated: `22215 + r * (15 ±0)` + // Minimum execution time: 295_689_000 picoseconds. + Weight::from_parts(314_004_541, 22215) + // Standard Error: 1_803 + .saturating_add(Weight::from_parts(131_102, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 1200).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2498,18 +2469,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `782 + r * (480 ±0)` - // Estimated: `21730 + r * (2400 ±0)` - // Minimum execution time: 294_929_000 picoseconds. - Weight::from_parts(295_916_817, 21730) - // Standard Error: 64_902 - .saturating_add(Weight::from_parts(22_944_018, 0).saturating_mul(r.into())) + // Measured: `878 + r * (6 ±0)` + // Estimated: `22220 + r * (30 ±0)` + // Minimum execution time: 297_579_000 picoseconds. + Weight::from_parts(299_326_920, 22220) + // Standard Error: 990 + .saturating_add(Weight::from_parts(284_789, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2521,18 +2492,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_gas_left(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `783 + r * (480 ±0)` - // Estimated: `21720 + r * (2405 ±0)` - // Minimum execution time: 296_783_000 picoseconds. - Weight::from_parts(299_399_332, 21720) - // Standard Error: 50_982 - .saturating_add(Weight::from_parts(22_173_249, 0).saturating_mul(r.into())) + // Measured: `879 + r * (6 ±0)` + // Estimated: `22205 + r * (30 ±0)` + // Minimum execution time: 297_651_000 picoseconds. + Weight::from_parts(304_465_467, 22205) + // Standard Error: 736 + .saturating_add(Weight::from_parts(272_149, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2405).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:2 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2544,18 +2515,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `921 + r * (480 ±0)` - // Estimated: `24193 + r * (2451 ±0)` - // Minimum execution time: 294_120_000 picoseconds. - Weight::from_parts(305_889_989, 24193) - // Standard Error: 116_244 - .saturating_add(Weight::from_parts(114_781_094, 0).saturating_mul(r.into())) + // Measured: `1050 + r * (6 ±0)` + // Estimated: `25258 + r * (30 ±0)` + // Minimum execution time: 296_957_000 picoseconds. + Weight::from_parts(308_680_068, 25258) + // Standard Error: 1_377 + .saturating_add(Weight::from_parts(1_419_294, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2451).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2567,18 +2538,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_value_transferred(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `792 + r * (480 ±0)` - // Estimated: `21830 + r * (2400 ±0)` - // Minimum execution time: 295_569_000 picoseconds. - Weight::from_parts(299_774_774, 21830) - // Standard Error: 46_252 - .saturating_add(Weight::from_parts(21_753_842, 0).saturating_mul(r.into())) + // Measured: `888 + r * (6 ±0)` + // Estimated: `22305 + r * (30 ±0)` + // Minimum execution time: 297_735_000 picoseconds. + Weight::from_parts(301_533_807, 22305) + // Standard Error: 1_119 + .saturating_add(Weight::from_parts(277_289, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2590,18 +2561,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_minimum_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `790 + r * (480 ±0)` - // Estimated: `21760 + r * (2400 ±0)` - // Minimum execution time: 295_400_000 picoseconds. - Weight::from_parts(300_637_266, 21760) - // Standard Error: 41_263 - .saturating_add(Weight::from_parts(21_565_466, 0).saturating_mul(r.into())) + // Measured: `886 + r * (6 ±0)` + // Estimated: `22295 + r * (30 ±0)` + // Minimum execution time: 299_599_000 picoseconds. + Weight::from_parts(303_664_496, 22295) + // Standard Error: 1_009 + .saturating_add(Weight::from_parts(280_353, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2613,18 +2584,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_block_number(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `787 + r * (480 ±0)` - // Estimated: `21785 + r * (2400 ±0)` - // Minimum execution time: 294_696_000 picoseconds. - Weight::from_parts(297_196_796, 21785) - // Standard Error: 61_173 - .saturating_add(Weight::from_parts(21_903_191, 0).saturating_mul(r.into())) + // Measured: `883 + r * (6 ±0)` + // Estimated: `22285 + r * (30 ±0)` + // Minimum execution time: 297_641_000 picoseconds. + Weight::from_parts(302_437_979, 22285) + // Standard Error: 669 + .saturating_add(Weight::from_parts(270_403, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2636,18 +2607,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_now(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `778 + r * (480 ±0)` - // Estimated: `21715 + r * (2400 ±0)` - // Minimum execution time: 297_714_000 picoseconds. - Weight::from_parts(306_030_237, 21715) - // Standard Error: 69_984 - .saturating_add(Weight::from_parts(21_744_413, 0).saturating_mul(r.into())) + // Measured: `874 + r * (6 ±0)` + // Estimated: `22215 + r * (30 ±0)` + // Minimum execution time: 297_217_000 picoseconds. + Weight::from_parts(299_538_157, 22215) + // Standard Error: 732 + .saturating_add(Weight::from_parts(280_800, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2661,18 +2632,18 @@ impl WeightInfo for () { /// Proof: TransactionPayment NextFeeMultiplier (max_values: Some(1), max_size: Some(16), added: 511, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_weight_to_fee(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `856 + r * (800 ±0)` - // Estimated: `24416 + r * (4805 ±0)` - // Minimum execution time: 295_180_000 picoseconds. - Weight::from_parts(308_851_025, 24416) - // Standard Error: 115_126 - .saturating_add(Weight::from_parts(98_678_404, 0).saturating_mul(r.into())) + // Measured: `952 + r * (10 ±0)` + // Estimated: `25022 + r * (60 ±0)` + // Minimum execution time: 297_286_000 picoseconds. + Weight::from_parts(311_436_352, 25022) + // Standard Error: 6_811 + .saturating_add(Weight::from_parts(1_291_941, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 4805).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2684,18 +2655,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_gas(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `745 + r * (320 ±0)` - // Estimated: `21590 + r * (1600 ±0)` - // Minimum execution time: 151_587_000 picoseconds. - Weight::from_parts(155_713_096, 21590) - // Standard Error: 32_464 - .saturating_add(Weight::from_parts(8_332_778, 0).saturating_mul(r.into())) + // Measured: `841 + r * (4 ±0)` + // Estimated: `22035 + r * (20 ±0)` + // Minimum execution time: 154_772_000 picoseconds. + Weight::from_parts(159_224_457, 22035) + // Standard Error: 212 + .saturating_add(Weight::from_parts(102_264, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 1600).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 20).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2707,18 +2678,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_input(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `780 + r * (480 ±0)` - // Estimated: `21715 + r * (2400 ±0)` - // Minimum execution time: 295_008_000 picoseconds. - Weight::from_parts(297_982_800, 21715) - // Standard Error: 37_480 - .saturating_add(Weight::from_parts(17_970_520, 0).saturating_mul(r.into())) + // Measured: `876 + r * (6 ±0)` + // Estimated: `22220 + r * (30 ±0)` + // Minimum execution time: 297_248_000 picoseconds. + Weight::from_parts(303_805_584, 22220) + // Standard Error: 858 + .saturating_add(Weight::from_parts(223_587, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2400).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2730,15 +2701,15 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 1024]`. - fn seal_input_per_kb(n: u32, ) -> Weight { + /// The range of component `n` is `[0, 1048576]`. + fn seal_input_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1260` - // Estimated: `24120` - // Minimum execution time: 314_970_000 picoseconds. - Weight::from_parts(345_339_508, 24120) - // Standard Error: 4_112 - .saturating_add(Weight::from_parts(9_746_966, 0).saturating_mul(n.into())) + // Measured: `880` + // Estimated: `22220` + // Minimum execution time: 298_464_000 picoseconds. + Weight::from_parts(300_996_431, 22220) + // Standard Error: 1 + .saturating_add(Weight::from_parts(600, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2755,12 +2726,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `768 + r * (45 ±0)` - // Estimated: `21660 + r * (225 ±0)` - // Minimum execution time: 293_072_000 picoseconds. - Weight::from_parts(295_694_824, 21660) - // Standard Error: 219_523 - .saturating_add(Weight::from_parts(783_975, 0).saturating_mul(r.into())) + // Measured: `864 + r * (45 ±0)` + // Estimated: `22140 + r * (225 ±0)` + // Minimum execution time: 294_347_000 picoseconds. + Weight::from_parts(296_793_034, 22140) + // Standard Error: 277_251 + .saturating_add(Weight::from_parts(1_711_665, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 225).saturating_mul(r.into())) @@ -2775,15 +2746,15 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 1024]`. - fn seal_return_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `778` - // Estimated: `21755` - // Minimum execution time: 295_959_000 picoseconds. - Weight::from_parts(299_004_761, 21755) - // Standard Error: 3_988 - .saturating_add(Weight::from_parts(194_268, 0).saturating_mul(n.into())) + /// The range of component `n` is `[0, 1048576]`. + fn seal_return_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `874` + // Estimated: `22255` + // Minimum execution time: 297_257_000 picoseconds. + Weight::from_parts(300_088_288, 22255) + // Standard Error: 1 + .saturating_add(Weight::from_parts(181, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2804,17 +2775,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `810 + r * (356 ±0)` - // Estimated: `25511 + r * (15321 ±0)` - // Minimum execution time: 294_626_000 picoseconds. - Weight::from_parts(297_839_179, 25511) - // Standard Error: 707_428 - .saturating_add(Weight::from_parts(81_507_620, 0).saturating_mul(r.into())) + // Measured: `906 + r * (452 ±0)` + // Estimated: `26183 + r * (15994 ±0)` + // Minimum execution time: 296_510_000 picoseconds. + Weight::from_parts(299_169_757, 26183) + // Standard Error: 205_313 + .saturating_add(Weight::from_parts(78_059_642, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 15321).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 15994).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2828,18 +2799,18 @@ impl WeightInfo for () { /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_random(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `825 + r * (800 ±0)` - // Estimated: `24199 + r * (4805 ±0)` - // Minimum execution time: 295_431_000 picoseconds. - Weight::from_parts(310_428_531, 24199) - // Standard Error: 143_501 - .saturating_add(Weight::from_parts(136_529_376, 0).saturating_mul(r.into())) + // Measured: `921 + r * (10 ±0)` + // Estimated: `24859 + r * (60 ±0)` + // Minimum execution time: 299_299_000 picoseconds. + Weight::from_parts(314_487_015, 24859) + // Standard Error: 1_552 + .saturating_add(Weight::from_parts(1_753_960, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 4805).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2851,18 +2822,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_deposit_event(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `778 + r * (800 ±0)` - // Estimated: `21720 + r * (4000 ±0)` - // Minimum execution time: 293_778_000 picoseconds. - Weight::from_parts(323_404_081, 21720) - // Standard Error: 243_095 - .saturating_add(Weight::from_parts(269_012_482, 0).saturating_mul(r.into())) + // Measured: `874 + r * (10 ±0)` + // Estimated: `22215 + r * (50 ±0)` + // Minimum execution time: 296_188_000 picoseconds. + Weight::from_parts(305_901_539, 22215) + // Standard Error: 2_782 + .saturating_add(Weight::from_parts(3_456_054, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 4000).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 50).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2872,26 +2843,25 @@ impl WeightInfo for () { /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:322 w:322) + /// Storage: System EventTopics (r:6 w:6) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[0, 4]`. - /// The range of component `n` is `[0, 16]`. - fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1725 + t * (2608 ±0) + n * (7 ±0)` - // Estimated: `26340 + t * (211030 ±0) + n * (50 ±0)` - // Minimum execution time: 1_317_129_000 picoseconds. - Weight::from_parts(566_722_295, 26340) - // Standard Error: 619_390 - .saturating_add(Weight::from_parts(194_334_643, 0).saturating_mul(t.into())) - // Standard Error: 170_114 - .saturating_add(Weight::from_parts(67_458_751, 0).saturating_mul(n.into())) + /// The range of component `n` is `[0, 16384]`. + fn seal_deposit_event_per_topic_and_byte(t: u32, n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `893 + t * (32 ±0)` + // Estimated: `22320 + t * (2640 ±0)` + // Minimum execution time: 313_860_000 picoseconds. + Weight::from_parts(312_473_092, 22320) + // Standard Error: 250_852 + .saturating_add(Weight::from_parts(2_258_502, 0).saturating_mul(t.into())) + // Standard Error: 70 + .saturating_add(Weight::from_parts(312, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(t.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(RocksDbWeight::get().writes((80_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 211030).saturating_mul(t.into())) - .saturating_add(Weight::from_parts(0, 50).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(t.into()))) + .saturating_add(Weight::from_parts(0, 2640).saturating_mul(t.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2903,18 +2873,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_debug_message(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `777 + r * (560 ±0)` - // Estimated: `21710 + r * (2800 ±0)` - // Minimum execution time: 159_087_000 picoseconds. - Weight::from_parts(163_703_981, 21710) - // Standard Error: 26_067 - .saturating_add(Weight::from_parts(14_810_256, 0).saturating_mul(r.into())) + // Measured: `873 + r * (7 ±0)` + // Estimated: `22205 + r * (35 ±0)` + // Minimum execution time: 162_043_000 picoseconds. + Weight::from_parts(166_132_332, 22205) + // Standard Error: 716 + .saturating_add(Weight::from_parts(184_981, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2800).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 35).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) @@ -2926,200 +2896,187 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `i` is `[0, 1024]`. - fn seal_debug_message_per_kb(i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `125728` - // Estimated: `269982` - // Minimum execution time: 413_391_000 picoseconds. - Weight::from_parts(414_927_640, 269982) - // Standard Error: 1_740 - .saturating_add(Weight::from_parts(763_359, 0).saturating_mul(i.into())) + /// The range of component `i` is `[0, 1048576]`. + fn seal_debug_message_per_byte(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `125824` + // Estimated: `270073` + // Minimum execution time: 414_433_000 picoseconds. + Weight::from_parts(417_483_627, 270073) + // Standard Error: 1 + .saturating_add(Weight::from_parts(748, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 10]`. + /// The range of component `r` is `[0, 800]`. fn seal_set_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `815 + r * (23420 ±0)` - // Estimated: `815 + r * (23418 ±0)` - // Minimum execution time: 296_108_000 picoseconds. - Weight::from_parts(208_214_040, 815) - // Standard Error: 860_573 - .saturating_add(Weight::from_parts(480_342_550, 0).saturating_mul(r.into())) + // Measured: `941 + r * (292 ±0)` + // Estimated: `939 + r * (293 ±0)` + // Minimum execution time: 299_500_000 picoseconds. + Weight::from_parts(194_466_413, 939) + // Standard Error: 9_986 + .saturating_add(Weight::from_parts(6_010_112, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(RocksDbWeight::get().writes((80_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 23418).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 293).saturating_mul(r.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 8]`. - fn seal_set_storage_per_new_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `12544 + n * (11945 ±0)` - // Estimated: `8401 + n * (12814 ±61)` - // Minimum execution time: 442_286_000 picoseconds. - Weight::from_parts(620_395_299, 8401) - // Standard Error: 1_661_554 - .saturating_add(Weight::from_parts(89_393_169, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(52_u64)) - .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(50_u64)) - .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 12814).saturating_mul(n.into())) + /// The range of component `n` is `[0, 16384]`. + fn seal_set_storage_per_new_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1432` + // Estimated: `1405` + // Minimum execution time: 314_171_000 picoseconds. + Weight::from_parts(335_595_397, 1405) + // Standard Error: 67 + .saturating_add(Weight::from_parts(90, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(8_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 8]`. - fn seal_set_storage_per_old_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `12532 + n * (175784 ±0)` - // Estimated: `8396 + n * (176649 ±61)` - // Minimum execution time: 440_882_000 picoseconds. - Weight::from_parts(587_317_981, 8396) - // Standard Error: 1_374_991 - .saturating_add(Weight::from_parts(66_271_084, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(51_u64)) - .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(49_u64)) - .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 176649).saturating_mul(n.into())) + /// The range of component `n` is `[0, 16384]`. + fn seal_set_storage_per_old_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1295 + n * (1 ±0)` + // Estimated: `1292 + n * (1 ±0)` + // Minimum execution time: 313_479_000 picoseconds. + Weight::from_parts(317_435_100, 1292) + // Standard Error: 41 + .saturating_add(Weight::from_parts(106, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 10]`. + /// The range of component `r` is `[0, 800]`. fn seal_clear_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `807 + r * (23099 ±0)` - // Estimated: `812 + r * (23099 ±0)` - // Minimum execution time: 296_023_000 picoseconds. - Weight::from_parts(221_471_559, 812) - // Standard Error: 814_503 - .saturating_add(Weight::from_parts(465_928_089, 0).saturating_mul(r.into())) + // Measured: `937 + r * (288 ±0)` + // Estimated: `941 + r * (289 ±0)` + // Minimum execution time: 297_831_000 picoseconds. + Weight::from_parts(196_983_778, 941) + // Standard Error: 9_899 + .saturating_add(Weight::from_parts(5_904_642, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(RocksDbWeight::get().writes((80_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 23099).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 289).saturating_mul(r.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 8]`. - fn seal_clear_storage_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `12256 + n * (175776 ±0)` - // Estimated: `8047 + n * (176655 ±62)` - // Minimum execution time: 412_212_000 picoseconds. - Weight::from_parts(569_213_147, 8047) - // Standard Error: 1_463_771 - .saturating_add(Weight::from_parts(67_932_081, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(51_u64)) - .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(48_u64)) - .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 176655).saturating_mul(n.into())) + /// The range of component `n` is `[0, 16384]`. + fn seal_clear_storage_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1291 + n * (1 ±0)` + // Estimated: `1288 + n * (1 ±0)` + // Minimum execution time: 320_156_000 picoseconds. + Weight::from_parts(327_504_368, 1288) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 10]`. + /// The range of component `r` is `[0, 800]`. fn seal_get_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `800 + r * (23744 ±0)` - // Estimated: `813 + r * (23740 ±0)` - // Minimum execution time: 296_007_000 picoseconds. - Weight::from_parts(229_100_700, 813) - // Standard Error: 684_970 - .saturating_add(Weight::from_parts(394_982_991, 0).saturating_mul(r.into())) + // Measured: `931 + r * (296 ±0)` + // Estimated: `936 + r * (297 ±0)` + // Minimum execution time: 305_849_000 picoseconds. + Weight::from_parts(219_649_351, 936) + // Standard Error: 9_157 + .saturating_add(Weight::from_parts(4_846_108, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 23740).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 297).saturating_mul(r.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 8]`. - fn seal_get_storage_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `12863 + n * (175784 ±0)` - // Estimated: `8538 + n * (176688 ±63)` - // Minimum execution time: 392_306_000 picoseconds. - Weight::from_parts(539_188_004, 8538) - // Standard Error: 1_371_839 - .saturating_add(Weight::from_parts(155_130_373, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(51_u64)) - .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) + /// The range of component `n` is `[0, 16384]`. + fn seal_get_storage_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1307 + n * (1 ±0)` + // Estimated: `1304 + n * (1 ±0)` + // Minimum execution time: 312_106_000 picoseconds. + Weight::from_parts(315_905_779, 1304) + // Standard Error: 44 + .saturating_add(Weight::from_parts(674, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 176688).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 10]`. + /// The range of component `r` is `[0, 800]`. fn seal_contains_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `818 + r * (23098 ±0)` - // Estimated: `824 + r * (23098 ±0)` - // Minimum execution time: 296_038_000 picoseconds. - Weight::from_parts(229_462_798, 824) - // Standard Error: 655_463 - .saturating_add(Weight::from_parts(372_593_685, 0).saturating_mul(r.into())) + // Measured: `952 + r * (288 ±0)` + // Estimated: `953 + r * (289 ±0)` + // Minimum execution time: 299_372_000 picoseconds. + Weight::from_parts(211_293_493, 953) + // Standard Error: 8_509 + .saturating_add(Weight::from_parts(4_688_993, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 23098).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 289).saturating_mul(r.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 8]`. - fn seal_contains_storage_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `12200 + n * (175798 ±0)` - // Estimated: `8028 + n * (176661 ±62)` - // Minimum execution time: 386_782_000 picoseconds. - Weight::from_parts(512_965_975, 8028) - // Standard Error: 1_168_132 - .saturating_add(Weight::from_parts(63_307_325, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(51_u64)) - .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) + /// The range of component `n` is `[0, 16384]`. + fn seal_contains_storage_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1294 + n * (1 ±0)` + // Estimated: `1291 + n * (1 ±0)` + // Minimum execution time: 311_605_000 picoseconds. + Weight::from_parts(315_473_850, 1291) + // Standard Error: 37 + .saturating_add(Weight::from_parts(3, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 176661).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 10]`. + /// The range of component `r` is `[0, 800]`. fn seal_take_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `815 + r * (23740 ±0)` - // Estimated: `817 + r * (23739 ±0)` - // Minimum execution time: 296_352_000 picoseconds. - Weight::from_parts(212_661_296, 817) - // Standard Error: 879_297 - .saturating_add(Weight::from_parts(494_182_672, 0).saturating_mul(r.into())) + // Measured: `925 + r * (296 ±0)` + // Estimated: `932 + r * (297 ±0)` + // Minimum execution time: 298_231_000 picoseconds. + Weight::from_parts(200_178_698, 932) + // Standard Error: 10_452 + .saturating_add(Weight::from_parts(6_107_653, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(RocksDbWeight::get().writes((80_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 23739).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 297).saturating_mul(r.into())) } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 8]`. - fn seal_take_storage_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `12864 + n * (175784 ±0)` - // Estimated: `8539 + n * (176686 ±63)` - // Minimum execution time: 414_693_000 picoseconds. - Weight::from_parts(595_693_859, 8539) - // Standard Error: 1_673_819 - .saturating_add(Weight::from_parts(163_090_316, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(51_u64)) - .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(48_u64)) - .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 176686).saturating_mul(n.into())) + /// The range of component `n` is `[0, 16384]`. + fn seal_take_storage_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1308 + n * (1 ±0)` + // Estimated: `1305 + n * (1 ±0)` + // Minimum execution time: 314_970_000 picoseconds. + Weight::from_parts(318_135_821, 1305) + // Standard Error: 26 + .saturating_add(Weight::from_parts(630, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: System Account (r:1602 w:1601) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3131,20 +3088,20 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_transfer(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1329 + r * (3604 ±0)` - // Estimated: `25928 + r * (216096 ±4)` - // Minimum execution time: 299_205_000 picoseconds. - Weight::from_parts(221_142_217, 25928) - // Standard Error: 1_369_909 - .saturating_add(Weight::from_parts(1_665_917_241, 0).saturating_mul(r.into())) + // Measured: `1501 + r * (45 ±0)` + // Estimated: `27383 + r * (2700 ±0)` + // Minimum execution time: 299_629_000 picoseconds. + Weight::from_parts(150_915_187, 27383) + // Standard Error: 25_604 + .saturating_add(Weight::from_parts(20_859_844, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) - .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) - .saturating_add(RocksDbWeight::get().writes((80_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 216096).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 2700).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3156,20 +3113,20 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:1602 w:1602) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1479 + r * (20514 ±0)` - // Estimated: `26429 + r * (498656 ±1)` - // Minimum execution time: 297_501_000 picoseconds. - Weight::from_parts(298_400_000, 26429) - // Standard Error: 9_372_890 - .saturating_add(Weight::from_parts(22_507_984_433, 0).saturating_mul(r.into())) + // Measured: `1670 + r * (288 ±0)` + // Estimated: `27813 + r * (6391 ±0)` + // Minimum execution time: 299_578_000 picoseconds. + Weight::from_parts(300_036_000, 27813) + // Standard Error: 102_709 + .saturating_add(Weight::from_parts(283_767_316, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) - .saturating_add(RocksDbWeight::get().reads((160_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(RocksDbWeight::get().writes((160_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 498656).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 6391).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3181,48 +3138,48 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:1537 w:1537) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (69030 ±0)` - // Estimated: `21755 + r * (647542 ±560)` - // Minimum execution time: 297_432_000 picoseconds. - Weight::from_parts(298_220_000, 21755) - // Standard Error: 9_420_834 - .saturating_add(Weight::from_parts(22_261_152_353, 0).saturating_mul(r.into())) + // Measured: `0 + r * (935 ±0)` + // Estimated: `22235 + r * (8322 ±10)` + // Minimum execution time: 298_943_000 picoseconds. + Weight::from_parts(299_619_000, 22235) + // Standard Error: 117_493 + .saturating_add(Weight::from_parts(280_555_517, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().reads((150_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(RocksDbWeight::get().writes((75_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 647542).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 8322).saturating_mul(r.into())) } - /// Storage: System Account (r:82 w:81) + /// Storage: System Account (r:3 w:2) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:81 w:81) + /// Storage: Contracts ContractInfoOf (r:2 w:2) /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) /// Storage: Contracts CodeStorage (r:2 w:0) /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:82 w:82) + /// Storage: System EventTopics (r:3 w:3) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[0, 1]`. - /// The range of component `c` is `[0, 1024]`. - fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `21581 + t * (14318 ±0)` - // Estimated: `524200 + t * (272065 ±0)` - // Minimum execution time: 11_799_802_000 picoseconds. - Weight::from_parts(10_575_328_547, 524200) - // Standard Error: 11_952_810 - .saturating_add(Weight::from_parts(1_603_077_083, 0).saturating_mul(t.into())) - // Standard Error: 17_922 - .saturating_add(Weight::from_parts(9_876_752, 0).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(167_u64)) - .saturating_add(RocksDbWeight::get().reads((81_u64).saturating_mul(t.into()))) - .saturating_add(RocksDbWeight::get().writes(163_u64)) - .saturating_add(RocksDbWeight::get().writes((81_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 272065).saturating_mul(t.into())) + /// The range of component `c` is `[0, 1048576]`. + fn seal_call_per_transfer_clone_byte(t: u32, c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1314 + t * (268 ±0)` + // Estimated: `31815 + t * (6290 ±0)` + // Minimum execution time: 453_013_000 picoseconds. + Weight::from_parts(442_536_283, 31815) + // Standard Error: 1_339_541 + .saturating_add(Weight::from_parts(17_062_445, 0).saturating_mul(t.into())) + // Standard Error: 1 + .saturating_add(Weight::from_parts(604, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(9_u64)) + .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(t.into()))) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(t.into()))) + .saturating_add(Weight::from_parts(0, 6290).saturating_mul(t.into())) } /// Storage: System Account (r:3202 w:3202) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3238,24 +3195,24 @@ impl WeightInfo for () { /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) /// Storage: System EventTopics (r:1602 w:1602) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_instantiate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1646 + r * (20288 ±0)` - // Estimated: `32625 + r * (1330150 ±2)` - // Minimum execution time: 298_155_000 picoseconds. - Weight::from_parts(299_212_000, 32625) - // Standard Error: 32_410_313 - .saturating_add(Weight::from_parts(30_417_025_178, 0).saturating_mul(r.into())) + // Measured: `1988 + r * (319 ±0)` + // Estimated: `34745 + r * (17090 ±0)` + // Minimum execution time: 300_123_000 picoseconds. + Weight::from_parts(300_406_000, 34745) + // Standard Error: 420_997 + .saturating_add(Weight::from_parts(382_704_025, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) - .saturating_add(RocksDbWeight::get().reads((480_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - .saturating_add(RocksDbWeight::get().writes((400_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 1330150).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + .saturating_add(RocksDbWeight::get().writes((5_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 17090).saturating_mul(r.into())) } - /// Storage: System Account (r:162 w:162) + /// Storage: System Account (r:4 w:4) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:81 w:81) + /// Storage: Contracts ContractInfoOf (r:2 w:2) /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) /// Storage: Contracts CodeStorage (r:2 w:0) /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) @@ -3265,28 +3222,28 @@ impl WeightInfo for () { /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: Contracts OwnerInfoOf (r:1 w:1) /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) - /// Storage: System EventTopics (r:82 w:82) + /// Storage: System EventTopics (r:3 w:3) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[0, 1]`. - /// The range of component `i` is `[0, 960]`. - /// The range of component `s` is `[0, 960]`. - fn seal_instantiate_per_transfer_input_salt_kb(t: u32, i: u32, s: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `5625 + t * (1 ±0)` - // Estimated: `856795 + t * (2471 ±3)` - // Minimum execution time: 105_914_928_000 picoseconds. - Weight::from_parts(13_229_760_432, 856795) - // Standard Error: 96_394_437 - .saturating_add(Weight::from_parts(398_413_888, 0).saturating_mul(t.into())) - // Standard Error: 157_192 - .saturating_add(Weight::from_parts(97_104_978, 0).saturating_mul(i.into())) - // Standard Error: 157_192 - .saturating_add(Weight::from_parts(97_146_130, 0).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(329_u64)) + /// The range of component `i` is `[0, 983040]`. + /// The range of component `s` is `[0, 983040]`. + fn seal_instantiate_per_transfer_input_salt_byte(t: u32, i: u32, s: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1231 + t * (219 ±0)` + // Estimated: `43797 + t * (3812 ±2)` + // Minimum execution time: 1_636_322_000 picoseconds. + Weight::from_parts(360_859_331, 43797) + // Standard Error: 4_816_923 + .saturating_add(Weight::from_parts(109_179_023, 0).saturating_mul(t.into())) + // Standard Error: 7 + .saturating_add(Weight::from_parts(1_180, 0).saturating_mul(i.into())) + // Standard Error: 7 + .saturating_add(Weight::from_parts(1_344, 0).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) - .saturating_add(RocksDbWeight::get().writes(326_u64)) + .saturating_add(RocksDbWeight::get().writes(10_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 2471).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 3812).saturating_mul(t.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3298,18 +3255,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 1600]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `775 + r * (642 ±0)` - // Estimated: `21695 + r * (3210 ±0)` - // Minimum execution time: 294_309_000 picoseconds. - Weight::from_parts(296_241_318, 21695) - // Standard Error: 127_872 - .saturating_add(Weight::from_parts(45_806_281, 0).saturating_mul(r.into())) + // Measured: `873 + r * (8 ±0)` + // Estimated: `22190 + r * (40 ±0)` + // Minimum execution time: 297_521_000 picoseconds. + Weight::from_parts(303_523_260, 22190) + // Standard Error: 1_162 + .saturating_add(Weight::from_parts(542_201, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 3210).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3321,15 +3278,15 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 1024]`. - fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1577` - // Estimated: `25630` - // Minimum execution time: 341_248_000 picoseconds. - Weight::from_parts(341_607_000, 25630) - // Standard Error: 66_687 - .saturating_add(Weight::from_parts(322_250_398, 0).saturating_mul(n.into())) + /// The range of component `n` is `[0, 1048576]`. + fn seal_hash_sha2_256_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `881` + // Estimated: `22225` + // Minimum execution time: 299_877_000 picoseconds. + Weight::from_parts(293_538_014, 22225) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_967, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3343,18 +3300,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 1600]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `777 + r * (642 ±0)` - // Estimated: `21705 + r * (3210 ±0)` - // Minimum execution time: 293_810_000 picoseconds. - Weight::from_parts(296_719_171, 21705) - // Standard Error: 450_807 - .saturating_add(Weight::from_parts(61_627_228, 0).saturating_mul(r.into())) + // Measured: `875 + r * (8 ±0)` + // Estimated: `22205 + r * (40 ±0)` + // Minimum execution time: 297_672_000 picoseconds. + Weight::from_parts(299_933_312, 22205) + // Standard Error: 1_138 + .saturating_add(Weight::from_parts(713_189, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 3210).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3366,15 +3323,15 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 1024]`. - fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1579` - // Estimated: `25675` - // Minimum execution time: 354_550_000 picoseconds. - Weight::from_parts(355_136_000, 25675) - // Standard Error: 61_761 - .saturating_add(Weight::from_parts(257_021_566, 0).saturating_mul(n.into())) + /// The range of component `n` is `[0, 1048576]`. + fn seal_hash_keccak_256_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `883` + // Estimated: `22245` + // Minimum execution time: 299_048_000 picoseconds. + Weight::from_parts(293_055_982, 22245) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_179, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3388,18 +3345,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `777 + r * (642 ±0)` - // Estimated: `21705 + r * (3210 ±0)` - // Minimum execution time: 293_369_000 picoseconds. - Weight::from_parts(295_990_893, 21705) - // Standard Error: 431_269 - .saturating_add(Weight::from_parts(32_213_406, 0).saturating_mul(r.into())) + // Measured: `875 + r * (8 ±0)` + // Estimated: `22220 + r * (40 ±0)` + // Minimum execution time: 301_991_000 picoseconds. + Weight::from_parts(300_027_441, 22220) + // Standard Error: 981 + .saturating_add(Weight::from_parts(391_319, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 3210).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3411,15 +3368,15 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 1024]`. - fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1579` - // Estimated: `25650` - // Minimum execution time: 326_595_000 picoseconds. - Weight::from_parts(327_188_000, 25650) - // Standard Error: 53_385 - .saturating_add(Weight::from_parts(74_046_074, 0).saturating_mul(n.into())) + /// The range of component `n` is `[0, 1048576]`. + fn seal_hash_blake2_256_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `883` + // Estimated: `22265` + // Minimum execution time: 296_522_000 picoseconds. + Weight::from_parts(296_121_638, 22265) + // Standard Error: 2 + .saturating_add(Weight::from_parts(916, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3433,18 +3390,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `777 + r * (679 ±0)` - // Estimated: `21705 + r * (3395 ±0)` - // Minimum execution time: 292_388_000 picoseconds. - Weight::from_parts(295_090_179, 21705) - // Standard Error: 170_487 - .saturating_add(Weight::from_parts(32_577_820, 0).saturating_mul(r.into())) + // Measured: `875 + r * (8 ±0)` + // Estimated: `22225 + r * (40 ±0)` + // Minimum execution time: 296_228_000 picoseconds. + Weight::from_parts(301_472_299, 22225) + // Standard Error: 875 + .saturating_add(Weight::from_parts(381_027, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 3395).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3456,15 +3413,15 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[0, 1024]`. - fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1579` - // Estimated: `25695` - // Minimum execution time: 326_862_000 picoseconds. - Weight::from_parts(327_449_000, 25695) - // Standard Error: 54_539 - .saturating_add(Weight::from_parts(74_042_337, 0).saturating_mul(n.into())) + /// The range of component `n` is `[0, 1048576]`. + fn seal_hash_blake2_128_per_byte(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `883` + // Estimated: `22235` + // Minimum execution time: 296_644_000 picoseconds. + Weight::from_parts(289_879_744, 22235) + // Standard Error: 2 + .saturating_add(Weight::from_parts(925, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3478,18 +3435,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 1600]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `821 + r * (6083 ±0)` - // Estimated: `21925 + r * (30415 ±0)` - // Minimum execution time: 295_597_000 picoseconds. - Weight::from_parts(298_267_200, 21925) - // Standard Error: 699_824 - .saturating_add(Weight::from_parts(3_021_734_700, 0).saturating_mul(r.into())) + // Measured: `800 + r * (78 ±0)` + // Estimated: `21845 + r * (390 ±0)` + // Minimum execution time: 297_804_000 picoseconds. + Weight::from_parts(471_994_534, 21845) + // Standard Error: 9_479 + .saturating_add(Weight::from_parts(36_886_028, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 30415).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 390).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3501,18 +3458,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 1600]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `790 + r * (3362 ±0)` - // Estimated: `21770 + r * (16810 ±0)` - // Minimum execution time: 295_539_000 picoseconds. - Weight::from_parts(297_844_822, 21770) - // Standard Error: 490_532 - .saturating_add(Weight::from_parts(747_592_977, 0).saturating_mul(r.into())) + // Measured: `645 + r * (44 ±0)` + // Estimated: `21110 + r * (220 ±0)` + // Minimum execution time: 298_623_000 picoseconds. + Weight::from_parts(322_192_102, 21110) + // Standard Error: 3_207 + .saturating_add(Weight::from_parts(9_243_653, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 16810).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 220).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3526,20 +3483,20 @@ impl WeightInfo for () { /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) /// Storage: System EventTopics (r:1538 w:1538) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (74020 ±0)` - // Estimated: `69192 + r * (913289 ±821)` - // Minimum execution time: 295_164_000 picoseconds. - Weight::from_parts(296_597_000, 69192) - // Standard Error: 3_646_577 - .saturating_add(Weight::from_parts(1_725_796_807, 0).saturating_mul(r.into())) + // Measured: `0 + r * (1030 ±0)` + // Estimated: `30592 + r * (11919 ±7)` + // Minimum execution time: 298_574_000 picoseconds. + Weight::from_parts(299_383_000, 30592) + // Standard Error: 44_061 + .saturating_add(Weight::from_parts(21_625_366, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().reads((225_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(RocksDbWeight::get().writes((150_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 913289).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 11919).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3551,18 +3508,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `773 + r * (240 ±0)` - // Estimated: `21685 + r * (1200 ±0)` - // Minimum execution time: 296_287_000 picoseconds. - Weight::from_parts(300_696_694, 21685) - // Standard Error: 27_891 - .saturating_add(Weight::from_parts(10_943_994, 0).saturating_mul(r.into())) + // Measured: `869 + r * (3 ±0)` + // Estimated: `22215 + r * (15 ±0)` + // Minimum execution time: 297_014_000 picoseconds. + Weight::from_parts(301_226_615, 22215) + // Standard Error: 439 + .saturating_add(Weight::from_parts(143_017, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 1200).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3574,18 +3531,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2006 + r * (3154 ±0)` - // Estimated: `26435 + r * (15875 ±2)` - // Minimum execution time: 298_000_000 picoseconds. - Weight::from_parts(328_282_119, 26435) - // Standard Error: 104_874 - .saturating_add(Weight::from_parts(18_428_267, 0).saturating_mul(r.into())) + // Measured: `2072 + r * (39 ±0)` + // Estimated: `27645 + r * (200 ±0)` + // Minimum execution time: 299_074_000 picoseconds. + Weight::from_parts(336_979_016, 27645) + // Standard Error: 1_163 + .saturating_add(Weight::from_parts(227_998, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 15875).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 200).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3599,537 +3556,525 @@ impl WeightInfo for () { /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 20]`. + /// The range of component `r` is `[0, 1600]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `776 + r * (240 ±0)` - // Estimated: `23962 + r * (1440 ±0)` - // Minimum execution time: 295_104_000 picoseconds. - Weight::from_parts(299_334_585, 23962) - // Standard Error: 25_840 - .saturating_add(Weight::from_parts(9_744_866, 0).saturating_mul(r.into())) + // Measured: `872 + r * (3 ±0)` + // Estimated: `24580 + r * (18 ±0)` + // Minimum execution time: 296_959_000 picoseconds. + Weight::from_parts(303_796_839, 24580) + // Standard Error: 534 + .saturating_add(Weight::from_parts(118_978, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) - .saturating_add(Weight::from_parts(0, 1440).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 18).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64const(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_132_000 picoseconds. - Weight::from_parts(1_100_159, 0) - // Standard Error: 10_131 - .saturating_add(Weight::from_parts(436_462, 0).saturating_mul(r.into())) + // Minimum execution time: 1_020_000 picoseconds. + Weight::from_parts(1_355_107, 0) + // Standard Error: 1 + .saturating_add(Weight::from_parts(4_110, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64load(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_368_000 picoseconds. - Weight::from_parts(1_974_308, 0) - // Standard Error: 811 - .saturating_add(Weight::from_parts(1_079_620, 0).saturating_mul(r.into())) + // Minimum execution time: 1_224_000 picoseconds. + Weight::from_parts(1_819_284, 0) + // Standard Error: 10 + .saturating_add(Weight::from_parts(10_803, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64store(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_354_000 picoseconds. - Weight::from_parts(2_057_834, 0) - // Standard Error: 4_277 - .saturating_add(Weight::from_parts(1_008_797, 0).saturating_mul(r.into())) + // Minimum execution time: 1_216_000 picoseconds. + Weight::from_parts(1_795_011, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(10_000, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_select(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_218_000 picoseconds. - Weight::from_parts(1_594_528, 0) - // Standard Error: 723 - .saturating_add(Weight::from_parts(1_147_486, 0).saturating_mul(r.into())) + // Minimum execution time: 1_127_000 picoseconds. + Weight::from_parts(1_491_730, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(11_471, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_156_000 picoseconds. - Weight::from_parts(1_460_611, 0) - // Standard Error: 419 - .saturating_add(Weight::from_parts(1_314_741, 0).saturating_mul(r.into())) + // Minimum execution time: 1_044_000 picoseconds. + Weight::from_parts(2_330_852, 0) + // Standard Error: 69 + .saturating_add(Weight::from_parts(12_866, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_br(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_166_000 picoseconds. - Weight::from_parts(1_454_460, 0) - // Standard Error: 493 - .saturating_add(Weight::from_parts(642_481, 0).saturating_mul(r.into())) + // Minimum execution time: 1_067_000 picoseconds. + Weight::from_parts(1_399_626, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(6_430, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_br_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_144_000 picoseconds. - Weight::from_parts(1_410_515, 0) - // Standard Error: 894 - .saturating_add(Weight::from_parts(958_765, 0).saturating_mul(r.into())) + // Minimum execution time: 1_087_000 picoseconds. + Weight::from_parts(1_463_592, 0) + // Standard Error: 12 + .saturating_add(Weight::from_parts(9_707, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_br_table(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_190_000 picoseconds. - Weight::from_parts(1_143_236, 0) - // Standard Error: 2_773 - .saturating_add(Weight::from_parts(1_164_764, 0).saturating_mul(r.into())) + // Minimum execution time: 1_110_000 picoseconds. + Weight::from_parts(1_058_258, 0) + // Standard Error: 22 + .saturating_add(Weight::from_parts(11_713, 0).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. - fn instr_br_table_per_entry(e: u32, ) -> Weight { + fn instr_br_table_per_entry(_e: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_993_000 picoseconds. - Weight::from_parts(3_270_525, 0) - // Standard Error: 65 - .saturating_add(Weight::from_parts(4_418, 0).saturating_mul(e.into())) + // Minimum execution time: 1_189_000 picoseconds. + Weight::from_parts(1_416_188, 0) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_163_000 picoseconds. - Weight::from_parts(1_999_458, 0) - // Standard Error: 1_418 - .saturating_add(Weight::from_parts(2_371_979, 0).saturating_mul(r.into())) + // Minimum execution time: 2_201_000 picoseconds. + Weight::from_parts(3_375_851, 0) + // Standard Error: 96 + .saturating_add(Weight::from_parts(22_970, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_call_indirect(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_288_000 picoseconds. - Weight::from_parts(2_340_227, 0) - // Standard Error: 3_234 - .saturating_add(Weight::from_parts(3_038_523, 0).saturating_mul(r.into())) - } - /// The range of component `p` is `[0, 128]`. - fn instr_call_indirect_per_param(p: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 5_270_000 picoseconds. - Weight::from_parts(6_360_011, 0) - // Standard Error: 2_585 - .saturating_add(Weight::from_parts(226_149, 0).saturating_mul(p.into())) + // Minimum execution time: 1_286_000 picoseconds. + Weight::from_parts(2_817_725, 0) + // Standard Error: 55 + .saturating_add(Weight::from_parts(29_437, 0).saturating_mul(r.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_580_000 picoseconds. - Weight::from_parts(5_183_658, 0) - // Standard Error: 80 - .saturating_add(Weight::from_parts(46_038, 0).saturating_mul(l.into())) + // Minimum execution time: 1_319_000 picoseconds. + Weight::from_parts(1_636_286, 0) + // Standard Error: 31 + .saturating_add(Weight::from_parts(1_240, 0).saturating_mul(l.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_local_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_559_000 picoseconds. - Weight::from_parts(2_846_350, 0) - // Standard Error: 2_809 - .saturating_add(Weight::from_parts(462_084, 0).saturating_mul(r.into())) + // Minimum execution time: 2_507_000 picoseconds. + Weight::from_parts(2_785_119, 0) + // Standard Error: 1 + .saturating_add(Weight::from_parts(4_601, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_local_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_530_000 picoseconds. - Weight::from_parts(2_835_072, 0) - // Standard Error: 479 - .saturating_add(Weight::from_parts(483_451, 0).saturating_mul(r.into())) + // Minimum execution time: 2_494_000 picoseconds. + Weight::from_parts(2_948_015, 0) + // Standard Error: 14 + .saturating_add(Weight::from_parts(4_788, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_local_tee(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_510_000 picoseconds. - Weight::from_parts(2_740_081, 0) - // Standard Error: 901 - .saturating_add(Weight::from_parts(664_354, 0).saturating_mul(r.into())) + // Minimum execution time: 2_443_000 picoseconds. + Weight::from_parts(3_065_273, 0) + // Standard Error: 15 + .saturating_add(Weight::from_parts(6_489, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_global_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_295_000 picoseconds. - Weight::from_parts(1_798_174, 0) - // Standard Error: 464 - .saturating_add(Weight::from_parts(896_289, 0).saturating_mul(r.into())) + // Minimum execution time: 1_214_000 picoseconds. + Weight::from_parts(1_634_049, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(8_960, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_global_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_287_000 picoseconds. - Weight::from_parts(1_636_548, 0) - // Standard Error: 658 - .saturating_add(Weight::from_parts(923_295, 0).saturating_mul(r.into())) + // Minimum execution time: 1_180_000 picoseconds. + Weight::from_parts(1_555_599, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_205, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_memory_current(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_353_000 picoseconds. - Weight::from_parts(1_672_309, 0) - // Standard Error: 403 - .saturating_add(Weight::from_parts(818_273, 0).saturating_mul(r.into())) + // Minimum execution time: 1_223_000 picoseconds. + Weight::from_parts(1_626_002, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(8_181, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 1]`. + /// The range of component `r` is `[0, 16]`. fn instr_memory_grow(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_180_000 picoseconds. - Weight::from_parts(1_304_714, 0) - // Standard Error: 88_180 - .saturating_add(Weight::from_parts(183_952_985, 0).saturating_mul(r.into())) + // Minimum execution time: 1_148_000 picoseconds. + Weight::from_parts(307_155, 0) + // Standard Error: 138_541 + .saturating_add(Weight::from_parts(13_291_570, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64clz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_158_000 picoseconds. - Weight::from_parts(1_800_065, 0) - // Standard Error: 2_104 - .saturating_add(Weight::from_parts(625_410, 0).saturating_mul(r.into())) + // Minimum execution time: 1_079_000 picoseconds. + Weight::from_parts(1_372_409, 0) + // Standard Error: 50 + .saturating_add(Weight::from_parts(6_427, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64ctz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_208_000 picoseconds. - Weight::from_parts(1_483_908, 0) - // Standard Error: 319 - .saturating_add(Weight::from_parts(635_095, 0).saturating_mul(r.into())) + // Minimum execution time: 1_116_000 picoseconds. + Weight::from_parts(1_415_180, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_353, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64popcnt(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_164_000 picoseconds. - Weight::from_parts(1_506_871, 0) - // Standard Error: 264 - .saturating_add(Weight::from_parts(633_660, 0).saturating_mul(r.into())) + // Minimum execution time: 1_058_000 picoseconds. + Weight::from_parts(1_314_206, 0) + // Standard Error: 35 + .saturating_add(Weight::from_parts(6_431, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64eqz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_141_000 picoseconds. - Weight::from_parts(1_467_219, 0) - // Standard Error: 191 - .saturating_add(Weight::from_parts(651_156, 0).saturating_mul(r.into())) + // Minimum execution time: 1_059_000 picoseconds. + Weight::from_parts(1_455_331, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_507, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64extendsi32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_170_000 picoseconds. - Weight::from_parts(1_474_718, 0) - // Standard Error: 224 - .saturating_add(Weight::from_parts(617_317, 0).saturating_mul(r.into())) + // Minimum execution time: 1_057_000 picoseconds. + Weight::from_parts(1_421_085, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_177, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64extendui32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_195_000 picoseconds. - Weight::from_parts(1_501_421, 0) - // Standard Error: 221 - .saturating_add(Weight::from_parts(616_559, 0).saturating_mul(r.into())) + // Minimum execution time: 1_079_000 picoseconds. + Weight::from_parts(1_429_275, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_175, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i32wrapi64(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_172_000 picoseconds. - Weight::from_parts(1_482_402, 0) - // Standard Error: 2_163 - .saturating_add(Weight::from_parts(619_230, 0).saturating_mul(r.into())) + // Minimum execution time: 1_065_000 picoseconds. + Weight::from_parts(1_403_813, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(6_192, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64eq(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_149_000 picoseconds. - Weight::from_parts(2_021_801, 0) - // Standard Error: 20_804 - .saturating_add(Weight::from_parts(913_888, 0).saturating_mul(r.into())) + // Minimum execution time: 1_061_000 picoseconds. + Weight::from_parts(1_421_984, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_094, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64ne(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_187_000 picoseconds. - Weight::from_parts(1_358_437, 0) - // Standard Error: 1_946 - .saturating_add(Weight::from_parts(916_378, 0).saturating_mul(r.into())) + // Minimum execution time: 1_075_000 picoseconds. + Weight::from_parts(1_431_453, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(9_084, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64lts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_175_000 picoseconds. - Weight::from_parts(1_527_336, 0) - // Standard Error: 243 - .saturating_add(Weight::from_parts(907_580, 0).saturating_mul(r.into())) + // Minimum execution time: 1_100_000 picoseconds. + Weight::from_parts(1_452_384, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(9_081, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64ltu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_220_000 picoseconds. - Weight::from_parts(1_530_715, 0) - // Standard Error: 224 - .saturating_add(Weight::from_parts(906_096, 0).saturating_mul(r.into())) + // Minimum execution time: 1_090_000 picoseconds. + Weight::from_parts(1_466_416, 0) + // Standard Error: 17 + .saturating_add(Weight::from_parts(9_091, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64gts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_107_000 picoseconds. - Weight::from_parts(1_496_553, 0) - // Standard Error: 299 - .saturating_add(Weight::from_parts(907_963, 0).saturating_mul(r.into())) + // Minimum execution time: 1_056_000 picoseconds. + Weight::from_parts(1_676_091, 0) + // Standard Error: 47 + .saturating_add(Weight::from_parts(9_082, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64gtu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_153_000 picoseconds. - Weight::from_parts(1_482_710, 0) - // Standard Error: 182 - .saturating_add(Weight::from_parts(918_439, 0).saturating_mul(r.into())) + // Minimum execution time: 1_053_000 picoseconds. + Weight::from_parts(1_232_790, 0) + // Standard Error: 43 + .saturating_add(Weight::from_parts(9_329, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64les(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_142_000 picoseconds. - Weight::from_parts(1_522_114, 0) - // Standard Error: 297 - .saturating_add(Weight::from_parts(906_633, 0).saturating_mul(r.into())) + // Minimum execution time: 1_091_000 picoseconds. + Weight::from_parts(1_476_212, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_074, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64leu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_119_000 picoseconds. - Weight::from_parts(2_199_831, 0) - // Standard Error: 4_234 - .saturating_add(Weight::from_parts(898_161, 0).saturating_mul(r.into())) + // Minimum execution time: 1_083_000 picoseconds. + Weight::from_parts(1_484_966, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(9_184, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64ges(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_163_000 picoseconds. - Weight::from_parts(1_489_404, 0) - // Standard Error: 416 - .saturating_add(Weight::from_parts(908_450, 0).saturating_mul(r.into())) + // Minimum execution time: 1_089_000 picoseconds. + Weight::from_parts(1_516_766, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_063, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64geu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_204_000 picoseconds. - Weight::from_parts(2_266_296, 0) - // Standard Error: 13_013 - .saturating_add(Weight::from_parts(899_225, 0).saturating_mul(r.into())) + // Minimum execution time: 996_000 picoseconds. + Weight::from_parts(1_460_638, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(9_076, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64add(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_160_000 picoseconds. - Weight::from_parts(1_470_799, 0) - // Standard Error: 422 - .saturating_add(Weight::from_parts(897_325, 0).saturating_mul(r.into())) + // Minimum execution time: 1_095_000 picoseconds. + Weight::from_parts(1_448_412, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(8_977, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64sub(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_125_000 picoseconds. - Weight::from_parts(1_521_508, 0) - // Standard Error: 594 - .saturating_add(Weight::from_parts(886_145, 0).saturating_mul(r.into())) + // Minimum execution time: 1_071_000 picoseconds. + Weight::from_parts(1_459_165, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(8_852, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64mul(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_139_000 picoseconds. - Weight::from_parts(1_490_535, 0) - // Standard Error: 211 - .saturating_add(Weight::from_parts(884_929, 0).saturating_mul(r.into())) + // Minimum execution time: 1_082_000 picoseconds. + Weight::from_parts(1_450_718, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(8_860, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64divs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_180_000 picoseconds. - Weight::from_parts(2_221_481, 0) - // Standard Error: 9_884 - .saturating_add(Weight::from_parts(1_507_511, 0).saturating_mul(r.into())) + // Minimum execution time: 1_065_000 picoseconds. + Weight::from_parts(1_436_871, 0) + // Standard Error: 9 + .saturating_add(Weight::from_parts(15_241, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64divu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_131_000 picoseconds. - Weight::from_parts(1_498_652, 0) - // Standard Error: 531 - .saturating_add(Weight::from_parts(1_451_498, 0).saturating_mul(r.into())) + // Minimum execution time: 1_065_000 picoseconds. + Weight::from_parts(1_423_806, 0) + // Standard Error: 17 + .saturating_add(Weight::from_parts(14_706, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64rems(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_145_000 picoseconds. - Weight::from_parts(1_504_118, 0) - // Standard Error: 439 - .saturating_add(Weight::from_parts(1_521_895, 0).saturating_mul(r.into())) + // Minimum execution time: 1_059_000 picoseconds. + Weight::from_parts(1_735_816, 0) + // Standard Error: 66 + .saturating_add(Weight::from_parts(15_230, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64remu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_124_000 picoseconds. - Weight::from_parts(1_497_209, 0) - // Standard Error: 198 - .saturating_add(Weight::from_parts(1_449_843, 0).saturating_mul(r.into())) + // Minimum execution time: 1_076_000 picoseconds. + Weight::from_parts(1_451_290, 0) + // Standard Error: 6 + .saturating_add(Weight::from_parts(14_530, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64and(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_169_000 picoseconds. - Weight::from_parts(1_534_491, 0) - // Standard Error: 283 - .saturating_add(Weight::from_parts(894_703, 0).saturating_mul(r.into())) + // Minimum execution time: 1_079_000 picoseconds. + Weight::from_parts(1_457_537, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(8_963, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64or(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_178_000 picoseconds. - Weight::from_parts(1_485_473, 0) - // Standard Error: 552 - .saturating_add(Weight::from_parts(897_878, 0).saturating_mul(r.into())) + // Minimum execution time: 1_032_000 picoseconds. + Weight::from_parts(1_475_315, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(8_956, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64xor(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_214_000 picoseconds. - Weight::from_parts(1_580_999, 0) - // Standard Error: 358 - .saturating_add(Weight::from_parts(894_207, 0).saturating_mul(r.into())) + // Minimum execution time: 1_056_000 picoseconds. + Weight::from_parts(1_450_071, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(8_960, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64shl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_176_000 picoseconds. - Weight::from_parts(1_490_470, 0) - // Standard Error: 738 - .saturating_add(Weight::from_parts(904_900, 0).saturating_mul(r.into())) + // Minimum execution time: 1_116_000 picoseconds. + Weight::from_parts(1_429_705, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(9_027, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64shrs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_197_000 picoseconds. - Weight::from_parts(1_519_703, 0) - // Standard Error: 336 - .saturating_add(Weight::from_parts(901_277, 0).saturating_mul(r.into())) + // Minimum execution time: 1_059_000 picoseconds. + Weight::from_parts(1_429_307, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_048, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64shru(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_166_000 picoseconds. - Weight::from_parts(1_507_499, 0) - // Standard Error: 298 - .saturating_add(Weight::from_parts(901_153, 0).saturating_mul(r.into())) + // Minimum execution time: 1_093_000 picoseconds. + Weight::from_parts(1_411_827, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_528, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64rotl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_158_000 picoseconds. - Weight::from_parts(1_491_176, 0) - // Standard Error: 341 - .saturating_add(Weight::from_parts(901_880, 0).saturating_mul(r.into())) + // Minimum execution time: 1_115_000 picoseconds. + Weight::from_parts(1_441_025, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_043, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 50]`. + /// The range of component `r` is `[0, 5000]`. fn instr_i64rotr(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_207_000 picoseconds. - Weight::from_parts(1_477_261, 0) - // Standard Error: 287 - .saturating_add(Weight::from_parts(902_622, 0).saturating_mul(r.into())) + // Minimum execution time: 1_077_000 picoseconds. + Weight::from_parts(1_480_666, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(9_031, 0).saturating_mul(r.into())) } } From a2d4f7dfa97c1496f964c6fe833d5128f8319c77 Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Fri, 17 Mar 2023 12:24:14 +0100 Subject: [PATCH 30/80] Keystore overhaul (#13615) * Remove 'supported_keys' 'sign_with_any' and 'sign_with_all' from keystore trait * Remove the aync keystore * Renaming: - SyncCryptoStore -> Keystore - SyncCryptoStorePtr -> KeystorePtr - KeyStore -> MemoryKeystore * Fix authority discovery worker and tests * Rename 'insert_unknown' to 'insert' * Remove leftover --- Cargo.lock | 1 - bin/node-template/node/src/service.rs | 9 +- bin/node/cli/src/service.rs | 17 +- bin/node/executor/tests/submit_transaction.rs | 22 +- bin/node/rpc/src/lib.rs | 4 +- bin/utils/chain-spec-builder/src/main.rs | 6 +- client/api/src/execution_extensions.rs | 6 +- client/authority-discovery/src/tests.rs | 5 +- client/authority-discovery/src/worker.rs | 38 ++- .../authority-discovery/src/worker/tests.rs | 86 +++--- client/cli/src/commands/insert_key.rs | 8 +- client/cli/src/error.rs | 2 +- client/consensus/aura/src/lib.rs | 18 +- client/consensus/babe/rpc/src/lib.rs | 17 +- client/consensus/babe/src/authorship.rs | 20 +- client/consensus/babe/src/lib.rs | 8 +- client/consensus/babe/src/tests.rs | 17 +- .../beefy/src/communication/gossip.rs | 6 +- client/consensus/beefy/src/keystore.rs | 33 ++- client/consensus/beefy/src/lib.rs | 4 +- client/consensus/beefy/src/tests.rs | 8 +- .../grandpa/src/communication/mod.rs | 10 +- client/consensus/grandpa/src/lib.rs | 12 +- client/consensus/grandpa/src/observer.rs | 6 +- client/consensus/grandpa/src/tests.rs | 12 +- .../manual-seal/src/consensus/babe.rs | 6 +- client/keystore/src/local.rs | 158 ++--------- client/rpc-api/src/author/error.rs | 2 +- client/rpc/src/author/mod.rs | 14 +- client/rpc/src/author/tests.rs | 12 +- client/service/src/builder.rs | 39 +-- client/service/src/client/client.rs | 6 +- frame/benchmarking/src/baseline.rs | 4 +- frame/contracts/src/tests.rs | 4 +- frame/examples/offchain-worker/src/tests.rs | 20 +- frame/nfts/src/mock.rs | 4 +- .../application-crypto/test/src/ecdsa.rs | 6 +- .../application-crypto/test/src/ed25519.rs | 6 +- .../application-crypto/test/src/sr25519.rs | 6 +- primitives/consensus/beefy/src/commitment.rs | 12 +- primitives/consensus/beefy/src/witness.rs | 12 +- primitives/consensus/grandpa/src/lib.rs | 6 +- primitives/io/src/lib.rs | 24 +- primitives/keystore/Cargo.toml | 1 - primitives/keystore/src/lib.rs | 250 +----------------- primitives/keystore/src/testing.rs | 156 ++--------- test-utils/client/src/lib.rs | 6 +- .../benchmarking-cli/src/pallet/command.rs | 4 +- utils/frame/try-runtime/cli/src/lib.rs | 4 +- 49 files changed, 317 insertions(+), 820 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0aea7729bd2d..9121a85919844 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10339,7 +10339,6 @@ dependencies = [ name = "sp-keystore" version = "0.13.0" dependencies = [ - "async-trait", "futures", "merlin", "parity-scale-codec", diff --git a/bin/node-template/node/src/service.rs b/bin/node-template/node/src/service.rs index 34e4e566d92fc..40ad80c7b3b79 100644 --- a/bin/node-template/node/src/service.rs +++ b/bin/node-template/node/src/service.rs @@ -150,7 +150,7 @@ pub fn new_partial( fn remote_keystore(_url: &String) -> Result, &'static str> { // FIXME: here would the concrete keystore be built, // must return a concrete type (NOT `LocalKeystore`) that - // implements `CryptoStore` and `SyncCryptoStore` + // implements `Keystore` Err("Remote Keystore not supported.") } @@ -233,7 +233,7 @@ pub fn new_full(mut config: Configuration) -> Result let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams { network: network.clone(), client: client.clone(), - keystore: keystore_container.sync_keystore(), + keystore: keystore_container.keystore(), task_manager: &mut task_manager, transaction_pool: transaction_pool.clone(), rpc_builder: rpc_extensions_builder, @@ -276,7 +276,7 @@ pub fn new_full(mut config: Configuration) -> Result }, force_authoring, backoff_authoring_blocks, - keystore: keystore_container.sync_keystore(), + keystore: keystore_container.keystore(), sync_oracle: sync_service.clone(), justification_sync_link: sync_service.clone(), block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32), @@ -296,8 +296,7 @@ pub fn new_full(mut config: Configuration) -> Result if enable_grandpa { // if the node isn't actively participating in consensus then it doesn't // need a keystore, regardless of which protocol we use below. - let keystore = - if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None }; + let keystore = if role.is_authority() { Some(keystore_container.keystore()) } else { None }; let grandpa_config = sc_consensus_grandpa::Config { // FIXME #1578 make this available through chainspec diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index 3c9716c08d1c0..a2d66cd6349de 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -251,7 +251,7 @@ pub fn new_partial( let client = client.clone(); let pool = transaction_pool.clone(); let select_chain = select_chain.clone(); - let keystore = keystore_container.sync_keystore(); + let keystore = keystore_container.keystore(); let chain_spec = config.chain_spec.cloned_box(); let rpc_backend = backend.clone(); @@ -386,7 +386,7 @@ pub fn new_full_base( config, backend, client: client.clone(), - keystore: keystore_container.sync_keystore(), + keystore: keystore_container.keystore(), network: network.clone(), rpc_builder: Box::new(rpc_builder), transaction_pool: transaction_pool.clone(), @@ -431,7 +431,7 @@ pub fn new_full_base( let client_clone = client.clone(); let slot_duration = babe_link.config().slot_duration(); let babe_config = sc_consensus_babe::BabeParams { - keystore: keystore_container.sync_keystore(), + keystore: keystore_container.keystore(), client: client.clone(), select_chain, env: proposer, @@ -507,8 +507,7 @@ pub fn new_full_base( // if the node isn't actively participating in consensus then it doesn't // need a keystore, regardless of which protocol we use below. - let keystore = - if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None }; + let keystore = if role.is_authority() { Some(keystore_container.keystore()) } else { None }; let config = grandpa::Config { // FIXME #1578 make this available through chainspec @@ -596,7 +595,7 @@ mod tests { use sp_core::{crypto::Pair as CryptoPair, Public}; use sp_inherents::InherentDataProvider; use sp_keyring::AccountKeyring; - use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; + use sp_keystore::{Keystore, KeystorePtr}; use sp_runtime::{ generic::{Digest, Era, SignedPayload}, key_types::BABE, @@ -616,10 +615,10 @@ mod tests { sp_tracing::try_init_simple(); let keystore_path = tempfile::tempdir().expect("Creates keystore path"); - let keystore: SyncCryptoStorePtr = + let keystore: KeystorePtr = Arc::new(LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore")); let alice: sp_consensus_babe::AuthorityId = - SyncCryptoStore::sr25519_generate_new(&*keystore, BABE, Some("//Alice")) + Keystore::sr25519_generate_new(&*keystore, BABE, Some("//Alice")) .expect("Creates authority pair") .into(); @@ -736,7 +735,7 @@ mod tests { // sign the pre-sealed hash of the block and then // add it to a digest item. let to_sign = pre_hash.encode(); - let signature = SyncCryptoStore::sign_with( + let signature = Keystore::sign_with( &*keystore, sp_consensus_babe::AuthorityId::ID, &alice.to_public_crypto_pair(), diff --git a/bin/node/executor/tests/submit_transaction.rs b/bin/node/executor/tests/submit_transaction.rs index ab5df62a2e714..32eacd78b78b7 100644 --- a/bin/node/executor/tests/submit_transaction.rs +++ b/bin/node/executor/tests/submit_transaction.rs @@ -21,7 +21,7 @@ use kitchensink_runtime::{Executive, Indices, Runtime, UncheckedExtrinsic}; use sp_application_crypto::AppKey; use sp_core::offchain::{testing::TestTransactionPoolExt, TransactionPoolExt}; use sp_keyring::sr25519::Keyring::Alice; -use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStore}; +use sp_keystore::{testing::MemoryKeystore, Keystore, KeystoreExt}; use std::sync::Arc; pub mod common; @@ -62,20 +62,20 @@ fn should_submit_signed_transaction() { let (pool, state) = TestTransactionPoolExt::new(); t.register_extension(TransactionPoolExt::new(pool)); - let keystore = KeyStore::new(); - SyncCryptoStore::sr25519_generate_new( + let keystore = MemoryKeystore::new(); + Keystore::sr25519_generate_new( &keystore, sr25519::AuthorityId::ID, Some(&format!("{}/hunter1", PHRASE)), ) .unwrap(); - SyncCryptoStore::sr25519_generate_new( + Keystore::sr25519_generate_new( &keystore, sr25519::AuthorityId::ID, Some(&format!("{}/hunter2", PHRASE)), ) .unwrap(); - SyncCryptoStore::sr25519_generate_new( + Keystore::sr25519_generate_new( &keystore, sr25519::AuthorityId::ID, Some(&format!("{}/hunter3", PHRASE)), @@ -105,14 +105,14 @@ fn should_submit_signed_twice_from_the_same_account() { let (pool, state) = TestTransactionPoolExt::new(); t.register_extension(TransactionPoolExt::new(pool)); - let keystore = KeyStore::new(); - SyncCryptoStore::sr25519_generate_new( + let keystore = MemoryKeystore::new(); + Keystore::sr25519_generate_new( &keystore, sr25519::AuthorityId::ID, Some(&format!("{}/hunter1", PHRASE)), ) .unwrap(); - SyncCryptoStore::sr25519_generate_new( + Keystore::sr25519_generate_new( &keystore, sr25519::AuthorityId::ID, Some(&format!("{}/hunter2", PHRASE)), @@ -162,7 +162,7 @@ fn should_submit_signed_twice_from_all_accounts() { let (pool, state) = TestTransactionPoolExt::new(); t.register_extension(TransactionPoolExt::new(pool)); - let keystore = KeyStore::new(); + let keystore = MemoryKeystore::new(); keystore .sr25519_generate_new(sr25519::AuthorityId::ID, Some(&format!("{}/hunter1", PHRASE))) .unwrap(); @@ -226,8 +226,8 @@ fn submitted_transaction_should_be_valid() { let (pool, state) = TestTransactionPoolExt::new(); t.register_extension(TransactionPoolExt::new(pool)); - let keystore = KeyStore::new(); - SyncCryptoStore::sr25519_generate_new( + let keystore = MemoryKeystore::new(); + Keystore::sr25519_generate_new( &keystore, sr25519::AuthorityId::ID, Some(&format!("{}/hunter1", PHRASE)), diff --git a/bin/node/rpc/src/lib.rs b/bin/node/rpc/src/lib.rs index 7c2f7c15e05c8..9dcdf0f218923 100644 --- a/bin/node/rpc/src/lib.rs +++ b/bin/node/rpc/src/lib.rs @@ -49,7 +49,7 @@ use sp_block_builder::BlockBuilder; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; use sp_consensus::SelectChain; use sp_consensus_babe::BabeApi; -use sp_keystore::SyncCryptoStorePtr; +use sp_keystore::KeystorePtr; /// Extra dependencies for BABE. pub struct BabeDeps { @@ -58,7 +58,7 @@ pub struct BabeDeps { /// BABE pending epoch changes. pub shared_epoch_changes: SharedEpochChanges, /// The keystore that manages the keys of the node. - pub keystore: SyncCryptoStorePtr, + pub keystore: KeystorePtr, } /// Extra dependencies for GRANDPA diff --git a/bin/utils/chain-spec-builder/src/main.rs b/bin/utils/chain-spec-builder/src/main.rs index b3f28b269fddd..f7b7d94c57d1c 100644 --- a/bin/utils/chain-spec-builder/src/main.rs +++ b/bin/utils/chain-spec-builder/src/main.rs @@ -32,7 +32,7 @@ use sp_core::{ crypto::{ByteArray, Ss58Codec}, sr25519, }; -use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{Keystore, KeystorePtr}; /// A utility to easily create a testnet chain spec definition with a given set /// of authorities and endowed accounts and/or generate random accounts. @@ -164,7 +164,7 @@ fn generate_chain_spec( fn generate_authority_keys_and_store(seeds: &[String], keystore_path: &Path) -> Result<(), String> { for (n, seed) in seeds.iter().enumerate() { - let keystore: SyncCryptoStorePtr = Arc::new( + let keystore: KeystorePtr = Arc::new( LocalKeystore::open(keystore_path.join(format!("auth-{}", n)), None) .map_err(|err| err.to_string())?, ); @@ -173,7 +173,7 @@ fn generate_authority_keys_and_store(seeds: &[String], keystore_path: &Path) -> chain_spec::authority_keys_from_seed(seed); let insert_key = |key_type, public| { - SyncCryptoStore::insert_unknown(&*keystore, key_type, &format!("//{}", seed), public) + Keystore::insert(&*keystore, key_type, &format!("//{}", seed), public) .map_err(|_| format!("Failed to insert key: {}", grandpa)) }; diff --git a/client/api/src/execution_extensions.rs b/client/api/src/execution_extensions.rs index b491d7672e8f0..ffa670f7bc628 100644 --- a/client/api/src/execution_extensions.rs +++ b/client/api/src/execution_extensions.rs @@ -30,7 +30,7 @@ use sp_core::{ ExecutionContext, }; use sp_externalities::{Extension, Extensions}; -use sp_keystore::{KeystoreExt, SyncCryptoStorePtr}; +use sp_keystore::{KeystoreExt, KeystorePtr}; use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, NumberFor}, @@ -163,7 +163,7 @@ impl DbExternaliti /// for each call, based on required `Capabilities`. pub struct ExecutionExtensions { strategies: ExecutionStrategies, - keystore: Option, + keystore: Option, offchain_db: Option>, // FIXME: these two are only RwLock because of https://github.com/paritytech/substrate/issues/4587 // remove when fixed. @@ -191,7 +191,7 @@ impl ExecutionExtensions { /// Create new `ExecutionExtensions` given a `keystore` and `ExecutionStrategies`. pub fn new( strategies: ExecutionStrategies, - keystore: Option, + keystore: Option, offchain_db: Option>, ) -> Self { let transaction_pool = RwLock::new(None); diff --git a/client/authority-discovery/src/tests.rs b/client/authority-discovery/src/tests.rs index 982c3fc04c590..d354f6a963e73 100644 --- a/client/authority-discovery/src/tests.rs +++ b/client/authority-discovery/src/tests.rs @@ -33,7 +33,7 @@ use std::{collections::HashSet, sync::Arc}; use sp_authority_discovery::AuthorityId; use sp_core::crypto::key_types; -use sp_keystore::{testing::KeyStore, CryptoStore}; +use sp_keystore::{testing::MemoryKeystore, Keystore}; #[test] fn get_addresses_and_authority_id() { @@ -42,12 +42,11 @@ fn get_addresses_and_authority_id() { let mut pool = LocalPool::new(); - let key_store = KeyStore::new(); + let key_store = MemoryKeystore::new(); let remote_authority_id: AuthorityId = pool.run_until(async { key_store .sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None) - .await .unwrap() .into() }); diff --git a/client/authority-discovery/src/worker.rs b/client/authority-discovery/src/worker.rs index 034d72902e65d..5d7d21a5b6de4 100644 --- a/client/authority-discovery/src/worker.rs +++ b/client/authority-discovery/src/worker.rs @@ -53,7 +53,7 @@ use sp_authority_discovery::{ use sp_blockchain::HeaderBackend; use sp_core::crypto::{key_types, CryptoTypePublicPair, Pair}; -use sp_keystore::CryptoStore; +use sp_keystore::{Keystore, KeystorePtr}; use sp_runtime::traits::Block as BlockT; mod addr_cache; @@ -78,7 +78,7 @@ const MAX_IN_FLIGHT_LOOKUPS: usize = 8; /// Role an authority discovery [`Worker`] can run as. pub enum Role { /// Publish own addresses and discover addresses of others. - PublishAndDiscover(Arc), + PublishAndDiscover(KeystorePtr), /// Discover addresses of others. Discover, } @@ -364,8 +364,7 @@ where Some(peer_signature), key_store.as_ref(), keys_vec, - ) - .await?; + )?; for (key, value) in kv_pairs.into_iter() { self.network.put_value(key, value); @@ -382,7 +381,6 @@ where let local_keys = match &self.role { Role::PublishAndDiscover(key_store) => key_store .sr25519_public_keys(key_types::AUTHORITY_DISCOVERY) - .await .into_iter() .collect::>(), Role::Discover => HashSet::new(), @@ -588,12 +586,11 @@ where // next authority set with two keys. The function does not return all of the local authority // discovery public keys, but only the ones intersecting with the current or next authority set. async fn get_own_public_keys_within_authority_set( - key_store: Arc, + key_store: KeystorePtr, client: &Client, ) -> Result> { let local_pub_keys = key_store .sr25519_public_keys(key_types::AUTHORITY_DISCOVERY) - .await .into_iter() .collect::>(); @@ -663,33 +660,28 @@ fn sign_record_with_peer_id( Ok(schema::PeerSignature { signature, public_key }) } -async fn sign_record_with_authority_ids( +fn sign_record_with_authority_ids( serialized_record: Vec, peer_signature: Option, - key_store: &dyn CryptoStore, + key_store: &dyn Keystore, keys: Vec, ) -> Result)>> { - let signatures = key_store - .sign_with_all(key_types::AUTHORITY_DISCOVERY, keys.clone(), &serialized_record) - .await - .map_err(|_| Error::Signing)?; + let mut result = Vec::with_capacity(keys.len()); - let mut result = vec![]; - for (sign_result, key) in signatures.into_iter().zip(keys.iter()) { - let mut signed_record = vec![]; + for key in keys.iter() { + let auth_signature = key_store + .sign_with(key_types::AUTHORITY_DISCOVERY, key, &serialized_record) + .map_err(|_| Error::Signing)? + .ok_or_else(|| Error::MissingSignature(key.clone()))?; - // Verify that all signatures exist for all provided keys. - let auth_signature = - sign_result.ok().flatten().ok_or_else(|| Error::MissingSignature(key.clone()))?; - schema::SignedAuthorityRecord { + let signed_record = schema::SignedAuthorityRecord { record: serialized_record.clone(), auth_signature, peer_signature: peer_signature.clone(), } - .encode(&mut signed_record) - .map_err(Error::EncodingProto)?; + .encode_to_vec(); - result.push((hash_authority_id(key.1.as_ref()), signed_record)); + result.push((hash_authority_id(&key.1), signed_record)); } Ok(result) diff --git a/client/authority-discovery/src/worker/tests.rs b/client/authority-discovery/src/worker/tests.rs index febe40657e06a..c918d79932624 100644 --- a/client/authority-discovery/src/worker/tests.rs +++ b/client/authority-discovery/src/worker/tests.rs @@ -40,7 +40,7 @@ use prometheus_endpoint::prometheus::default_registry; use sc_client_api::HeaderBackend; use sc_network::Signature; use sp_api::{ApiRef, ProvideRuntimeApi}; -use sp_keystore::{testing::KeyStore, CryptoStore}; +use sp_keystore::{testing::MemoryKeystore, Keystore}; use sp_runtime::traits::{Block as BlockT, NumberFor, Zero}; use substrate_test_runtime_client::runtime::Block; @@ -208,10 +208,10 @@ impl<'a> NetworkSigner for TestSigner<'a> { } } -async fn build_dht_event( +fn build_dht_event( addresses: Vec, public_key: AuthorityId, - key_store: &dyn CryptoStore, + key_store: &MemoryKeystore, network: Option<&Signer>, ) -> Vec<(KademliaKey, Vec)> { let serialized_record = @@ -224,7 +224,6 @@ async fn build_dht_event( key_store, vec![public_key.into()], ) - .await .unwrap(); // There is always a single item in it, because we signed it with a single key kv_pairs @@ -234,7 +233,7 @@ async fn build_dht_event( fn new_registers_metrics() { let (_dht_event_tx, dht_event_rx) = mpsc::channel(1000); let network: Arc = Arc::new(Default::default()); - let key_store = KeyStore::new(); + let key_store = MemoryKeystore::new(); let test_api = Arc::new(TestApi { authorities: vec![] }); let registry = prometheus_endpoint::Registry::new(); @@ -266,7 +265,7 @@ fn triggers_dht_get_query() { let test_api = Arc::new(TestApi { authorities: authorities.clone() }); let network = Arc::new(TestNetwork::default()); - let key_store = KeyStore::new(); + let key_store = MemoryKeystore::new(); let (_to_worker, from_service) = mpsc::channel(0); let mut worker = Worker::new( @@ -298,14 +297,12 @@ fn publish_discover_cycle() { let network: Arc = Arc::new(Default::default()); - let key_store = KeyStore::new(); + let key_store = MemoryKeystore::new(); let _ = pool.spawner().spawn_local_obj( async move { - let node_a_public = key_store - .sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None) - .await - .unwrap(); + let node_a_public = + key_store.sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None).unwrap(); let test_api = Arc::new(TestApi { authorities: vec![node_a_public.into()] }); let (_to_worker, from_service) = mpsc::channel(0); @@ -337,7 +334,7 @@ fn publish_discover_cycle() { authorities: vec![node_a_public.into()], }); let network: Arc = Arc::new(Default::default()); - let key_store = KeyStore::new(); + let key_store = MemoryKeystore::new(); let (_to_worker, from_service) = mpsc::channel(0); let mut worker = Worker::new( @@ -371,7 +368,7 @@ fn publish_discover_cycle() { fn terminate_when_event_stream_terminates() { let (dht_event_tx, dht_event_rx) = channel(1000); let network: Arc = Arc::new(Default::default()); - let key_store = KeyStore::new(); + let key_store = MemoryKeystore::new(); let test_api = Arc::new(TestApi { authorities: vec![] }); let (to_worker, from_service) = mpsc::channel(0); @@ -420,11 +417,11 @@ fn dont_stop_polling_dht_event_stream_after_bogus_event() { address.with(multiaddr::Protocol::P2p(peer_id.into())) }; - let remote_key_store = KeyStore::new(); - let remote_public_key: AuthorityId = - block_on(remote_key_store.sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None)) - .unwrap() - .into(); + let remote_key_store = MemoryKeystore::new(); + let remote_public_key: AuthorityId = remote_key_store + .sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None) + .unwrap() + .into(); let (mut dht_event_tx, dht_event_rx) = channel(1); let (network, mut network_events) = { @@ -433,7 +430,7 @@ fn dont_stop_polling_dht_event_stream_after_bogus_event() { (Arc::new(n), r) }; - let key_store = KeyStore::new(); + let key_store = MemoryKeystore::new(); let test_api = Arc::new(TestApi { authorities: vec![remote_public_key.clone()] }); let mut pool = LocalPool::new(); @@ -480,8 +477,7 @@ fn dont_stop_polling_dht_event_stream_after_bogus_event() { remote_public_key.clone(), &remote_key_store, None, - ) - .await; + ); DhtEvent::ValueFound(kv_pairs) }; dht_event_tx.send(dht_event).await.expect("Channel has capacity of 1."); @@ -498,7 +494,7 @@ fn dont_stop_polling_dht_event_stream_after_bogus_event() { } struct DhtValueFoundTester { - pub remote_key_store: KeyStore, + pub remote_key_store: MemoryKeystore, pub remote_authority_public: sp_core::sr25519::Public, pub remote_node_key: Keypair, pub local_worker: Option< @@ -516,10 +512,10 @@ struct DhtValueFoundTester { impl DhtValueFoundTester { fn new() -> Self { - let remote_key_store = KeyStore::new(); - let remote_authority_public = - block_on(remote_key_store.sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None)) - .unwrap(); + let remote_key_store = MemoryKeystore::new(); + let remote_authority_public = remote_key_store + .sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None) + .unwrap(); let remote_node_key = Keypair::generate_ed25519(); Self { remote_key_store, remote_authority_public, remote_node_key, local_worker: None } @@ -542,7 +538,7 @@ impl DhtValueFoundTester { let local_test_api = Arc::new(TestApi { authorities: vec![self.remote_authority_public.into()] }); let local_network: Arc = Arc::new(Default::default()); - let local_key_store = KeyStore::new(); + let local_key_store = MemoryKeystore::new(); let (_to_worker, from_service) = mpsc::channel(0); let mut local_worker = Worker::new( @@ -576,12 +572,12 @@ fn limit_number_of_addresses_added_to_cache_per_authority() { let mut tester = DhtValueFoundTester::new(); assert!(MAX_ADDRESSES_PER_AUTHORITY < 100); let addresses = (1..100).map(|i| tester.multiaddr_with_peer_id(i)).collect(); - let kv_pairs = block_on(build_dht_event::( + let kv_pairs = build_dht_event::( addresses, tester.remote_authority_public.into(), &tester.remote_key_store, None, - )); + ); let cached_remote_addresses = tester.process_value_found(false, kv_pairs); assert_eq!(MAX_ADDRESSES_PER_AUTHORITY, cached_remote_addresses.unwrap().len()); @@ -591,12 +587,12 @@ fn limit_number_of_addresses_added_to_cache_per_authority() { fn strict_accept_address_with_peer_signature() { let mut tester = DhtValueFoundTester::new(); let addr = tester.multiaddr_with_peer_id(1); - let kv_pairs = block_on(build_dht_event( + let kv_pairs = build_dht_event( vec![addr.clone()], tester.remote_authority_public.into(), &tester.remote_key_store, Some(&TestSigner { keypair: &tester.remote_node_key }), - )); + ); let cached_remote_addresses = tester.process_value_found(true, kv_pairs); @@ -611,12 +607,12 @@ fn strict_accept_address_with_peer_signature() { fn reject_address_with_rogue_peer_signature() { let mut tester = DhtValueFoundTester::new(); let rogue_remote_node_key = Keypair::generate_ed25519(); - let kv_pairs = block_on(build_dht_event( + let kv_pairs = build_dht_event( vec![tester.multiaddr_with_peer_id(1)], tester.remote_authority_public.into(), &tester.remote_key_store, Some(&TestSigner { keypair: &rogue_remote_node_key }), - )); + ); let cached_remote_addresses = tester.process_value_found(false, kv_pairs); @@ -629,12 +625,12 @@ fn reject_address_with_rogue_peer_signature() { #[test] fn reject_address_with_invalid_peer_signature() { let mut tester = DhtValueFoundTester::new(); - let mut kv_pairs = block_on(build_dht_event( + let mut kv_pairs = build_dht_event( vec![tester.multiaddr_with_peer_id(1)], tester.remote_authority_public.into(), &tester.remote_key_store, Some(&TestSigner { keypair: &tester.remote_node_key }), - )); + ); // tamper with the signature let mut record = schema::SignedAuthorityRecord::decode(kv_pairs[0].1.as_slice()).unwrap(); record.peer_signature.as_mut().map(|p| p.signature[1] = !p.signature[1]); @@ -651,12 +647,12 @@ fn reject_address_with_invalid_peer_signature() { #[test] fn reject_address_without_peer_signature() { let mut tester = DhtValueFoundTester::new(); - let kv_pairs = block_on(build_dht_event::( + let kv_pairs = build_dht_event::( vec![tester.multiaddr_with_peer_id(1)], tester.remote_authority_public.into(), &tester.remote_key_store, None, - )); + ); let cached_remote_addresses = tester.process_value_found(true, kv_pairs); @@ -669,12 +665,12 @@ fn do_not_cache_addresses_without_peer_id() { let multiaddr_with_peer_id = tester.multiaddr_with_peer_id(1); let multiaddr_without_peer_id: Multiaddr = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333".parse().unwrap(); - let kv_pairs = block_on(build_dht_event::( + let kv_pairs = build_dht_event::( vec![multiaddr_with_peer_id.clone(), multiaddr_without_peer_id], tester.remote_authority_public.into(), &tester.remote_key_store, None, - )); + ); let cached_remote_addresses = tester.process_value_found(false, kv_pairs); @@ -701,7 +697,7 @@ fn addresses_to_publish_adds_p2p() { Arc::new(TestApi { authorities: vec![] }), network.clone(), Box::pin(dht_event_rx), - Role::PublishAndDiscover(Arc::new(KeyStore::new())), + Role::PublishAndDiscover(Arc::new(MemoryKeystore::new())), Some(prometheus_endpoint::Registry::new()), Default::default(), ); @@ -735,7 +731,7 @@ fn addresses_to_publish_respects_existing_p2p_protocol() { Arc::new(TestApi { authorities: vec![] }), network.clone(), Box::pin(dht_event_rx), - Role::PublishAndDiscover(Arc::new(KeyStore::new())), + Role::PublishAndDiscover(Arc::new(MemoryKeystore::new())), Some(prometheus_endpoint::Registry::new()), Default::default(), ); @@ -755,10 +751,11 @@ fn lookup_throttling() { address.with(multiaddr::Protocol::P2p(peer_id.into())) }; - let remote_key_store = KeyStore::new(); + let remote_key_store = MemoryKeystore::new(); let remote_public_keys: Vec = (0..20) .map(|_| { - block_on(remote_key_store.sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None)) + remote_key_store + .sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None) .unwrap() .into() }) @@ -818,8 +815,7 @@ fn lookup_throttling() { remote_key, &remote_key_store, None, - ) - .await; + ); DhtEvent::ValueFound(kv_pairs) }; dht_event_tx.send(dht_event).await.expect("Channel has capacity of 1."); diff --git a/client/cli/src/commands/insert_key.rs b/client/cli/src/commands/insert_key.rs index 77d0f57780a94..b02c0181d43a2 100644 --- a/client/cli/src/commands/insert_key.rs +++ b/client/cli/src/commands/insert_key.rs @@ -24,7 +24,7 @@ use clap::Parser; use sc_keystore::LocalKeystore; use sc_service::config::{BasePath, KeystoreConfig}; use sp_core::crypto::{KeyTypeId, SecretString}; -use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{Keystore, KeystorePtr}; use std::sync::Arc; /// The `insert` command @@ -69,7 +69,7 @@ impl InsertKeyCmd { let (keystore, public) = match self.keystore_params.keystore_config(&config_dir)? { (_, KeystoreConfig::Path { path, password }) => { let public = with_crypto_scheme!(self.scheme, to_vec(&suri, password.clone()))?; - let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::open(path, password)?); + let keystore: KeystorePtr = Arc::new(LocalKeystore::open(path, password)?); (keystore, public) }, _ => unreachable!("keystore_config always returns path and password; qed"), @@ -78,8 +78,8 @@ impl InsertKeyCmd { let key_type = KeyTypeId::try_from(self.key_type.as_str()).map_err(|_| Error::KeyTypeInvalid)?; - SyncCryptoStore::insert_unknown(&*keystore, key_type, &suri, &public[..]) - .map_err(|_| Error::KeyStoreOperation)?; + Keystore::insert(&*keystore, key_type, &suri, &public[..]) + .map_err(|_| Error::KeystoreOperation)?; Ok(()) } diff --git a/client/cli/src/error.rs b/client/cli/src/error.rs index 3b30ccb3ed6b0..6c0cfca4932ef 100644 --- a/client/cli/src/error.rs +++ b/client/cli/src/error.rs @@ -64,7 +64,7 @@ pub enum Error { SignatureInvalid, #[error("Key store operation failed")] - KeyStoreOperation, + KeystoreOperation, #[error("Key storage issue encountered")] KeyStorage(#[from] sc_keystore::Error), diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index e90494ddfc177..8cdad148d6ef4 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -51,7 +51,7 @@ use sp_consensus::{BlockOrigin, Environment, Error as ConsensusError, Proposer, use sp_consensus_slots::Slot; use sp_core::crypto::{ByteArray, Pair, Public}; use sp_inherents::CreateInherentDataProviders; -use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{Keystore, KeystorePtr}; use sp_runtime::{ traits::{Block as BlockT, Header, Member, NumberFor, Zero}, DigestItem, @@ -168,7 +168,7 @@ pub struct StartAuraParams { /// The backoff strategy when we miss slots. pub backoff_authoring_blocks: Option, /// The keystore used by the node. - pub keystore: SyncCryptoStorePtr, + pub keystore: KeystorePtr, /// The proportion of the slot dedicated to proposing. /// /// The block proposing will be limited to this proportion of the slot from the starting of the @@ -265,7 +265,7 @@ pub struct BuildAuraWorkerParams { /// The backoff strategy when we miss slots. pub backoff_authoring_blocks: Option, /// The keystore used by the node. - pub keystore: SyncCryptoStorePtr, + pub keystore: KeystorePtr, /// The proportion of the slot dedicated to proposing. /// /// The block proposing will be limited to this proportion of the slot from the starting of the @@ -346,7 +346,7 @@ struct AuraWorker { client: Arc, block_import: I, env: E, - keystore: SyncCryptoStorePtr, + keystore: KeystorePtr, sync_oracle: SO, justification_sync_link: L, force_authoring: bool, @@ -418,7 +418,7 @@ where ) -> Option { let expected_author = slot_author::

(slot, epoch_data); expected_author.and_then(|p| { - if SyncCryptoStore::has_keys( + if Keystore::has_keys( &*self.keystore, &[(p.to_raw_vec(), sp_application_crypto::key_types::AURA)], ) { @@ -449,7 +449,7 @@ where // add it to a digest item. let public_type_pair = public.to_public_crypto_pair(); let public = public.to_raw_vec(); - let signature = SyncCryptoStore::sign_with( + let signature = Keystore::sign_with( &*self.keystore, as AppKey>::ID, &public_type_pair, @@ -798,7 +798,7 @@ mod tests { LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore."), ); - SyncCryptoStore::sr25519_generate_new(&*keystore, AURA, Some(&key.to_seed())) + Keystore::sr25519_generate_new(&*keystore, AURA, Some(&key.to_seed())) .expect("Creates authority key"); keystore_paths.push(keystore_path); @@ -883,7 +883,7 @@ mod tests { let keystore_path = tempfile::tempdir().expect("Creates keystore path"); let keystore = LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore."); - let public = SyncCryptoStore::sr25519_generate_new(&keystore, AuthorityPair::ID, None) + let public = Keystore::sr25519_generate_new(&keystore, AuthorityPair::ID, None) .expect("Key should be created"); authorities.push(public.into()); @@ -933,7 +933,7 @@ mod tests { let keystore_path = tempfile::tempdir().expect("Creates keystore path"); let keystore = LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore."); - SyncCryptoStore::sr25519_generate_new( + Keystore::sr25519_generate_new( &keystore, AuthorityPair::ID, Some(&Keyring::Alice.to_seed()), diff --git a/client/consensus/babe/rpc/src/lib.rs b/client/consensus/babe/rpc/src/lib.rs index 677a4ad92c9e1..bc4d1c17eb3f1 100644 --- a/client/consensus/babe/rpc/src/lib.rs +++ b/client/consensus/babe/rpc/src/lib.rs @@ -37,7 +37,7 @@ use sp_consensus_babe::{ digests::PreDigest, AuthorityId, BabeApi as BabeRuntimeApi, BabeConfiguration, }; use sp_core::crypto::ByteArray; -use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{Keystore, KeystorePtr}; use sp_runtime::traits::{Block as BlockT, Header as _}; use std::{collections::HashMap, sync::Arc}; @@ -57,7 +57,7 @@ pub struct Babe { /// shared reference to EpochChanges shared_epoch_changes: SharedEpochChanges, /// shared reference to the Keystore - keystore: SyncCryptoStorePtr, + keystore: KeystorePtr, /// config (actually holds the slot duration) babe_config: BabeConfiguration, /// The SelectChain strategy @@ -71,7 +71,7 @@ impl Babe { pub fn new( client: Arc, shared_epoch_changes: SharedEpochChanges, - keystore: SyncCryptoStorePtr, + keystore: KeystorePtr, babe_config: BabeConfiguration, select_chain: SC, deny_unsafe: DenyUnsafe, @@ -117,10 +117,7 @@ where .iter() .enumerate() .filter_map(|(i, a)| { - if SyncCryptoStore::has_keys( - &*self.keystore, - &[(a.0.to_raw_vec(), AuthorityId::ID)], - ) { + if Keystore::has_keys(&*self.keystore, &[(a.0.to_raw_vec(), AuthorityId::ID)]) { Some((a.0.clone(), i)) } else { None @@ -217,7 +214,7 @@ mod tests { use sp_application_crypto::AppPair; use sp_core::crypto::key_types::BABE; use sp_keyring::Sr25519Keyring; - use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; + use sp_keystore::{Keystore, KeystorePtr}; use substrate_test_runtime_client::{ runtime::Block, Backend, DefaultTestClientBuilderExt, TestClient, TestClientBuilder, TestClientBuilderExt, @@ -229,11 +226,11 @@ mod tests { /// creates keystore backed by a temp file fn create_temp_keystore( authority: Sr25519Keyring, - ) -> (SyncCryptoStorePtr, tempfile::TempDir) { + ) -> (KeystorePtr, tempfile::TempDir) { let keystore_path = tempfile::tempdir().expect("Creates keystore path"); let keystore = Arc::new(LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore")); - SyncCryptoStore::sr25519_generate_new(&*keystore, BABE, Some(&authority.to_seed())) + Keystore::sr25519_generate_new(&*keystore, BABE, Some(&authority.to_seed())) .expect("Creates authority key"); (keystore, keystore_path) diff --git a/client/consensus/babe/src/authorship.rs b/client/consensus/babe/src/authorship.rs index 195a19b3d0f61..956e886d1254c 100644 --- a/client/consensus/babe/src/authorship.rs +++ b/client/consensus/babe/src/authorship.rs @@ -29,7 +29,7 @@ use sp_consensus_babe::{ }; use sp_consensus_vrf::schnorrkel::{VRFOutput, VRFProof}; use sp_core::{blake2_256, crypto::ByteArray, U256}; -use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{Keystore, KeystorePtr}; /// Calculates the primary selection threshold for a given authority, taking /// into account `c` (`1 - c` represents the probability of a slot being empty). @@ -133,7 +133,7 @@ fn claim_secondary_slot( slot: Slot, epoch: &Epoch, keys: &[(AuthorityId, usize)], - keystore: &SyncCryptoStorePtr, + keystore: &KeystorePtr, author_secondary_vrf: bool, ) -> Option<(PreDigest, AuthorityId)> { let Epoch { authorities, randomness, mut epoch_index, .. } = epoch; @@ -153,7 +153,7 @@ fn claim_secondary_slot( if authority_id == expected_author { let pre_digest = if author_secondary_vrf { let transcript_data = make_transcript_data(randomness, slot, epoch_index); - let result = SyncCryptoStore::sr25519_vrf_sign( + let result = Keystore::sr25519_vrf_sign( &**keystore, AuthorityId::ID, authority_id.as_ref(), @@ -169,7 +169,7 @@ fn claim_secondary_slot( } else { None } - } else if SyncCryptoStore::has_keys( + } else if Keystore::has_keys( &**keystore, &[(authority_id.to_raw_vec(), AuthorityId::ID)], ) { @@ -197,7 +197,7 @@ fn claim_secondary_slot( pub fn claim_slot( slot: Slot, epoch: &Epoch, - keystore: &SyncCryptoStorePtr, + keystore: &KeystorePtr, ) -> Option<(PreDigest, AuthorityId)> { let authorities = epoch .authorities @@ -213,7 +213,7 @@ pub fn claim_slot( pub fn claim_slot_using_keys( slot: Slot, epoch: &Epoch, - keystore: &SyncCryptoStorePtr, + keystore: &KeystorePtr, keys: &[(AuthorityId, usize)], ) -> Option<(PreDigest, AuthorityId)> { claim_primary_slot(slot, epoch, epoch.config.c, keystore, keys).or_else(|| { @@ -241,7 +241,7 @@ fn claim_primary_slot( slot: Slot, epoch: &Epoch, c: (u64, u64), - keystore: &SyncCryptoStorePtr, + keystore: &KeystorePtr, keys: &[(AuthorityId, usize)], ) -> Option<(PreDigest, AuthorityId)> { let Epoch { authorities, randomness, mut epoch_index, .. } = epoch; @@ -254,7 +254,7 @@ fn claim_primary_slot( for (authority_id, authority_index) in keys { let transcript = make_transcript(randomness, slot, epoch_index); let transcript_data = make_transcript_data(randomness, slot, epoch_index); - let result = SyncCryptoStore::sr25519_vrf_sign( + let result = Keystore::sr25519_vrf_sign( &**keystore, AuthorityId::ID, authority_id.as_ref(), @@ -294,8 +294,8 @@ mod tests { #[test] fn claim_secondary_plain_slot_works() { - let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory()); - let valid_public_key = SyncCryptoStore::sr25519_generate_new( + let keystore: KeystorePtr = Arc::new(LocalKeystore::in_memory()); + let valid_public_key = Keystore::sr25519_generate_new( &*keystore, AuthorityId::ID, Some(sp_core::crypto::DEV_PHRASE), diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 1d42057a36b23..621aac391630b 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -119,7 +119,7 @@ use sp_consensus_babe::inherents::BabeInherentData; use sp_consensus_slots::Slot; use sp_core::{crypto::ByteArray, ExecutionContext}; use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider}; -use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{Keystore, KeystorePtr}; use sp_runtime::{ generic::OpaqueDigestItemId, traits::{Block as BlockT, Header, NumberFor, SaturatedConversion, Zero}, @@ -404,7 +404,7 @@ where /// Parameters for BABE. pub struct BabeParams { /// The keystore that manages the keys of the node. - pub keystore: SyncCryptoStorePtr, + pub keystore: KeystorePtr, /// The client to use pub client: Arc, @@ -711,7 +711,7 @@ struct BabeSlotWorker { justification_sync_link: L, force_authoring: bool, backoff_authoring_blocks: Option, - keystore: SyncCryptoStorePtr, + keystore: KeystorePtr, epoch_changes: SharedEpochChanges, slot_notification_sinks: SlotNotificationSinks, config: BabeConfiguration, @@ -834,7 +834,7 @@ where // add it to a digest item. let public_type_pair = public.clone().into(); let public = public.to_raw_vec(); - let signature = SyncCryptoStore::sign_with( + let signature = Keystore::sign_with( &*self.keystore, ::ID, &public_type_pair, diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 25f1f87235702..4ac15bf2634d7 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -41,8 +41,7 @@ use sp_consensus_vrf::schnorrkel::VRFOutput; use sp_core::crypto::Pair; use sp_keyring::Sr25519Keyring; use sp_keystore::{ - testing::KeyStore as TestKeyStore, vrf::make_transcript as transcript_from_data, - SyncCryptoStore, + testing::MemoryKeystore, vrf::make_transcript as transcript_from_data, Keystore, }; use sp_runtime::{ generic::{Digest, DigestItem}, @@ -369,9 +368,9 @@ async fn rejects_empty_block() { }) } -fn create_keystore(authority: Sr25519Keyring) -> SyncCryptoStorePtr { - let keystore = Arc::new(TestKeyStore::new()); - SyncCryptoStore::sr25519_generate_new(&*keystore, BABE, Some(&authority.to_seed())) +fn create_keystore(authority: Sr25519Keyring) -> KeystorePtr { + let keystore = Arc::new(MemoryKeystore::new()); + Keystore::sr25519_generate_new(&*keystore, BABE, Some(&authority.to_seed())) .expect("Generates authority key"); keystore } @@ -638,7 +637,7 @@ fn claim_vrf_check() { v => panic!("Unexpected pre-digest variant {:?}", v), }; let transcript = make_transcript_data(&epoch.randomness.clone(), 0.into(), epoch.epoch_index); - let sign = SyncCryptoStore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) + let sign = Keystore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) .unwrap() .unwrap(); assert_eq!(pre_digest.vrf_output, VRFOutput(sign.output)); @@ -649,7 +648,7 @@ fn claim_vrf_check() { v => panic!("Unexpected pre-digest variant {:?}", v), }; let transcript = make_transcript_data(&epoch.randomness.clone(), 1.into(), epoch.epoch_index); - let sign = SyncCryptoStore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) + let sign = Keystore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) .unwrap() .unwrap(); assert_eq!(pre_digest.vrf_output, VRFOutput(sign.output)); @@ -662,7 +661,7 @@ fn claim_vrf_check() { }; let fixed_epoch = epoch.clone_for_slot(slot); let transcript = make_transcript_data(&epoch.randomness.clone(), slot, fixed_epoch.epoch_index); - let sign = SyncCryptoStore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) + let sign = Keystore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) .unwrap() .unwrap(); assert_eq!(fixed_epoch.epoch_index, 11); @@ -676,7 +675,7 @@ fn claim_vrf_check() { }; let fixed_epoch = epoch.clone_for_slot(slot); let transcript = make_transcript_data(&epoch.randomness.clone(), slot, fixed_epoch.epoch_index); - let sign = SyncCryptoStore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) + let sign = Keystore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) .unwrap() .unwrap(); assert_eq!(fixed_epoch.epoch_index, 11); diff --git a/client/consensus/beefy/src/communication/gossip.rs b/client/consensus/beefy/src/communication/gossip.rs index e49382251e846..4bbd7a7f68d5c 100644 --- a/client/consensus/beefy/src/communication/gossip.rs +++ b/client/consensus/beefy/src/communication/gossip.rs @@ -245,7 +245,7 @@ where mod tests { use sc_keystore::LocalKeystore; use sc_network_test::Block; - use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; + use sp_keystore::{Keystore, KeystorePtr}; use crate::keystore::BeefyKeystore; use sp_consensus_beefy::{ @@ -306,8 +306,8 @@ mod tests { } fn sign_commitment(who: &Keyring, commitment: &Commitment) -> Signature { - let store: SyncCryptoStorePtr = std::sync::Arc::new(LocalKeystore::in_memory()); - SyncCryptoStore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&who.to_seed())).unwrap(); + let store: KeystorePtr = std::sync::Arc::new(LocalKeystore::in_memory()); + Keystore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&who.to_seed())).unwrap(); let beefy_keystore: BeefyKeystore = Some(store).into(); beefy_keystore.sign(&who.public(), &commitment.encode()).unwrap() diff --git a/client/consensus/beefy/src/keystore.rs b/client/consensus/beefy/src/keystore.rs index 421f7149018c8..596e8f2eb9c6d 100644 --- a/client/consensus/beefy/src/keystore.rs +++ b/client/consensus/beefy/src/keystore.rs @@ -18,7 +18,7 @@ use sp_application_crypto::RuntimeAppPublic; use sp_core::keccak_256; -use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{Keystore, KeystorePtr}; use log::warn; @@ -33,9 +33,9 @@ use crate::{error, LOG_TARGET}; pub(crate) type BeefySignatureHasher = sp_runtime::traits::Keccak256; /// A BEEFY specific keystore implemented as a `Newtype`. This is basically a -/// wrapper around [`sp_keystore::SyncCryptoStore`] and allows to customize +/// wrapper around [`sp_keystore::Keystore`] and allows to customize /// common cryptographic functionality. -pub(crate) struct BeefyKeystore(Option); +pub(crate) struct BeefyKeystore(Option); impl BeefyKeystore { /// Check if the keystore contains a private key for one of the public keys @@ -50,7 +50,7 @@ impl BeefyKeystore { // we do check for multiple private keys as a key store sanity check. let public: Vec = keys .iter() - .filter(|k| SyncCryptoStore::has_keys(&*store, &[(k.to_raw_vec(), KEY_TYPE)])) + .filter(|k| Keystore::has_keys(&*store, &[(k.to_raw_vec(), KEY_TYPE)])) .cloned() .collect(); @@ -77,7 +77,7 @@ impl BeefyKeystore { let msg = keccak_256(message); let public = public.as_ref(); - let sig = SyncCryptoStore::ecdsa_sign_prehashed(&*store, KEY_TYPE, public, &msg) + let sig = Keystore::ecdsa_sign_prehashed(&*store, KEY_TYPE, public, &msg) .map_err(|e| error::Error::Keystore(e.to_string()))? .ok_or_else(|| error::Error::Signature("ecdsa_sign_prehashed() failed".to_string()))?; @@ -94,7 +94,7 @@ impl BeefyKeystore { pub fn public_keys(&self) -> Result, error::Error> { let store = self.0.clone().ok_or_else(|| error::Error::Keystore("no Keystore".into()))?; - let pk: Vec = SyncCryptoStore::ecdsa_public_keys(&*store, KEY_TYPE) + let pk: Vec = Keystore::ecdsa_public_keys(&*store, KEY_TYPE) .drain(..) .map(Public::from) .collect(); @@ -110,8 +110,8 @@ impl BeefyKeystore { } } -impl From> for BeefyKeystore { - fn from(store: Option) -> BeefyKeystore { +impl From> for BeefyKeystore { + fn from(store: Option) -> BeefyKeystore { BeefyKeystore(store) } } @@ -128,7 +128,7 @@ pub mod tests { use super::*; use crate::error::Error; - fn keystore() -> SyncCryptoStorePtr { + fn keystore() -> KeystorePtr { Arc::new(LocalKeystore::in_memory()) } @@ -198,7 +198,7 @@ pub mod tests { let store = keystore(); let alice: crypto::Public = - SyncCryptoStore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&Keyring::Alice.to_seed())) + Keystore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&Keyring::Alice.to_seed())) .ok() .unwrap() .into(); @@ -224,7 +224,7 @@ pub mod tests { let store = keystore(); let alice: crypto::Public = - SyncCryptoStore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&Keyring::Alice.to_seed())) + Keystore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&Keyring::Alice.to_seed())) .ok() .unwrap() .into(); @@ -243,10 +243,9 @@ pub mod tests { fn sign_error() { let store = keystore(); - let _ = - SyncCryptoStore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&Keyring::Bob.to_seed())) - .ok() - .unwrap(); + let _ = Keystore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&Keyring::Bob.to_seed())) + .ok() + .unwrap(); let store: BeefyKeystore = Some(store).into(); @@ -276,7 +275,7 @@ pub mod tests { let store = keystore(); let alice: crypto::Public = - SyncCryptoStore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&Keyring::Alice.to_seed())) + Keystore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&Keyring::Alice.to_seed())) .ok() .unwrap() .into(); @@ -302,7 +301,7 @@ pub mod tests { let store = keystore(); let add_key = |key_type, seed: Option<&str>| { - SyncCryptoStore::ecdsa_generate_new(&*store, key_type, seed).unwrap() + Keystore::ecdsa_generate_new(&*store, key_type, seed).unwrap() }; // test keys diff --git a/client/consensus/beefy/src/lib.rs b/client/consensus/beefy/src/lib.rs index d632f58332a77..b84fa45e7e2f3 100644 --- a/client/consensus/beefy/src/lib.rs +++ b/client/consensus/beefy/src/lib.rs @@ -49,7 +49,7 @@ use sp_consensus_beefy::{ crypto::AuthorityId, BeefyApi, MmrRootHash, PayloadProvider, ValidatorSet, BEEFY_ENGINE_ID, GENESIS_AUTHORITY_SET_ID, }; -use sp_keystore::SyncCryptoStorePtr; +use sp_keystore::KeystorePtr; use sp_mmr_primitives::MmrApi; use sp_runtime::traits::{Block, Zero}; use std::{collections::VecDeque, marker::PhantomData, sync::Arc}; @@ -197,7 +197,7 @@ pub struct BeefyParams { /// Runtime Api Provider pub runtime: Arc, /// Local key store - pub key_store: Option, + pub key_store: Option, /// BEEFY voter network params pub network_params: BeefyNetworkParams, /// Minimal delta between blocks, BEEFY should vote for diff --git a/client/consensus/beefy/src/tests.rs b/client/consensus/beefy/src/tests.rs index 629f144246d7f..9a3653f7cc549 100644 --- a/client/consensus/beefy/src/tests.rs +++ b/client/consensus/beefy/src/tests.rs @@ -54,7 +54,7 @@ use sp_consensus_beefy::{ VersionedFinalityProof, BEEFY_ENGINE_ID, KEY_TYPE as BeefyKeyType, }; use sp_core::H256; -use sp_keystore::{testing::KeyStore as TestKeystore, SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{testing::MemoryKeystore, Keystore, KeystorePtr}; use sp_mmr_primitives::{Error as MmrError, MmrApi}; use sp_runtime::{ codec::Encode, @@ -339,9 +339,9 @@ pub(crate) fn make_beefy_ids(keys: &[BeefyKeyring]) -> Vec { keys.iter().map(|&key| key.public().into()).collect() } -pub(crate) fn create_beefy_keystore(authority: BeefyKeyring) -> SyncCryptoStorePtr { - let keystore = Arc::new(TestKeystore::new()); - SyncCryptoStore::ecdsa_generate_new(&*keystore, BeefyKeyType, Some(&authority.to_seed())) +pub(crate) fn create_beefy_keystore(authority: BeefyKeyring) -> KeystorePtr { + let keystore = Arc::new(MemoryKeystore::new()); + Keystore::ecdsa_generate_new(&*keystore, BeefyKeyType, Some(&authority.to_seed())) .expect("Creates authority key"); keystore } diff --git a/client/consensus/grandpa/src/communication/mod.rs b/client/consensus/grandpa/src/communication/mod.rs index 3896bc36031ba..81365c20b1ebe 100644 --- a/client/consensus/grandpa/src/communication/mod.rs +++ b/client/consensus/grandpa/src/communication/mod.rs @@ -49,7 +49,7 @@ use parity_scale_codec::{Decode, Encode}; use sc_network::{NetworkBlock, NetworkSyncForkRequest, ReputationChange}; use sc_network_gossip::{GossipEngine, Network as GossipNetwork}; use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_INFO}; -use sp_keystore::SyncCryptoStorePtr; +use sp_keystore::KeystorePtr; use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, NumberFor}; use crate::{ @@ -136,7 +136,7 @@ mod benefit { /// A type that ties together our local authority id and a keystore where it is /// available for signing. -pub struct LocalIdKeystore((AuthorityId, SyncCryptoStorePtr)); +pub struct LocalIdKeystore((AuthorityId, KeystorePtr)); impl LocalIdKeystore { /// Returns a reference to our local authority id. @@ -145,13 +145,13 @@ impl LocalIdKeystore { } /// Returns a reference to the keystore. - fn keystore(&self) -> SyncCryptoStorePtr { + fn keystore(&self) -> KeystorePtr { (self.0).1.clone() } } -impl From<(AuthorityId, SyncCryptoStorePtr)> for LocalIdKeystore { - fn from(inner: (AuthorityId, SyncCryptoStorePtr)) -> LocalIdKeystore { +impl From<(AuthorityId, KeystorePtr)> for LocalIdKeystore { + fn from(inner: (AuthorityId, KeystorePtr)) -> LocalIdKeystore { LocalIdKeystore(inner) } } diff --git a/client/consensus/grandpa/src/lib.rs b/client/consensus/grandpa/src/lib.rs index 2baa135081c55..6b3730fc7f476 100644 --- a/client/consensus/grandpa/src/lib.rs +++ b/client/consensus/grandpa/src/lib.rs @@ -79,7 +79,7 @@ use sp_consensus_grandpa::{ AuthorityList, AuthoritySignature, SetId, CLIENT_LOG_TARGET as LOG_TARGET, }; use sp_core::{crypto::ByteArray, traits::CallContext}; -use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{Keystore, KeystorePtr}; use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, NumberFor, Zero}, @@ -228,7 +228,7 @@ pub struct Config { /// Some local identifier of the voter. pub name: Option, /// The keystore that manages the keys of this node. - pub keystore: Option, + pub keystore: Option, /// TelemetryHandle instance. pub telemetry: Option, /// Chain specific GRANDPA protocol name. See [`crate::protocol_standard_name`]. @@ -623,7 +623,7 @@ fn global_communication( voters: &Arc>, client: Arc, network: &NetworkBridge, - keystore: Option<&SyncCryptoStorePtr>, + keystore: Option<&KeystorePtr>, metrics: Option, ) -> ( impl Stream< @@ -1136,14 +1136,12 @@ where /// available. fn local_authority_id( voters: &VoterSet, - keystore: Option<&SyncCryptoStorePtr>, + keystore: Option<&KeystorePtr>, ) -> Option { keystore.and_then(|keystore| { voters .iter() - .find(|(p, _)| { - SyncCryptoStore::has_keys(&**keystore, &[(p.to_raw_vec(), AuthorityId::ID)]) - }) + .find(|(p, _)| Keystore::has_keys(&**keystore, &[(p.to_raw_vec(), AuthorityId::ID)])) .map(|(p, _)| p.clone()) }) } diff --git a/client/consensus/grandpa/src/observer.rs b/client/consensus/grandpa/src/observer.rs index 53672c1f02225..8541baa822bb4 100644 --- a/client/consensus/grandpa/src/observer.rs +++ b/client/consensus/grandpa/src/observer.rs @@ -33,7 +33,7 @@ use sc_utils::mpsc::TracingUnboundedReceiver; use sp_blockchain::HeaderMetadata; use sp_consensus::SelectChain; use sp_consensus_grandpa::AuthorityId; -use sp_keystore::SyncCryptoStorePtr; +use sp_keystore::KeystorePtr; use sp_runtime::traits::{Block as BlockT, NumberFor}; use crate::{ @@ -220,7 +220,7 @@ struct ObserverWork, S: SyncingT> { client: Arc, network: NetworkBridge, persistent_data: PersistentData, - keystore: Option, + keystore: Option, voter_commands_rx: TracingUnboundedReceiver>>, justification_sender: Option>, telemetry: Option, @@ -240,7 +240,7 @@ where client: Arc, network: NetworkBridge, persistent_data: PersistentData, - keystore: Option, + keystore: Option, voter_commands_rx: TracingUnboundedReceiver>>, justification_sender: Option>, telemetry: Option, diff --git a/client/consensus/grandpa/src/tests.rs b/client/consensus/grandpa/src/tests.rs index f5e5c45e74207..6f19ca7391e65 100644 --- a/client/consensus/grandpa/src/tests.rs +++ b/client/consensus/grandpa/src/tests.rs @@ -40,7 +40,7 @@ use sp_consensus_grandpa::{ }; use sp_core::H256; use sp_keyring::Ed25519Keyring; -use sp_keystore::{testing::KeyStore as TestKeyStore, SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{testing::MemoryKeystore, Keystore, KeystorePtr}; use sp_runtime::{ codec::Encode, generic::{BlockId, DigestItem}, @@ -280,9 +280,9 @@ fn make_ids(keys: &[Ed25519Keyring]) -> AuthorityList { keys.iter().map(|&key| key.public().into()).map(|id| (id, 1)).collect() } -fn create_keystore(authority: Ed25519Keyring) -> SyncCryptoStorePtr { - let keystore = Arc::new(TestKeyStore::new()); - SyncCryptoStore::ed25519_generate_new(&*keystore, GRANDPA, Some(&authority.to_seed())) +fn create_keystore(authority: Ed25519Keyring) -> KeystorePtr { + let keystore = Arc::new(MemoryKeystore::new()); + Keystore::ed25519_generate_new(&*keystore, GRANDPA, Some(&authority.to_seed())) .expect("Creates authority key"); keystore } @@ -1376,7 +1376,7 @@ type TestEnvironment = fn test_environment_with_select_chain( link: &TestLinkHalf, - keystore: Option, + keystore: Option, network_service: N, sync_service: S, select_chain: SC, @@ -1428,7 +1428,7 @@ where fn test_environment( link: &TestLinkHalf, - keystore: Option, + keystore: Option, network_service: N, sync_service: S, voting_rule: VR, diff --git a/client/consensus/manual-seal/src/consensus/babe.rs b/client/consensus/manual-seal/src/consensus/babe.rs index 3d21fd73d95ae..2485bd603e785 100644 --- a/client/consensus/manual-seal/src/consensus/babe.rs +++ b/client/consensus/manual-seal/src/consensus/babe.rs @@ -29,7 +29,7 @@ use sc_consensus_babe::{ use sc_consensus_epochs::{ descendent_query, EpochHeader, SharedEpochChanges, ViableEpochDescriptor, }; -use sp_keystore::SyncCryptoStorePtr; +use sp_keystore::KeystorePtr; use std::{marker::PhantomData, sync::Arc}; use sc_consensus::{BlockImportParams, ForkChoiceStrategy, Verifier}; @@ -53,7 +53,7 @@ use sp_timestamp::TimestampInherentData; /// Intended for use with BABE runtimes. pub struct BabeConsensusDataProvider { /// shared reference to keystore - keystore: SyncCryptoStorePtr, + keystore: KeystorePtr, /// Shared reference to the client. client: Arc, @@ -143,7 +143,7 @@ where { pub fn new( client: Arc, - keystore: SyncCryptoStorePtr, + keystore: KeystorePtr, epoch_changes: SharedEpochChanges, authorities: Vec<(AuthorityId, BabeAuthorityWeight)>, ) -> Result { diff --git a/client/keystore/src/local.rs b/client/keystore/src/local.rs index cd55739a9fac3..18ee58b8719b9 100644 --- a/client/keystore/src/local.rs +++ b/client/keystore/src/local.rs @@ -17,7 +17,6 @@ // //! Local keystore implementation -use async_trait::async_trait; use parking_lot::RwLock; use sp_application_crypto::{ecdsa, ed25519, sr25519, AppKey, AppPair, IsWrappedBy}; use sp_core::{ @@ -29,10 +28,10 @@ use sp_core::{ }; use sp_keystore::{ vrf::{make_transcript, VRFSignature, VRFTranscriptData}, - CryptoStore, Error as TraitError, SyncCryptoStore, SyncCryptoStorePtr, + Error as TraitError, Keystore, KeystorePtr, }; use std::{ - collections::{HashMap, HashSet}, + collections::HashMap, fs::{self, File}, io::Write, path::PathBuf, @@ -69,101 +68,7 @@ impl LocalKeystore { } } -#[async_trait] -impl CryptoStore for LocalKeystore { - async fn keys( - &self, - id: KeyTypeId, - ) -> std::result::Result, TraitError> { - SyncCryptoStore::keys(self, id) - } - - async fn sr25519_public_keys(&self, id: KeyTypeId) -> Vec { - SyncCryptoStore::sr25519_public_keys(self, id) - } - - async fn sr25519_generate_new( - &self, - id: KeyTypeId, - seed: Option<&str>, - ) -> std::result::Result { - SyncCryptoStore::sr25519_generate_new(self, id, seed) - } - - async fn ed25519_public_keys(&self, id: KeyTypeId) -> Vec { - SyncCryptoStore::ed25519_public_keys(self, id) - } - - async fn ed25519_generate_new( - &self, - id: KeyTypeId, - seed: Option<&str>, - ) -> std::result::Result { - SyncCryptoStore::ed25519_generate_new(self, id, seed) - } - - async fn ecdsa_public_keys(&self, id: KeyTypeId) -> Vec { - SyncCryptoStore::ecdsa_public_keys(self, id) - } - - async fn ecdsa_generate_new( - &self, - id: KeyTypeId, - seed: Option<&str>, - ) -> std::result::Result { - SyncCryptoStore::ecdsa_generate_new(self, id, seed) - } - - async fn insert_unknown( - &self, - id: KeyTypeId, - suri: &str, - public: &[u8], - ) -> std::result::Result<(), ()> { - SyncCryptoStore::insert_unknown(self, id, suri, public) - } - - async fn has_keys(&self, public_keys: &[(Vec, KeyTypeId)]) -> bool { - SyncCryptoStore::has_keys(self, public_keys) - } - - async fn supported_keys( - &self, - id: KeyTypeId, - keys: Vec, - ) -> std::result::Result, TraitError> { - SyncCryptoStore::supported_keys(self, id, keys) - } - - async fn sign_with( - &self, - id: KeyTypeId, - key: &CryptoTypePublicPair, - msg: &[u8], - ) -> std::result::Result>, TraitError> { - SyncCryptoStore::sign_with(self, id, key, msg) - } - - async fn sr25519_vrf_sign( - &self, - key_type: KeyTypeId, - public: &sr25519::Public, - transcript_data: VRFTranscriptData, - ) -> std::result::Result, TraitError> { - SyncCryptoStore::sr25519_vrf_sign(self, key_type, public, transcript_data) - } - - async fn ecdsa_sign_prehashed( - &self, - id: KeyTypeId, - public: &ecdsa::Public, - msg: &[u8; 32], - ) -> std::result::Result, TraitError> { - SyncCryptoStore::ecdsa_sign_prehashed(self, id, public, msg) - } -} - -impl SyncCryptoStore for LocalKeystore { +impl Keystore for LocalKeystore { fn keys(&self, id: KeyTypeId) -> std::result::Result, TraitError> { let raw_keys = self.0.read().raw_public_keys(id)?; Ok(raw_keys.into_iter().fold(Vec::new(), |mut v, k| { @@ -174,15 +79,6 @@ impl SyncCryptoStore for LocalKeystore { })) } - fn supported_keys( - &self, - id: KeyTypeId, - keys: Vec, - ) -> std::result::Result, TraitError> { - let all_keys = SyncCryptoStore::keys(self, id)?.into_iter().collect::>(); - Ok(keys.into_iter().filter(|key| all_keys.contains(key)).collect::>()) - } - fn sign_with( &self, id: KeyTypeId, @@ -308,13 +204,13 @@ impl SyncCryptoStore for LocalKeystore { Ok(pair.public()) } - fn insert_unknown( + fn insert( &self, key_type: KeyTypeId, suri: &str, public: &[u8], ) -> std::result::Result<(), ()> { - self.0.write().insert_unknown(key_type, suri, public).map_err(|_| ()) + self.0.write().insert(key_type, suri, public).map_err(|_| ()) } fn has_keys(&self, public_keys: &[(Vec, KeyTypeId)]) -> bool { @@ -352,14 +248,8 @@ impl SyncCryptoStore for LocalKeystore { } } -impl Into for LocalKeystore { - fn into(self) -> SyncCryptoStorePtr { - Arc::new(self) - } -} - -impl Into> for LocalKeystore { - fn into(self) -> Arc { +impl Into for LocalKeystore { + fn into(self) -> KeystorePtr { Arc::new(self) } } @@ -414,7 +304,7 @@ impl KeystoreInner { /// Insert a new key with anonymous crypto. /// /// Places it into the file system store, if a path is configured. - fn insert_unknown(&self, key_type: KeyTypeId, suri: &str, public: &[u8]) -> Result<()> { + fn insert(&self, key_type: KeyTypeId, suri: &str, public: &[u8]) -> Result<()> { if let Some(path) = self.key_file_path(public, key_type) { Self::write_to_file(path, suri)?; } @@ -614,12 +504,9 @@ mod tests { let key: ed25519::AppPair = store.0.write().generate().unwrap(); let key2 = ed25519::Pair::generate().0; - assert!(!SyncCryptoStore::has_keys( - &store, - &[(key2.public().to_vec(), ed25519::AppPublic::ID)] - )); + assert!(!Keystore::has_keys(&store, &[(key2.public().to_vec(), ed25519::AppPublic::ID)])); - assert!(!SyncCryptoStore::has_keys( + assert!(!Keystore::has_keys( &store, &[ (key2.public().to_vec(), ed25519::AppPublic::ID), @@ -627,10 +514,7 @@ mod tests { ], )); - assert!(SyncCryptoStore::has_keys( - &store, - &[(key.public().to_raw_vec(), ed25519::AppPublic::ID)] - )); + assert!(Keystore::has_keys(&store, &[(key.public().to_raw_vec(), ed25519::AppPublic::ID)])); } #[test] @@ -723,7 +607,7 @@ mod tests { let key_pair = sr25519::AppPair::from_string(secret_uri, None).expect("Generates key pair"); store - .insert_unknown(SR25519, secret_uri, key_pair.public().as_ref()) + .insert(SR25519, secret_uri, key_pair.public().as_ref()) .expect("Inserts unknown key"); let store_key_pair = store @@ -742,7 +626,7 @@ mod tests { let file_name = temp_dir.path().join(array_bytes::bytes2hex("", &SR25519.0[..2])); fs::write(file_name, "test").expect("Invalid file is written"); - assert!(SyncCryptoStore::sr25519_public_keys(&store, SR25519).is_empty()); + assert!(Keystore::sr25519_public_keys(&store, SR25519).is_empty()); } #[test] @@ -750,23 +634,23 @@ mod tests { let temp_dir = TempDir::new().unwrap(); let store = LocalKeystore::open(temp_dir.path(), None).unwrap(); let _alice_tmp_key = - SyncCryptoStore::sr25519_generate_new(&store, TEST_KEY_TYPE, Some("//Alice")).unwrap(); + Keystore::sr25519_generate_new(&store, TEST_KEY_TYPE, Some("//Alice")).unwrap(); - assert_eq!(SyncCryptoStore::sr25519_public_keys(&store, TEST_KEY_TYPE).len(), 1); + assert_eq!(Keystore::sr25519_public_keys(&store, TEST_KEY_TYPE).len(), 1); drop(store); let store = LocalKeystore::open(temp_dir.path(), None).unwrap(); - assert_eq!(SyncCryptoStore::sr25519_public_keys(&store, TEST_KEY_TYPE).len(), 0); + assert_eq!(Keystore::sr25519_public_keys(&store, TEST_KEY_TYPE).len(), 0); } #[test] fn generate_can_be_fetched_in_memory() { let store = LocalKeystore::in_memory(); - SyncCryptoStore::sr25519_generate_new(&store, TEST_KEY_TYPE, Some("//Alice")).unwrap(); + Keystore::sr25519_generate_new(&store, TEST_KEY_TYPE, Some("//Alice")).unwrap(); - assert_eq!(SyncCryptoStore::sr25519_public_keys(&store, TEST_KEY_TYPE).len(), 1); - SyncCryptoStore::sr25519_generate_new(&store, TEST_KEY_TYPE, None).unwrap(); - assert_eq!(SyncCryptoStore::sr25519_public_keys(&store, TEST_KEY_TYPE).len(), 2); + assert_eq!(Keystore::sr25519_public_keys(&store, TEST_KEY_TYPE).len(), 1); + Keystore::sr25519_generate_new(&store, TEST_KEY_TYPE, None).unwrap(); + assert_eq!(Keystore::sr25519_public_keys(&store, TEST_KEY_TYPE).len(), 2); } #[test] @@ -777,7 +661,7 @@ mod tests { let temp_dir = TempDir::new().unwrap(); let store = LocalKeystore::open(temp_dir.path(), None).unwrap(); - let public = SyncCryptoStore::sr25519_generate_new(&store, TEST_KEY_TYPE, None).unwrap(); + let public = Keystore::sr25519_generate_new(&store, TEST_KEY_TYPE, None).unwrap(); let path = store.0.read().key_file_path(public.as_ref(), TEST_KEY_TYPE).unwrap(); let permissions = File::open(path).unwrap().metadata().unwrap().permissions(); diff --git a/client/rpc-api/src/author/error.rs b/client/rpc-api/src/author/error.rs index 7ca96bbab7f19..8149a1f8d1afe 100644 --- a/client/rpc-api/src/author/error.rs +++ b/client/rpc-api/src/author/error.rs @@ -47,7 +47,7 @@ pub enum Error { BadKeyType, /// Some random issue with the key store. Shouldn't happen. #[error("The key store is unavailable")] - KeyStoreUnavailable, + KeystoreUnavailable, /// Invalid session keys encoding. #[error("Session keys are not encoded correctly")] InvalidSessionKeys, diff --git a/client/rpc/src/author/mod.rs b/client/rpc/src/author/mod.rs index 2bb88352eb2e5..9752a32b17c67 100644 --- a/client/rpc/src/author/mod.rs +++ b/client/rpc/src/author/mod.rs @@ -40,7 +40,7 @@ use sc_transaction_pool_api::{ use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_core::Bytes; -use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{Keystore, KeystorePtr}; use sp_runtime::{generic, traits::Block as BlockT}; use sp_session::SessionKeys; @@ -55,7 +55,7 @@ pub struct Author { /// Transactions pool pool: Arc

, /// The key store. - keystore: SyncCryptoStorePtr, + keystore: KeystorePtr, /// Whether to deny unsafe calls deny_unsafe: DenyUnsafe, /// Executor to spawn subscriptions. @@ -67,7 +67,7 @@ impl Author { pub fn new( client: Arc, pool: Arc

, - keystore: SyncCryptoStorePtr, + keystore: KeystorePtr, deny_unsafe: DenyUnsafe, executor: SubscriptionTaskExecutor, ) -> Self { @@ -112,8 +112,8 @@ where self.deny_unsafe.check_if_safe()?; let key_type = key_type.as_str().try_into().map_err(|_| Error::BadKeyType)?; - SyncCryptoStore::insert_unknown(&*self.keystore, key_type, &suri, &public[..]) - .map_err(|_| Error::KeyStoreUnavailable)?; + Keystore::insert(&*self.keystore, key_type, &suri, &public[..]) + .map_err(|_| Error::KeystoreUnavailable)?; Ok(()) } @@ -139,14 +139,14 @@ where .map_err(|e| Error::Client(Box::new(e)))? .ok_or(Error::InvalidSessionKeys)?; - Ok(SyncCryptoStore::has_keys(&*self.keystore, &keys)) + Ok(Keystore::has_keys(&*self.keystore, &keys)) } fn has_key(&self, public_key: Bytes, key_type: String) -> RpcResult { self.deny_unsafe.check_if_safe()?; let key_type = key_type.as_str().try_into().map_err(|_| Error::BadKeyType)?; - Ok(SyncCryptoStore::has_keys(&*self.keystore, &[(public_key.to_vec(), key_type)])) + Ok(Keystore::has_keys(&*self.keystore, &[(public_key.to_vec(), key_type)])) } fn pending_extrinsics(&self) -> RpcResult> { diff --git a/client/rpc/src/author/tests.rs b/client/rpc/src/author/tests.rs index bf880cfbcfe9b..209673fce2602 100644 --- a/client/rpc/src/author/tests.rs +++ b/client/rpc/src/author/tests.rs @@ -36,7 +36,7 @@ use sp_core::{ testing::{ED25519, SR25519}, H256, }; -use sp_keystore::testing::KeyStore; +use sp_keystore::testing::MemoryKeystore; use std::sync::Arc; use substrate_test_runtime_client::{ self, @@ -58,13 +58,13 @@ type FullTransactionPool = BasicPool, Block>, Block struct TestSetup { pub client: Arc>, - pub keystore: Arc, + pub keystore: Arc, pub pool: Arc, } impl Default for TestSetup { fn default() -> Self { - let keystore = Arc::new(KeyStore::new()); + let keystore = Arc::new(MemoryKeystore::new()); let client_builder = substrate_test_runtime_client::TestClientBuilder::new(); let client = Arc::new(client_builder.set_keystore(keystore.clone()).build()); @@ -225,7 +225,7 @@ async fn author_should_insert_key() { keypair.public().0.to_vec().into(), ); api.call::<_, ()>("author_insertKey", params).await.unwrap(); - let pubkeys = SyncCryptoStore::keys(&*setup.keystore, ED25519).unwrap(); + let pubkeys = Keystore::keys(&*setup.keystore, ED25519).unwrap(); assert!( pubkeys.contains(&CryptoTypePublicPair(ed25519::CRYPTO_ID, keypair.public().to_raw_vec())) @@ -240,8 +240,8 @@ async fn author_should_rotate_keys() { let new_pubkeys: Bytes = api.call("author_rotateKeys", EmptyParams::new()).await.unwrap(); let session_keys = SessionKeys::decode(&mut &new_pubkeys[..]).expect("SessionKeys decode successfully"); - let ed25519_pubkeys = SyncCryptoStore::keys(&*setup.keystore, ED25519).unwrap(); - let sr25519_pubkeys = SyncCryptoStore::keys(&*setup.keystore, SR25519).unwrap(); + let ed25519_pubkeys = Keystore::keys(&*setup.keystore, ED25519).unwrap(); + let sr25519_pubkeys = Keystore::keys(&*setup.keystore, SR25519).unwrap(); assert!(ed25519_pubkeys .contains(&CryptoTypePublicPair(ed25519::CRYPTO_ID, session_keys.ed25519.to_raw_vec()))); assert!(sr25519_pubkeys diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 91ef65cf134e4..034d056d6f66f 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -67,7 +67,7 @@ use sp_consensus::block_validation::{ BlockAnnounceValidator, Chain, DefaultBlockAnnounceValidator, }; use sp_core::traits::{CodeExecutor, SpawnNamed}; -use sp_keystore::{CryptoStore, SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{Keystore, KeystorePtr}; use sp_runtime::traits::{Block as BlockT, BlockIdTo, NumberFor, Zero}; use std::{str::FromStr, sync::Arc, time::SystemTime}; @@ -85,26 +85,22 @@ pub type TFullCallExecutor = type TFullParts = (TFullClient, Arc>, KeystoreContainer, TaskManager); -trait AsCryptoStoreRef { - fn keystore_ref(&self) -> Arc; - fn sync_keystore_ref(&self) -> Arc; +trait AsKeystoreRef { + fn keystore_ref(&self) -> Arc; } -impl AsCryptoStoreRef for Arc +impl AsKeystoreRef for Arc where - T: CryptoStore + SyncCryptoStore + 'static, + T: Keystore + 'static, { - fn keystore_ref(&self) -> Arc { - self.clone() - } - fn sync_keystore_ref(&self) -> Arc { + fn keystore_ref(&self) -> Arc { self.clone() } } /// Construct and hold different layers of Keystore wrappers pub struct KeystoreContainer { - remote: Option>, + remote: Option>, local: Arc, } @@ -127,13 +123,13 @@ impl KeystoreContainer { /// stick around. pub fn set_remote_keystore(&mut self, remote: Arc) where - T: CryptoStore + SyncCryptoStore + 'static, + T: Keystore + 'static, { self.remote = Some(Box::new(remote)) } - /// Returns an adapter to the asynchronous keystore that implements `CryptoStore` - pub fn keystore(&self) -> Arc { + /// Returns an adapter to a `Keystore` implementation. + pub fn keystore(&self) -> Arc { if let Some(c) = self.remote.as_ref() { c.keystore_ref() } else { @@ -141,15 +137,6 @@ impl KeystoreContainer { } } - /// Returns the synchronous keystore wrapper - pub fn sync_keystore(&self) -> SyncCryptoStorePtr { - if let Some(c) = self.remote.as_ref() { - c.sync_keystore_ref() - } else { - self.local.clone() as SyncCryptoStorePtr - } - } - /// Returns the local keystore if available /// /// The function will return None if the available keystore is not a local keystore. @@ -234,7 +221,7 @@ where let client = { let extensions = sc_client_api::execution_extensions::ExecutionExtensions::new( config.execution_strategies.clone(), - Some(keystore_container.sync_keystore()), + Some(keystore_container.keystore()), sc_offchain::OffchainDb::factory_from_backend(&*backend), ); @@ -374,7 +361,7 @@ pub struct SpawnTasksParams<'a, TBl: BlockT, TCl, TExPool, TRpc, Backend> { /// A task manager returned by `new_full_parts`. pub task_manager: &'a mut TaskManager, /// A shared keystore returned by `new_full_parts`. - pub keystore: SyncCryptoStorePtr, + pub keystore: KeystorePtr, /// A shared transaction pool. pub transaction_pool: Arc, /// Builds additional [`RpcModule`]s that should be added to the server @@ -645,7 +632,7 @@ fn gen_rpc_module( spawn_handle: SpawnTaskHandle, client: Arc, transaction_pool: Arc, - keystore: SyncCryptoStorePtr, + keystore: KeystorePtr, system_rpc_tx: TracingUnboundedSender>, config: &Configuration, backend: Arc, diff --git a/client/service/src/client/client.rs b/client/service/src/client/client.rs index 3613cc760f569..d5212021f2d79 100644 --- a/client/service/src/client/client.rs +++ b/client/service/src/client/client.rs @@ -65,7 +65,7 @@ use sp_core::{ traits::SpawnNamed, }; #[cfg(feature = "test-helpers")] -use sp_keystore::SyncCryptoStorePtr; +use sp_keystore::KeystorePtr; use sp_runtime::{ generic::{BlockId, SignedBlock}, traits::{ @@ -161,7 +161,7 @@ pub fn new_in_mem( backend: Arc>, executor: E, genesis_block_builder: G, - keystore: Option, + keystore: Option, prometheus_registry: Option, telemetry: Option, spawn_handle: Box, @@ -224,7 +224,7 @@ pub fn new_with_backend( backend: Arc, executor: E, genesis_block_builder: G, - keystore: Option, + keystore: Option, spawn_handle: Box, prometheus_registry: Option, telemetry: Option, diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 11d4ba5011a2f..1f6e9c5a68892 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -160,12 +160,12 @@ pub mod mock { impl super::Config for Test {} pub fn new_test_ext() -> sp_io::TestExternalities { - use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr}; + use sp_keystore::{testing::MemoryKeystore, KeystoreExt, KeystorePtr}; use sp_std::sync::Arc; let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); let mut ext = sp_io::TestExternalities::new(t); - ext.register_extension(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); + ext.register_extension(KeystoreExt(Arc::new(MemoryKeystore::new()) as KeystorePtr)); ext } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index d74b08243df4b..ba9873f07efee 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -44,7 +44,7 @@ use frame_support::{ use frame_system::{self as system, EventRecord, Phase}; use pretty_assertions::{assert_eq, assert_ne}; use sp_io::hashing::blake2_256; -use sp_keystore::{testing::KeyStore, KeystoreExt}; +use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ testing::{Header, H256}, traits::{BlakeTwo256, Convert, Hash, IdentityLookup}, @@ -440,7 +440,7 @@ impl ExtBuilder { .assimilate_storage(&mut t) .unwrap(); let mut ext = sp_io::TestExternalities::new(t); - ext.register_extension(KeystoreExt(Arc::new(KeyStore::new()))); + ext.register_extension(KeystoreExt(Arc::new(MemoryKeystore::new()))); ext.execute_with(|| System::set_block_number(1)); ext } diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 75a42e872ae52..c513590435252 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -29,7 +29,7 @@ use sp_core::{ }; use std::sync::Arc; -use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStore}; +use sp_keystore::{testing::MemoryKeystore, Keystore, KeystoreExt}; use sp_runtime::{ testing::{Header, TestXt}, traits::{BlakeTwo256, Extrinsic as ExtrinsicT, IdentifyAccount, IdentityLookup, Verify}, @@ -205,8 +205,8 @@ fn should_submit_signed_transaction_on_chain() { let (offchain, offchain_state) = testing::TestOffchainExt::new(); let (pool, pool_state) = testing::TestTransactionPoolExt::new(); - let keystore = KeyStore::new(); - SyncCryptoStore::sr25519_generate_new( + let keystore = MemoryKeystore::new(); + Keystore::sr25519_generate_new( &keystore, crate::crypto::Public::ID, Some(&format!("{}/hunter1", PHRASE)), @@ -239,16 +239,16 @@ fn should_submit_unsigned_transaction_on_chain_for_any_account() { let (offchain, offchain_state) = testing::TestOffchainExt::new(); let (pool, pool_state) = testing::TestTransactionPoolExt::new(); - let keystore = KeyStore::new(); + let keystore = MemoryKeystore::new(); - SyncCryptoStore::sr25519_generate_new( + Keystore::sr25519_generate_new( &keystore, crate::crypto::Public::ID, Some(&format!("{}/hunter1", PHRASE)), ) .unwrap(); - let public_key = *SyncCryptoStore::sr25519_public_keys(&keystore, crate::crypto::Public::ID) + let public_key = *Keystore::sr25519_public_keys(&keystore, crate::crypto::Public::ID) .get(0) .unwrap(); @@ -298,16 +298,16 @@ fn should_submit_unsigned_transaction_on_chain_for_all_accounts() { let (offchain, offchain_state) = testing::TestOffchainExt::new(); let (pool, pool_state) = testing::TestTransactionPoolExt::new(); - let keystore = KeyStore::new(); + let keystore = MemoryKeystore::new(); - SyncCryptoStore::sr25519_generate_new( + Keystore::sr25519_generate_new( &keystore, crate::crypto::Public::ID, Some(&format!("{}/hunter1", PHRASE)), ) .unwrap(); - let public_key = *SyncCryptoStore::sr25519_public_keys(&keystore, crate::crypto::Public::ID) + let public_key = *Keystore::sr25519_public_keys(&keystore, crate::crypto::Public::ID) .get(0) .unwrap(); @@ -355,7 +355,7 @@ fn should_submit_raw_unsigned_transaction_on_chain() { let (offchain, offchain_state) = testing::TestOffchainExt::new(); let (pool, pool_state) = testing::TestTransactionPoolExt::new(); - let keystore = KeyStore::new(); + let keystore = MemoryKeystore::new(); let mut t = sp_io::TestExternalities::default(); t.register_extension(OffchainWorkerExt::new(offchain)); diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index a9db1a62c9d67..f21547b720c34 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -25,7 +25,7 @@ use frame_support::{ traits::{AsEnsureOriginWithArg, ConstU32, ConstU64}, }; use sp_core::H256; -use sp_keystore::{testing::KeyStore, KeystoreExt}; +use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, @@ -130,7 +130,7 @@ impl Config for Test { pub(crate) fn new_test_ext() -> sp_io::TestExternalities { let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - let keystore = KeyStore::new(); + let keystore = MemoryKeystore::new(); let mut ext = sp_io::TestExternalities::new(t); ext.register_extension(KeystoreExt(Arc::new(keystore))); ext.execute_with(|| System::set_block_number(1)); diff --git a/primitives/application-crypto/test/src/ecdsa.rs b/primitives/application-crypto/test/src/ecdsa.rs index df3be6f934304..7b96b42d5556b 100644 --- a/primitives/application-crypto/test/src/ecdsa.rs +++ b/primitives/application-crypto/test/src/ecdsa.rs @@ -19,7 +19,7 @@ use sp_api::ProvideRuntimeApi; use sp_application_crypto::ecdsa::{AppPair, AppPublic}; use sp_core::{crypto::Pair, testing::ECDSA}; -use sp_keystore::{testing::KeyStore, SyncCryptoStore}; +use sp_keystore::{testing::MemoryKeystore, Keystore}; use std::sync::Arc; use substrate_test_runtime_client::{ runtime::TestAPI, DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt, @@ -27,14 +27,14 @@ use substrate_test_runtime_client::{ #[test] fn ecdsa_works_in_runtime() { - let keystore = Arc::new(KeyStore::new()); + let keystore = Arc::new(MemoryKeystore::new()); let test_client = TestClientBuilder::new().set_keystore(keystore.clone()).build(); let (signature, public) = test_client .runtime_api() .test_ecdsa_crypto(test_client.chain_info().genesis_hash) .expect("Tests `ecdsa` crypto."); - let supported_keys = SyncCryptoStore::keys(&*keystore, ECDSA).unwrap(); + let supported_keys = Keystore::keys(&*keystore, ECDSA).unwrap(); assert!(supported_keys.contains(&public.clone().into())); assert!(AppPair::verify(&signature, "ecdsa", &AppPublic::from(public))); } diff --git a/primitives/application-crypto/test/src/ed25519.rs b/primitives/application-crypto/test/src/ed25519.rs index 8ce08717a8947..1cf2b574b6bfb 100644 --- a/primitives/application-crypto/test/src/ed25519.rs +++ b/primitives/application-crypto/test/src/ed25519.rs @@ -20,7 +20,7 @@ use sp_api::ProvideRuntimeApi; use sp_application_crypto::ed25519::{AppPair, AppPublic}; use sp_core::{crypto::Pair, testing::ED25519}; -use sp_keystore::{testing::KeyStore, SyncCryptoStore}; +use sp_keystore::{testing::MemoryKeystore, Keystore}; use std::sync::Arc; use substrate_test_runtime_client::{ runtime::TestAPI, DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt, @@ -28,14 +28,14 @@ use substrate_test_runtime_client::{ #[test] fn ed25519_works_in_runtime() { - let keystore = Arc::new(KeyStore::new()); + let keystore = Arc::new(MemoryKeystore::new()); let test_client = TestClientBuilder::new().set_keystore(keystore.clone()).build(); let (signature, public) = test_client .runtime_api() .test_ed25519_crypto(test_client.chain_info().genesis_hash) .expect("Tests `ed25519` crypto."); - let supported_keys = SyncCryptoStore::keys(&*keystore, ED25519).unwrap(); + let supported_keys = Keystore::keys(&*keystore, ED25519).unwrap(); assert!(supported_keys.contains(&public.clone().into())); assert!(AppPair::verify(&signature, "ed25519", &AppPublic::from(public))); } diff --git a/primitives/application-crypto/test/src/sr25519.rs b/primitives/application-crypto/test/src/sr25519.rs index 4c1d0f1ef7a97..aa8f75c0dc27a 100644 --- a/primitives/application-crypto/test/src/sr25519.rs +++ b/primitives/application-crypto/test/src/sr25519.rs @@ -20,7 +20,7 @@ use sp_api::ProvideRuntimeApi; use sp_application_crypto::sr25519::{AppPair, AppPublic}; use sp_core::{crypto::Pair, testing::SR25519}; -use sp_keystore::{testing::KeyStore, SyncCryptoStore}; +use sp_keystore::{testing::MemoryKeystore, Keystore}; use std::sync::Arc; use substrate_test_runtime_client::{ runtime::TestAPI, DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt, @@ -28,14 +28,14 @@ use substrate_test_runtime_client::{ #[test] fn sr25519_works_in_runtime() { - let keystore = Arc::new(KeyStore::new()); + let keystore = Arc::new(MemoryKeystore::new()); let test_client = TestClientBuilder::new().set_keystore(keystore.clone()).build(); let (signature, public) = test_client .runtime_api() .test_sr25519_crypto(test_client.chain_info().genesis_hash) .expect("Tests `sr25519` crypto."); - let supported_keys = SyncCryptoStore::keys(&*keystore, SR25519).unwrap(); + let supported_keys = Keystore::keys(&*keystore, SR25519).unwrap(); assert!(supported_keys.contains(&public.clone().into())); assert!(AppPair::verify(&signature, "sr25519", &AppPublic::from(public))); } diff --git a/primitives/consensus/beefy/src/commitment.rs b/primitives/consensus/beefy/src/commitment.rs index f824c90e27c46..6ae17b06d96a4 100644 --- a/primitives/consensus/beefy/src/commitment.rs +++ b/primitives/consensus/beefy/src/commitment.rs @@ -253,7 +253,7 @@ mod tests { use crate::{crypto, known_payloads, KEY_TYPE}; use codec::Decode; use sp_core::{keccak_256, Pair}; - use sp_keystore::{testing::KeyStore, SyncCryptoStore, SyncCryptoStorePtr}; + use sp_keystore::{testing::MemoryKeystore, Keystore, KeystorePtr}; type TestCommitment = Commitment; type TestSignedCommitment = SignedCommitment; @@ -263,20 +263,18 @@ mod tests { // The mock signatures are equivalent to the ones produced by the BEEFY keystore fn mock_signatures() -> (crypto::Signature, crypto::Signature) { - let store: SyncCryptoStorePtr = KeyStore::new().into(); + let store: KeystorePtr = MemoryKeystore::new().into(); let alice = sp_core::ecdsa::Pair::from_string("//Alice", None).unwrap(); - let _ = - SyncCryptoStore::insert_unknown(&*store, KEY_TYPE, "//Alice", alice.public().as_ref()) - .unwrap(); + let _ = Keystore::insert(&*store, KEY_TYPE, "//Alice", alice.public().as_ref()).unwrap(); let msg = keccak_256(b"This is the first message"); - let sig1 = SyncCryptoStore::ecdsa_sign_prehashed(&*store, KEY_TYPE, &alice.public(), &msg) + let sig1 = Keystore::ecdsa_sign_prehashed(&*store, KEY_TYPE, &alice.public(), &msg) .unwrap() .unwrap(); let msg = keccak_256(b"This is the second message"); - let sig2 = SyncCryptoStore::ecdsa_sign_prehashed(&*store, KEY_TYPE, &alice.public(), &msg) + let sig2 = Keystore::ecdsa_sign_prehashed(&*store, KEY_TYPE, &alice.public(), &msg) .unwrap() .unwrap(); diff --git a/primitives/consensus/beefy/src/witness.rs b/primitives/consensus/beefy/src/witness.rs index 9cc31d54b4c1d..70b924c0a42fe 100644 --- a/primitives/consensus/beefy/src/witness.rs +++ b/primitives/consensus/beefy/src/witness.rs @@ -76,7 +76,7 @@ impl SignedCommitmentWitness (crypto::Signature, crypto::Signature) { - let store: SyncCryptoStorePtr = KeyStore::new().into(); + let store: KeystorePtr = MemoryKeystore::new().into(); let alice = sp_core::ecdsa::Pair::from_string("//Alice", None).unwrap(); - let _ = - SyncCryptoStore::insert_unknown(&*store, KEY_TYPE, "//Alice", alice.public().as_ref()) - .unwrap(); + let _ = Keystore::insert(&*store, KEY_TYPE, "//Alice", alice.public().as_ref()).unwrap(); let msg = keccak_256(b"This is the first message"); - let sig1 = SyncCryptoStore::ecdsa_sign_prehashed(&*store, KEY_TYPE, &alice.public(), &msg) + let sig1 = Keystore::ecdsa_sign_prehashed(&*store, KEY_TYPE, &alice.public(), &msg) .unwrap() .unwrap(); let msg = keccak_256(b"This is the second message"); - let sig2 = SyncCryptoStore::ecdsa_sign_prehashed(&*store, KEY_TYPE, &alice.public(), &msg) + let sig2 = Keystore::ecdsa_sign_prehashed(&*store, KEY_TYPE, &alice.public(), &msg) .unwrap() .unwrap(); diff --git a/primitives/consensus/grandpa/src/lib.rs b/primitives/consensus/grandpa/src/lib.rs index 26cee07b80be8..32fc563b1facd 100644 --- a/primitives/consensus/grandpa/src/lib.rs +++ b/primitives/consensus/grandpa/src/lib.rs @@ -28,7 +28,7 @@ use serde::Serialize; use codec::{Codec, Decode, Encode, Input}; use scale_info::TypeInfo; #[cfg(feature = "std")] -use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; +use sp_keystore::{Keystore, KeystorePtr}; use sp_runtime::{ traits::{Header as HeaderT, NumberFor}, ConsensusEngineId, RuntimeDebug, @@ -444,7 +444,7 @@ where /// Localizes the message to the given set and round and signs the payload. #[cfg(feature = "std")] pub fn sign_message( - keystore: SyncCryptoStorePtr, + keystore: KeystorePtr, message: grandpa::Message, public: AuthorityId, round: RoundNumber, @@ -458,7 +458,7 @@ where use sp_core::crypto::Public; let encoded = localized_payload(round, set_id, &message); - let signature = SyncCryptoStore::sign_with( + let signature = Keystore::sign_with( &*keystore, AuthorityId::ID, &public.to_public_crypto_pair(), diff --git a/primitives/io/src/lib.rs b/primitives/io/src/lib.rs index 8c3cdc668cba3..65c583330ca73 100644 --- a/primitives/io/src/lib.rs +++ b/primitives/io/src/lib.rs @@ -43,7 +43,7 @@ use sp_core::{ traits::TaskExecutorExt, }; #[cfg(feature = "std")] -use sp_keystore::{KeystoreExt, SyncCryptoStore}; +use sp_keystore::{Keystore, KeystoreExt}; use sp_core::{ crypto::KeyTypeId, @@ -734,7 +734,7 @@ pub trait Crypto { let keystore = &***self .extension::() .expect("No `keystore` associated for the current context!"); - SyncCryptoStore::ed25519_public_keys(keystore, id) + Keystore::ed25519_public_keys(keystore, id) } /// Generate an `ed22519` key for the given key type using an optional `seed` and @@ -748,8 +748,7 @@ pub trait Crypto { let keystore = &***self .extension::() .expect("No `keystore` associated for the current context!"); - SyncCryptoStore::ed25519_generate_new(keystore, id, seed) - .expect("`ed25519_generate` failed") + Keystore::ed25519_generate_new(keystore, id, seed).expect("`ed25519_generate` failed") } /// Sign the given `msg` with the `ed25519` key that corresponds to the given public key and @@ -765,7 +764,7 @@ pub trait Crypto { let keystore = &***self .extension::() .expect("No `keystore` associated for the current context!"); - SyncCryptoStore::sign_with(keystore, id, &pub_key.into(), msg) + Keystore::sign_with(keystore, id, &pub_key.into(), msg) .ok() .flatten() .and_then(|sig| ed25519::Signature::from_slice(&sig)) @@ -877,7 +876,7 @@ pub trait Crypto { let keystore = &***self .extension::() .expect("No `keystore` associated for the current context!"); - SyncCryptoStore::sr25519_public_keys(keystore, id) + Keystore::sr25519_public_keys(keystore, id) } /// Generate an `sr22519` key for the given key type using an optional seed and @@ -891,8 +890,7 @@ pub trait Crypto { let keystore = &***self .extension::() .expect("No `keystore` associated for the current context!"); - SyncCryptoStore::sr25519_generate_new(keystore, id, seed) - .expect("`sr25519_generate` failed") + Keystore::sr25519_generate_new(keystore, id, seed).expect("`sr25519_generate` failed") } /// Sign the given `msg` with the `sr25519` key that corresponds to the given public key and @@ -908,7 +906,7 @@ pub trait Crypto { let keystore = &***self .extension::() .expect("No `keystore` associated for the current context!"); - SyncCryptoStore::sign_with(keystore, id, &pub_key.into(), msg) + Keystore::sign_with(keystore, id, &pub_key.into(), msg) .ok() .flatten() .and_then(|sig| sr25519::Signature::from_slice(&sig)) @@ -927,7 +925,7 @@ pub trait Crypto { let keystore = &***self .extension::() .expect("No `keystore` associated for the current context!"); - SyncCryptoStore::ecdsa_public_keys(keystore, id) + Keystore::ecdsa_public_keys(keystore, id) } /// Generate an `ecdsa` key for the given key type using an optional `seed` and @@ -941,7 +939,7 @@ pub trait Crypto { let keystore = &***self .extension::() .expect("No `keystore` associated for the current context!"); - SyncCryptoStore::ecdsa_generate_new(keystore, id, seed).expect("`ecdsa_generate` failed") + Keystore::ecdsa_generate_new(keystore, id, seed).expect("`ecdsa_generate` failed") } /// Sign the given `msg` with the `ecdsa` key that corresponds to the given public key and @@ -957,7 +955,7 @@ pub trait Crypto { let keystore = &***self .extension::() .expect("No `keystore` associated for the current context!"); - SyncCryptoStore::sign_with(keystore, id, &pub_key.into(), msg) + Keystore::sign_with(keystore, id, &pub_key.into(), msg) .ok() .flatten() .and_then(|sig| ecdsa::Signature::from_slice(&sig)) @@ -976,7 +974,7 @@ pub trait Crypto { let keystore = &***self .extension::() .expect("No `keystore` associated for the current context!"); - SyncCryptoStore::ecdsa_sign_prehashed(keystore, id, pub_key, msg).ok().flatten() + Keystore::ecdsa_sign_prehashed(keystore, id, pub_key, msg).ok().flatten() } /// Verify `ecdsa` signature. diff --git a/primitives/keystore/Cargo.toml b/primitives/keystore/Cargo.toml index 9386cb5d104d2..543f01059412e 100644 --- a/primitives/keystore/Cargo.toml +++ b/primitives/keystore/Cargo.toml @@ -13,7 +13,6 @@ documentation = "https://docs.rs/sp-core" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -async-trait = "0.1.57" codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } futures = "0.3.21" merlin = { version = "2.0", default-features = false } diff --git a/primitives/keystore/src/lib.rs b/primitives/keystore/src/lib.rs index 17c435483bae5..e0c00967b6b5e 100644 --- a/primitives/keystore/src/lib.rs +++ b/primitives/keystore/src/lib.rs @@ -20,15 +20,13 @@ pub mod testing; pub mod vrf; use crate::vrf::{VRFSignature, VRFTranscriptData}; -use async_trait::async_trait; -use futures::{executor::block_on, future::join_all}; use sp_core::{ crypto::{CryptoTypePublicPair, KeyTypeId}, ecdsa, ed25519, sr25519, }; use std::sync::Arc; -/// CryptoStore error +/// Keystore error #[derive(Debug, thiserror::Error)] pub enum Error { /// Public key type is not supported @@ -45,179 +43,8 @@ pub enum Error { Other(String), } -/// Something that generates, stores and provides access to keys. -#[async_trait] -pub trait CryptoStore: Send + Sync { - /// Returns all sr25519 public keys for the given key type. - async fn sr25519_public_keys(&self, id: KeyTypeId) -> Vec; - /// Generate a new sr25519 key pair for the given key type and an optional seed. - /// - /// If the given seed is `Some(_)`, the key pair will only be stored in memory. - /// - /// Returns the public key of the generated key pair. - async fn sr25519_generate_new( - &self, - id: KeyTypeId, - seed: Option<&str>, - ) -> Result; - /// Returns all ed25519 public keys for the given key type. - async fn ed25519_public_keys(&self, id: KeyTypeId) -> Vec; - /// Generate a new ed25519 key pair for the given key type and an optional seed. - /// - /// If the given seed is `Some(_)`, the key pair will only be stored in memory. - /// - /// Returns the public key of the generated key pair. - async fn ed25519_generate_new( - &self, - id: KeyTypeId, - seed: Option<&str>, - ) -> Result; - /// Returns all ecdsa public keys for the given key type. - async fn ecdsa_public_keys(&self, id: KeyTypeId) -> Vec; - /// Generate a new ecdsa key pair for the given key type and an optional seed. - /// - /// If the given seed is `Some(_)`, the key pair will only be stored in memory. - /// - /// Returns the public key of the generated key pair. - async fn ecdsa_generate_new( - &self, - id: KeyTypeId, - seed: Option<&str>, - ) -> Result; - - /// Insert a new key. This doesn't require any known of the crypto; but a public key must be - /// manually provided. - /// - /// Places it into the file system store. - /// - /// `Err` if there's some sort of weird filesystem error, but should generally be `Ok`. - async fn insert_unknown(&self, id: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()>; - - /// Find intersection between provided keys and supported keys - /// - /// Provided a list of (CryptoTypeId,[u8]) pairs, this would return - /// a filtered set of public keys which are supported by the keystore. - async fn supported_keys( - &self, - id: KeyTypeId, - keys: Vec, - ) -> Result, Error>; - /// List all supported keys - /// - /// Returns a set of public keys the signer supports. - async fn keys(&self, id: KeyTypeId) -> Result, Error>; - - /// Checks if the private keys for the given public key and key type combinations exist. - /// - /// Returns `true` iff all private keys could be found. - async fn has_keys(&self, public_keys: &[(Vec, KeyTypeId)]) -> bool; - - /// Sign with key - /// - /// Signs a message with the private key that matches - /// the public key passed. - /// - /// Returns the SCALE encoded signature if key is found and supported, `None` if the key doesn't - /// exist or an error when something failed. - async fn sign_with( - &self, - id: KeyTypeId, - key: &CryptoTypePublicPair, - msg: &[u8], - ) -> Result>, Error>; - - /// Sign with any key - /// - /// Given a list of public keys, find the first supported key and - /// sign the provided message with that key. - /// - /// Returns a tuple of the used key and the SCALE encoded signature or `None` if no key could - /// be found to sign. - async fn sign_with_any( - &self, - id: KeyTypeId, - keys: Vec, - msg: &[u8], - ) -> Result)>, Error> { - if keys.len() == 1 { - return Ok(self.sign_with(id, &keys[0], msg).await?.map(|s| (keys[0].clone(), s))) - } else { - for k in self.supported_keys(id, keys).await? { - if let Ok(Some(sign)) = self.sign_with(id, &k, msg).await { - return Ok(Some((k, sign))) - } - } - } - - Ok(None) - } - - /// Sign with all keys - /// - /// Provided a list of public keys, sign a message with - /// each key given that the key is supported. - /// - /// Returns a list of `Result`s each representing the SCALE encoded - /// signature of each key, `None` if the key doesn't exist or a error when something failed. - async fn sign_with_all( - &self, - id: KeyTypeId, - keys: Vec, - msg: &[u8], - ) -> Result>, Error>>, ()> { - let futs = keys.iter().map(|k| self.sign_with(id, k, msg)); - - Ok(join_all(futs).await) - } - - /// Generate VRF signature for given transcript data. - /// - /// Receives KeyTypeId and Public key to be able to map - /// them to a private key that exists in the keystore which - /// is, in turn, used for signing the provided transcript. - /// - /// Returns a result containing the signature data. - /// Namely, VRFOutput and VRFProof which are returned - /// inside the `VRFSignature` container struct. - /// - /// This function will return `None` if the given `key_type` and `public` combination - /// doesn't exist in the keystore or an `Err` when something failed. - async fn sr25519_vrf_sign( - &self, - key_type: KeyTypeId, - public: &sr25519::Public, - transcript_data: VRFTranscriptData, - ) -> Result, Error>; - - /// Generate an ECDSA signature for a given pre-hashed message. - /// - /// Receives [`KeyTypeId`] and an [`ecdsa::Public`] key to be able to map - /// them to a private key that exists in the keystore. This private key is, - /// in turn, used for signing the provided pre-hashed message. - /// - /// The `msg` argument provided should be a hashed message for which an - /// ECDSA signature should be generated. - /// - /// Returns an [`ecdsa::Signature`] or `None` in case the given `id` and - /// `public` combination doesn't exist in the keystore. An `Err` will be - /// returned if generating the signature itself failed. - async fn ecdsa_sign_prehashed( - &self, - id: KeyTypeId, - public: &ecdsa::Public, - msg: &[u8; 32], - ) -> Result, Error>; -} - -/// Sync version of the CryptoStore -/// -/// Some parts of Substrate still rely on a sync version of the `CryptoStore`. -/// To make the transition easier this auto trait wraps any async `CryptoStore` and -/// exposes a `sync` interface using `block_on`. Usage of this is deprecated and it -/// will be removed as soon as the internal usage has transitioned successfully. -/// If you are starting out building something new **do not use this**, -/// instead, use [`CryptoStore`]. -pub trait SyncCryptoStore: CryptoStore + Send + Sync { +/// Something that generates, stores and provides access to secret keys. +pub trait Keystore: Send + Sync { /// Returns all sr25519 public keys for the given key type. fn sr25519_public_keys(&self, id: KeyTypeId) -> Vec; @@ -257,30 +84,13 @@ pub trait SyncCryptoStore: CryptoStore + Send + Sync { fn ecdsa_generate_new(&self, id: KeyTypeId, seed: Option<&str>) -> Result; - /// Insert a new key. This doesn't require any known of the crypto; but a public key must be - /// manually provided. - /// - /// Places it into the file system store. - /// - /// `Err` if there's some sort of weird filesystem error, but should generally be `Ok`. - fn insert_unknown(&self, key_type: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()>; - - /// Find intersection between provided keys and supported keys - /// - /// Provided a list of (CryptoTypeId,[u8]) pairs, this would return - /// a filtered set of public keys which are supported by the keystore. - fn supported_keys( - &self, - id: KeyTypeId, - keys: Vec, - ) -> Result, Error>; + /// Insert a new secret key. + fn insert(&self, key_type: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()>; /// List all supported keys /// /// Returns a set of public keys the signer supports. - fn keys(&self, id: KeyTypeId) -> Result, Error> { - block_on(CryptoStore::keys(self, id)) - } + fn keys(&self, id: KeyTypeId) -> Result, Error>; /// Checks if the private keys for the given public key and key type combinations exist. /// @@ -301,50 +111,6 @@ pub trait SyncCryptoStore: CryptoStore + Send + Sync { msg: &[u8], ) -> Result>, Error>; - /// Sign with any key - /// - /// Given a list of public keys, find the first supported key and - /// sign the provided message with that key. - /// - /// Returns a tuple of the used key and the SCALE encoded signature or `None` if no key could - /// be found to sign. - fn sign_with_any( - &self, - id: KeyTypeId, - keys: Vec, - msg: &[u8], - ) -> Result)>, Error> { - if keys.len() == 1 { - return Ok( - SyncCryptoStore::sign_with(self, id, &keys[0], msg)?.map(|s| (keys[0].clone(), s)) - ) - } else { - for k in SyncCryptoStore::supported_keys(self, id, keys)? { - if let Ok(Some(sign)) = SyncCryptoStore::sign_with(self, id, &k, msg) { - return Ok(Some((k, sign))) - } - } - } - - Ok(None) - } - - /// Sign with all keys - /// - /// Provided a list of public keys, sign a message with - /// each key given that the key is supported. - /// - /// Returns a list of `Result`s each representing the SCALE encoded - /// signature of each key, `None` if the key doesn't exist or an error when something failed. - fn sign_with_all( - &self, - id: KeyTypeId, - keys: Vec, - msg: &[u8], - ) -> Result>, Error>>, ()> { - Ok(keys.iter().map(|k| SyncCryptoStore::sign_with(self, id, k, msg)).collect()) - } - /// Generate VRF signature for given transcript data. /// /// Receives KeyTypeId and Public key to be able to map @@ -385,9 +151,9 @@ pub trait SyncCryptoStore: CryptoStore + Send + Sync { } /// A pointer to a keystore. -pub type SyncCryptoStorePtr = Arc; +pub type KeystorePtr = Arc; sp_externalities::decl_extension! { /// The keystore extension to register/retrieve from the externalities. - pub struct KeystoreExt(SyncCryptoStorePtr); + pub struct KeystoreExt(KeystorePtr); } diff --git a/primitives/keystore/src/testing.rs b/primitives/keystore/src/testing.rs index 5058a06508eac..fecc11342c464 100644 --- a/primitives/keystore/src/testing.rs +++ b/primitives/keystore/src/testing.rs @@ -24,23 +24,19 @@ use sp_core::{ use crate::{ vrf::{make_transcript, VRFSignature, VRFTranscriptData}, - CryptoStore, Error, SyncCryptoStore, SyncCryptoStorePtr, + Error, Keystore, KeystorePtr, }; -use async_trait::async_trait; use parking_lot::RwLock; -use std::{ - collections::{HashMap, HashSet}, - sync::Arc, -}; +use std::{collections::HashMap, sync::Arc}; /// A keystore implementation usable in tests. #[derive(Default)] -pub struct KeyStore { +pub struct MemoryKeystore { /// `KeyTypeId` maps to public keys and public keys map to private keys. keys: Arc, String>>>>, } -impl KeyStore { +impl MemoryKeystore { /// Creates a new instance of `Self`. pub fn new() -> Self { Self::default() @@ -71,93 +67,7 @@ impl KeyStore { } } -#[async_trait] -impl CryptoStore for KeyStore { - async fn keys(&self, id: KeyTypeId) -> Result, Error> { - SyncCryptoStore::keys(self, id) - } - - async fn sr25519_public_keys(&self, id: KeyTypeId) -> Vec { - SyncCryptoStore::sr25519_public_keys(self, id) - } - - async fn sr25519_generate_new( - &self, - id: KeyTypeId, - seed: Option<&str>, - ) -> Result { - SyncCryptoStore::sr25519_generate_new(self, id, seed) - } - - async fn ed25519_public_keys(&self, id: KeyTypeId) -> Vec { - SyncCryptoStore::ed25519_public_keys(self, id) - } - - async fn ed25519_generate_new( - &self, - id: KeyTypeId, - seed: Option<&str>, - ) -> Result { - SyncCryptoStore::ed25519_generate_new(self, id, seed) - } - - async fn ecdsa_public_keys(&self, id: KeyTypeId) -> Vec { - SyncCryptoStore::ecdsa_public_keys(self, id) - } - - async fn ecdsa_generate_new( - &self, - id: KeyTypeId, - seed: Option<&str>, - ) -> Result { - SyncCryptoStore::ecdsa_generate_new(self, id, seed) - } - - async fn insert_unknown(&self, id: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()> { - SyncCryptoStore::insert_unknown(self, id, suri, public) - } - - async fn has_keys(&self, public_keys: &[(Vec, KeyTypeId)]) -> bool { - SyncCryptoStore::has_keys(self, public_keys) - } - - async fn supported_keys( - &self, - id: KeyTypeId, - keys: Vec, - ) -> std::result::Result, Error> { - SyncCryptoStore::supported_keys(self, id, keys) - } - - async fn sign_with( - &self, - id: KeyTypeId, - key: &CryptoTypePublicPair, - msg: &[u8], - ) -> Result>, Error> { - SyncCryptoStore::sign_with(self, id, key, msg) - } - - async fn sr25519_vrf_sign( - &self, - key_type: KeyTypeId, - public: &sr25519::Public, - transcript_data: VRFTranscriptData, - ) -> Result, Error> { - SyncCryptoStore::sr25519_vrf_sign(self, key_type, public, transcript_data) - } - - async fn ecdsa_sign_prehashed( - &self, - id: KeyTypeId, - public: &ecdsa::Public, - msg: &[u8; 32], - ) -> Result, Error> { - SyncCryptoStore::ecdsa_sign_prehashed(self, id, public, msg) - } -} - -impl SyncCryptoStore for KeyStore { +impl Keystore for MemoryKeystore { fn keys(&self, id: KeyTypeId) -> Result, Error> { self.keys .read() @@ -304,7 +214,7 @@ impl SyncCryptoStore for KeyStore { } } - fn insert_unknown(&self, id: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()> { + fn insert(&self, id: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()> { self.keys .write() .entry(id) @@ -319,17 +229,6 @@ impl SyncCryptoStore for KeyStore { .all(|(k, t)| self.keys.read().get(t).and_then(|s| s.get(k)).is_some()) } - fn supported_keys( - &self, - id: KeyTypeId, - keys: Vec, - ) -> std::result::Result, Error> { - let provided_keys = keys.into_iter().collect::>(); - let all_keys = SyncCryptoStore::keys(self, id)?.into_iter().collect::>(); - - Ok(provided_keys.intersection(&all_keys).cloned().collect()) - } - fn sign_with( &self, id: KeyTypeId, @@ -386,14 +285,8 @@ impl SyncCryptoStore for KeyStore { } } -impl Into for KeyStore { - fn into(self) -> SyncCryptoStorePtr { - Arc::new(self) - } -} - -impl Into> for KeyStore { - fn into(self) -> Arc { +impl Into for MemoryKeystore { + fn into(self) -> KeystorePtr { Arc::new(self) } } @@ -401,7 +294,7 @@ impl Into> for KeyStore { #[cfg(test)] mod tests { use super::*; - use crate::{vrf::VRFTranscriptValue, SyncCryptoStore}; + use crate::vrf::VRFTranscriptValue; use sp_core::{ sr25519, testing::{ECDSA, ED25519, SR25519}, @@ -409,34 +302,33 @@ mod tests { #[test] fn store_key_and_extract() { - let store = KeyStore::new(); + let store = MemoryKeystore::new(); - let public = - SyncCryptoStore::ed25519_generate_new(&store, ED25519, None).expect("Generates key"); + let public = Keystore::ed25519_generate_new(&store, ED25519, None).expect("Generates key"); - let public_keys = SyncCryptoStore::keys(&store, ED25519).unwrap(); + let public_keys = Keystore::keys(&store, ED25519).unwrap(); assert!(public_keys.contains(&public.into())); } #[test] fn store_unknown_and_extract_it() { - let store = KeyStore::new(); + let store = MemoryKeystore::new(); let secret_uri = "//Alice"; let key_pair = sr25519::Pair::from_string(secret_uri, None).expect("Generates key pair"); - SyncCryptoStore::insert_unknown(&store, SR25519, secret_uri, key_pair.public().as_ref()) + Keystore::insert(&store, SR25519, secret_uri, key_pair.public().as_ref()) .expect("Inserts unknown key"); - let public_keys = SyncCryptoStore::keys(&store, SR25519).unwrap(); + let public_keys = Keystore::keys(&store, SR25519).unwrap(); assert!(public_keys.contains(&key_pair.public().into())); } #[test] fn vrf_sign() { - let store = KeyStore::new(); + let store = MemoryKeystore::new(); let secret_uri = "//Alice"; let key_pair = sr25519::Pair::from_string(secret_uri, None).expect("Generates key pair"); @@ -450,7 +342,7 @@ mod tests { ], }; - let result = SyncCryptoStore::sr25519_vrf_sign( + let result = Keystore::sr25519_vrf_sign( &store, SR25519, &key_pair.public(), @@ -458,18 +350,18 @@ mod tests { ); assert!(result.unwrap().is_none()); - SyncCryptoStore::insert_unknown(&store, SR25519, secret_uri, key_pair.public().as_ref()) + Keystore::insert(&store, SR25519, secret_uri, key_pair.public().as_ref()) .expect("Inserts unknown key"); let result = - SyncCryptoStore::sr25519_vrf_sign(&store, SR25519, &key_pair.public(), transcript_data); + Keystore::sr25519_vrf_sign(&store, SR25519, &key_pair.public(), transcript_data); assert!(result.unwrap().is_some()); } #[test] fn ecdsa_sign_prehashed_works() { - let store = KeyStore::new(); + let store = MemoryKeystore::new(); let suri = "//Alice"; let pair = ecdsa::Pair::from_string(suri, None).unwrap(); @@ -477,15 +369,13 @@ mod tests { let msg = sp_core::keccak_256(b"this should be a hashed message"); // no key in key store - let res = - SyncCryptoStore::ecdsa_sign_prehashed(&store, ECDSA, &pair.public(), &msg).unwrap(); + let res = Keystore::ecdsa_sign_prehashed(&store, ECDSA, &pair.public(), &msg).unwrap(); assert!(res.is_none()); // insert key, sign again - SyncCryptoStore::insert_unknown(&store, ECDSA, suri, pair.public().as_ref()).unwrap(); + Keystore::insert(&store, ECDSA, suri, pair.public().as_ref()).unwrap(); - let res = - SyncCryptoStore::ecdsa_sign_prehashed(&store, ECDSA, &pair.public(), &msg).unwrap(); + let res = Keystore::ecdsa_sign_prehashed(&store, ECDSA, &pair.public(), &msg).unwrap(); assert!(res.is_some()); } } diff --git a/test-utils/client/src/lib.rs b/test-utils/client/src/lib.rs index a27178792579a..a91aa99929e2f 100644 --- a/test-utils/client/src/lib.rs +++ b/test-utils/client/src/lib.rs @@ -33,7 +33,7 @@ pub use sp_consensus; pub use sp_keyring::{ ed25519::Keyring as Ed25519Keyring, sr25519::Keyring as Sr25519Keyring, AccountKeyring, }; -pub use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; +pub use sp_keystore::{Keystore, KeystorePtr}; pub use sp_runtime::{Storage, StorageChild}; pub use sp_state_machine::ExecutionStrategy; @@ -70,7 +70,7 @@ pub struct TestClientBuilder, StorageChild>, backend: Arc, _executor: std::marker::PhantomData, - keystore: Option, + keystore: Option, fork_blocks: ForkBlocks, bad_blocks: BadBlocks, enable_offchain_indexing_api: bool, @@ -128,7 +128,7 @@ impl } /// Set the keystore that should be used by the externalities. - pub fn set_keystore(mut self, keystore: SyncCryptoStorePtr) -> Self { + pub fn set_keystore(mut self, keystore: KeystorePtr) -> Self { self.keystore = Some(keystore); self } diff --git a/utils/frame/benchmarking-cli/src/pallet/command.rs b/utils/frame/benchmarking-cli/src/pallet/command.rs index 60f078142e17f..f11e6bd920abf 100644 --- a/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -38,7 +38,7 @@ use sp_core::{ traits::CallContext, }; use sp_externalities::Extensions; -use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr}; +use sp_keystore::{testing::MemoryKeystore, KeystoreExt, KeystorePtr}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; use sp_state_machine::StateMachine; use std::{collections::HashMap, fmt::Debug, fs, str::FromStr, sync::Arc, time}; @@ -218,7 +218,7 @@ impl PalletCmd { let extensions = || -> Extensions { let mut extensions = Extensions::default(); - extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); + extensions.register(KeystoreExt(Arc::new(MemoryKeystore::new()) as KeystorePtr)); let (offchain, _) = TestOffchainExt::new(); let (pool, _) = TestTransactionPoolExt::new(); extensions.register(OffchainWorkerExt::new(offchain.clone())); diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index 6fb4b44392546..e1d75064ac87f 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -383,7 +383,7 @@ use sp_core::{ }; use sp_externalities::Extensions; use sp_inherents::InherentData; -use sp_keystore::{testing::KeyStore, KeystoreExt}; +use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ traits::{BlakeTwo256, Block as BlockT, NumberFor}, DeserializeOwned, Digest, @@ -820,7 +820,7 @@ pub(crate) fn full_extensions() -> Extensions { let (pool, _pool_state) = TestTransactionPoolExt::new(); extensions.register(OffchainDbExt::new(offchain.clone())); extensions.register(OffchainWorkerExt::new(offchain)); - extensions.register(KeystoreExt(std::sync::Arc::new(KeyStore::new()))); + extensions.register(KeystoreExt(std::sync::Arc::new(MemoryKeystore::new()))); extensions.register(TransactionPoolExt::new(pool)); extensions From a87aa29b4b8796afe50ffbda4ad6f7692cc9a65e Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Fri, 17 Mar 2023 14:21:02 +0100 Subject: [PATCH 31/80] Bump grandpa to 0.16.2 (#13622) --- Cargo.lock | 4 ++-- client/consensus/grandpa/Cargo.toml | 4 ++-- client/consensus/grandpa/rpc/Cargo.toml | 2 +- frame/grandpa/Cargo.toml | 2 +- primitives/consensus/grandpa/Cargo.toml | 2 +- primitives/consensus/grandpa/src/lib.rs | 7 ++----- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9121a85919844..df0e54a3d7ecd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2080,9 +2080,9 @@ dependencies = [ [[package]] name = "finality-grandpa" -version = "0.16.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e24e6c429951433ccb7c87fd528c60084834dcd14763182c1f83291bcde24c34" +checksum = "36530797b9bf31cd4ff126dcfee8170f86b00cfdcea3269d73133cc0415945c3" dependencies = [ "either", "futures", diff --git a/client/consensus/grandpa/Cargo.toml b/client/consensus/grandpa/Cargo.toml index 511e546aa7256..67c58d37a2cf5 100644 --- a/client/consensus/grandpa/Cargo.toml +++ b/client/consensus/grandpa/Cargo.toml @@ -18,7 +18,7 @@ ahash = "0.8.2" array-bytes = "4.1" async-trait = "0.1.57" dyn-clone = "1.0" -finality-grandpa = { version = "0.16.1", features = ["derive-codec"] } +finality-grandpa = { version = "0.16.2", features = ["derive-codec"] } futures = "0.3.21" futures-timer = "3.0.1" log = "0.4.17" @@ -50,7 +50,7 @@ sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } [dev-dependencies] assert_matches = "1.3.0" -finality-grandpa = { version = "0.16.1", features = ["derive-codec", "test-helpers"] } +finality-grandpa = { version = "0.16.2", features = ["derive-codec", "test-helpers"] } serde = "1.0.136" tokio = "1.22.0" sc-network = { version = "0.10.0-dev", path = "../../network" } diff --git a/client/consensus/grandpa/rpc/Cargo.toml b/client/consensus/grandpa/rpc/Cargo.toml index 4880b50d30630..76a06ad298f77 100644 --- a/client/consensus/grandpa/rpc/Cargo.toml +++ b/client/consensus/grandpa/rpc/Cargo.toml @@ -10,7 +10,7 @@ readme = "README.md" homepage = "https://substrate.io" [dependencies] -finality-grandpa = { version = "0.16.1", features = ["derive-codec"] } +finality-grandpa = { version = "0.16.2", features = ["derive-codec"] } futures = "0.3.16" jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] } log = "0.4.8" diff --git a/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index 3ffb516423906..4eb796cf0c6b3 100644 --- a/frame/grandpa/Cargo.toml +++ b/frame/grandpa/Cargo.toml @@ -31,7 +31,7 @@ sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../pr sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" } [dev-dependencies] -grandpa = { package = "finality-grandpa", version = "0.16.1", features = ["derive-codec"] } +grandpa = { package = "finality-grandpa", version = "0.16.2", features = ["derive-codec"] } frame-benchmarking = { version = "4.0.0-dev", path = "../benchmarking" } frame-election-provider-support = { version = "4.0.0-dev", path = "../election-provider-support" } pallet-balances = { version = "4.0.0-dev", path = "../balances" } diff --git a/primitives/consensus/grandpa/Cargo.toml b/primitives/consensus/grandpa/Cargo.toml index 7146873e0a751..5536cf73558d9 100644 --- a/primitives/consensus/grandpa/Cargo.toml +++ b/primitives/consensus/grandpa/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } -grandpa = { package = "finality-grandpa", version = "0.16.1", default-features = false, features = ["derive-codec"] } +grandpa = { package = "finality-grandpa", version = "0.16.2", default-features = false, features = ["derive-codec"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", features = ["derive"], optional = true } diff --git a/primitives/consensus/grandpa/src/lib.rs b/primitives/consensus/grandpa/src/lib.rs index 32fc563b1facd..28c7de0677830 100644 --- a/primitives/consensus/grandpa/src/lib.rs +++ b/primitives/consensus/grandpa/src/lib.rs @@ -234,15 +234,12 @@ impl ConsensusLog { /// GRANDPA happens when a voter votes on the same round (either at prevote or /// precommit stage) for different blocks. Proving is achieved by collecting the /// signed messages of conflicting votes. -#[derive(Clone, Debug, Decode, Encode, PartialEq, TypeInfo)] +#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq, TypeInfo)] pub struct EquivocationProof { set_id: SetId, equivocation: Equivocation, } -// Don't bother the grandpa crate... -impl Eq for EquivocationProof {} - impl EquivocationProof { /// Create a new `EquivocationProof` for the given set id and using the /// given equivocation as proof. @@ -271,7 +268,7 @@ impl EquivocationProof { /// Wrapper object for GRANDPA equivocation proofs, useful for unifying prevote /// and precommit equivocations under a common type. -#[derive(Clone, Debug, Decode, Encode, PartialEq, TypeInfo)] +#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq, TypeInfo)] pub enum Equivocation { /// Proof of equivocation at prevote stage. Prevote(grandpa::Equivocation, AuthoritySignature>), From 0506da00297757babe63b7bb62e487c657066117 Mon Sep 17 00:00:00 2001 From: Oleg Plakida <112385193+oleg-plakida@users.noreply.github.com> Date: Fri, 17 Mar 2023 14:14:13 +0000 Subject: [PATCH 32/80] Fix `test-linux-stable` excessive run time (#13597) * ci-cd#754:Fix slow unit tests - Add nextest config - Add slow tests to mutual exclusion list * Update .config/nextest.toml Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> --------- Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> --- .config/nextest.toml | 124 +++++++++++++++++++++++++++++++++++ .github/pr-custom-review.yml | 4 +- 2 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 .config/nextest.toml diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 0000000000000..c111b0abeb7a2 --- /dev/null +++ b/.config/nextest.toml @@ -0,0 +1,124 @@ +# This is the default config used by nextest. It is embedded in the binary at +# build time. It may be used as a template for .config/nextest.toml. + +[store] +# The directory under the workspace root at which nextest-related files are +# written. Profile-specific storage is currently written to dir/. +dir = "target/nextest" + +# This section defines the default nextest profile. Custom profiles are layered +# on top of the default profile. +[profile.default] +# "retries" defines the number of times a test should be retried. If set to a +# non-zero value, tests that succeed on a subsequent attempt will be marked as +# non-flaky. Can be overridden through the `--retries` option. +# Examples +# * retries = 3 +# * retries = { backoff = "fixed", count = 2, delay = "1s" } +# * retries = { backoff = "exponential", count = 10, delay = "1s", jitter = true, max-delay = "10s" } +retries = 0 + +# The number of threads to run tests with. Supported values are either an integer or +# the string "num-cpus". Can be overridden through the `--test-threads` option. +test-threads = "num-cpus" + +# The number of threads required for each test. This is generally used in overrides to +# mark certain tests as heavier than others. However, it can also be set as a global parameter. +threads-required = 1 + +# Show these test statuses in the output. +# +# The possible values this can take are: +# * none: no output +# * fail: show failed (including exec-failed) tests +# * retry: show flaky and retried tests +# * slow: show slow tests +# * pass: show passed tests +# * skip: show skipped tests (most useful for CI) +# * all: all of the above +# +# Each value includes all the values above it; for example, "slow" includes +# failed and retried tests. +# +# Can be overridden through the `--status-level` flag. +status-level = "pass" + +# Similar to status-level, show these test statuses at the end of the run. +final-status-level = "flaky" + +# "failure-output" defines when standard output and standard error for failing tests are produced. +# Accepted values are +# * "immediate": output failures as soon as they happen +# * "final": output failures at the end of the test run +# * "immediate-final": output failures as soon as they happen and at the end of +# the test run; combination of "immediate" and "final" +# * "never": don't output failures at all +# +# For large test suites and CI it is generally useful to use "immediate-final". +# +# Can be overridden through the `--failure-output` option. +failure-output = "immediate" + +# "success-output" controls production of standard output and standard error on success. This should +# generally be set to "never". +success-output = "never" + +# Cancel the test run on the first failure. For CI runs, consider setting this +# to false. +fail-fast = true + +# Treat a test that takes longer than the configured 'period' as slow, and print a message. +# See for more information. +# +# Optional: specify the parameter 'terminate-after' with a non-zero integer, +# which will cause slow tests to be terminated after the specified number of +# periods have passed. +# Example: slow-timeout = { period = "60s", terminate-after = 2 } +slow-timeout = { period = "60s" } + +# Treat a test as leaky if after the process is shut down, standard output and standard error +# aren't closed within this duration. +# +# This usually happens in case of a test that creates a child process and lets it inherit those +# handles, but doesn't clean the child process up (especially when it fails). +# +# See for more information. +leak-timeout = "100ms" + +[profile.default.junit] +# Output a JUnit report into the given file inside 'store.dir/'. +# If unspecified, JUnit is not written out. + +# path = "junit.xml" + +# The name of the top-level "report" element in JUnit report. If aggregating +# reports across different test runs, it may be useful to provide separate names +# for each report. +report-name = "nextest-run" + +# Whether standard output and standard error for passing tests should be stored in the JUnit report. +# Output is stored in the and elements of the element. +store-success-output = false + +# Whether standard output and standard error for failing tests should be stored in the JUnit report. +# Output is stored in the and elements of the element. +# +# Note that if a description can be extracted from the output, it is always stored in the +# element. +store-failure-output = true + +# This profile is activated if MIRI_SYSROOT is set. +[profile.default-miri] +# Miri tests take up a lot of memory, so only run 1 test at a time by default. +test-threads = 1 + +# Mutual exclusion of tests with `cargo build` invocation as a lock to avoid multiple +# simultaneous invocations clobbering each other. +[test-groups] +serial-integration = { max-threads = 1 } + +# Running UI tests sequentially +# More info can be found here: https://github.com/paritytech/ci_cd/issues/754 +[[profile.default.overrides]] +filter = 'test(/(^ui$|_ui|ui_)/)' +test-group = 'serial-integration' diff --git a/.github/pr-custom-review.yml b/.github/pr-custom-review.yml index 769ac1e110d33..3620f7e770674 100644 --- a/.github/pr-custom-review.yml +++ b/.github/pr-custom-review.yml @@ -9,7 +9,7 @@ rules: condition: include: .* # excluding files from 'CI team' rules - exclude: ^\.gitlab-ci\.yml|^scripts/ci/.*|^\.github/.* + exclude: ^\.gitlab-ci\.yml|^scripts/ci/.*|^\.github/.*|^\.config/nextest.toml min_approvals: 2 teams: - core-devs @@ -17,7 +17,7 @@ rules: - name: CI team check_type: changed_files condition: - include: ^\.gitlab-ci\.yml|^scripts/ci/.*|^\.github/.* + include: ^\.gitlab-ci\.yml|^scripts/ci/.*|^\.github/.*|^\.config/nextest.toml min_approvals: 2 teams: - ci From acdbf010f5c81497edfe65377a46ba0d6e50baa5 Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Fri, 17 Mar 2023 16:31:51 +0100 Subject: [PATCH 33/80] Fix typos in pallet-contracts (#13629) * Fix typos in pallet-contracts --- client/state-db/src/lib.rs | 4 ++-- frame/contracts/README.md | 2 +- frame/contracts/primitives/src/lib.rs | 4 ++-- frame/contracts/proc-macro/src/lib.rs | 6 +++--- frame/contracts/src/address.rs | 2 +- frame/contracts/src/benchmarking/code.rs | 2 +- frame/contracts/src/benchmarking/mod.rs | 8 ++++---- frame/contracts/src/chain_extension.rs | 2 +- frame/contracts/src/exec.rs | 10 +++++----- frame/contracts/src/lib.rs | 6 +++--- frame/contracts/src/storage/meter.rs | 2 +- frame/contracts/src/wasm/mod.rs | 4 ++-- frame/contracts/src/wasm/prepare.rs | 6 +++--- frame/contracts/src/wasm/runtime.rs | 16 ++++++++-------- 14 files changed, 37 insertions(+), 37 deletions(-) diff --git a/client/state-db/src/lib.rs b/client/state-db/src/lib.rs index 14b4622ac0670..5ebfbaad6d8f6 100644 --- a/client/state-db/src/lib.rs +++ b/client/state-db/src/lib.rs @@ -594,7 +594,7 @@ impl StateDb { } /// Prevents pruning of specified block and its descendants. - /// `hint` used for futher checking if the given block exists + /// `hint` used for further checking if the given block exists pub fn pin(&self, hash: &BlockHash, number: u64, hint: F) -> Result<(), PinError> where F: Fn() -> bool, @@ -665,7 +665,7 @@ pub enum IsPruned { Pruned, /// Definitely not pruned NotPruned, - /// May or may not pruned, need futher checking + /// May or may not pruned, need further checking MaybePruned, } diff --git a/frame/contracts/README.md b/frame/contracts/README.md index 4df7d9449682d..9b1d3f7d6de08 100644 --- a/frame/contracts/README.md +++ b/frame/contracts/README.md @@ -64,7 +64,7 @@ When setting up the `Schedule` for your runtime make sure to set `InstructionWei to a non zero value. The default is `0` and prevents the upload of any non deterministic code. An indeterministic code can be deployed on-chain by passing `Determinism::AllowIndeterministic` -to `upload_code`. A determinstic contract can then delegate call into it if and only if it +to `upload_code`. A deterministic contract can then delegate call into it if and only if it is ran by using `bare_call` and passing `Determinism::AllowIndeterministic` to it. **Never use this argument when the contract is called from an on-chain transaction.** diff --git a/frame/contracts/primitives/src/lib.rs b/frame/contracts/primitives/src/lib.rs index ee415cb822257..e73ceb031e184 100644 --- a/frame/contracts/primitives/src/lib.rs +++ b/frame/contracts/primitives/src/lib.rs @@ -131,7 +131,7 @@ pub struct InstantiateReturnValue { pub account_id: AccountId, } -/// The result of succesfully uploading a contract. +/// The result of successfully uploading a contract. #[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)] pub struct CodeUploadReturnValue { /// The key under which the new code is stored. @@ -239,7 +239,7 @@ where } } - /// If the amount of deposit (this type) is constrained by a `limit` this calcuates how + /// If the amount of deposit (this type) is constrained by a `limit` this calculates how /// much balance (if any) is still available from this limit. /// /// # Note diff --git a/frame/contracts/proc-macro/src/lib.rs b/frame/contracts/proc-macro/src/lib.rs index 1b530a409b933..c3e61dae5f000 100644 --- a/frame/contracts/proc-macro/src/lib.rs +++ b/frame/contracts/proc-macro/src/lib.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Procedural macroses used in the contracts module. +//! Procedural macros used in the contracts module. //! //! Most likely you should use the [`#[define_env]`][`macro@define_env`] attribute macro which hides //! boilerplate of defining external environment for a wasm module. @@ -527,7 +527,7 @@ fn expand_docs(def: &EnvDef) -> TokenStream2 { } } -/// Expands environment definiton. +/// Expands environment definition. /// Should generate source code for: /// - implementations of the host functions to be added to the wasm runtime environment (see /// `expand_impls()`). @@ -778,7 +778,7 @@ fn expand_functions(def: &EnvDef, expand_blocks: bool, host_state: TokenStream2) #[proc_macro_attribute] pub fn define_env(attr: TokenStream, item: TokenStream) -> TokenStream { if !attr.is_empty() && !(attr.to_string() == "doc".to_string()) { - let msg = r#"Invalid `define_env` attribute macro: expected either no attributes or a single `doc` attibute: + let msg = r#"Invalid `define_env` attribute macro: expected either no attributes or a single `doc` attribute: - `#[define_env]` - `#[define_env(doc)]`"#; let span = TokenStream2::from(attr).span(); diff --git a/frame/contracts/src/address.rs b/frame/contracts/src/address.rs index 1c25af21e8cb7..e36fc6fffd6f7 100644 --- a/frame/contracts/src/address.rs +++ b/frame/contracts/src/address.rs @@ -32,7 +32,7 @@ use sp_runtime::traits::{Hash, TrailingZeroInput}; pub trait AddressGenerator { /// The address of a contract based on the given instantiate parameters. /// - /// Changing the formular for an already deployed chain is fine as long as no collisons + /// Changing the formular for an already deployed chain is fine as long as no collisions /// with the old formular. Changes only affect existing contracts. fn contract_address( deploying_address: &T::AccountId, diff --git a/frame/contracts/src/benchmarking/code.rs b/frame/contracts/src/benchmarking/code.rs index 96eb5e501d068..c2d623ae4e834 100644 --- a/frame/contracts/src/benchmarking/code.rs +++ b/frame/contracts/src/benchmarking/code.rs @@ -39,7 +39,7 @@ use wasm_instrument::{ }, }; -/// The location where to put the genrated code. +/// The location where to put the generated code. pub enum Location { /// Generate all code into the `call` exported function. Call, diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 873314981b7ed..96368ebb3f604 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -355,7 +355,7 @@ benchmarks! { }: _(origin, callee, value, Weight::MAX, None, data) verify { let deposit = T::Currency::free_balance(&deposit_account); - // value and value transfered via call should be removed from the caller + // value and value transferred via call should be removed from the caller assert_eq!( T::Currency::free_balance(&instance.caller), caller_funding::() - instance.value - value - deposit - Pallet::::min_balance(), @@ -2224,7 +2224,7 @@ benchmarks! { // the same amount of time. We follow that `t.load` and `drop` both have the weight // of this benchmark / 2. We need to make this assumption because there is no way // to measure them on their own using a valid wasm module. We need their individual - // values to derive the weight of individual instructions (by substraction) from + // values to derive the weight of individual instructions (by subtraction) from // benchmarks that include those for parameter pushing and return type dropping. // We call the weight of `t.load` and `drop`: `w_param`. // The weight that would result from the respective benchmark we call: `w_bench`. @@ -3003,9 +3003,9 @@ benchmarks! { sbox.invoke(); } - // This is no benchmark. It merely exist to have an easy way to pretty print the curently + // This is no benchmark. It merely exist to have an easy way to pretty print the currently // configured `Schedule` during benchmark development. - // It can be outputed using the following command: + // It can be outputted using the following command: // cargo run --manifest-path=bin/node/cli/Cargo.toml \ // --features runtime-benchmarks -- benchmark pallet --extra --dev --execution=native \ // -p pallet_contracts -e print_schedule --no-median-slopes --no-min-squares diff --git a/frame/contracts/src/chain_extension.rs b/frame/contracts/src/chain_extension.rs index 56d41a759391b..2c378070813bd 100644 --- a/frame/contracts/src/chain_extension.rs +++ b/frame/contracts/src/chain_extension.rs @@ -138,7 +138,7 @@ pub trait ChainExtension { /// /// # Note /// -/// Currently, we support tuples of up to ten registred chain extensions. If more chain extensions +/// Currently, we support tuples of up to ten registered chain extensions. If more chain extensions /// are needed consider opening an issue. pub trait RegisteredChainExtension: ChainExtension { /// The extensions globally unique identifier. diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 37be12d50d689..35ef43da5ed40 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -84,14 +84,14 @@ where pub enum ErrorOrigin { /// Caller error origin. /// - /// The error happened in the current exeuction context rather than in the one + /// The error happened in the current execution context rather than in the one /// of the contract that is called into. Caller, /// The error happened during execution of the called contract. Callee, } -/// Error returned by contract exection. +/// Error returned by contract execution. #[cfg_attr(test, derive(Debug, PartialEq))] pub struct ExecError { /// The reason why the execution failed. @@ -2455,7 +2455,7 @@ mod tests { #[test] fn in_memory_changes_not_discarded() { // Call stack: BOB -> CHARLIE (trap) -> BOB' (success) - // This tests verfies some edge case of the contract info cache: + // This tests verifies some edge case of the contract info cache: // We change some value in our contract info before calling into a contract // that calls into ourself. This triggers a case where BOBs contract info // is written to storage and invalidated by the successful execution of BOB'. @@ -3405,7 +3405,7 @@ mod tests { let code_hash = MockLoader::insert(Call, move |ctx, _| { // It is set to one when this contract was instantiated by `place_contract` assert_eq!(ctx.ext.nonce(), 1); - // Should not change without any instantation in-between + // Should not change without any instantiation in-between assert_eq!(ctx.ext.nonce(), 1); // Should not change with a failed instantiation assert_err!( @@ -3416,7 +3416,7 @@ mod tests { } ); assert_eq!(ctx.ext.nonce(), 1); - // Successful instantation increments + // Successful instantiation increments ctx.ext.instantiate(Weight::zero(), success_code, 0, vec![], &[]).unwrap(); assert_eq!(ctx.ext.nonce(), 2); exec_success() diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 4f5d7ba305fc1..0aff18fd62083 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -403,7 +403,7 @@ pub mod pallet { T::MaxCodeLen::get(), ); - // Debug buffer should at least be large enough to accomodate a simple error message + // Debug buffer should at least be large enough to accommodate a simple error message const MIN_DEBUG_BUF_SIZE: u32 = 256; assert!( T::MaxDebugBufferLen::get() > MIN_DEBUG_BUF_SIZE, @@ -891,7 +891,7 @@ pub mod pallet { /// The contract's code was found to be invalid during validation or instrumentation. /// /// The most likely cause of this is that an API was used which is not supported by the - /// node. This hapens if an older node is used with a new version of ink!. Try updating + /// node. This happens if an older node is used with a new version of ink!. Try updating /// your node to the newest available version. /// /// A more detailed error can be found on the node console if debug messages are enabled @@ -987,7 +987,7 @@ struct InternalOutput { result: Result, } -/// Helper trait to wrap contract execution entry points into a signle function +/// Helper trait to wrap contract execution entry points into a single function /// [`Invokable::run_guarded`]. trait Invokable { /// What is returned as a result of a successful invocation. diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index ef6fb3277c11b..b4fc443fe7f35 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -513,7 +513,7 @@ impl Ext for ReservingExt { // we make sure to leave at least the ed in the free balance. // // The sender always has enough balance because we track it in the `ContractInfo` and - // never send more back than we have. Noone has access to the deposit account. Hence no + // never send more back than we have. No one has access to the deposit account. Hence no // other interaction with this account takes place. Deposit::Refund(amount) => { if terminated { diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index f8c5a6ed96c57..f74df2c361442 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -186,7 +186,7 @@ impl PrefabWasmModule { code_cache::try_remove::(origin, code_hash) } - /// Returns whether there is a deposit to be payed for this module. + /// Returns whether there is a deposit to be paid for this module. /// /// Returns `0` if the module is already in storage and hence no deposit will /// be charged when storing it. @@ -689,7 +689,7 @@ mod tests { executable.execute(ext.borrow_mut(), entry_point, input_data) } - /// Execute the suppplied code. + /// Execute the supplied code. fn execute>(wat: &str, input_data: Vec, ext: E) -> ExecResult { execute_internal(wat, input_data, ext, &ExportedFunction::Call, true, false) } diff --git a/frame/contracts/src/wasm/prepare.rs b/frame/contracts/src/wasm/prepare.rs index eed60891d66f4..6a2eb6a769ecc 100644 --- a/frame/contracts/src/wasm/prepare.rs +++ b/frame/contracts/src/wasm/prepare.rs @@ -50,7 +50,7 @@ pub enum TryInstantiate { Instantiate, /// Skip the instantiation during preparation. /// - /// This makes sense when the preparation takes place as part of an instantation. Then + /// This makes sense when the preparation takes place as part of an instantiation. Then /// this instantiation would fail the whole transaction and an extra check is not /// necessary. Skip, @@ -376,7 +376,7 @@ fn get_memory_limits( }, } } else { - // If none memory imported then just crate an empty placeholder. + // If none memory imported then just create an empty placeholder. // Any access to it will lead to out of bounds trap. Ok((0, 0)) } @@ -412,7 +412,7 @@ where extended_const: false, component_model: false, // This is not our only defense: We check for float types later in the preparation - // process. Additionally, all instructions explictily need to have weights assigned + // process. Additionally, all instructions explicitly need to have weights assigned // or the deployment will fail. We have none assigned for float instructions. deterministic_only: matches!(determinism, Determinism::Deterministic), mutable_global: false, diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index e80e2cde302fe..b30bad38bfce5 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -1336,7 +1336,7 @@ pub mod env { /// /// # Parameters /// - /// - `flags`: See `crate::wasm::runtime::CallFlags` for a documenation of the supported flags. + /// - `flags`: See `crate::wasm::runtime::CallFlags` for a documentation of the supported flags. /// - `callee_ptr`: a pointer to the address of the callee contract. Should be decodable as an /// `T::AccountId`. Traps otherwise. /// - `gas`: how much gas to devote to the execution. @@ -2038,7 +2038,7 @@ pub mod env { /// # Note /// /// The state rent functionality was removed. This is stub only exists for - /// backwards compatiblity + /// backwards compatibility #[prefixed_alias] #[deprecated] fn restore_to( @@ -2062,7 +2062,7 @@ pub mod env { /// # Note /// /// The state rent functionality was removed. This is stub only exists for - /// backwards compatiblity + /// backwards compatibility #[version(1)] #[prefixed_alias] #[deprecated] @@ -2084,7 +2084,7 @@ pub mod env { /// # Note /// /// The state rent functionality was removed. This is stub only exists for - /// backwards compatiblity. + /// backwards compatibility. #[prefixed_alias] #[deprecated] fn set_rent_allowance( @@ -2102,7 +2102,7 @@ pub mod env { /// # Note /// /// The state rent functionality was removed. This is stub only exists for - /// backwards compatiblity. + /// backwards compatibility. #[version(1)] #[prefixed_alias] #[deprecated] @@ -2116,7 +2116,7 @@ pub mod env { /// # Note /// /// The state rent functionality was removed. This is stub only exists for - /// backwards compatiblity. + /// backwards compatibility. #[prefixed_alias] #[deprecated] fn rent_allowance(ctx: _, memory: _, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> { @@ -2409,7 +2409,7 @@ pub mod env { /// /// # Return Value /// - /// Returns `ReturnCode::Success` when the dispatchable was succesfully executed and + /// Returns `ReturnCode::Success` when the dispatchable was successfully executed and /// returned `Ok`. When the dispatchable was exeuted but returned an error /// `ReturnCode::CallRuntimeFailed` is returned. The full error is not /// provided because it is not guaranteed to be stable. @@ -2603,7 +2603,7 @@ pub mod env { /// Returns a nonce that is unique per contract instantiation. /// - /// The nonce is incremented for each succesful contract instantiation. This is a + /// The nonce is incremented for each successful contract instantiation. This is a /// sensible default salt for contract instantiations. #[unstable] fn instantiation_nonce(ctx: _, _memory: _) -> Result { From 44c5c99880346d5b9d4874725500c03b30994774 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 17 Mar 2023 17:06:40 +0100 Subject: [PATCH 34/80] Ignore flaky test (#13631) * Ignore flaky test Signed-off-by: Oliver Tale-Yazdi * Re-enable running_the_node_works_and_can_be_interrupted Signed-off-by: Oliver Tale-Yazdi * Re-enable notifications_back_pressure Signed-off-by: Oliver Tale-Yazdi * Unused import Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi --- client/rpc-spec-v2/src/chain_head/tests.rs | 6 ++++++ client/service/test/src/client/mod.rs | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/client/rpc-spec-v2/src/chain_head/tests.rs b/client/rpc-spec-v2/src/chain_head/tests.rs index fcd906dcf5be0..0110c97a05910 100644 --- a/client/rpc-spec-v2/src/chain_head/tests.rs +++ b/client/rpc-spec-v2/src/chain_head/tests.rs @@ -1024,6 +1024,9 @@ async fn follow_prune_best_block() { } #[tokio::test] +#[cfg(disable_flaky)] +#[allow(dead_code)] +// FIXME: https://github.com/paritytech/substrate/issues/11321 async fn follow_forks_pruned_block() { let builder = TestClientBuilder::new(); let backend = builder.backend(); @@ -1137,6 +1140,9 @@ async fn follow_forks_pruned_block() { } #[tokio::test] +#[cfg(disable_flaky)] +#[allow(dead_code)] +// FIXME: https://github.com/paritytech/substrate/issues/11321 async fn follow_report_multiple_pruned_block() { let builder = TestClientBuilder::new(); let backend = builder.backend(); diff --git a/client/service/test/src/client/mod.rs b/client/service/test/src/client/mod.rs index cae69413c7a02..96a0a8fe2a023 100644 --- a/client/service/test/src/client/mod.rs +++ b/client/service/test/src/client/mod.rs @@ -30,7 +30,7 @@ use sc_consensus::{ }; use sc_service::client::{new_in_mem, Client, LocalCallExecutor}; use sp_api::ProvideRuntimeApi; -use sp_consensus::{BlockOrigin, BlockStatus, Error as ConsensusError, SelectChain}; +use sp_consensus::{BlockOrigin, Error as ConsensusError, SelectChain}; use sp_core::{testing::TaskExecutor, traits::CallContext, H256}; use sp_runtime::{ generic::BlockId, @@ -1567,7 +1567,11 @@ fn respects_block_rules() { } #[test] +#[cfg(disable_flaky)] +#[allow(dead_code)] +// FIXME: https://github.com/paritytech/substrate/issues/11321 fn returns_status_for_pruned_blocks() { + use sc_consensus::BlockStatus; sp_tracing::try_init_simple(); let tmp = tempfile::tempdir().unwrap(); From bab32f81dd5f9261605b572595de6eb9c40cb0be Mon Sep 17 00:00:00 2001 From: Koute Date: Sat, 18 Mar 2023 01:09:28 +0900 Subject: [PATCH 35/80] Bump `trie-db` to 0.27.1 (fix storage iteration bug + change seek behavior with prefix) (#13630) --- Cargo.lock | 4 +- primitives/state-machine/Cargo.toml | 2 +- primitives/state-machine/src/trie_backend.rs | 119 ++++++++++++++++++- 3 files changed, 121 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df0e54a3d7ecd..da100658bef9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11653,9 +11653,9 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.27.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d75c77ea43f2ad8ea9d9c58de49dfc9c3995bdef32b503df7883ff054e7f1" +checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" dependencies = [ "hash-db", "hashbrown 0.13.2", diff --git a/primitives/state-machine/Cargo.toml b/primitives/state-machine/Cargo.toml index 9759547d7f384..cc780e51abcaf 100644 --- a/primitives/state-machine/Cargo.toml +++ b/primitives/state-machine/Cargo.toml @@ -33,7 +33,7 @@ array-bytes = "4.1" pretty_assertions = "1.2.1" rand = "0.8.5" sp-runtime = { version = "7.0.0", path = "../runtime" } -trie-db = "0.27.0" +trie-db = "0.27.1" assert_matches = "1.5" [features] diff --git a/primitives/state-machine/src/trie_backend.rs b/primitives/state-machine/src/trie_backend.rs index 10e2dfd16d66a..afbe6cbbea081 100644 --- a/primitives/state-machine/src/trie_backend.rs +++ b/primitives/state-machine/src/trie_backend.rs @@ -536,6 +536,29 @@ pub mod tests { (mdb, root) } + pub(crate) fn test_db_with_hex_keys( + state_version: StateVersion, + keys: &[&str], + ) -> (PrefixedMemoryDB, H256) { + let mut root = H256::default(); + let mut mdb = PrefixedMemoryDB::::default(); + match state_version { + StateVersion::V0 => { + let mut trie = TrieDBMutBuilderV0::new(&mut mdb, &mut root).build(); + for (index, key) in keys.iter().enumerate() { + trie.insert(&array_bytes::hex2bytes(key).unwrap(), &[index as u8]).unwrap(); + } + }, + StateVersion::V1 => { + let mut trie = TrieDBMutBuilderV1::new(&mut mdb, &mut root).build(); + for (index, key) in keys.iter().enumerate() { + trie.insert(&array_bytes::hex2bytes(key).unwrap(), &[index as u8]).unwrap(); + } + }, + }; + (mdb, root) + } + pub(crate) fn test_trie( hashed_value: StateVersion, cache: Option, @@ -549,6 +572,20 @@ pub mod tests { .build() } + pub(crate) fn test_trie_with_hex_keys( + hashed_value: StateVersion, + cache: Option, + recorder: Option, + keys: &[&str], + ) -> TrieBackend, BlakeTwo256> { + let (mdb, root) = test_db_with_hex_keys(hashed_value, keys); + + TrieBackendBuilder::new(mdb, root) + .with_optional_cache(cache) + .with_optional_recorder(recorder) + .build() + } + parameterized_test!(read_from_storage_returns_some, read_from_storage_returns_some_inner); fn read_from_storage_returns_some_inner( state_version: StateVersion, @@ -697,10 +734,25 @@ pub mod tests { ); // Fetch starting at a given key and with prefix which doesn't match that key. + // (Start *before* the prefix.) + assert_eq!( + trie.keys(IterArgs { + prefix: Some(b"value"), + start_at: Some(b"key"), + ..IterArgs::default() + }) + .unwrap() + .map(|result| result.unwrap()) + .collect::>(), + vec![b"value1".to_vec(), b"value2".to_vec(),] + ); + + // Fetch starting at a given key and with prefix which doesn't match that key. + // (Start *after* the prefix.) assert!(trie .keys(IterArgs { prefix: Some(b"value"), - start_at: Some(b"key"), + start_at: Some(b"vblue"), ..IterArgs::default() }) .unwrap() @@ -722,6 +774,71 @@ pub mod tests { ); } + // This test reproduces an actual real-world issue: https://github.com/polkadot-js/apps/issues/9103 + parameterized_test!( + storage_iter_does_not_return_out_of_prefix_keys, + storage_iter_does_not_return_out_of_prefix_keys_inner + ); + fn storage_iter_does_not_return_out_of_prefix_keys_inner( + state_version: StateVersion, + cache: Option, + recorder: Option, + ) { + let trie = test_trie_with_hex_keys(state_version, cache, recorder, &[ + "6cf4040bbce30824850f1a4823d8c65faeefaa25a5bae16a431719647c1d99da", + "6cf4040bbce30824850f1a4823d8c65ff536928ca5ba50039bc2766a48ddbbab", + "70f943199f1a2dde80afdaf3f447db834e7b9012096b41c4eb3aaf947f6ea429", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d007fc7effcb0c044a0c41fd8a77eb55d2133058a86d1f4d6f8e45612cd271eefd77f91caeaacfe011b8f41540e0a793b0fd51b245dae19382b45386570f2b545fab75e3277910f7324b55f47c29f9965e8298371404e50ac", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d0179c23cd593c770fde9fc7aa8f84b3e401e654b8986c67728844da0080ec9ee222b41a85708a471a511548302870b53f40813d8354b6d2969e1b7ca9e083ecf96f9647e004ecb41c7f26f0110f778bdb3d9da31bef323d9", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d024de296f88310247001277477f4ace4d0aa5685ea2928d518a807956e4806a656520d6520b8ac259f684aa0d91961d76f697716f04e6c997338d03560ab7d703829fe7b9d0e6d7eff8d8412fc428364c2f474a67b36586d", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d13dc5d83f2361c14d05933eb3182a92ac14665718569703baf1da25c7d571843b6489f03d8549c87bfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d1786d20bbb4b91eb1f5765432d750bd0111a0807c8d04f05110ffaf73f4fa7b360422c13bc97efc3a2324d9fa8f954b424c0bcfce7236a2e8107dd31c2042a9860a964f8472fda49749dec3f146e81470b55aa0f3930d854", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d18c246484ec5335a40903e7cd05771be7c0b8459333f1ae2925c3669fc3e5accd0f38c4711a15544bfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d1aca749033252ce75245528397430d14cb8e8c09248d81ee5de00b6ae93ee880b6d19a595e6dc106bfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d1d6bceb91bc07973e7b3296f83af9f1c4300ce9198cc3b44c54dafddb58f4a43aee44a9bef1a2e9dbfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d203383772f45721232139e1a8863b0f2f8d480bdc15bcc1f2033cf467e137059558da743838f6b58bfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d2197cc5c3eb3a6a67538e0dc3eaaf8c820d71310d377499c4a5d276381789e0a234475e69cddf709d207458083d6146d3a36fce7f1fe05b232702bf154096e5e3a8c378bdc237d7a27909acd663563917f0f70bb0e8e61a3", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d4f19c117f2ea36100f753c4885aa8d63b4d65a0dc32106f829f89eeabd52c37105c9bdb75f752469729fa3f0e7d907c1d949192c8e264a1a510c32abe3a05ed50be2262d5bfb981673ec80a07fd2ce28c7f27cd0043a788c", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d547d5aaa651bafa63d077560dfe823ac75665ebf1dcfd96a06e45499f03dda31282977706918d4821b8f41540e0a793b0fd51b245dae19382b45386570f2b545fab75e3277910f7324b55f47c29f9965e8298371404e50ac", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d6037207d54d69a082ea225ab4a412e4b87d6f5612053b07c405cf05ea25e482a4908c0713be2998abfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d63d0920de0c7315ebaed1d639d926961d28af89461c31eca890441e449147d23bb7c9d4fc42d7c16bfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d7912c66be82a5972e5bc11c8d10551a296ba9aaff8ca6ab22a8cd1987974b87a97121c871f786d2e17e0a629acf01c38947f170b7e02a9ebb4ee60f83779acb99b71114c01a4f0a60694611a1502c399c77214ffa26e955b", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d7aa00f217f3a374a2f1ca0f388719f84099e8157a8a83c5ccf54eae1617f93933fa976baa629e6febfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d9e1c3c8ab41943cf377b1aa724d7f518a3cfc96a732bdc4658155d09ed2bfc31b5ccbc6d8646b59f1b8f41540e0a793b0fd51b245dae19382b45386570f2b545fab75e3277910f7324b55f47c29f9965e8298371404e50ac", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d9fb8d6d95d5214a3305a4fa07e344eb99fad4be3565d646c8ac5af85514d9c96702c9c207be234958dbdb9185f467d2be3b84e8b2f529f7ec3844b378a889afd6bd31a9b5ed22ffee2019ad82c6692f1736dd41c8bb85726", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8d9fb8d6d95d5214a3305a4fa07e344eb99fad4be3565d646c8ac5af85514d9c96702c9c207be23495ec1caa509591a36a8403684384ce40838c9bd7fc49d933a10d3b26e979273e2f17ebf0bf41cd90e4287e126a59d5a243", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8da7fc066aae2ffe03b36e9a72f9a39cb2befac7e47f320309f31f1c1676288d9596045807304b3d79bfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8daf3c377b0fddf7c7ad6d390fab0ab45ac16c21645be880af5cab2fbbeb04820401a4c9f766c17bef9fc14a2e16ade86fe26ee81d4497dc6aab81cc5f5bb0458d6149a763ecb09aefec06950dd61db1ba025401d2a04e3b9d", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8daf3c377b0fddf7c7ad6d390fab0ab45ac16c21645be880af5cab2fbbeb04820401a4c9f766c17befbfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8db60505ba8b77ef03ed805436d3242f26dc828084b12aaf4bcb96af468816a182b5360149398aad6b1dafe949b0918138ceef924f6393d1818a04842301294604972da17b24b31b155e4409a01273733b8d21a156c2e7eb71", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8dbd27136a6e028656073cc840bfabb48fe935880c4c4c990ee98458b2fed308e9765f7f7f717dd3b2862fa5361d3b55afa6040e582687403c852b2d065b24f253276cc581226991f8e1818a78fc64c39da7f0b383c6726e0f", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8dca40d91320edd326500f9e8b5a0b23a8bdf21549f98f0e014f66b6a18bdd78e337a6c05d670c80c88a55d4c7bb6fbae546e2d03ac9ab16e85fe11dad6adfd6a20618905477b831d7d48ca32d0bfd2bdc8dbeba26ffe2c710", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8dd27478512243ed62c1c1f7066021798a464d4cf9099546d5d9907b3369f1b9d7a5aa5d60ca845619bfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8de6da5659cbbe1489abbe99c4d3a474f4d1e78edb55a9be68d8f52c6fe730388a298e6f6325db3da7bfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8de6da5659cbbe1489abbe99c4d3a474f4d1e78edb55a9be68d8f52c6fe730388a298e6f6325db3da7e94ca3e8c297d82f71e232a2892992d1f6480475fb797ce64e58f773d8fafd9fbcee4bdf4b14f2a71b6d3a428cf9f24b", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8decdd1760c61ff7234f2876dbe817af803170233320d778b92043b2359e3de6d16c9e5359f6302da31c84d6f551ad2a831263ef956f0cdb3b4810cefcb2d0b57bcce7b82007016ae4fe752c31d1a01b589a7966cea03ec65c", + "7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8df9981ee6b69eb7af2153af34f39ffc06e2daa5272c99798c8849091284dc8905f2a76b65754c2089bfa5709836ba729443c319659e83ad5ee133e6f11af51d883e56216e9e1bbb1e2920c7c6120cbb55cd469b1f95b61601", + "7474449cca95dc5d0c00e71735a6d17d4e7b9012096b41c4eb3aaf947f6ea429", + "89d139e01a5eb2256f222e5fc5dbe6b33c9c1284130706f5aea0c8b3d4c54d89", + "89d139e01a5eb2256f222e5fc5dbe6b36254e9d55588784fa2a62b726696e2b1" + ]); + + let key = array_bytes::hex2bytes("7474449cca95dc5d0c00e71735a6d17d3cd15a3fd6e04e47bee3922dbfa92c8da7dad55cf08ffe8194efa962146801b0503092b1ed6a3fa6aee9107334aefd7965bbe568c3d24c6d").unwrap(); + + assert_eq!( + trie.keys(IterArgs { + prefix: Some(&key), + start_at: Some(&key), + start_at_exclusive: true, + ..IterArgs::default() + }) + .unwrap() + .map(|result| result.unwrap()) + .collect::>(), + Vec::>::new() + ); + } + parameterized_test!(storage_root_is_non_default, storage_root_is_non_default_inner); fn storage_root_is_non_default_inner( state_version: StateVersion, From d574cb75ce70148f5e082201beaef24b5a00741e Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Fri, 17 Mar 2023 23:17:21 +0100 Subject: [PATCH 36/80] contracts: Refactor `trait Ext::*_storage_transparent` functions (#13600) * Refactor _transparent methods rewrote commits, stashed the typo changes to remove some diff noise fixed my unverified email commit * remove type alias * Get rid of From impl blocks * Get rid of KeyType impl block * remove unnecessary Key export * Update frame/contracts/src/exec.rs Co-authored-by: Sasha Gryaznov * PR review comment --------- Co-authored-by: Sasha Gryaznov --- bin/node/executor/tests/basic.rs | 6 +- frame/contracts/src/benchmarking/mod.rs | 28 +-- frame/contracts/src/exec.rs | 267 ++++++++++-------------- frame/contracts/src/lib.rs | 8 +- frame/contracts/src/storage.rs | 10 +- frame/contracts/src/tests.rs | 6 +- frame/contracts/src/wasm/mod.rs | 68 ++---- frame/contracts/src/wasm/runtime.rs | 103 ++++----- 8 files changed, 200 insertions(+), 296 deletions(-) diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs index ecfe02aa41596..9200fe735be41 100644 --- a/bin/node/executor/tests/basic.rs +++ b/bin/node/executor/tests/basic.rs @@ -710,11 +710,7 @@ fn deploying_wasm_contract_should_work() { t.execute_with(|| { // Verify that the contract does exist by querying some of its storage items // It does not matter that the storage item itself does not exist. - assert!(&pallet_contracts::Pallet::::get_storage( - addr, - pallet_contracts::StorageKey::::default().to_vec() - ) - .is_ok()); + assert!(&pallet_contracts::Pallet::::get_storage(addr, vec![]).is_ok()); }); } diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 96368ebb3f604..2fb033cf85d8c 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -30,7 +30,7 @@ use self::{ sandbox::Sandbox, }; use crate::{ - exec::{AccountIdOf, FixSizedKey, VarSizedKey}, + exec::{AccountIdOf, Key}, wasm::CallFlags, Pallet as Contracts, *, }; @@ -135,10 +135,10 @@ where } /// Store the supplied storage items into this contracts storage. - fn store(&self, items: &Vec<(FixSizedKey, Vec)>) -> Result<(), &'static str> { + fn store(&self, items: &Vec<([u8; 32], Vec)>) -> Result<(), &'static str> { let info = self.info()?; for item in items { - info.write(&item.0 as &FixSizedKey, Some(item.1.clone()), None, false) + info.write(&Key::Fix(item.0), Some(item.1.clone()), None, false) .map_err(|_| "Failed to write storage to restoration dest")?; } >::insert(&self.account_id, info); @@ -1044,7 +1044,7 @@ benchmarks! { let info = instance.info()?; for key in keys { info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + &Key::::try_from_var(key).map_err(|e| "Key has wrong length")?, Some(vec![]), None, false, @@ -1088,7 +1088,7 @@ benchmarks! { let instance = Contract::::new(code, vec![])?; let info = instance.info()?; info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + &Key::::try_from_var(key).map_err(|e| "Key has wrong length")?, Some(vec![]), None, false, @@ -1131,7 +1131,7 @@ benchmarks! { let instance = Contract::::new(code, vec![])?; let info = instance.info()?; info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + &Key::::try_from_var(key).map_err(|e| "Key has wrong length")?, Some(vec![42u8; n as usize]), None, false, @@ -1180,7 +1180,7 @@ benchmarks! { let info = instance.info()?; for key in keys { info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + &Key::::try_from_var(key).map_err(|e| "Key has wrong length")?, Some(vec![]), None, false, @@ -1223,7 +1223,7 @@ benchmarks! { let instance = Contract::::new(code, vec![])?; let info = instance.info()?; info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + &Key::::try_from_var(key).map_err(|e| "Key has wrong length")?, Some(vec![42u8; n as usize]), None, false, @@ -1276,7 +1276,7 @@ benchmarks! { let info = instance.info()?; for key in keys { info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + &Key::::try_from_var(key).map_err(|e| "Key has wrong length")?, Some(vec![]), None, false, @@ -1325,7 +1325,7 @@ benchmarks! { let instance = Contract::::new(code, vec![])?; let info = instance.info()?; info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + &Key::::try_from_var(key).map_err(|e| "Key has wrong length")?, Some(vec![42u8; n as usize]), None, false, @@ -1373,7 +1373,7 @@ benchmarks! { let info = instance.info()?; for key in keys { info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + &Key::::try_from_var(key).map_err(|e| "Key has wrong length")?, Some(vec![]), None, false, @@ -1416,7 +1416,7 @@ benchmarks! { let instance = Contract::::new(code, vec![])?; let info = instance.info()?; info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + &Key::::try_from_var(key).map_err(|e| "Key has wrong length")?, Some(vec![42u8; n as usize]), None, false, @@ -1469,7 +1469,7 @@ benchmarks! { let info = instance.info()?; for key in keys { info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + &Key::::try_from_var(key).map_err(|e| "Key has wrong length")?, Some(vec![]), None, false, @@ -1518,7 +1518,7 @@ benchmarks! { let instance = Contract::::new(code, vec![])?; let info = instance.info()?; info.write( - &VarSizedKey::::try_from(key).map_err(|e| "Key has wrong length")?, + &Key::::try_from_var(key).map_err(|e| "Key has wrong length")?, Some(vec![42u8; n as usize]), None, false, diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 35ef43da5ed40..bd63c524c6152 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -35,7 +35,7 @@ use smallvec::{Array, SmallVec}; use sp_core::ecdsa::Public as ECDSAPublic; use sp_io::{crypto::secp256k1_ecdsa_recover_compressed, hashing::blake2_256}; use sp_runtime::traits::{Convert, Hash}; -use sp_std::{marker::PhantomData, mem, prelude::*}; +use sp_std::{marker::PhantomData, mem, prelude::*, vec::Vec}; pub type AccountIdOf = ::AccountId; pub type MomentOf = <::Time as Time>::Moment; @@ -46,32 +46,39 @@ pub type ExecResult = Result; /// A type that represents a topic of an event. At the moment a hash is used. pub type TopicOf = ::Hash; -/// Type for fix sized storage key. -pub type FixSizedKey = [u8; 32]; - /// Type for variable sized storage key. Used for transparent hashing. -pub type VarSizedKey = BoundedVec::MaxStorageKeyLen>; - -/// Trait for hashing storage keys. -pub trait StorageKey -where - T: Config, -{ - fn hash(&self) -> Vec; +type VarSizedKey = BoundedVec::MaxStorageKeyLen>; + +/// Combined key type for both fixed and variable sized storage keys. +pub enum Key { + /// Variant for fixed sized keys. + Fix([u8; 32]), + /// Variant for variable sized keys. + Var(VarSizedKey), } -impl StorageKey for FixSizedKey { - fn hash(&self) -> Vec { - blake2_256(self.as_slice()).to_vec() +impl Key { + /// Copies self into a new vec. + pub fn to_vec(&self) -> Vec { + match self { + Key::Fix(v) => v.to_vec(), + Key::Var(v) => v.to_vec(), + } } -} -impl StorageKey for VarSizedKey -where - T: Config, -{ - fn hash(&self) -> Vec { - Blake2_128Concat::hash(self.as_slice()) + pub fn hash(&self) -> Vec { + match self { + Key::Fix(v) => blake2_256(v.as_slice()).to_vec(), + Key::Var(v) => Blake2_128Concat::hash(v.as_slice()), + } + } + + pub fn try_from_fix(v: Vec) -> Result> { + <[u8; 32]>::try_from(v).map(Self::Fix) + } + + pub fn try_from_var(v: Vec) -> Result> { + VarSizedKey::::try_from(v).map(Self::Var) } } @@ -169,44 +176,19 @@ pub trait Ext: sealing::Sealed { /// /// Returns `None` if the `key` wasn't previously set by `set_storage` or /// was deleted. - fn get_storage(&mut self, key: &FixSizedKey) -> Option>; - - /// This is a variation of `get_storage()` to be used with transparent hashing. - /// These two will be merged into a single function after some refactoring is done. - /// Returns the storage entry of the executing account by the given `key`. - /// - /// Returns `None` if the `key` wasn't previously set by `set_storage` or - /// was deleted. - fn get_storage_transparent(&mut self, key: &VarSizedKey) -> Option>; + fn get_storage(&mut self, key: &Key) -> Option>; /// Returns `Some(len)` (in bytes) if a storage item exists at `key`. /// /// Returns `None` if the `key` wasn't previously set by `set_storage` or /// was deleted. - fn get_storage_size(&mut self, key: &FixSizedKey) -> Option; - - /// This is the variation of `get_storage_size()` to be used with transparent hashing. - /// These two will be merged into a single function after some refactoring is done. - /// Returns `Some(len)` (in bytes) if a storage item exists at `key`. - /// - /// Returns `None` if the `key` wasn't previously set by `set_storage` or - /// was deleted. - fn get_storage_size_transparent(&mut self, key: &VarSizedKey) -> Option; + fn get_storage_size(&mut self, key: &Key) -> Option; /// Sets the storage entry by the given key to the specified value. If `value` is `None` then /// the storage entry is deleted. fn set_storage( &mut self, - key: &FixSizedKey, - value: Option>, - take_old: bool, - ) -> Result; - - /// This is the variation of `set_storage()` to be used with transparent hashing. - /// These two will be merged into a single function after some refactoring is done. - fn set_storage_transparent( - &mut self, - key: &VarSizedKey, + key: &Key, value: Option>, take_old: bool, ) -> Result; @@ -1236,46 +1218,23 @@ where Self::transfer(ExistenceRequirement::KeepAlive, &self.top_frame().account_id, to, value) } - fn get_storage(&mut self, key: &FixSizedKey) -> Option> { - self.top_frame_mut().contract_info().read(key) - } - - fn get_storage_transparent(&mut self, key: &VarSizedKey) -> Option> { + fn get_storage(&mut self, key: &Key) -> Option> { self.top_frame_mut().contract_info().read(key) } - fn get_storage_size(&mut self, key: &FixSizedKey) -> Option { - self.top_frame_mut().contract_info().size(key) - } - - fn get_storage_size_transparent(&mut self, key: &VarSizedKey) -> Option { - self.top_frame_mut().contract_info().size(key) + fn get_storage_size(&mut self, key: &Key) -> Option { + self.top_frame_mut().contract_info().size(key.into()) } fn set_storage( &mut self, - key: &FixSizedKey, + key: &Key, value: Option>, take_old: bool, ) -> Result { let frame = self.top_frame_mut(); frame.contract_info.get(&frame.account_id).write( - key, - value, - Some(&mut frame.nested_storage), - take_old, - ) - } - - fn set_storage_transparent( - &mut self, - key: &VarSizedKey, - value: Option>, - take_old: bool, - ) -> Result { - let frame = self.top_frame_mut(); - frame.contract_info.get(&frame.account_id).write( - key, + key.into(), value, Some(&mut frame.nested_storage), take_old, @@ -1688,7 +1647,7 @@ mod tests { place_contract(&dest, success_ch); set_balance(&origin, 100); let balance = get_balance(&dest); - let mut storage_meter = storage::meter::Meter::new(&origin, Some(0), 55).unwrap(); + let mut storage_meter = storage::meter::Meter::new(&origin, Some(0), value).unwrap(); let _ = MockStack::run_call( origin.clone(), @@ -2986,35 +2945,41 @@ mod tests { let code_hash = MockLoader::insert(Call, |ctx, _| { // Write assert_eq!( - ctx.ext.set_storage(&[1; 32], Some(vec![1, 2, 3]), false), + ctx.ext.set_storage(&Key::Fix([1; 32]), Some(vec![1, 2, 3]), false), + Ok(WriteOutcome::New) + ); + assert_eq!( + ctx.ext.set_storage(&Key::Fix([2; 32]), Some(vec![4, 5, 6]), true), + Ok(WriteOutcome::New) + ); + assert_eq!(ctx.ext.set_storage(&Key::Fix([3; 32]), None, false), Ok(WriteOutcome::New)); + assert_eq!(ctx.ext.set_storage(&Key::Fix([4; 32]), None, true), Ok(WriteOutcome::New)); + assert_eq!( + ctx.ext.set_storage(&Key::Fix([5; 32]), Some(vec![]), false), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage(&[2; 32], Some(vec![4, 5, 6]), true), + ctx.ext.set_storage(&Key::Fix([6; 32]), Some(vec![]), true), Ok(WriteOutcome::New) ); - assert_eq!(ctx.ext.set_storage(&[3; 32], None, false), Ok(WriteOutcome::New)); - assert_eq!(ctx.ext.set_storage(&[4; 32], None, true), Ok(WriteOutcome::New)); - assert_eq!(ctx.ext.set_storage(&[5; 32], Some(vec![]), false), Ok(WriteOutcome::New)); - assert_eq!(ctx.ext.set_storage(&[6; 32], Some(vec![]), true), Ok(WriteOutcome::New)); // Overwrite assert_eq!( - ctx.ext.set_storage(&[1; 32], Some(vec![42]), false), + ctx.ext.set_storage(&Key::Fix([1; 32]), Some(vec![42]), false), Ok(WriteOutcome::Overwritten(3)) ); assert_eq!( - ctx.ext.set_storage(&[2; 32], Some(vec![48]), true), + ctx.ext.set_storage(&Key::Fix([2; 32]), Some(vec![48]), true), Ok(WriteOutcome::Taken(vec![4, 5, 6])) ); - assert_eq!(ctx.ext.set_storage(&[3; 32], None, false), Ok(WriteOutcome::New)); - assert_eq!(ctx.ext.set_storage(&[4; 32], None, true), Ok(WriteOutcome::New)); + assert_eq!(ctx.ext.set_storage(&Key::Fix([3; 32]), None, false), Ok(WriteOutcome::New)); + assert_eq!(ctx.ext.set_storage(&Key::Fix([4; 32]), None, true), Ok(WriteOutcome::New)); assert_eq!( - ctx.ext.set_storage(&[5; 32], Some(vec![]), false), + ctx.ext.set_storage(&Key::Fix([5; 32]), Some(vec![]), false), Ok(WriteOutcome::Overwritten(0)) ); assert_eq!( - ctx.ext.set_storage(&[6; 32], Some(vec![]), true), + ctx.ext.set_storage(&Key::Fix([6; 32]), Some(vec![]), true), Ok(WriteOutcome::Taken(vec![])) ); @@ -3043,52 +3008,52 @@ mod tests { } #[test] - fn set_storage_transparent_works() { + fn set_storage_varsized_key_works() { let code_hash = MockLoader::insert(Call, |ctx, _| { // Write assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([1; 64].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([1; 64].to_vec()).unwrap(), Some(vec![1, 2, 3]), false ), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([2; 19].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([2; 19].to_vec()).unwrap(), Some(vec![4, 5, 6]), true ), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([3; 19].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([3; 19].to_vec()).unwrap(), None, false ), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([4; 64].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([4; 64].to_vec()).unwrap(), None, true ), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([5; 30].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([5; 30].to_vec()).unwrap(), Some(vec![]), false ), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([6; 128].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([6; 128].to_vec()).unwrap(), Some(vec![]), true ), @@ -3097,48 +3062,48 @@ mod tests { // Overwrite assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([1; 64].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([1; 64].to_vec()).unwrap(), Some(vec![42, 43, 44]), false ), Ok(WriteOutcome::Overwritten(3)) ); assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([2; 19].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([2; 19].to_vec()).unwrap(), Some(vec![48]), true ), Ok(WriteOutcome::Taken(vec![4, 5, 6])) ); assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([3; 19].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([3; 19].to_vec()).unwrap(), None, false ), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([4; 64].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([4; 64].to_vec()).unwrap(), None, true ), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([5; 30].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([5; 30].to_vec()).unwrap(), Some(vec![]), false ), Ok(WriteOutcome::Overwritten(0)) ); assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([6; 128].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([6; 128].to_vec()).unwrap(), Some(vec![]), true ), @@ -3173,13 +3138,16 @@ mod tests { fn get_storage_works() { let code_hash = MockLoader::insert(Call, |ctx, _| { assert_eq!( - ctx.ext.set_storage(&[1; 32], Some(vec![1, 2, 3]), false), + ctx.ext.set_storage(&Key::Fix([1; 32]), Some(vec![1, 2, 3]), false), Ok(WriteOutcome::New) ); - assert_eq!(ctx.ext.set_storage(&[2; 32], Some(vec![]), false), Ok(WriteOutcome::New)); - assert_eq!(ctx.ext.get_storage(&[1; 32]), Some(vec![1, 2, 3])); - assert_eq!(ctx.ext.get_storage(&[2; 32]), Some(vec![])); - assert_eq!(ctx.ext.get_storage(&[3; 32]), None); + assert_eq!( + ctx.ext.set_storage(&Key::Fix([2; 32]), Some(vec![]), false), + Ok(WriteOutcome::New) + ); + assert_eq!(ctx.ext.get_storage(&Key::Fix([1; 32])), Some(vec![1, 2, 3])); + assert_eq!(ctx.ext.get_storage(&Key::Fix([2; 32])), Some(vec![])); + assert_eq!(ctx.ext.get_storage(&Key::Fix([3; 32])), None); exec_success() }); @@ -3209,13 +3177,16 @@ mod tests { fn get_storage_size_works() { let code_hash = MockLoader::insert(Call, |ctx, _| { assert_eq!( - ctx.ext.set_storage(&[1; 32], Some(vec![1, 2, 3]), false), + ctx.ext.set_storage(&Key::Fix([1; 32]), Some(vec![1, 2, 3]), false), Ok(WriteOutcome::New) ); - assert_eq!(ctx.ext.set_storage(&[2; 32], Some(vec![]), false), Ok(WriteOutcome::New)); - assert_eq!(ctx.ext.get_storage_size(&[1; 32]), Some(3)); - assert_eq!(ctx.ext.get_storage_size(&[2; 32]), Some(0)); - assert_eq!(ctx.ext.get_storage_size(&[3; 32]), None); + assert_eq!( + ctx.ext.set_storage(&Key::Fix([2; 32]), Some(vec![]), false), + Ok(WriteOutcome::New) + ); + assert_eq!(ctx.ext.get_storage_size(&Key::Fix([1; 32])), Some(3)); + assert_eq!(ctx.ext.get_storage_size(&Key::Fix([2; 32])), Some(0)); + assert_eq!(ctx.ext.get_storage_size(&Key::Fix([3; 32])), None); exec_success() }); @@ -3242,40 +3213,34 @@ mod tests { } #[test] - fn get_storage_transparent_works() { + fn get_storage_varsized_key_works() { let code_hash = MockLoader::insert(Call, |ctx, _| { assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([1; 19].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([1; 19].to_vec()).unwrap(), Some(vec![1, 2, 3]), false ), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([2; 16].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([2; 16].to_vec()).unwrap(), Some(vec![]), false ), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.get_storage_transparent( - &VarSizedKey::::try_from([1; 19].to_vec()).unwrap() - ), + ctx.ext.get_storage(&Key::::try_from_var([1; 19].to_vec()).unwrap()), Some(vec![1, 2, 3]) ); assert_eq!( - ctx.ext.get_storage_transparent( - &VarSizedKey::::try_from([2; 16].to_vec()).unwrap() - ), + ctx.ext.get_storage(&Key::::try_from_var([2; 16].to_vec()).unwrap()), Some(vec![]) ); assert_eq!( - ctx.ext.get_storage_transparent( - &VarSizedKey::::try_from([3; 8].to_vec()).unwrap() - ), + ctx.ext.get_storage(&Key::::try_from_var([3; 8].to_vec()).unwrap()), None ); @@ -3304,40 +3269,34 @@ mod tests { } #[test] - fn get_storage_size_transparent_works() { + fn get_storage_size_varsized_key_works() { let code_hash = MockLoader::insert(Call, |ctx, _| { assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([1; 19].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([1; 19].to_vec()).unwrap(), Some(vec![1, 2, 3]), false ), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from([2; 16].to_vec()).unwrap(), + ctx.ext.set_storage( + &Key::::try_from_var([2; 16].to_vec()).unwrap(), Some(vec![]), false ), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.get_storage_size_transparent( - &VarSizedKey::::try_from([1; 19].to_vec()).unwrap() - ), + ctx.ext.get_storage_size(&Key::::try_from_var([1; 19].to_vec()).unwrap()), Some(3) ); assert_eq!( - ctx.ext.get_storage_size_transparent( - &VarSizedKey::::try_from([2; 16].to_vec()).unwrap() - ), + ctx.ext.get_storage_size(&Key::::try_from_var([2; 16].to_vec()).unwrap()), Some(0) ); assert_eq!( - ctx.ext.get_storage_size_transparent( - &VarSizedKey::::try_from([3; 8].to_vec()).unwrap() - ), + ctx.ext.get_storage_size(&Key::::try_from_var([3; 8].to_vec()).unwrap()), None ); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 0aff18fd62083..7aac94d11148b 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -100,7 +100,7 @@ pub mod weights; mod tests; use crate::{ - exec::{AccountIdOf, ErrorOrigin, ExecError, Executable, Stack as ExecStack}, + exec::{AccountIdOf, ErrorOrigin, ExecError, Executable, Key, Stack as ExecStack}, gas::GasMeter, storage::{meter::Meter as StorageMeter, ContractInfo, DeletedContract}, wasm::{OwnerInfo, PrefabWasmModule, TryInstantiate}, @@ -131,7 +131,7 @@ use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; pub use crate::{ address::{AddressGenerator, DefaultAddressGenerator}, - exec::{Frame, VarSizedKey as StorageKey}, + exec::Frame, migration::Migration, pallet::*, schedule::{HostFnWeights, InstructionWeights, Limits, Schedule}, @@ -1265,7 +1265,9 @@ impl Pallet { ContractInfoOf::::get(&address).ok_or(ContractAccessError::DoesntExist)?; let maybe_value = contract_info.read( - &StorageKey::::try_from(key).map_err(|_| ContractAccessError::KeyDecodingFailed)?, + &Key::::try_from_var(key) + .map_err(|_| ContractAccessError::KeyDecodingFailed)? + .into(), ); Ok(maybe_value) } diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 26162b55ca393..19c5f391d670b 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -20,7 +20,7 @@ pub mod meter; use crate::{ - exec::{AccountIdOf, StorageKey}, + exec::{AccountIdOf, Key}, weights::WeightInfo, AddressGenerator, BalanceOf, CodeHash, Config, ContractInfoOf, DeletionQueue, Error, Pallet, TrieId, SENTINEL, @@ -132,7 +132,7 @@ impl ContractInfo { /// /// The read is performed from the `trie_id` only. The `address` is not necessary. If the /// contract doesn't store under the given `key` `None` is returned. - pub fn read>(&self, key: &K) -> Option> { + pub fn read(&self, key: &Key) -> Option> { child::get_raw(&self.child_trie_info(), key.hash().as_slice()) } @@ -140,7 +140,7 @@ impl ContractInfo { /// /// Returns `None` if the `key` wasn't previously set by `set_storage` or /// was deleted. - pub fn size>(&self, key: &K) -> Option { + pub fn size(&self, key: &Key) -> Option { child::len(&self.child_trie_info(), key.hash().as_slice()) } @@ -151,9 +151,9 @@ impl ContractInfo { /// /// This function also records how much storage was created or removed if a `storage_meter` /// is supplied. It should only be absent for testing or benchmarking code. - pub fn write>( + pub fn write( &self, - key: &K, + key: &Key, new_value: Option>, storage_meter: Option<&mut meter::NestedMeter>, take: bool, diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index ba9873f07efee..30a39eebfcfdd 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -21,7 +21,7 @@ use crate::{ ChainExtension, Environment, Ext, InitState, RegisteredChainExtension, Result as ExtensionResult, RetVal, ReturnFlags, SysConfig, }, - exec::{FixSizedKey, Frame}, + exec::{Frame, Key}, tests::test_utils::{get_contract, get_contract_checked}, wasm::{Determinism, PrefabWasmModule, ReturnCode as RuntimeReturnCode}, weights::WeightInfo, @@ -2145,7 +2145,7 @@ fn lazy_removal_partial_remove_works() { // Put value into the contracts child trie for val in &vals { - info.write(&val.0 as &FixSizedKey, Some(val.2.clone()), None, false).unwrap(); + info.write(&Key::Fix(val.0), Some(val.2.clone()), None, false).unwrap(); } >::insert(&addr, info.clone()); @@ -2330,7 +2330,7 @@ fn lazy_removal_does_not_use_all_weight() { // Put value into the contracts child trie for val in &vals { - info.write(&val.0 as &FixSizedKey, Some(val.2.clone()), None, false).unwrap(); + info.write(&Key::Fix(val.0), Some(val.2.clone()), None, false).unwrap(); } >::insert(&addr, info.clone()); diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index f74df2c361442..cfda9c37611b9 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -366,10 +366,7 @@ impl Executable for PrefabWasmModule { mod tests { use super::*; use crate::{ - exec::{ - AccountIdOf, BlockNumberOf, ErrorOrigin, ExecError, Executable, Ext, FixSizedKey, - SeedOf, VarSizedKey, - }, + exec::{AccountIdOf, BlockNumberOf, ErrorOrigin, ExecError, Executable, Ext, Key, SeedOf}, gas::GasMeter, storage::WriteOutcome, tests::{RuntimeCall, Test, ALICE, BOB}, @@ -521,40 +518,15 @@ mod tests { self.terminations.push(TerminationEntry { beneficiary: beneficiary.clone() }); Ok(()) } - fn get_storage(&mut self, key: &FixSizedKey) -> Option> { + fn get_storage(&mut self, key: &Key) -> Option> { self.storage.get(&key.to_vec()).cloned() } - fn get_storage_transparent(&mut self, key: &VarSizedKey) -> Option> { - self.storage.get(&key.to_vec()).cloned() - } - fn get_storage_size(&mut self, key: &FixSizedKey) -> Option { - self.storage.get(&key.to_vec()).map(|val| val.len() as u32) - } - fn get_storage_size_transparent(&mut self, key: &VarSizedKey) -> Option { + fn get_storage_size(&mut self, key: &Key) -> Option { self.storage.get(&key.to_vec()).map(|val| val.len() as u32) } fn set_storage( &mut self, - key: &FixSizedKey, - value: Option>, - take_old: bool, - ) -> Result { - let key = key.to_vec(); - let entry = self.storage.entry(key.clone()); - let result = match (entry, take_old) { - (Entry::Vacant(_), _) => WriteOutcome::New, - (Entry::Occupied(entry), false) => - WriteOutcome::Overwritten(entry.remove().len() as u32), - (Entry::Occupied(entry), true) => WriteOutcome::Taken(entry.remove()), - }; - if let Some(value) = value { - self.storage.insert(key, value); - } - Ok(result) - } - fn set_storage_transparent( - &mut self, - key: &VarSizedKey, + key: &Key, value: Option>, take_old: bool, ) -> Result { @@ -1071,14 +1043,14 @@ mod tests { "#; let mut ext = MockExt::default(); - ext.set_storage_transparent( - &VarSizedKey::::try_from([1u8; 64].to_vec()).unwrap(), + ext.set_storage( + &Key::::try_from_var([1u8; 64].to_vec()).unwrap(), Some(vec![42u8]), false, ) .unwrap(); - ext.set_storage_transparent( - &VarSizedKey::::try_from([2u8; 19].to_vec()).unwrap(), + ext.set_storage( + &Key::::try_from_var([2u8; 19].to_vec()).unwrap(), Some(vec![]), false, ) @@ -2547,15 +2519,15 @@ mod tests { let mut ext = MockExt::default(); - ext.set_storage_transparent( - &VarSizedKey::::try_from([1u8; 64].to_vec()).unwrap(), + ext.set_storage( + &Key::::try_from_var([1u8; 64].to_vec()).unwrap(), Some(vec![42u8]), false, ) .unwrap(); - ext.set_storage_transparent( - &VarSizedKey::::try_from([2u8; 19].to_vec()).unwrap(), + ext.set_storage( + &Key::::try_from_var([2u8; 19].to_vec()).unwrap(), Some(vec![]), false, ) @@ -2631,14 +2603,14 @@ mod tests { let mut ext = MockExt::default(); - ext.set_storage_transparent( - &VarSizedKey::::try_from([1u8; 64].to_vec()).unwrap(), + ext.set_storage( + &Key::::try_from_var([1u8; 64].to_vec()).unwrap(), Some(vec![42u8]), false, ) .unwrap(); - ext.set_storage_transparent( - &VarSizedKey::::try_from([2u8; 19].to_vec()).unwrap(), + ext.set_storage( + &Key::::try_from_var([2u8; 19].to_vec()).unwrap(), Some(vec![]), false, ) @@ -2728,15 +2700,15 @@ mod tests { let mut ext = MockExt::default(); - ext.set_storage_transparent( - &VarSizedKey::::try_from([1u8; 64].to_vec()).unwrap(), + ext.set_storage( + &Key::::try_from_var([1u8; 64].to_vec()).unwrap(), Some(vec![42u8]), false, ) .unwrap(); - ext.set_storage_transparent( - &VarSizedKey::::try_from([2u8; 19].to_vec()).unwrap(), + ext.set_storage( + &Key::::try_from_var([2u8; 19].to_vec()).unwrap(), Some(vec![]), false, ) diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index b30bad38bfce5..a8a19e6f95150 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -18,7 +18,7 @@ //! Environment definition of the wasm smart-contract runtime. use crate::{ - exec::{ExecError, ExecResult, Ext, FixSizedKey, TopicOf, VarSizedKey}, + exec::{ExecError, ExecResult, Ext, Key, TopicOf}, gas::{ChargedAmount, Token}, schedule::HostFnWeights, BalanceOf, CodeHash, Config, DebugBufferVec, Error, SENTINEL, @@ -73,19 +73,7 @@ enum KeyType { Fix, /// Variable sized key used in transparent hashing, /// cannot be larger than MaxStorageKeyLen. - Variable(u32), -} - -impl KeyType { - fn len(&self) -> Result { - match self { - KeyType::Fix => Ok(32u32), - KeyType::Variable(len) => { - ensure!(len <= &::MaxStorageKeyLen::get(), Error::::DecodingFailed); - Ok(*len) - }, - } - } + Var(u32), } /// Every error that can be returned to a contract when it calls any of the host functions. @@ -752,6 +740,29 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> { (err, _) => Self::err_into_return_code(err), } } + fn decode_key( + &self, + memory: &[u8], + key_type: KeyType, + key_ptr: u32, + ) -> Result, TrapReason> { + let res = match key_type { + KeyType::Fix => { + let key = self.read_sandbox_memory(memory, key_ptr, 32u32)?; + Key::try_from_fix(key) + }, + KeyType::Var(len) => { + ensure!( + len <= <::T as Config>::MaxStorageKeyLen::get(), + Error::::DecodingFailed + ); + let key = self.read_sandbox_memory(memory, key_ptr, len)?; + Key::try_from_var(key) + }, + }; + + res.map_err(|_| Error::::DecodingFailed.into()) + } fn set_storage( &mut self, @@ -767,20 +778,9 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> { if value_len > max_size { return Err(Error::::ValueTooLarge.into()) } - let key = self.read_sandbox_memory(memory, key_ptr, key_type.len::()?)?; + let key = self.decode_key(memory, key_type, key_ptr)?; let value = Some(self.read_sandbox_memory(memory, value_ptr, value_len)?); - let write_outcome = match key_type { - KeyType::Fix => self.ext.set_storage( - &FixSizedKey::try_from(key).map_err(|_| Error::::DecodingFailed)?, - value, - false, - )?, - KeyType::Variable(_) => self.ext.set_storage_transparent( - &VarSizedKey::::try_from(key).map_err(|_| Error::::DecodingFailed)?, - value, - false, - )?, - }; + let write_outcome = self.ext.set_storage(&key, value, false)?; self.adjust_gas( charged, @@ -796,19 +796,8 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> { key_ptr: u32, ) -> Result { let charged = self.charge_gas(RuntimeCosts::ClearStorage(self.ext.max_value_size()))?; - let key = self.read_sandbox_memory(memory, key_ptr, key_type.len::()?)?; - let outcome = match key_type { - KeyType::Fix => self.ext.set_storage( - &FixSizedKey::try_from(key).map_err(|_| Error::::DecodingFailed)?, - None, - false, - )?, - KeyType::Variable(_) => self.ext.set_storage_transparent( - &VarSizedKey::::try_from(key).map_err(|_| Error::::DecodingFailed)?, - None, - false, - )?, - }; + let key = self.decode_key(memory, key_type, key_ptr)?; + let outcome = self.ext.set_storage(&key, None, false)?; self.adjust_gas(charged, RuntimeCosts::ClearStorage(outcome.old_len())); Ok(outcome.old_len_with_sentinel()) @@ -823,15 +812,8 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> { out_len_ptr: u32, ) -> Result { let charged = self.charge_gas(RuntimeCosts::GetStorage(self.ext.max_value_size()))?; - let key = self.read_sandbox_memory(memory, key_ptr, key_type.len::()?)?; - let outcome = match key_type { - KeyType::Fix => self.ext.get_storage( - &FixSizedKey::try_from(key).map_err(|_| Error::::DecodingFailed)?, - ), - KeyType::Variable(_) => self.ext.get_storage_transparent( - &VarSizedKey::::try_from(key).map_err(|_| Error::::DecodingFailed)?, - ), - }; + let key = self.decode_key(memory, key_type, key_ptr)?; + let outcome = self.ext.get_storage(&key); if let Some(value) = outcome { self.adjust_gas(charged, RuntimeCosts::GetStorage(value.len() as u32)); @@ -857,15 +839,8 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> { key_ptr: u32, ) -> Result { let charged = self.charge_gas(RuntimeCosts::ContainsStorage(self.ext.max_value_size()))?; - let key = self.read_sandbox_memory(memory, key_ptr, key_type.len::()?)?; - let outcome = match key_type { - KeyType::Fix => self.ext.get_storage_size( - &FixSizedKey::try_from(key).map_err(|_| Error::::DecodingFailed)?, - ), - KeyType::Variable(_) => self.ext.get_storage_size_transparent( - &VarSizedKey::::try_from(key).map_err(|_| Error::::DecodingFailed)?, - ), - }; + let key = self.decode_key(memory, key_type, key_ptr)?; + let outcome = self.ext.get_storage_size(&key); self.adjust_gas(charged, RuntimeCosts::ClearStorage(outcome.unwrap_or(0))); Ok(outcome.unwrap_or(SENTINEL)) @@ -1092,7 +1067,7 @@ pub mod env { value_ptr: u32, value_len: u32, ) -> Result { - ctx.set_storage(memory, KeyType::Variable(key_len), key_ptr, value_ptr, value_len) + ctx.set_storage(memory, KeyType::Var(key_len), key_ptr, value_ptr, value_len) } /// Clear the value at the given key in the contract storage. @@ -1118,7 +1093,7 @@ pub mod env { #[version(1)] #[prefixed_alias] fn clear_storage(ctx: _, memory: _, key_ptr: u32, key_len: u32) -> Result { - ctx.clear_storage(memory, KeyType::Variable(key_len), key_ptr) + ctx.clear_storage(memory, KeyType::Var(key_len), key_ptr) } /// Retrieve the value under the given key from storage. @@ -1175,7 +1150,7 @@ pub mod env { out_ptr: u32, out_len_ptr: u32, ) -> Result { - ctx.get_storage(memory, KeyType::Variable(key_len), key_ptr, out_ptr, out_len_ptr) + ctx.get_storage(memory, KeyType::Var(key_len), key_ptr, out_ptr, out_len_ptr) } /// Checks whether there is a value stored under the given key. @@ -1212,7 +1187,7 @@ pub mod env { #[version(1)] #[prefixed_alias] fn contains_storage(ctx: _, memory: _, key_ptr: u32, key_len: u32) -> Result { - ctx.contains_storage(memory, KeyType::Variable(key_len), key_ptr) + ctx.contains_storage(memory, KeyType::Var(key_len), key_ptr) } /// Retrieve and remove the value under the given key from storage. @@ -1239,8 +1214,8 @@ pub mod env { ) -> Result { let charged = ctx.charge_gas(RuntimeCosts::TakeStorage(ctx.ext.max_value_size()))?; let key = ctx.read_sandbox_memory(memory, key_ptr, key_len)?; - if let crate::storage::WriteOutcome::Taken(value) = ctx.ext.set_storage_transparent( - &VarSizedKey::::try_from(key).map_err(|_| Error::::DecodingFailed)?, + if let crate::storage::WriteOutcome::Taken(value) = ctx.ext.set_storage( + &Key::::try_from_var(key).map_err(|_| Error::::DecodingFailed)?, None, true, )? { From 29466db4b711730f5fa95f3fe1f289871b2c7c5c Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Sat, 18 Mar 2023 08:44:46 +0100 Subject: [PATCH 37/80] Add linguist-generated to gitattributes (#13628) --- .gitattributes | 1 + frame/balances/src/weights.rs | 70 +++++++++++++++++------------------ 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/.gitattributes b/.gitattributes index 1762f1a04d802..a77c52fccdb77 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ Cargo.lock linguist-generated=true /.gitlab-ci.yml filter=ci-prettier /scripts/ci/gitlab/pipeline/*.yml filter=ci-prettier +frame/**/src/weights.rs linguist-generated=true diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index 500eb3371d635..e7fd539c061aa 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -18,28 +18,26 @@ //! Autogenerated weights for pallet_balances //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-17, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/substrate +// target/production/substrate // benchmark // pallet -// --chain=dev // --steps=50 // --repeat=20 -// --pallet=pallet_balances -// --no-storage-info -// --no-median-slopes -// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./frame/balances/src/weights.rs +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json +// --pallet=pallet_balances +// --chain=dev // --header=./HEADER-APACHE2 +// --output=./frame/balances/src/weights.rs // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -69,8 +67,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 37_266_000 picoseconds. - Weight::from_parts(37_757_000, 3593) + // Minimum execution time: 36_551_000 picoseconds. + Weight::from_parts(37_150_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -80,8 +78,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 28_782_000 picoseconds. - Weight::from_parts(29_185_000, 3593) + // Minimum execution time: 28_246_000 picoseconds. + Weight::from_parts(28_647_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -91,8 +89,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 17_406_000 picoseconds. - Weight::from_parts(17_781_000, 3593) + // Minimum execution time: 17_407_000 picoseconds. + Weight::from_parts(17_827_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -102,8 +100,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 20_942_000 picoseconds. - Weight::from_parts(21_270_000, 3593) + // Minimum execution time: 20_941_000 picoseconds. + Weight::from_parts(21_383_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -113,8 +111,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `103` // Estimated: `6196` - // Minimum execution time: 41_706_000 picoseconds. - Weight::from_parts(42_176_000, 6196) + // Minimum execution time: 38_741_000 picoseconds. + Weight::from_parts(39_201_000, 6196) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -124,8 +122,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 35_622_000 picoseconds. - Weight::from_parts(35_943_000, 3593) + // Minimum execution time: 33_791_000 picoseconds. + Weight::from_parts(34_500_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -135,8 +133,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 16_586_000 picoseconds. - Weight::from_parts(17_352_000, 3593) + // Minimum execution time: 16_538_000 picoseconds. + Weight::from_parts(16_859_000, 3593) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -150,8 +148,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 37_266_000 picoseconds. - Weight::from_parts(37_757_000, 3593) + // Minimum execution time: 36_551_000 picoseconds. + Weight::from_parts(37_150_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -161,8 +159,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 28_782_000 picoseconds. - Weight::from_parts(29_185_000, 3593) + // Minimum execution time: 28_246_000 picoseconds. + Weight::from_parts(28_647_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -172,8 +170,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 17_406_000 picoseconds. - Weight::from_parts(17_781_000, 3593) + // Minimum execution time: 17_407_000 picoseconds. + Weight::from_parts(17_827_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -183,8 +181,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 20_942_000 picoseconds. - Weight::from_parts(21_270_000, 3593) + // Minimum execution time: 20_941_000 picoseconds. + Weight::from_parts(21_383_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -194,8 +192,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `103` // Estimated: `6196` - // Minimum execution time: 41_706_000 picoseconds. - Weight::from_parts(42_176_000, 6196) + // Minimum execution time: 38_741_000 picoseconds. + Weight::from_parts(39_201_000, 6196) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -205,8 +203,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 35_622_000 picoseconds. - Weight::from_parts(35_943_000, 3593) + // Minimum execution time: 33_791_000 picoseconds. + Weight::from_parts(34_500_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -216,8 +214,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 16_586_000 picoseconds. - Weight::from_parts(17_352_000, 3593) + // Minimum execution time: 16_538_000 picoseconds. + Weight::from_parts(16_859_000, 3593) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } From f8a1dd4c836d7d29382ba66fc2fce40fc1364546 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Sat, 18 Mar 2023 14:47:55 +0000 Subject: [PATCH 38/80] Deprecate `Currency`; introduce holds and freezing into `fungible` traits (#12951) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * First reworking of fungibles API * New API and docs * More fungible::* API improvements * New ref-counting logic for old API * Missing files * Fixes * Use the new transfer logic * Use fungibles for the dispatchables * Use shelve/restore names * Locking works with total balance. * repotting and removal * Separate Holds from Reserves * Introduce freezes * Missing files * Tests for freezing * Fix hold+freeze combo * More tests * Fee-free dispatchable for upgrading accounts * Benchmarks and a few fixes * Another test * Docs and refactor to avoid blanket impls * Repot * Fit out ItemOf fully * Add events to Balanced traits * Introduced events into Hold traits * Fix Assets pallet tests * Assets benchmarks pass * Missing files and fixes * Fixes * Fixes * Benchmarks fixes * Fix balance benchmarks * Formatting * Expose fungible sub modules * Move NIS to fungible API * Fix broken impl and add test * Fix tests * API for `transfer_and_hold` * Use composite APIs * Formatting * Upgraded event * Fixes * Fixes * Fixes * Fixes * Repot tests and some fixed * Fix some bits * Fix dust tests * Rename `set_balance` - `Balances::set_balance` becomes `Balances::force_set_balance` - `Unbalanced::set_balance` becomes `Unbalances::write_balance` * becomes * Move dust handling to fungibles API * Formatting * Fixes and more refactoring * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Use reducible_balance for better correctness on fees * Reducing hold to zero should remove entry. * Add test * Docs * Update frame/support/src/traits/tokens/fungibles/hold.rs Co-authored-by: Muharem Ismailov * Update frame/support/src/traits/tokens/fungibles/regular.rs Co-authored-by: Muharem Ismailov * Update frame/support/src/traits/tokens/fungible/hold.rs Co-authored-by: Muharem Ismailov * Update frame/support/src/traits/tokens/fungible/regular.rs Co-authored-by: Muharem Ismailov * Docs * Docs * Docs * Fix NIS benchmarks * Doc comment * Remove post_mutation * Fix some tests * Fix some grumbles * Enumify bool args to fungible(s) functions * Fix up assets and balances * Formatting * Fix contracts * Fix tests & benchmarks build * Typify minted boolean arg * Typify on_hold boolean arg; renames * Fix numerous tests * Fix dependency issue * Privatize dangerous API mutate_account * Fix contracts (@alext - please check this commit) * Remove println * Fix tests for contracts * Fix broken rename * Fix broken rename * Fix broken rename * Docs * Update frame/support/src/traits/tokens/fungible/hold.rs Co-authored-by: Anthony Alaribe * remove from_ref_time * Update frame/executive/src/lib.rs Co-authored-by: Anthony Alaribe * Update frame/executive/src/lib.rs Co-authored-by: Anthony Alaribe * Reenable test * Update frame/support/src/traits/tokens/fungibles/hold.rs Co-authored-by: Anthony Alaribe * Update frame/support/src/traits/tokens/fungible/hold.rs Co-authored-by: Anthony Alaribe * Update frame/support/src/traits/tokens/fungible/hold.rs Co-authored-by: Anthony Alaribe * Update frame/support/src/traits/tokens/fungible/hold.rs Co-authored-by: Anthony Alaribe * Update frame/support/src/traits/tokens/currency.rs Co-authored-by: Anthony Alaribe * Update frame/lottery/src/tests.rs Co-authored-by: Anthony Alaribe * Update frame/support/src/traits/tokens/fungible/mod.rs Co-authored-by: Anthony Alaribe * Update frame/support/src/traits/tokens/fungible/regular.rs Co-authored-by: Anthony Alaribe * Update frame/support/src/traits/tokens/fungibles/freeze.rs Co-authored-by: Anthony Alaribe * Update frame/support/src/traits/tokens/fungible/regular.rs Co-authored-by: Anthony Alaribe * Update frame/support/src/traits/tokens/fungibles/hold.rs Co-authored-by: Anthony Alaribe * Update frame/support/src/traits/tokens/fungibles/hold.rs Co-authored-by: Anthony Alaribe * Update frame/support/src/traits/tokens/fungibles/hold.rs Co-authored-by: Anthony Alaribe * Rename UnwantedRemoval to UnwantedAccountRemoval * Docs * Formatting * Update frame/balances/src/lib.rs Co-authored-by: Oliver Tale-Yazdi * Update primitives/runtime/src/lib.rs Co-authored-by: Keith Yeung * handle_raw_dust oes nothing * Formatting * Fixes * Grumble * Fixes * Add test * Add test * Tests for reducible_balance * Fixes * Fix Salary * Fixes * Disable broken test * Disable nicely * Fixes * Fixes * Fixes * Rename some events * Fix nomination pools breakage * Add compatibility stub for transfer tx * Reinstate a safely compatible version of Balances set_balance * Fixes * Grumble * Update frame/nis/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_balances * disable flakey tests * Update frame/balances/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Grumbles * Grumble --------- Co-authored-by: Muharem Ismailov Co-authored-by: Alexander Theißen Co-authored-by: Anthony Alaribe Co-authored-by: Oliver Tale-Yazdi Co-authored-by: Keith Yeung Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: command-bot <> --- bin/node-template/runtime/src/lib.rs | 4 + bin/node/cli/benches/block_production.rs | 2 +- bin/node/cli/benches/transaction_pool.rs | 8 +- bin/node/cli/src/service.rs | 2 +- bin/node/cli/tests/temp_base_path_works.rs | 4 +- bin/node/executor/benches/bench.rs | 2 +- bin/node/executor/tests/basic.rs | 57 +- bin/node/executor/tests/common.rs | 5 +- bin/node/executor/tests/fees.rs | 6 +- bin/node/executor/tests/submit_transaction.rs | 12 +- bin/node/runtime/src/impls.rs | 4 +- bin/node/runtime/src/lib.rs | 21 +- bin/node/testing/src/bench.rs | 2 +- frame/alliance/src/mock.rs | 4 + frame/assets/src/benchmarking.rs | 8 +- frame/assets/src/functions.rs | 15 +- frame/assets/src/impl_fungibles.rs | 126 +- frame/assets/src/lib.rs | 6 +- frame/assets/src/mock.rs | 6 +- frame/assets/src/tests.rs | 30 +- frame/atomic-swap/src/tests.rs | 4 + frame/babe/src/mock.rs | 4 + frame/balances/README.md | 2 +- frame/balances/src/benchmarking.rs | 74 +- frame/balances/src/impl_currency.rs | 898 +++++++ frame/balances/src/impl_fungible.rs | 358 +++ frame/balances/src/lib.rs | 2387 +++++------------ frame/balances/src/tests.rs | 1460 ---------- frame/balances/src/tests/currency_tests.rs | 1231 +++++++++ .../balances/src/tests/dispatchable_tests.rs | 224 ++ frame/balances/src/tests/fungible_tests.rs | 399 +++ frame/balances/src/tests/mod.rs | 296 ++ frame/balances/src/tests/reentrancy_tests.rs | 195 ++ frame/balances/src/tests_composite.rs | 149 - frame/balances/src/tests_local.rs | 191 -- frame/balances/src/tests_reentrancy.rs | 264 -- frame/balances/src/types.rs | 157 ++ frame/balances/src/weights.rs | 49 +- frame/beefy/src/mock.rs | 4 + frame/bounties/src/benchmarking.rs | 7 +- frame/bounties/src/tests.rs | 8 +- frame/child-bounties/src/benchmarking.rs | 12 +- frame/child-bounties/src/tests.rs | 8 +- frame/contracts/src/benchmarking/mod.rs | 12 +- frame/contracts/src/exec.rs | 15 +- frame/contracts/src/lib.rs | 2 +- frame/contracts/src/storage/meter.rs | 7 +- frame/contracts/src/tests.rs | 73 +- frame/conviction-voting/src/benchmarking.rs | 12 +- frame/conviction-voting/src/lib.rs | 7 +- frame/conviction-voting/src/tests.rs | 6 +- frame/democracy/src/tests.rs | 8 +- .../src/benchmarking.rs | 10 +- .../election-provider-multi-phase/src/mock.rs | 4 + frame/elections-phragmen/src/lib.rs | 7 +- frame/examples/basic/src/tests.rs | 4 + frame/executive/src/lib.rs | 100 +- frame/fast-unstake/src/mock.rs | 4 + frame/grandpa/src/mock.rs | 4 + frame/identity/src/tests.rs | 4 + frame/indices/src/mock.rs | 4 + frame/lottery/src/mock.rs | 4 + frame/lottery/src/tests.rs | 77 +- frame/multisig/src/tests.rs | 72 +- frame/nfts/src/mock.rs | 4 + frame/nicks/src/lib.rs | 4 + frame/nis/README.md | 5 +- frame/nis/src/benchmarking.rs | 102 +- frame/nis/src/lib.rs | 240 +- frame/nis/src/mock.rs | 50 +- frame/nis/src/tests.rs | 110 +- .../nomination-pools/benchmarking/src/mock.rs | 4 + frame/nomination-pools/src/mock.rs | 4 + frame/nomination-pools/src/tests.rs | 177 +- .../nomination-pools/test-staking/src/mock.rs | 4 + frame/offences/benchmarking/src/mock.rs | 4 + frame/preimage/src/mock.rs | 4 + frame/proxy/src/tests.rs | 28 +- frame/recovery/src/mock.rs | 4 + frame/recovery/src/tests.rs | 10 +- frame/referenda/src/migration.rs | 2 +- frame/referenda/src/mock.rs | 17 +- frame/root-offences/src/mock.rs | 4 + frame/scored-pool/src/mock.rs | 4 + frame/session/benchmarking/src/mock.rs | 4 + frame/society/src/mock.rs | 4 + frame/staking/src/mock.rs | 4 + frame/staking/src/tests.rs | 22 +- frame/state-trie-migration/src/lib.rs | 4 + frame/support/src/traits/stored_map.rs | 35 +- frame/support/src/traits/tokens.rs | 3 +- frame/support/src/traits/tokens/fungible.rs | 367 --- .../src/traits/tokens/fungible/balanced.rs | 354 --- .../src/traits/tokens/fungible/freeze.rs | 68 + .../src/traits/tokens/fungible/hold.rs | 393 +++ .../src/traits/tokens/fungible/imbalance.rs | 15 +- .../src/traits/tokens/fungible/item_of.rs | 451 ++++ .../support/src/traits/tokens/fungible/mod.rs | 56 + .../src/traits/tokens/fungible/regular.rs | 506 ++++ frame/support/src/traits/tokens/fungibles.rs | 332 --- .../src/traits/tokens/fungibles/balanced.rs | 394 --- .../src/traits/tokens/fungibles/enumerable.rs | 4 +- .../src/traits/tokens/fungibles/freeze.rs | 78 + .../src/traits/tokens/fungibles/hold.rs | 457 ++++ .../src/traits/tokens/fungibles/imbalance.rs | 13 +- .../src/traits/tokens/fungibles/lifetime.rs | 84 + .../src/traits/tokens/fungibles/mod.rs | 40 + .../src/traits/tokens/fungibles/regular.rs | 571 ++++ frame/support/src/traits/tokens/misc.rs | 62 +- frame/support/src/traits/tokens/pay.rs | 8 +- frame/system/src/lib.rs | 23 +- frame/system/src/tests.rs | 2 + frame/tips/src/tests.rs | 4 + .../asset-tx-payment/src/lib.rs | 8 +- .../asset-tx-payment/src/mock.rs | 6 +- .../asset-tx-payment/src/payment.rs | 23 +- .../asset-tx-payment/src/tests.rs | 2 +- frame/transaction-payment/src/mock.rs | 6 +- frame/transaction-payment/src/tests.rs | 10 +- frame/transaction-storage/src/mock.rs | 4 + frame/treasury/src/tests.rs | 4 + frame/uniques/src/mock.rs | 4 + frame/utility/Cargo.toml | 1 + frame/utility/src/tests.rs | 17 +- frame/vesting/src/benchmarking.rs | 12 +- frame/vesting/src/mock.rs | 4 + frame/vesting/src/tests.rs | 37 +- frame/whitelist/src/mock.rs | 4 + primitives/runtime/src/lib.rs | 22 +- 129 files changed, 8325 insertions(+), 6119 deletions(-) create mode 100644 frame/balances/src/impl_currency.rs create mode 100644 frame/balances/src/impl_fungible.rs delete mode 100644 frame/balances/src/tests.rs create mode 100644 frame/balances/src/tests/currency_tests.rs create mode 100644 frame/balances/src/tests/dispatchable_tests.rs create mode 100644 frame/balances/src/tests/fungible_tests.rs create mode 100644 frame/balances/src/tests/mod.rs create mode 100644 frame/balances/src/tests/reentrancy_tests.rs delete mode 100644 frame/balances/src/tests_composite.rs delete mode 100644 frame/balances/src/tests_local.rs delete mode 100644 frame/balances/src/tests_reentrancy.rs create mode 100644 frame/balances/src/types.rs delete mode 100644 frame/support/src/traits/tokens/fungible.rs delete mode 100644 frame/support/src/traits/tokens/fungible/balanced.rs create mode 100644 frame/support/src/traits/tokens/fungible/freeze.rs create mode 100644 frame/support/src/traits/tokens/fungible/hold.rs create mode 100644 frame/support/src/traits/tokens/fungible/item_of.rs create mode 100644 frame/support/src/traits/tokens/fungible/mod.rs create mode 100644 frame/support/src/traits/tokens/fungible/regular.rs delete mode 100644 frame/support/src/traits/tokens/fungibles.rs delete mode 100644 frame/support/src/traits/tokens/fungibles/balanced.rs create mode 100644 frame/support/src/traits/tokens/fungibles/freeze.rs create mode 100644 frame/support/src/traits/tokens/fungibles/hold.rs create mode 100644 frame/support/src/traits/tokens/fungibles/lifetime.rs create mode 100644 frame/support/src/traits/tokens/fungibles/mod.rs create mode 100644 frame/support/src/traits/tokens/fungibles/regular.rs diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 41871c06bd923..50bcb67cb4790 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -243,6 +243,10 @@ impl pallet_balances::Config for Runtime { type ExistentialDeposit = ConstU128; type AccountStore = System; type WeightInfo = pallet_balances::weights::SubstrateWeight; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { diff --git a/bin/node/cli/benches/block_production.rs b/bin/node/cli/benches/block_production.rs index 501d69fc287b7..f1c65955eaef8 100644 --- a/bin/node/cli/benches/block_production.rs +++ b/bin/node/cli/benches/block_production.rs @@ -162,7 +162,7 @@ fn prepare_benchmark(client: &FullClient) -> (usize, Vec) { let extrinsic: OpaqueExtrinsic = create_extrinsic( client, src.clone(), - BalancesCall::transfer { dest: dst.clone(), value: 1 * DOLLARS }, + BalancesCall::transfer_allow_death { dest: dst.clone(), value: 1 * DOLLARS }, Some(nonce), ) .into(); diff --git a/bin/node/cli/benches/transaction_pool.rs b/bin/node/cli/benches/transaction_pool.rs index 165c67f602777..72c1c81608e13 100644 --- a/bin/node/cli/benches/transaction_pool.rs +++ b/bin/node/cli/benches/transaction_pool.rs @@ -140,10 +140,9 @@ fn create_account_extrinsics( Sr25519Keyring::Alice.pair(), SudoCall::sudo { call: Box::new( - BalancesCall::set_balance { + BalancesCall::force_set_balance { who: AccountId::from(a.public()).into(), new_free: 0, - new_reserved: 0, } .into(), ), @@ -156,10 +155,9 @@ fn create_account_extrinsics( Sr25519Keyring::Alice.pair(), SudoCall::sudo { call: Box::new( - BalancesCall::set_balance { + BalancesCall::force_set_balance { who: AccountId::from(a.public()).into(), new_free: 1_000_000 * DOLLARS, - new_reserved: 0, } .into(), ), @@ -184,7 +182,7 @@ fn create_benchmark_extrinsics( create_extrinsic( client, account.clone(), - BalancesCall::transfer { + BalancesCall::transfer_allow_death { dest: Sr25519Keyring::Bob.to_account_id().into(), value: 1 * DOLLARS, }, diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index a2d66cd6349de..d32223339dc4a 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -772,7 +772,7 @@ mod tests { }; let signer = charlie.clone(); - let function = RuntimeCall::Balances(BalancesCall::transfer { + let function = RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: to.into(), value: amount, }); diff --git a/bin/node/cli/tests/temp_base_path_works.rs b/bin/node/cli/tests/temp_base_path_works.rs index 89e901c00e118..bfc9f88220030 100644 --- a/bin/node/cli/tests/temp_base_path_works.rs +++ b/bin/node/cli/tests/temp_base_path_works.rs @@ -26,7 +26,9 @@ use std::{ pub mod common; -#[tokio::test] +#[allow(dead_code)] +// Apparently `#[ignore]` doesn't actually work to disable this one. +//#[tokio::test] async fn temp_base_path_works() { common::run_with_timeout(Duration::from_secs(60 * 10), async move { let mut cmd = Command::new(cargo_bin("substrate")); diff --git a/bin/node/executor/benches/bench.rs b/bin/node/executor/benches/bench.rs index 19e7b158a8c81..a8c31068e853b 100644 --- a/bin/node/executor/benches/bench.rs +++ b/bin/node/executor/benches/bench.rs @@ -167,7 +167,7 @@ fn test_blocks( }]; block1_extrinsics.extend((0..20).map(|i| CheckedExtrinsic { signed: Some((alice(), signed_extra(i, 0))), - function: RuntimeCall::Balances(pallet_balances::Call::transfer { + function: RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { dest: bob().into(), value: 1 * DOLLARS, }), diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs index 9200fe735be41..d301aa06f90b0 100644 --- a/bin/node/executor/tests/basic.rs +++ b/bin/node/executor/tests/basic.rs @@ -89,7 +89,7 @@ fn changes_trie_block() -> (Vec, Hash) { }, CheckedExtrinsic { signed: Some((alice(), signed_extra(0, 0))), - function: RuntimeCall::Balances(pallet_balances::Call::transfer { + function: RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { dest: bob().into(), value: 69 * DOLLARS, }), @@ -116,7 +116,7 @@ fn blocks() -> ((Vec, Hash), (Vec, Hash)) { }, CheckedExtrinsic { signed: Some((alice(), signed_extra(0, 0))), - function: RuntimeCall::Balances(pallet_balances::Call::transfer { + function: RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { dest: bob().into(), value: 69 * DOLLARS, }), @@ -136,14 +136,14 @@ fn blocks() -> ((Vec, Hash), (Vec, Hash)) { }, CheckedExtrinsic { signed: Some((bob(), signed_extra(0, 0))), - function: RuntimeCall::Balances(pallet_balances::Call::transfer { + function: RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { dest: alice().into(), value: 5 * DOLLARS, }), }, CheckedExtrinsic { signed: Some((alice(), signed_extra(1, 0))), - function: RuntimeCall::Balances(pallet_balances::Call::transfer { + function: RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { dest: bob().into(), value: 15 * DOLLARS, }), @@ -183,7 +183,12 @@ fn panic_execution_with_foreign_code_gives_error() { let mut t = new_test_ext(bloaty_code_unwrap()); t.insert( >::hashed_key_for(alice()), - (69u128, 0u32, 0u128, 0u128, 0u128).encode(), + AccountInfo::<::Index, _> { + providers: 1, + data: (69u128, 0u128, 0u128, 1u128 << 127), + ..Default::default() + } + .encode(), ); t.insert(>::hashed_key().to_vec(), 69_u128.encode()); t.insert(>::hashed_key_for(0), vec![0u8; 32]); @@ -204,9 +209,14 @@ fn bad_extrinsic_with_native_equivalent_code_gives_error() { let mut t = new_test_ext(compact_code_unwrap()); t.insert( >::hashed_key_for(alice()), - (0u32, 0u32, 0u32, 69u128, 0u128, 0u128, 0u128).encode(), + AccountInfo::<::Index, _> { + providers: 1, + data: (69u128, 0u128, 0u128, 1u128 << 127), + ..Default::default() + } + .encode(), ); - t.insert(>::hashed_key().to_vec(), 69_u128.encode()); + t.insert(>::hashed_key().to_vec(), 69u128.encode()); t.insert(>::hashed_key_for(0), vec![0u8; 32]); let r = @@ -226,17 +236,18 @@ fn successful_execution_with_native_equivalent_code_gives_ok() { t.insert( >::hashed_key_for(alice()), AccountInfo::<::Index, _> { - data: (111 * DOLLARS, 0u128, 0u128, 0u128), + providers: 1, + data: (111 * DOLLARS, 0u128, 0u128, 1u128 << 127), ..Default::default() } .encode(), ); t.insert( >::hashed_key_for(bob()), - AccountInfo::<::Index, _> { - data: (0 * DOLLARS, 0u128, 0u128, 0u128), - ..Default::default() - } + AccountInfo::< + ::Index, + ::AccountData, + >::default() .encode(), ); t.insert( @@ -267,17 +278,18 @@ fn successful_execution_with_foreign_code_gives_ok() { t.insert( >::hashed_key_for(alice()), AccountInfo::<::Index, _> { - data: (111 * DOLLARS, 0u128, 0u128, 0u128), + providers: 1, + data: (111 * DOLLARS, 0u128, 0u128, 1u128 << 127), ..Default::default() } .encode(), ); t.insert( >::hashed_key_for(bob()), - AccountInfo::<::Index, _> { - data: (0 * DOLLARS, 0u128, 0u128, 0u128), - ..Default::default() - } + AccountInfo::< + ::Index, + ::AccountData, + >::default() .encode(), ); t.insert( @@ -784,17 +796,18 @@ fn successful_execution_gives_ok() { t.insert( >::hashed_key_for(alice()), AccountInfo::<::Index, _> { - data: (111 * DOLLARS, 0u128, 0u128, 0u128), + providers: 1, + data: (111 * DOLLARS, 0u128, 0u128, 1u128 << 127), ..Default::default() } .encode(), ); t.insert( >::hashed_key_for(bob()), - AccountInfo::<::Index, _> { - data: (0 * DOLLARS, 0u128, 0u128, 0u128), - ..Default::default() - } + AccountInfo::< + ::Index, + ::AccountData, + >::default() .encode(), ); t.insert( diff --git a/bin/node/executor/tests/common.rs b/bin/node/executor/tests/common.rs index 036528f8dae1f..2f92423ffb508 100644 --- a/bin/node/executor/tests/common.rs +++ b/bin/node/executor/tests/common.rs @@ -87,7 +87,10 @@ pub fn sign(xt: CheckedExtrinsic) -> UncheckedExtrinsic { } pub fn default_transfer_call() -> pallet_balances::Call { - pallet_balances::Call::::transfer { dest: bob().into(), value: 69 * DOLLARS } + pallet_balances::Call::::transfer_allow_death { + dest: bob().into(), + value: 69 * DOLLARS, + } } pub fn from_block_number(n: u32) -> Header { diff --git a/bin/node/executor/tests/fees.rs b/bin/node/executor/tests/fees.rs index cbf0fdce9476b..970d790a87d3b 100644 --- a/bin/node/executor/tests/fees.rs +++ b/bin/node/executor/tests/fees.rs @@ -120,9 +120,9 @@ fn new_account_info(free_dollars: u128) -> Vec { frame_system::AccountInfo { nonce: 0u32, consumers: 0, - providers: 0, + providers: 1, sufficients: 0, - data: (free_dollars * DOLLARS, 0 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS), + data: (free_dollars * DOLLARS, 0 * DOLLARS, 0 * DOLLARS, 1u128 << 127), } .encode() } @@ -214,7 +214,7 @@ fn block_weight_capacity_report() { let mut xts = (0..num_transfers) .map(|i| CheckedExtrinsic { signed: Some((charlie(), signed_extra(nonce + i as Index, 0))), - function: RuntimeCall::Balances(pallet_balances::Call::transfer { + function: RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { dest: bob().into(), value: 0, }), diff --git a/bin/node/executor/tests/submit_transaction.rs b/bin/node/executor/tests/submit_transaction.rs index 32eacd78b78b7..a3d6681fb6928 100644 --- a/bin/node/executor/tests/submit_transaction.rs +++ b/bin/node/executor/tests/submit_transaction.rs @@ -86,7 +86,7 @@ fn should_submit_signed_transaction() { t.execute_with(|| { let results = Signer::::all_accounts().send_signed_transaction(|_| { - pallet_balances::Call::transfer { + pallet_balances::Call::transfer_allow_death { dest: Alice.to_account_id().into(), value: Default::default(), } @@ -123,7 +123,7 @@ fn should_submit_signed_twice_from_the_same_account() { t.execute_with(|| { let result = Signer::::any_account().send_signed_transaction(|_| { - pallet_balances::Call::transfer { + pallet_balances::Call::transfer_allow_death { dest: Alice.to_account_id().into(), value: Default::default(), } @@ -135,7 +135,7 @@ fn should_submit_signed_twice_from_the_same_account() { // submit another one from the same account. The nonce should be incremented. let result = Signer::::any_account().send_signed_transaction(|_| { - pallet_balances::Call::transfer { + pallet_balances::Call::transfer_allow_death { dest: Alice.to_account_id().into(), value: Default::default(), } @@ -174,7 +174,7 @@ fn should_submit_signed_twice_from_all_accounts() { t.execute_with(|| { let results = Signer::::all_accounts() .send_signed_transaction(|_| { - pallet_balances::Call::transfer { dest: Alice.to_account_id().into(), value: Default::default() } + pallet_balances::Call::transfer_allow_death { dest: Alice.to_account_id().into(), value: Default::default() } }); let len = results.len(); @@ -185,7 +185,7 @@ fn should_submit_signed_twice_from_all_accounts() { // submit another one from the same account. The nonce should be incremented. let results = Signer::::all_accounts() .send_signed_transaction(|_| { - pallet_balances::Call::transfer { dest: Alice.to_account_id().into(), value: Default::default() } + pallet_balances::Call::transfer_allow_death { dest: Alice.to_account_id().into(), value: Default::default() } }); let len = results.len(); @@ -238,7 +238,7 @@ fn submitted_transaction_should_be_valid() { t.execute_with(|| { let results = Signer::::all_accounts().send_signed_transaction(|_| { - pallet_balances::Call::transfer { + pallet_balances::Call::transfer_allow_death { dest: Alice.to_account_id().into(), value: Default::default(), } diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index 09f7b6a29e0b6..033549549a73f 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -24,7 +24,7 @@ use crate::{ use frame_support::{ pallet_prelude::*, traits::{ - fungibles::{Balanced, CreditOf}, + fungibles::{Balanced, Credit}, Currency, OnUnbalanced, }, }; @@ -45,7 +45,7 @@ impl OnUnbalanced for Author { /// Will drop and burn the assets in case the transfer fails. pub struct CreditToBlockAuthor; impl HandleCredit for CreditToBlockAuthor { - fn handle_credit(credit: CreditOf) { + fn handle_credit(credit: Credit) { if let Some(author) = pallet_authorship::Pallet::::author() { // Drop the result which will trigger the `OnDrop` of the imbalance in case of error. let _ = Assets::resolve(&author, credit); diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 9f4ad2ed26474..3f0ea07122884 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -59,6 +59,7 @@ use pallet_nis::WithMaximumOf; use pallet_session::historical as pallet_session_historical; pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; +use scale_info::TypeInfo; use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_grandpa::AuthorityId as GrandpaId; @@ -432,6 +433,15 @@ parameter_types! { pub const MaxReserves: u32 = 50; } +/// A reason for placing a hold on funds. +#[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, Debug, TypeInfo, +)] +pub enum HoldReason { + /// The NIS Pallet has reserved it for a non-fungible receipt. + Nis, +} + impl pallet_balances::Config for Runtime { type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; @@ -442,6 +452,10 @@ impl pallet_balances::Config for Runtime { type ExistentialDeposit = ExistentialDeposit; type AccountStore = frame_system::Pallet; type WeightInfo = pallet_balances::weights::SubstrateWeight; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = HoldReason; + type MaxHolds = ConstU32<1>; } parameter_types! { @@ -1481,7 +1495,6 @@ impl pallet_assets::Config for Runtime { } parameter_types! { - pub IgnoredIssuance: Balance = Treasury::pot(); pub const QueueCount: u32 = 300; pub const MaxQueueLen: u32 = 1000; pub const FifoQueueLen: u32 = 500; @@ -1493,7 +1506,7 @@ parameter_types! { pub const ThawThrottle: (Perquintill, BlockNumber) = (Perquintill::from_percent(25), 5); pub Target: Perquintill = Perquintill::zero(); pub const NisPalletId: PalletId = PalletId(*b"py/nis "); - pub const NisReserveId: [u8; 8] = *b"py/nis "; + pub const NisHoldReason: HoldReason = HoldReason::Nis; } impl pallet_nis::Config for Runtime { @@ -1505,7 +1518,7 @@ impl pallet_nis::Config for Runtime { type Counterpart = ItemOf, AccountId>; type CounterpartAmount = WithMaximumOf>; type Deficit = (); - type IgnoredIssuance = IgnoredIssuance; + type IgnoredIssuance = (); type Target = Target; type PalletId = NisPalletId; type QueueCount = QueueCount; @@ -1517,7 +1530,7 @@ impl pallet_nis::Config for Runtime { type IntakePeriod = IntakePeriod; type MaxIntakeWeight = MaxIntakeWeight; type ThawThrottle = ThawThrottle; - type ReserveId = NisReserveId; + type HoldReason = NisHoldReason; } parameter_types! { diff --git a/bin/node/testing/src/bench.rs b/bin/node/testing/src/bench.rs index 1a9af13028483..d6bcf6e252fe0 100644 --- a/bin/node/testing/src/bench.rs +++ b/bin/node/testing/src/bench.rs @@ -308,7 +308,7 @@ impl<'a> Iterator for BlockContentIterator<'a> { value: kitchensink_runtime::ExistentialDeposit::get() + 1, }), BlockType::RandomTransfersReaping => { - RuntimeCall::Balances(BalancesCall::transfer { + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: sp_runtime::MultiAddress::Id(receiver), // Transfer so that ending balance would be 1 less than existential // deposit so that we kill the sender account. diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index b8fd998eb20a0..848f6b2a00557 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -85,6 +85,10 @@ impl pallet_balances::Config for Test { type MaxLocks = MaxLocks; type MaxReserves = (); type ReserveIdentifier = [u8; 8]; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } const MOTION_DURATION_IN_BLOCKS: BlockNumber = 3; diff --git a/frame/assets/src/benchmarking.rs b/frame/assets/src/benchmarking.rs index 5b4f1489df5db..047ede2ce6964 100644 --- a/frame/assets/src/benchmarking.rs +++ b/frame/assets/src/benchmarking.rs @@ -105,14 +105,18 @@ fn add_sufficients, I: 'static>(minter: T::AccountId, n: u32) { fn add_approvals, I: 'static>(minter: T::AccountId, n: u32) { let asset_id = default_asset_id::(); - T::Currency::deposit_creating(&minter, T::ApprovalDeposit::get() * n.into()); + T::Currency::deposit_creating( + &minter, + T::ApprovalDeposit::get() * n.into() + T::Currency::minimum_balance(), + ); let minter_lookup = T::Lookup::unlookup(minter.clone()); let origin = SystemOrigin::Signed(minter); Assets::::mint(origin.clone().into(), asset_id, minter_lookup, (100 * (n + 1)).into()) .unwrap(); + let enough = T::Currency::minimum_balance(); for i in 0..n { let target = account("approval", i, SEED); - T::Currency::make_free_balance_be(&target, T::Currency::minimum_balance()); + T::Currency::make_free_balance_be(&target, enough); let target_lookup = T::Lookup::unlookup(target); Assets::::approve_transfer( origin.clone().into(), diff --git a/frame/assets/src/functions.rs b/frame/assets/src/functions.rs index 47657ff267494..af9e269acf8bc 100644 --- a/frame/assets/src/functions.rs +++ b/frame/assets/src/functions.rs @@ -76,7 +76,14 @@ impl, I: 'static> Pallet { d.sufficients += 1; ExistenceReason::Sufficient } else { - frame_system::Pallet::::inc_consumers(who).map_err(|_| Error::::NoProvider)?; + frame_system::Pallet::::inc_consumers(who) + .map_err(|_| Error::::UnavailableConsumer)?; + // We ensure that we can still increment consumers once more because we could otherwise + // allow accidental usage of all consumer references which could cause grief. + if !frame_system::Pallet::::can_inc_consumer(who) { + frame_system::Pallet::::dec_consumers(who); + return Err(Error::::UnavailableConsumer.into()) + } ExistenceReason::Consumer }; d.accounts = accounts; @@ -165,7 +172,7 @@ impl, I: 'static> Pallet { } let account = match Account::::get(id, who) { Some(a) => a, - None => return NoFunds, + None => return BalanceLow, }; if account.is_frozen { return Frozen @@ -193,7 +200,7 @@ impl, I: 'static> Pallet { Success } } else { - NoFunds + BalanceLow } } @@ -254,7 +261,7 @@ impl, I: 'static> Pallet { ensure!(f.best_effort || actual >= amount, Error::::BalanceLow); let conseq = Self::can_decrease(id, target, actual, f.keep_alive); - let actual = match conseq.into_result() { + let actual = match conseq.into_result(f.keep_alive) { Ok(dust) => actual.saturating_add(dust), //< guaranteed by reducible_balance Err(e) => { debug_assert!(false, "passed from reducible_balance; qed"); diff --git a/frame/assets/src/impl_fungibles.rs b/frame/assets/src/impl_fungibles.rs index f420ea02c31e9..7bec884f4c56b 100644 --- a/frame/assets/src/impl_fungibles.rs +++ b/frame/assets/src/impl_fungibles.rs @@ -17,6 +17,16 @@ //! Implementations for fungibles trait. +use frame_support::{ + defensive, + traits::tokens::{ + Fortitude, + Precision::{self, BestEffort}, + Preservation::{self, Expendable}, + Provenance::{self, Minted}, + }, +}; + use super::*; impl, I: 'static> fungibles::Inspect<::AccountId> for Pallet { @@ -35,21 +45,27 @@ impl, I: 'static> fungibles::Inspect<::AccountId Pallet::::balance(asset, who) } + fn total_balance(asset: Self::AssetId, who: &::AccountId) -> Self::Balance { + Pallet::::balance(asset, who) + } + fn reducible_balance( asset: Self::AssetId, who: &::AccountId, - keep_alive: bool, + preservation: Preservation, + _: Fortitude, ) -> Self::Balance { - Pallet::::reducible_balance(asset, who, keep_alive).unwrap_or(Zero::zero()) + Pallet::::reducible_balance(asset, who, !matches!(preservation, Expendable)) + .unwrap_or(Zero::zero()) } fn can_deposit( asset: Self::AssetId, who: &::AccountId, amount: Self::Balance, - mint: bool, + provenance: Provenance, ) -> DepositConsequence { - Pallet::::can_increase(asset, who, amount, mint) + Pallet::::can_increase(asset, who, amount, provenance == Minted) } fn can_withdraw( @@ -65,69 +81,26 @@ impl, I: 'static> fungibles::Inspect<::AccountId } } -impl, I: 'static> fungibles::InspectMetadata<::AccountId> +impl, I: 'static> fungibles::Mutate<::AccountId> for Pallet {} +impl, I: 'static> fungibles::Balanced<::AccountId> for Pallet { - /// Return the name of an asset. - fn name(asset: &Self::AssetId) -> Vec { - Metadata::::get(asset).name.to_vec() - } - - /// Return the symbol of an asset. - fn symbol(asset: &Self::AssetId) -> Vec { - Metadata::::get(asset).symbol.to_vec() - } - - /// Return the decimals of an asset. - fn decimals(asset: &Self::AssetId) -> u8 { - Metadata::::get(asset).decimals - } -} - -impl, I: 'static> fungibles::Mutate<::AccountId> for Pallet { - fn mint_into( - asset: Self::AssetId, - who: &::AccountId, - amount: Self::Balance, - ) -> DispatchResult { - Self::do_mint(asset, who, amount, None) - } - - fn burn_from( - asset: Self::AssetId, - who: &::AccountId, - amount: Self::Balance, - ) -> Result { - let f = DebitFlags { keep_alive: false, best_effort: false }; - Self::do_burn(asset, who, amount, None, f) - } - - fn slash( - asset: Self::AssetId, - who: &::AccountId, - amount: Self::Balance, - ) -> Result { - let f = DebitFlags { keep_alive: false, best_effort: true }; - Self::do_burn(asset, who, amount, None, f) - } -} - -impl, I: 'static> fungibles::Transfer for Pallet { - fn transfer( - asset: Self::AssetId, - source: &T::AccountId, - dest: &T::AccountId, - amount: T::Balance, - keep_alive: bool, - ) -> Result { - let f = TransferFlags { keep_alive, best_effort: false, burn_dust: false }; - Self::do_transfer(asset, source, dest, amount, None, f) - } + type OnDropCredit = fungibles::DecreaseIssuance; + type OnDropDebt = fungibles::IncreaseIssuance; } impl, I: 'static> fungibles::Unbalanced for Pallet { - fn set_balance(_: Self::AssetId, _: &T::AccountId, _: Self::Balance) -> DispatchResult { - unreachable!("set_balance is not used if other functions are impl'd"); + fn handle_raw_dust(_: Self::AssetId, _: Self::Balance) {} + fn handle_dust(_: fungibles::Dust) { + defensive!("`decrease_balance` and `increase_balance` have non-default impls; nothing else calls this; qed"); + } + fn write_balance( + _: Self::AssetId, + _: &T::AccountId, + _: Self::Balance, + ) -> Result, DispatchError> { + defensive!("write_balance is not used if other functions are impl'd"); + Err(DispatchError::Unavailable) } fn set_total_issuance(id: T::AssetId, amount: Self::Balance) { Asset::::mutate_exists(id, |maybe_asset| { @@ -140,36 +113,27 @@ impl, I: 'static> fungibles::Unbalanced for Pallet Result { - let f = DebitFlags { keep_alive: false, best_effort: false }; + let f = DebitFlags { + keep_alive: preservation != Expendable, + best_effort: precision == BestEffort, + }; Self::decrease_balance(asset, who, amount, f, |_, _| Ok(())) } - fn decrease_balance_at_most( - asset: T::AssetId, - who: &T::AccountId, - amount: Self::Balance, - ) -> Self::Balance { - let f = DebitFlags { keep_alive: false, best_effort: true }; - Self::decrease_balance(asset, who, amount, f, |_, _| Ok(())).unwrap_or(Zero::zero()) - } fn increase_balance( asset: T::AssetId, who: &T::AccountId, amount: Self::Balance, + _: Precision, ) -> Result { Self::increase_balance(asset, who, amount, |_| Ok(()))?; Ok(amount) } - fn increase_balance_at_most( - asset: T::AssetId, - who: &T::AccountId, - amount: Self::Balance, - ) -> Self::Balance { - match Self::increase_balance(asset, who, amount, |_| Ok(())) { - Ok(()) => amount, - Err(_) => Zero::zero(), - } - } + + // TODO: #13196 implement deactivate/reactivate once we have inactive balance tracking. } impl, I: 'static> fungibles::Create for Pallet { diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index b36a5cabd377a..859a13243d509 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -540,9 +540,9 @@ pub mod pallet { /// Minimum balance should be non-zero. MinBalanceZero, /// Unable to increment the consumer reference counters on the account. Either no provider - /// reference exists to allow a non-zero balance of a non-self-sufficient asset, or the - /// maximum number of consumers has been reached. - NoProvider, + /// reference exists to allow a non-zero balance of a non-self-sufficient asset, or one + /// fewer then the maximum number of consumers has been reached. + UnavailableConsumer, /// Invalid metadata given. BadMetadata, /// No approval exists that would allow the transfer. diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 3f456a7de3eda..3926d2fa8b010 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -74,7 +74,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = ConstU32<2>; + type MaxConsumers = ConstU32<3>; } impl pallet_balances::Config for Test { @@ -87,6 +87,10 @@ impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); type ReserveIdentifier = [u8; 8]; + type HoldIdentifier = (); + type FreezeIdentifier = (); + type MaxHolds = (); + type MaxFreezes = (); } pub struct AssetsCallbackHandle; diff --git a/frame/assets/src/tests.rs b/frame/assets/src/tests.rs index bc61810a76ac4..d4a49ac5a4651 100644 --- a/frame/assets/src/tests.rs +++ b/frame/assets/src/tests.rs @@ -57,7 +57,10 @@ fn minting_too_many_insufficient_assets_fails() { Balances::make_free_balance_be(&1, 100); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 1, 1, 100)); - assert_noop!(Assets::mint(RuntimeOrigin::signed(1), 2, 1, 100), TokenError::CannotCreate); + assert_noop!( + Assets::mint(RuntimeOrigin::signed(1), 2, 1, 100), + Error::::UnavailableConsumer + ); Balances::make_free_balance_be(&2, 1); assert_ok!(Assets::transfer(RuntimeOrigin::signed(1), 0, 2, 100)); @@ -75,7 +78,10 @@ fn minting_insufficient_asset_with_deposit_should_work_when_consumers_exhausted( Balances::make_free_balance_be(&1, 100); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 1, 1, 100)); - assert_noop!(Assets::mint(RuntimeOrigin::signed(1), 2, 1, 100), TokenError::CannotCreate); + assert_noop!( + Assets::mint(RuntimeOrigin::signed(1), 2, 1, 100), + Error::::UnavailableConsumer + ); assert_ok!(Assets::touch(RuntimeOrigin::signed(1), 2)); assert_eq!(Balances::reserved_balance(&1), 10); @@ -93,7 +99,7 @@ fn minting_insufficient_assets_with_deposit_without_consumer_should_work() { assert_ok!(Assets::touch(RuntimeOrigin::signed(1), 0)); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); assert_eq!(Balances::reserved_balance(&1), 10); - assert_eq!(System::consumers(&1), 0); + assert_eq!(System::consumers(&1), 1); }); } @@ -167,7 +173,7 @@ fn approval_lifecycle_works() { // so we create it :) assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, 1, true, 1)); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); - Balances::make_free_balance_be(&1, 1); + Balances::make_free_balance_be(&1, 2); assert_ok!(Assets::approve_transfer(RuntimeOrigin::signed(1), 0, 2, 50)); assert_eq!(Asset::::get(0).unwrap().approvals, 1); assert_eq!(Balances::reserved_balance(&1), 1); @@ -193,7 +199,7 @@ fn transfer_approved_all_funds() { // so we create it :) assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, 1, true, 1)); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); - Balances::make_free_balance_be(&1, 1); + Balances::make_free_balance_be(&1, 2); assert_ok!(Assets::approve_transfer(RuntimeOrigin::signed(1), 0, 2, 50)); assert_eq!(Asset::::get(0).unwrap().approvals, 1); assert_eq!(Balances::reserved_balance(&1), 1); @@ -215,7 +221,7 @@ fn approval_deposits_work() { let e = BalancesError::::InsufficientBalance; assert_noop!(Assets::approve_transfer(RuntimeOrigin::signed(1), 0, 2, 50), e); - Balances::make_free_balance_be(&1, 1); + Balances::make_free_balance_be(&1, 2); assert_ok!(Assets::approve_transfer(RuntimeOrigin::signed(1), 0, 2, 50)); assert_eq!(Balances::reserved_balance(&1), 1); @@ -233,7 +239,7 @@ fn cannot_transfer_more_than_approved() { new_test_ext().execute_with(|| { assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, 1, true, 1)); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); - Balances::make_free_balance_be(&1, 1); + Balances::make_free_balance_be(&1, 2); assert_ok!(Assets::approve_transfer(RuntimeOrigin::signed(1), 0, 2, 50)); let e = Error::::Unapproved; assert_noop!(Assets::transfer_approved(RuntimeOrigin::signed(2), 0, 1, 3, 51), e); @@ -245,7 +251,7 @@ fn cannot_transfer_more_than_exists() { new_test_ext().execute_with(|| { assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, 1, true, 1)); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); - Balances::make_free_balance_be(&1, 1); + Balances::make_free_balance_be(&1, 2); assert_ok!(Assets::approve_transfer(RuntimeOrigin::signed(1), 0, 2, 101)); let e = Error::::BalanceLow; assert_noop!(Assets::transfer_approved(RuntimeOrigin::signed(2), 0, 1, 3, 101), e); @@ -257,7 +263,7 @@ fn cancel_approval_works() { new_test_ext().execute_with(|| { assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, 1, true, 1)); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); - Balances::make_free_balance_be(&1, 1); + Balances::make_free_balance_be(&1, 2); assert_ok!(Assets::approve_transfer(RuntimeOrigin::signed(1), 0, 2, 50)); assert_eq!(Asset::::get(0).unwrap().approvals, 1); assert_noop!( @@ -287,7 +293,7 @@ fn force_cancel_approval_works() { new_test_ext().execute_with(|| { assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, 1, true, 1)); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); - Balances::make_free_balance_be(&1, 1); + Balances::make_free_balance_be(&1, 2); assert_ok!(Assets::approve_transfer(RuntimeOrigin::signed(1), 0, 2, 50)); assert_eq!(Asset::::get(0).unwrap().approvals, 1); let e = Error::::NoPermission; @@ -516,7 +522,7 @@ fn min_balance_should_work() { // Death by `transfer_approved`. assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); - Balances::make_free_balance_be(&1, 1); + Balances::make_free_balance_be(&1, 2); assert_ok!(Assets::approve_transfer(RuntimeOrigin::signed(1), 0, 2, 100)); assert_ok!(Assets::transfer_approved(RuntimeOrigin::signed(2), 0, 1, 3, 91)); assert_eq!(take_hooks(), vec![Hook::Died(0, 1)]); @@ -1217,7 +1223,7 @@ fn querying_allowance_should_work() { use frame_support::traits::tokens::fungibles::approvals::{Inspect, Mutate}; assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, 1, true, 1)); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); - Balances::make_free_balance_be(&1, 1); + Balances::make_free_balance_be(&1, 2); assert_ok!(Assets::approve(0, &1, &2, 50)); assert_eq!(Assets::allowance(0, &1, &2), 50); // Transfer asset 0, from owner 1 and delegate 2 to destination 3 diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 081a449ec9a2e..7437d62a99c95 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -62,6 +62,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl Config for Test { diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 9b832bfffdb69..94e748d0bca52 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -144,6 +144,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU128<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } pallet_staking_reward_curve::build! { diff --git a/frame/balances/README.md b/frame/balances/README.md index 93e424a89c721..dd56ab3fadfb5 100644 --- a/frame/balances/README.md +++ b/frame/balances/README.md @@ -70,7 +70,7 @@ given account is unused. ### Dispatchable Functions - `transfer` - Transfer some liquid free balance to another account. -- `set_balance` - Set the balances of a given account. The origin of this call must be root. +- `force_set_balance` - Set the balances of a given account. The origin of this call must be root. ## Usage diff --git a/frame/balances/src/benchmarking.rs b/frame/balances/src/benchmarking.rs index b36fe1e341de3..5641c68516c28 100644 --- a/frame/balances/src/benchmarking.rs +++ b/frame/balances/src/benchmarking.rs @@ -24,6 +24,8 @@ use crate::Pallet as Balances; use frame_benchmarking::v2::*; use frame_system::RawOrigin; +use sp_runtime::traits::Bounded; +use types::ExtraFlags; const SEED: u32 = 0; // existential deposit multiplier @@ -37,7 +39,7 @@ mod benchmarks { // * Transfer will kill the sender account. // * Transfer will create the recipient account. #[benchmark] - fn transfer() { + fn transfer_allow_death() { let existential_deposit = T::ExistentialDeposit::get(); let caller = whitelisted_caller(); @@ -79,7 +81,7 @@ mod benchmarks { let transfer_amount = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); #[extrinsic_call] - transfer(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount); + transfer_allow_death(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount); assert!(!Balances::::free_balance(&caller).is_zero()); assert!(!Balances::::free_balance(&recipient).is_zero()); @@ -106,9 +108,9 @@ mod benchmarks { assert_eq!(Balances::::free_balance(&recipient), transfer_amount); } - // Benchmark `set_balance` coming from ROOT account. This always creates an account. + // Benchmark `force_set_balance` coming from ROOT account. This always creates an account. #[benchmark] - fn set_balance_creating() { + fn force_set_balance_creating() { let user: T::AccountId = account("user", 0, SEED); let user_lookup = T::Lookup::unlookup(user.clone()); @@ -118,15 +120,14 @@ mod benchmarks { let _ = as Currency<_>>::make_free_balance_be(&user, balance_amount); #[extrinsic_call] - set_balance(RawOrigin::Root, user_lookup, balance_amount, balance_amount); + force_set_balance(RawOrigin::Root, user_lookup, balance_amount); assert_eq!(Balances::::free_balance(&user), balance_amount); - assert_eq!(Balances::::reserved_balance(&user), balance_amount); } - // Benchmark `set_balance` coming from ROOT account. This always kills an account. + // Benchmark `force_set_balance` coming from ROOT account. This always kills an account. #[benchmark] - fn set_balance_killing() { + fn force_set_balance_killing() { let user: T::AccountId = account("user", 0, SEED); let user_lookup = T::Lookup::unlookup(user.clone()); @@ -136,7 +137,7 @@ mod benchmarks { let _ = as Currency<_>>::make_free_balance_be(&user, balance_amount); #[extrinsic_call] - set_balance(RawOrigin::Root, user_lookup, Zero::zero(), Zero::zero()); + force_set_balance(RawOrigin::Root, user_lookup, Zero::zero()); assert!(Balances::::free_balance(&user).is_zero()); } @@ -197,7 +198,7 @@ mod benchmarks { } #[extrinsic_call] - transfer(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount); + transfer_allow_death(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount); assert_eq!(Balances::::free_balance(&caller), Zero::zero()); assert_eq!(Balances::::free_balance(&recipient), transfer_amount); @@ -230,27 +231,64 @@ mod benchmarks { let user_lookup = T::Lookup::unlookup(user.clone()); // Give some multiple of the existential deposit - let existential_deposit = T::ExistentialDeposit::get(); - let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); + let ed = T::ExistentialDeposit::get(); + let balance = ed + ed; let _ = as Currency<_>>::make_free_balance_be(&user, balance); // Reserve the balance - as ReservableCurrency<_>>::reserve(&user, balance)?; - assert_eq!(Balances::::reserved_balance(&user), balance); - assert!(Balances::::free_balance(&user).is_zero()); + as ReservableCurrency<_>>::reserve(&user, ed)?; + assert_eq!(Balances::::reserved_balance(&user), ed); + assert_eq!(Balances::::free_balance(&user), ed); #[extrinsic_call] _(RawOrigin::Root, user_lookup, balance); assert!(Balances::::reserved_balance(&user).is_zero()); - assert_eq!(Balances::::free_balance(&user), balance); + assert_eq!(Balances::::free_balance(&user), ed + ed); Ok(()) } + #[benchmark] + fn upgrade_accounts(u: Linear<1, 1_000>) { + let caller: T::AccountId = whitelisted_caller(); + let who = (0..u) + .into_iter() + .map(|i| -> T::AccountId { + let user = account("old_user", i, SEED); + let account = AccountData { + free: T::ExistentialDeposit::get(), + reserved: T::ExistentialDeposit::get(), + frozen: Zero::zero(), + flags: ExtraFlags::old_logic(), + }; + frame_system::Pallet::::inc_providers(&user); + assert!(T::AccountStore::try_mutate_exists(&user, |a| -> DispatchResult { + *a = Some(account); + Ok(()) + }) + .is_ok()); + assert!(!Balances::::account(&user).flags.is_new_logic()); + assert_eq!(frame_system::Pallet::::providers(&user), 1); + assert_eq!(frame_system::Pallet::::consumers(&user), 0); + user + }) + .collect(); + + #[extrinsic_call] + _(RawOrigin::Signed(caller.clone()), who); + + for i in 0..u { + let user: T::AccountId = account("old_user", i, SEED); + assert!(Balances::::account(&user).flags.is_new_logic()); + assert_eq!(frame_system::Pallet::::providers(&user), 1); + assert_eq!(frame_system::Pallet::::consumers(&user), 1); + } + } + impl_benchmark_test_suite! { Balances, - crate::tests_composite::ExtBuilder::default().build(), - crate::tests_composite::Test, + crate::tests::ExtBuilder::default().build(), + crate::tests::Test, } } diff --git a/frame/balances/src/impl_currency.rs b/frame/balances/src/impl_currency.rs new file mode 100644 index 0000000000000..790a29f004764 --- /dev/null +++ b/frame/balances/src/impl_currency.rs @@ -0,0 +1,898 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2022 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. + +//! Implementations for the `Currency` family of traits. + +use super::*; +use frame_support::{ + ensure, + pallet_prelude::DispatchResult, + traits::{ + tokens::{fungible, BalanceStatus as Status}, + Currency, DefensiveSaturating, ExistenceRequirement, + ExistenceRequirement::AllowDeath, + Get, Imbalance, LockIdentifier, LockableCurrency, NamedReservableCurrency, + ReservableCurrency, SignedImbalance, TryDrop, WithdrawReasons, + }, +}; +pub use imbalances::{NegativeImbalance, PositiveImbalance}; + +// wrapping these imbalances in a private module is necessary to ensure absolute privacy +// of the inner member. +mod imbalances { + use super::{result, Config, Imbalance, RuntimeDebug, Saturating, TryDrop, Zero}; + use frame_support::traits::SameOrOther; + use sp_std::mem; + + /// Opaque, move-only struct with private fields that serves as a token denoting that + /// funds have been created without any equal and opposite accounting. + #[must_use] + #[derive(RuntimeDebug, PartialEq, Eq)] + pub struct PositiveImbalance, I: 'static = ()>(T::Balance); + + impl, I: 'static> PositiveImbalance { + /// Create a new positive imbalance from a balance. + pub fn new(amount: T::Balance) -> Self { + PositiveImbalance(amount) + } + } + + /// Opaque, move-only struct with private fields that serves as a token denoting that + /// funds have been destroyed without any equal and opposite accounting. + #[must_use] + #[derive(RuntimeDebug, PartialEq, Eq)] + pub struct NegativeImbalance, I: 'static = ()>(T::Balance); + + impl, I: 'static> NegativeImbalance { + /// Create a new negative imbalance from a balance. + pub fn new(amount: T::Balance) -> Self { + NegativeImbalance(amount) + } + } + + impl, I: 'static> TryDrop for PositiveImbalance { + fn try_drop(self) -> result::Result<(), Self> { + self.drop_zero() + } + } + + impl, I: 'static> Default for PositiveImbalance { + fn default() -> Self { + Self::zero() + } + } + + impl, I: 'static> Imbalance for PositiveImbalance { + type Opposite = NegativeImbalance; + + fn zero() -> Self { + Self(Zero::zero()) + } + fn drop_zero(self) -> result::Result<(), Self> { + if self.0.is_zero() { + Ok(()) + } else { + Err(self) + } + } + fn split(self, amount: T::Balance) -> (Self, Self) { + let first = self.0.min(amount); + let second = self.0 - first; + + mem::forget(self); + (Self(first), Self(second)) + } + fn merge(mut self, other: Self) -> Self { + self.0 = self.0.saturating_add(other.0); + mem::forget(other); + + self + } + fn subsume(&mut self, other: Self) { + self.0 = self.0.saturating_add(other.0); + mem::forget(other); + } + fn offset(self, other: Self::Opposite) -> SameOrOther { + let (a, b) = (self.0, other.0); + mem::forget((self, other)); + + if a > b { + SameOrOther::Same(Self(a - b)) + } else if b > a { + SameOrOther::Other(NegativeImbalance::new(b - a)) + } else { + SameOrOther::None + } + } + fn peek(&self) -> T::Balance { + self.0 + } + } + + impl, I: 'static> TryDrop for NegativeImbalance { + fn try_drop(self) -> result::Result<(), Self> { + self.drop_zero() + } + } + + impl, I: 'static> Default for NegativeImbalance { + fn default() -> Self { + Self::zero() + } + } + + impl, I: 'static> Imbalance for NegativeImbalance { + type Opposite = PositiveImbalance; + + fn zero() -> Self { + Self(Zero::zero()) + } + fn drop_zero(self) -> result::Result<(), Self> { + if self.0.is_zero() { + Ok(()) + } else { + Err(self) + } + } + fn split(self, amount: T::Balance) -> (Self, Self) { + let first = self.0.min(amount); + let second = self.0 - first; + + mem::forget(self); + (Self(first), Self(second)) + } + fn merge(mut self, other: Self) -> Self { + self.0 = self.0.saturating_add(other.0); + mem::forget(other); + + self + } + fn subsume(&mut self, other: Self) { + self.0 = self.0.saturating_add(other.0); + mem::forget(other); + } + fn offset(self, other: Self::Opposite) -> SameOrOther { + let (a, b) = (self.0, other.0); + mem::forget((self, other)); + + if a > b { + SameOrOther::Same(Self(a - b)) + } else if b > a { + SameOrOther::Other(PositiveImbalance::new(b - a)) + } else { + SameOrOther::None + } + } + fn peek(&self) -> T::Balance { + self.0 + } + } + + impl, I: 'static> Drop for PositiveImbalance { + /// Basic drop handler will just square up the total issuance. + fn drop(&mut self) { + >::mutate(|v| *v = v.saturating_add(self.0)); + } + } + + impl, I: 'static> Drop for NegativeImbalance { + /// Basic drop handler will just square up the total issuance. + fn drop(&mut self) { + >::mutate(|v| *v = v.saturating_sub(self.0)); + } + } +} + +impl, I: 'static> Currency for Pallet +where + T::Balance: MaybeSerializeDeserialize + Debug, +{ + type Balance = T::Balance; + type PositiveImbalance = PositiveImbalance; + type NegativeImbalance = NegativeImbalance; + + fn total_balance(who: &T::AccountId) -> Self::Balance { + Self::account(who).total() + } + + // Check if `value` amount of free balance can be slashed from `who`. + fn can_slash(who: &T::AccountId, value: Self::Balance) -> bool { + if value.is_zero() { + return true + } + Self::free_balance(who) >= value + } + + fn total_issuance() -> Self::Balance { + TotalIssuance::::get() + } + + fn active_issuance() -> Self::Balance { + >::active_issuance() + } + + fn deactivate(amount: Self::Balance) { + >::deactivate(amount); + } + + fn reactivate(amount: Self::Balance) { + >::reactivate(amount); + } + + fn minimum_balance() -> Self::Balance { + T::ExistentialDeposit::get() + } + + // Burn funds from the total issuance, returning a positive imbalance for the amount burned. + // Is a no-op if amount to be burned is zero. + fn burn(mut amount: Self::Balance) -> Self::PositiveImbalance { + if amount.is_zero() { + return PositiveImbalance::zero() + } + >::mutate(|issued| { + *issued = issued.checked_sub(&amount).unwrap_or_else(|| { + amount = *issued; + Zero::zero() + }); + }); + PositiveImbalance::new(amount) + } + + // Create new funds into the total issuance, returning a negative imbalance + // for the amount issued. + // Is a no-op if amount to be issued it zero. + fn issue(mut amount: Self::Balance) -> Self::NegativeImbalance { + if amount.is_zero() { + return NegativeImbalance::zero() + } + >::mutate(|issued| { + *issued = issued.checked_add(&amount).unwrap_or_else(|| { + amount = Self::Balance::max_value() - *issued; + Self::Balance::max_value() + }) + }); + NegativeImbalance::new(amount) + } + + fn free_balance(who: &T::AccountId) -> Self::Balance { + Self::account(who).free + } + + // Ensure that an account can withdraw from their free balance given any existing withdrawal + // restrictions like locks and vesting balance. + // Is a no-op if amount to be withdrawn is zero. + fn ensure_can_withdraw( + who: &T::AccountId, + amount: T::Balance, + _reasons: WithdrawReasons, + new_balance: T::Balance, + ) -> DispatchResult { + if amount.is_zero() { + return Ok(()) + } + ensure!(new_balance >= Self::account(who).frozen, Error::::LiquidityRestrictions); + Ok(()) + } + + // Transfer some free balance from `transactor` to `dest`, respecting existence requirements. + // Is a no-op if value to be transferred is zero or the `transactor` is the same as `dest`. + fn transfer( + transactor: &T::AccountId, + dest: &T::AccountId, + value: Self::Balance, + existence_requirement: ExistenceRequirement, + ) -> DispatchResult { + if value.is_zero() || transactor == dest { + return Ok(()) + } + let keep_alive = match existence_requirement { + ExistenceRequirement::KeepAlive => Preserve, + ExistenceRequirement::AllowDeath => Expendable, + }; + >::transfer(transactor, dest, value, keep_alive)?; + Ok(()) + } + + /// Slash a target account `who`, returning the negative imbalance created and any left over + /// amount that could not be slashed. + /// + /// Is a no-op if `value` to be slashed is zero or the account does not exist. + /// + /// NOTE: `slash()` prefers free balance, but assumes that reserve balance can be drawn + /// from in extreme circumstances. `can_slash()` should be used prior to `slash()` to avoid + /// having to draw from reserved funds, however we err on the side of punishment if things are + /// inconsistent or `can_slash` wasn't used appropriately. + fn slash(who: &T::AccountId, value: Self::Balance) -> (Self::NegativeImbalance, Self::Balance) { + if value.is_zero() { + return (NegativeImbalance::zero(), Zero::zero()) + } + if Self::total_balance(who).is_zero() { + return (NegativeImbalance::zero(), value) + } + + let result = match Self::try_mutate_account_handling_dust( + who, + |account, _is_new| -> Result<(Self::NegativeImbalance, Self::Balance), DispatchError> { + // Best value is the most amount we can slash following liveness rules. + let ed = T::ExistentialDeposit::get(); + let actual = match system::Pallet::::can_dec_provider(who) { + true => value.min(account.free), + false => value.min(account.free.saturating_sub(ed)), + }; + account.free.saturating_reduce(actual); + let remaining = value.saturating_sub(actual); + Ok((NegativeImbalance::new(actual), remaining)) + }, + ) { + Ok((imbalance, remaining)) => { + Self::deposit_event(Event::Slashed { + who: who.clone(), + amount: value.saturating_sub(remaining), + }); + (imbalance, remaining) + }, + Err(_) => (Self::NegativeImbalance::zero(), value), + }; + result + } + + /// Deposit some `value` into the free balance of an existing target account `who`. + /// + /// Is a no-op if the `value` to be deposited is zero. + fn deposit_into_existing( + who: &T::AccountId, + value: Self::Balance, + ) -> Result { + if value.is_zero() { + return Ok(PositiveImbalance::zero()) + } + + Self::try_mutate_account_handling_dust( + who, + |account, is_new| -> Result { + ensure!(!is_new, Error::::DeadAccount); + account.free = account.free.checked_add(&value).ok_or(ArithmeticError::Overflow)?; + Self::deposit_event(Event::Deposit { who: who.clone(), amount: value }); + Ok(PositiveImbalance::new(value)) + }, + ) + } + + /// Deposit some `value` into the free balance of `who`, possibly creating a new account. + /// + /// This function is a no-op if: + /// - the `value` to be deposited is zero; or + /// - the `value` to be deposited is less than the required ED and the account does not yet + /// exist; or + /// - the deposit would necessitate the account to exist and there are no provider references; + /// or + /// - `value` is so large it would cause the balance of `who` to overflow. + fn deposit_creating(who: &T::AccountId, value: Self::Balance) -> Self::PositiveImbalance { + if value.is_zero() { + return Self::PositiveImbalance::zero() + } + + Self::try_mutate_account_handling_dust( + who, + |account, is_new| -> Result { + let ed = T::ExistentialDeposit::get(); + ensure!(value >= ed || !is_new, Error::::ExistentialDeposit); + + // defensive only: overflow should never happen, however in case it does, then this + // operation is a no-op. + account.free = match account.free.checked_add(&value) { + Some(x) => x, + None => return Ok(Self::PositiveImbalance::zero()), + }; + + Self::deposit_event(Event::Deposit { who: who.clone(), amount: value }); + Ok(PositiveImbalance::new(value)) + }, + ) + .unwrap_or_else(|_| Self::PositiveImbalance::zero()) + } + + /// Withdraw some free balance from an account, respecting existence requirements. + /// + /// Is a no-op if value to be withdrawn is zero. + fn withdraw( + who: &T::AccountId, + value: Self::Balance, + reasons: WithdrawReasons, + liveness: ExistenceRequirement, + ) -> result::Result { + if value.is_zero() { + return Ok(NegativeImbalance::zero()) + } + + Self::try_mutate_account_handling_dust( + who, + |account, _| -> Result { + let new_free_account = + account.free.checked_sub(&value).ok_or(Error::::InsufficientBalance)?; + + // bail if we need to keep the account alive and this would kill it. + let ed = T::ExistentialDeposit::get(); + let would_be_dead = new_free_account < ed; + let would_kill = would_be_dead && account.free >= ed; + ensure!(liveness == AllowDeath || !would_kill, Error::::Expendability); + + Self::ensure_can_withdraw(who, value, reasons, new_free_account)?; + + account.free = new_free_account; + + Self::deposit_event(Event::Withdraw { who: who.clone(), amount: value }); + Ok(NegativeImbalance::new(value)) + }, + ) + } + + /// Force the new free balance of a target account `who` to some new value `balance`. + fn make_free_balance_be( + who: &T::AccountId, + value: Self::Balance, + ) -> SignedImbalance { + Self::try_mutate_account_handling_dust( + who, + |account, + is_new| + -> Result, DispatchError> { + let ed = T::ExistentialDeposit::get(); + // If we're attempting to set an existing account to less than ED, then + // bypass the entire operation. It's a no-op if you follow it through, but + // since this is an instance where we might account for a negative imbalance + // (in the dust cleaner of set_account) before we account for its actual + // equal and opposite cause (returned as an Imbalance), then in the + // instance that there's no other accounts on the system at all, we might + // underflow the issuance and our arithmetic will be off. + ensure!(value >= ed || !is_new, Error::::ExistentialDeposit); + + let imbalance = if account.free <= value { + SignedImbalance::Positive(PositiveImbalance::new(value - account.free)) + } else { + SignedImbalance::Negative(NegativeImbalance::new(account.free - value)) + }; + account.free = value; + Self::deposit_event(Event::BalanceSet { who: who.clone(), free: account.free }); + Ok(imbalance) + }, + ) + .unwrap_or_else(|_| SignedImbalance::Positive(Self::PositiveImbalance::zero())) + } +} + +impl, I: 'static> ReservableCurrency for Pallet +where + T::Balance: MaybeSerializeDeserialize + Debug, +{ + /// Check if `who` can reserve `value` from their free balance. + /// + /// Always `true` if value to be reserved is zero. + fn can_reserve(who: &T::AccountId, value: Self::Balance) -> bool { + if value.is_zero() { + return true + } + Self::account(who).free.checked_sub(&value).map_or(false, |new_balance| { + Self::ensure_can_withdraw(who, value, WithdrawReasons::RESERVE, new_balance).is_ok() + }) + } + + fn reserved_balance(who: &T::AccountId) -> Self::Balance { + Self::account(who).reserved + } + + /// Move `value` from the free balance from `who` to their reserved balance. + /// + /// Is a no-op if value to be reserved is zero. + fn reserve(who: &T::AccountId, value: Self::Balance) -> DispatchResult { + if value.is_zero() { + return Ok(()) + } + + Self::try_mutate_account_handling_dust(who, |account, _| -> DispatchResult { + account.free = + account.free.checked_sub(&value).ok_or(Error::::InsufficientBalance)?; + account.reserved = + account.reserved.checked_add(&value).ok_or(ArithmeticError::Overflow)?; + Self::ensure_can_withdraw(&who, value, WithdrawReasons::RESERVE, account.free) + })?; + + Self::deposit_event(Event::Reserved { who: who.clone(), amount: value }); + Ok(()) + } + + /// Unreserve some funds, returning any amount that was unable to be unreserved. + /// + /// Is a no-op if the value to be unreserved is zero or the account does not exist. + /// + /// NOTE: returns amount value which wasn't successfully unreserved. + fn unreserve(who: &T::AccountId, value: Self::Balance) -> Self::Balance { + if value.is_zero() { + return Zero::zero() + } + if Self::total_balance(who).is_zero() { + return value + } + + let actual = match Self::mutate_account_handling_dust(who, |account| { + let actual = cmp::min(account.reserved, value); + account.reserved -= actual; + // defensive only: this can never fail since total issuance which is at least + // free+reserved fits into the same data type. + account.free = account.free.defensive_saturating_add(actual); + actual + }) { + Ok(x) => x, + Err(_) => { + // This should never happen since we don't alter the total amount in the account. + // If it ever does, then we should fail gracefully though, indicating that nothing + // could be done. + return value + }, + }; + + Self::deposit_event(Event::Unreserved { who: who.clone(), amount: actual }); + value - actual + } + + /// Slash from reserved balance, returning the negative imbalance created, + /// and any amount that was unable to be slashed. + /// + /// Is a no-op if the value to be slashed is zero or the account does not exist. + fn slash_reserved( + who: &T::AccountId, + value: Self::Balance, + ) -> (Self::NegativeImbalance, Self::Balance) { + if value.is_zero() { + return (NegativeImbalance::zero(), Zero::zero()) + } + if Self::total_balance(who).is_zero() { + return (NegativeImbalance::zero(), value) + } + + // NOTE: `mutate_account` may fail if it attempts to reduce the balance to the point that an + // account is attempted to be illegally destroyed. + + match Self::mutate_account_handling_dust(who, |account| { + let actual = value.min(account.reserved); + account.reserved.saturating_reduce(actual); + + // underflow should never happen, but it if does, there's nothing to be done here. + (NegativeImbalance::new(actual), value.saturating_sub(actual)) + }) { + Ok((imbalance, not_slashed)) => { + Self::deposit_event(Event::Slashed { + who: who.clone(), + amount: value.saturating_sub(not_slashed), + }); + (imbalance, not_slashed) + }, + Err(_) => (Self::NegativeImbalance::zero(), value), + } + } + + /// Move the reserved balance of one account into the balance of another, according to `status`. + /// + /// Is a no-op if: + /// - the value to be moved is zero; or + /// - the `slashed` id equal to `beneficiary` and the `status` is `Reserved`. + fn repatriate_reserved( + slashed: &T::AccountId, + beneficiary: &T::AccountId, + value: Self::Balance, + status: Status, + ) -> Result { + let actual = Self::do_transfer_reserved(slashed, beneficiary, value, true, status)?; + Ok(value.saturating_sub(actual)) + } +} + +impl, I: 'static> NamedReservableCurrency for Pallet +where + T::Balance: MaybeSerializeDeserialize + Debug, +{ + type ReserveIdentifier = T::ReserveIdentifier; + + fn reserved_balance_named(id: &Self::ReserveIdentifier, who: &T::AccountId) -> Self::Balance { + let reserves = Self::reserves(who); + reserves + .binary_search_by_key(id, |data| data.id) + .map(|index| reserves[index].amount) + .unwrap_or_default() + } + + /// Move `value` from the free balance from `who` to a named reserve balance. + /// + /// Is a no-op if value to be reserved is zero. + fn reserve_named( + id: &Self::ReserveIdentifier, + who: &T::AccountId, + value: Self::Balance, + ) -> DispatchResult { + if value.is_zero() { + return Ok(()) + } + + Reserves::::try_mutate(who, |reserves| -> DispatchResult { + match reserves.binary_search_by_key(id, |data| data.id) { + Ok(index) => { + // this add can't overflow but just to be defensive. + reserves[index].amount = reserves[index].amount.defensive_saturating_add(value); + }, + Err(index) => { + reserves + .try_insert(index, ReserveData { id: *id, amount: value }) + .map_err(|_| Error::::TooManyReserves)?; + }, + }; + >::reserve(who, value)?; + Ok(()) + }) + } + + /// Unreserve some funds, returning any amount that was unable to be unreserved. + /// + /// Is a no-op if the value to be unreserved is zero. + fn unreserve_named( + id: &Self::ReserveIdentifier, + who: &T::AccountId, + value: Self::Balance, + ) -> Self::Balance { + if value.is_zero() { + return Zero::zero() + } + + Reserves::::mutate_exists(who, |maybe_reserves| -> Self::Balance { + if let Some(reserves) = maybe_reserves.as_mut() { + match reserves.binary_search_by_key(id, |data| data.id) { + Ok(index) => { + let to_change = cmp::min(reserves[index].amount, value); + + let remain = >::unreserve(who, to_change); + + // remain should always be zero but just to be defensive here. + let actual = to_change.defensive_saturating_sub(remain); + + // `actual <= to_change` and `to_change <= amount`; qed; + reserves[index].amount -= actual; + + if reserves[index].amount.is_zero() { + if reserves.len() == 1 { + // no more named reserves + *maybe_reserves = None; + } else { + // remove this named reserve + reserves.remove(index); + } + } + + value - actual + }, + Err(_) => value, + } + } else { + value + } + }) + } + + /// Slash from reserved balance, returning the negative imbalance created, + /// and any amount that was unable to be slashed. + /// + /// Is a no-op if the value to be slashed is zero. + fn slash_reserved_named( + id: &Self::ReserveIdentifier, + who: &T::AccountId, + value: Self::Balance, + ) -> (Self::NegativeImbalance, Self::Balance) { + if value.is_zero() { + return (NegativeImbalance::zero(), Zero::zero()) + } + + Reserves::::mutate(who, |reserves| -> (Self::NegativeImbalance, Self::Balance) { + match reserves.binary_search_by_key(id, |data| data.id) { + Ok(index) => { + let to_change = cmp::min(reserves[index].amount, value); + + let (imb, remain) = + >::slash_reserved(who, to_change); + + // remain should always be zero but just to be defensive here. + let actual = to_change.defensive_saturating_sub(remain); + + // `actual <= to_change` and `to_change <= amount`; qed; + reserves[index].amount -= actual; + + Self::deposit_event(Event::Slashed { who: who.clone(), amount: actual }); + (imb, value - actual) + }, + Err(_) => (NegativeImbalance::zero(), value), + } + }) + } + + /// Move the reserved balance of one account into the balance of another, according to `status`. + /// If `status` is `Reserved`, the balance will be reserved with given `id`. + /// + /// Is a no-op if: + /// - the value to be moved is zero; or + /// - the `slashed` id equal to `beneficiary` and the `status` is `Reserved`. + fn repatriate_reserved_named( + id: &Self::ReserveIdentifier, + slashed: &T::AccountId, + beneficiary: &T::AccountId, + value: Self::Balance, + status: Status, + ) -> Result { + if value.is_zero() { + return Ok(Zero::zero()) + } + + if slashed == beneficiary { + return match status { + Status::Free => Ok(Self::unreserve_named(id, slashed, value)), + Status::Reserved => + Ok(value.saturating_sub(Self::reserved_balance_named(id, slashed))), + } + } + + Reserves::::try_mutate(slashed, |reserves| -> Result { + match reserves.binary_search_by_key(id, |data| data.id) { + Ok(index) => { + let to_change = cmp::min(reserves[index].amount, value); + + let actual = if status == Status::Reserved { + // make it the reserved under same identifier + Reserves::::try_mutate( + beneficiary, + |reserves| -> Result { + match reserves.binary_search_by_key(id, |data| data.id) { + Ok(index) => { + let remain = + >::repatriate_reserved( + slashed, + beneficiary, + to_change, + status, + )?; + + // remain should always be zero but just to be defensive + // here. + let actual = to_change.defensive_saturating_sub(remain); + + // this add can't overflow but just to be defensive. + reserves[index].amount = + reserves[index].amount.defensive_saturating_add(actual); + + Ok(actual) + }, + Err(index) => { + let remain = + >::repatriate_reserved( + slashed, + beneficiary, + to_change, + status, + )?; + + // remain should always be zero but just to be defensive + // here + let actual = to_change.defensive_saturating_sub(remain); + + reserves + .try_insert( + index, + ReserveData { id: *id, amount: actual }, + ) + .map_err(|_| Error::::TooManyReserves)?; + + Ok(actual) + }, + } + }, + )? + } else { + let remain = >::repatriate_reserved( + slashed, + beneficiary, + to_change, + status, + )?; + + // remain should always be zero but just to be defensive here + to_change.defensive_saturating_sub(remain) + }; + + // `actual <= to_change` and `to_change <= amount`; qed; + reserves[index].amount -= actual; + + Ok(value - actual) + }, + Err(_) => Ok(value), + } + }) + } +} + +impl, I: 'static> LockableCurrency for Pallet +where + T::Balance: MaybeSerializeDeserialize + Debug, +{ + type Moment = T::BlockNumber; + + type MaxLocks = T::MaxLocks; + + // Set a lock on the balance of `who`. + // Is a no-op if lock amount is zero or `reasons` `is_none()`. + fn set_lock( + id: LockIdentifier, + who: &T::AccountId, + amount: T::Balance, + reasons: WithdrawReasons, + ) { + if amount.is_zero() || reasons.is_empty() { + return + } + let mut new_lock = Some(BalanceLock { id, amount, reasons: reasons.into() }); + let mut locks = Self::locks(who) + .into_iter() + .filter_map(|l| if l.id == id { new_lock.take() } else { Some(l) }) + .collect::>(); + if let Some(lock) = new_lock { + locks.push(lock) + } + Self::update_locks(who, &locks[..]); + } + + // Extend a lock on the balance of `who`. + // Is a no-op if lock amount is zero or `reasons` `is_none()`. + fn extend_lock( + id: LockIdentifier, + who: &T::AccountId, + amount: T::Balance, + reasons: WithdrawReasons, + ) { + if amount.is_zero() || reasons.is_empty() { + return + } + let mut new_lock = Some(BalanceLock { id, amount, reasons: reasons.into() }); + let mut locks = Self::locks(who) + .into_iter() + .filter_map(|l| { + if l.id == id { + new_lock.take().map(|nl| BalanceLock { + id: l.id, + amount: l.amount.max(nl.amount), + reasons: l.reasons | nl.reasons, + }) + } else { + Some(l) + } + }) + .collect::>(); + if let Some(lock) = new_lock { + locks.push(lock) + } + Self::update_locks(who, &locks[..]); + } + + fn remove_lock(id: LockIdentifier, who: &T::AccountId) { + let mut locks = Self::locks(who); + locks.retain(|l| l.id != id); + Self::update_locks(who, &locks[..]); + } +} diff --git a/frame/balances/src/impl_fungible.rs b/frame/balances/src/impl_fungible.rs new file mode 100644 index 0000000000000..f8f8fe17ae0ef --- /dev/null +++ b/frame/balances/src/impl_fungible.rs @@ -0,0 +1,358 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2022 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. + +//! Implementation of `fungible` traits for Balances pallet. +use super::*; +use frame_support::traits::tokens::{ + Fortitude, + Preservation::{self, Preserve, Protect}, + Provenance::{self, Minted}, +}; + +impl, I: 'static> fungible::Inspect for Pallet { + type Balance = T::Balance; + + fn total_issuance() -> Self::Balance { + TotalIssuance::::get() + } + fn active_issuance() -> Self::Balance { + TotalIssuance::::get().saturating_sub(InactiveIssuance::::get()) + } + fn minimum_balance() -> Self::Balance { + T::ExistentialDeposit::get() + } + fn total_balance(who: &T::AccountId) -> Self::Balance { + Self::account(who).total() + } + fn balance(who: &T::AccountId) -> Self::Balance { + Self::account(who).free + } + fn reducible_balance( + who: &T::AccountId, + preservation: Preservation, + force: Fortitude, + ) -> Self::Balance { + let a = Self::account(who); + let mut untouchable = Zero::zero(); + if force == Polite { + // Frozen balance applies to total. Anything on hold therefore gets discounted from the + // limit given by the freezes. + untouchable = a.frozen.saturating_sub(a.reserved); + } + // If we want to keep our provider ref.. + if preservation == Preserve + // ..or we don't want the account to die and our provider ref is needed for it to live.. + || preservation == Protect && !a.free.is_zero() && + frame_system::Pallet::::providers(who) == 1 + // ..or we don't care about the account dying but our provider ref is required.. + || preservation == Expendable && !a.free.is_zero() && + !frame_system::Pallet::::can_dec_provider(who) + { + // ..then the ED needed.. + untouchable = untouchable.max(T::ExistentialDeposit::get()); + } + // Liquid balance is what is neither on hold nor frozen/required for provider. + a.free.saturating_sub(untouchable) + } + fn can_deposit( + who: &T::AccountId, + amount: Self::Balance, + provenance: Provenance, + ) -> DepositConsequence { + if amount.is_zero() { + return DepositConsequence::Success + } + + if provenance == Minted && TotalIssuance::::get().checked_add(&amount).is_none() { + return DepositConsequence::Overflow + } + + let account = Self::account(who); + let new_free = match account.free.checked_add(&amount) { + None => return DepositConsequence::Overflow, + Some(x) if x < T::ExistentialDeposit::get() => return DepositConsequence::BelowMinimum, + Some(x) => x, + }; + + match account.reserved.checked_add(&new_free) { + Some(_) => {}, + None => return DepositConsequence::Overflow, + }; + + // NOTE: We assume that we are a provider, so don't need to do any checks in the + // case of account creation. + + DepositConsequence::Success + } + fn can_withdraw( + who: &T::AccountId, + amount: Self::Balance, + ) -> WithdrawConsequence { + if amount.is_zero() { + return WithdrawConsequence::Success + } + + if TotalIssuance::::get().checked_sub(&amount).is_none() { + return WithdrawConsequence::Underflow + } + + let account = Self::account(who); + let new_free_balance = match account.free.checked_sub(&amount) { + Some(x) => x, + None => return WithdrawConsequence::BalanceLow, + }; + + let liquid = Self::reducible_balance(who, Expendable, Polite); + if amount > liquid { + return WithdrawConsequence::Frozen + } + + // Provider restriction - total account balance cannot be reduced to zero if it cannot + // sustain the loss of a provider reference. + // NOTE: This assumes that the pallet is a provider (which is true). Is this ever changes, + // then this will need to adapt accordingly. + let ed = T::ExistentialDeposit::get(); + let success = if new_free_balance < ed { + if frame_system::Pallet::::can_dec_provider(who) { + WithdrawConsequence::ReducedToZero(new_free_balance) + } else { + return WithdrawConsequence::WouldDie + } + } else { + WithdrawConsequence::Success + }; + + let new_total_balance = new_free_balance.saturating_add(account.reserved); + + // Eventual free funds must be no less than the frozen balance. + if new_total_balance < account.frozen { + return WithdrawConsequence::Frozen + } + + success + } +} + +impl, I: 'static> fungible::Unbalanced for Pallet { + fn handle_dust(dust: fungible::Dust) { + T::DustRemoval::on_unbalanced(dust.into_credit()); + } + fn write_balance( + who: &T::AccountId, + amount: Self::Balance, + ) -> Result, DispatchError> { + let max_reduction = + >::reducible_balance(who, Expendable, Force); + let (result, maybe_dust) = Self::mutate_account(who, |account| -> DispatchResult { + // Make sure the reduction (if there is one) is no more than the maximum allowed. + let reduction = account.free.saturating_sub(amount); + ensure!(reduction <= max_reduction, Error::::InsufficientBalance); + + account.free = amount; + Ok(()) + })?; + result?; + Ok(maybe_dust) + } + + fn set_total_issuance(amount: Self::Balance) { + TotalIssuance::::mutate(|t| *t = amount); + } + + fn deactivate(amount: Self::Balance) { + InactiveIssuance::::mutate(|b| b.saturating_accrue(amount)); + } + + fn reactivate(amount: Self::Balance) { + InactiveIssuance::::mutate(|b| b.saturating_reduce(amount)); + } +} + +impl, I: 'static> fungible::Mutate for Pallet { + fn done_mint_into(who: &T::AccountId, amount: Self::Balance) { + Self::deposit_event(Event::::Minted { who: who.clone(), amount }); + } + fn done_burn_from(who: &T::AccountId, amount: Self::Balance) { + Self::deposit_event(Event::::Burned { who: who.clone(), amount }); + } + fn done_shelve(who: &T::AccountId, amount: Self::Balance) { + Self::deposit_event(Event::::Suspended { who: who.clone(), amount }); + } + fn done_restore(who: &T::AccountId, amount: Self::Balance) { + Self::deposit_event(Event::::Restored { who: who.clone(), amount }); + } + fn done_transfer(source: &T::AccountId, dest: &T::AccountId, amount: Self::Balance) { + Self::deposit_event(Event::::Transfer { + from: source.clone(), + to: dest.clone(), + amount, + }); + } +} + +impl, I: 'static> fungible::MutateHold for Pallet {} + +impl, I: 'static> fungible::InspectHold for Pallet { + type Reason = T::HoldIdentifier; + + fn total_balance_on_hold(who: &T::AccountId) -> T::Balance { + Self::account(who).reserved + } + fn reducible_total_balance_on_hold(who: &T::AccountId, force: Fortitude) -> Self::Balance { + // The total balance must never drop below the freeze requirements if we're not forcing: + let a = Self::account(who); + let unavailable = if force == Force { + Self::Balance::zero() + } else { + // The freeze lock applies to the total balance, so we can discount the free balance + // from the amount which the total reserved balance must provide to satisfy it. + a.frozen.saturating_sub(a.free) + }; + a.reserved.saturating_sub(unavailable) + } + fn balance_on_hold(reason: &Self::Reason, who: &T::AccountId) -> T::Balance { + Holds::::get(who) + .iter() + .find(|x| &x.id == reason) + .map_or_else(Zero::zero, |x| x.amount) + } + fn hold_available(reason: &Self::Reason, who: &T::AccountId) -> bool { + if frame_system::Pallet::::providers(who) == 0 { + return false + } + let holds = Holds::::get(who); + if holds.is_full() && !holds.iter().any(|x| &x.id == reason) { + return false + } + true + } +} + +impl, I: 'static> fungible::UnbalancedHold for Pallet { + fn set_balance_on_hold( + reason: &Self::Reason, + who: &T::AccountId, + amount: Self::Balance, + ) -> DispatchResult { + let mut new_account = Self::account(who); + let mut holds = Holds::::get(who); + let mut increase = true; + let mut delta = amount; + + if let Some(item) = holds.iter_mut().find(|x| &x.id == reason) { + delta = item.amount.max(amount) - item.amount.min(amount); + increase = amount > item.amount; + item.amount = amount; + holds.retain(|x| !x.amount.is_zero()); + } else { + if !amount.is_zero() { + holds + .try_push(IdAmount { id: *reason, amount }) + .map_err(|_| Error::::TooManyHolds)?; + } + } + + new_account.reserved = if increase { + new_account.reserved.checked_add(&delta).ok_or(ArithmeticError::Overflow)? + } else { + new_account.reserved.checked_sub(&delta).ok_or(ArithmeticError::Underflow)? + }; + + let (result, maybe_dust) = Self::try_mutate_account(who, |a, _| -> DispatchResult { + *a = new_account; + Ok(()) + })?; + debug_assert!( + maybe_dust.is_none(), + "Does not alter main balance; dust only happens when it is altered; qed" + ); + Holds::::insert(who, holds); + Ok(result) + } +} + +impl, I: 'static> fungible::InspectFreeze for Pallet { + type Id = T::FreezeIdentifier; + + fn balance_frozen(id: &Self::Id, who: &T::AccountId) -> Self::Balance { + let locks = Freezes::::get(who); + locks.into_iter().find(|l| &l.id == id).map_or(Zero::zero(), |l| l.amount) + } + + fn can_freeze(id: &Self::Id, who: &T::AccountId) -> bool { + let l = Freezes::::get(who); + !l.is_full() || l.iter().any(|x| &x.id == id) + } +} + +impl, I: 'static> fungible::MutateFreeze for Pallet { + fn set_freeze(id: &Self::Id, who: &T::AccountId, amount: Self::Balance) -> DispatchResult { + if amount.is_zero() { + return Self::thaw(id, who) + } + let mut locks = Freezes::::get(who); + if let Some(i) = locks.iter_mut().find(|x| &x.id == id) { + i.amount = amount; + } else { + locks + .try_push(IdAmount { id: *id, amount }) + .map_err(|_| Error::::TooManyFreezes)?; + } + Self::update_freezes(who, locks.as_bounded_slice()) + } + + fn extend_freeze(id: &Self::Id, who: &T::AccountId, amount: Self::Balance) -> DispatchResult { + if amount.is_zero() { + return Ok(()) + } + let mut locks = Freezes::::get(who); + if let Some(i) = locks.iter_mut().find(|x| &x.id == id) { + i.amount = i.amount.max(amount); + } else { + locks + .try_push(IdAmount { id: *id, amount }) + .map_err(|_| Error::::TooManyFreezes)?; + } + Self::update_freezes(who, locks.as_bounded_slice()) + } + + fn thaw(id: &Self::Id, who: &T::AccountId) -> DispatchResult { + let mut locks = Freezes::::get(who); + locks.retain(|l| &l.id != id); + Self::update_freezes(who, locks.as_bounded_slice()) + } +} + +impl, I: 'static> fungible::Balanced for Pallet { + type OnDropCredit = fungible::DecreaseIssuance; + type OnDropDebt = fungible::IncreaseIssuance; + + fn done_deposit(who: &T::AccountId, amount: Self::Balance) { + Self::deposit_event(Event::::Deposit { who: who.clone(), amount }); + } + fn done_withdraw(who: &T::AccountId, amount: Self::Balance) { + Self::deposit_event(Event::::Withdraw { who: who.clone(), amount }); + } + fn done_issue(amount: Self::Balance) { + Self::deposit_event(Event::::Issued { amount }); + } + fn done_rescind(amount: Self::Balance) { + Self::deposit_event(Event::::Rescinded { amount }); + } +} + +impl, I: 'static> fungible::BalancedHold for Pallet {} diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index ecd7e171e39ec..ca8e86ef2f64a 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -89,8 +89,9 @@ //! //! ### Dispatchable Functions //! -//! - `transfer` - Transfer some liquid free balance to another account. -//! - `set_balance` - Set the balances of a given account. The origin of this call must be root. +//! - `transfer_allow_death` - Transfer some liquid free balance to another account. +//! - `force_set_balance` - Set the balances of a given account. The origin of this call must be +//! root. //! //! ## Usage //! @@ -152,43 +153,43 @@ //! * Total issued balanced of all accounts should be less than `Config::Balance::max_value()`. #![cfg_attr(not(feature = "std"), no_std)] - -#[macro_use] -mod tests; mod benchmarking; +mod impl_currency; +mod impl_fungible; pub mod migration; -mod tests_composite; -mod tests_local; -#[cfg(test)] -mod tests_reentrancy; +mod tests; +mod types; pub mod weights; -pub use self::imbalances::{NegativeImbalance, PositiveImbalance}; -use codec::{Codec, Decode, Encode, MaxEncodedLen}; +use codec::{Codec, MaxEncodedLen}; #[cfg(feature = "std")] use frame_support::traits::GenesisBuild; use frame_support::{ ensure, pallet_prelude::DispatchResult, traits::{ - tokens::{fungible, BalanceStatus as Status, DepositConsequence, WithdrawConsequence}, - Currency, DefensiveSaturating, ExistenceRequirement, - ExistenceRequirement::{AllowDeath, KeepAlive}, - Get, Imbalance, LockIdentifier, LockableCurrency, NamedReservableCurrency, OnUnbalanced, - ReservableCurrency, SignedImbalance, StoredMap, TryDrop, WithdrawReasons, + tokens::{ + fungible, BalanceStatus as Status, DepositConsequence, + Fortitude::{self, Force, Polite}, + Preservation::{Expendable, Preserve, Protect}, + WithdrawConsequence, + }, + Currency, Defensive, Get, OnUnbalanced, ReservableCurrency, StoredMap, }, - WeakBoundedVec, + BoundedSlice, WeakBoundedVec, }; use frame_system as system; +pub use impl_currency::{NegativeImbalance, PositiveImbalance}; use scale_info::TypeInfo; use sp_runtime::{ traits::{ AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedSub, MaybeSerializeDeserialize, Saturating, StaticLookup, Zero, }, - ArithmeticError, DispatchError, FixedPointOperand, RuntimeDebug, + ArithmeticError, DispatchError, FixedPointOperand, Perbill, RuntimeDebug, TokenError, }; -use sp_std::{cmp, fmt::Debug, mem, ops::BitOr, prelude::*, result}; +use sp_std::{cmp, fmt::Debug, mem, prelude::*, result}; +pub use types::{AccountData, BalanceLock, DustCleaner, IdAmount, Reasons, ReserveData}; pub use weights::WeightInfo; pub use pallet::*; @@ -200,11 +201,20 @@ type AccountIdLookupOf = <::Lookup as StaticLookup #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::pallet_prelude::*; + use frame_support::{pallet_prelude::*, traits::fungible::Credit}; use frame_system::pallet_prelude::*; + pub type CreditOf = Credit<::AccountId, Pallet>; + #[pallet::config] pub trait Config: frame_system::Config { + /// The overarching event type. + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; + + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; + /// The balance of an account. type Balance: Parameter + Member @@ -219,11 +229,7 @@ pub mod pallet { + FixedPointOperand; /// Handler for the unbalanced reduction when removing a dust account. - type DustRemoval: OnUnbalanced>; - - /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type DustRemoval: OnUnbalanced>; /// The minimum amount required to keep an account open. #[pallet::constant] @@ -232,8 +238,16 @@ pub mod pallet { /// The means of storing the balances of an account. type AccountStore: StoredMap>; - /// Weight information for extrinsics in this pallet. - type WeightInfo: WeightInfo; + /// The ID type for reserves. + /// + /// Use of reserves is deprecated in favour of holds. See `https://github.com/paritytech/substrate/pull/12951/` + type ReserveIdentifier: Parameter + Member + MaxEncodedLen + Ord + Copy; + + /// The ID type for holds. + type HoldIdentifier: Parameter + Member + MaxEncodedLen + Ord + Copy; + + /// The ID type for freezes. + type FreezeIdentifier: Parameter + Member + MaxEncodedLen + Ord + Copy; /// The maximum number of locks that should exist on an account. /// Not strictly enforced, but used for weight estimation. @@ -244,8 +258,13 @@ pub mod pallet { #[pallet::constant] type MaxReserves: Get; - /// The id type for named reserves. - type ReserveIdentifier: Parameter + Member + MaxEncodedLen + Ord + Copy; + /// The maximum number of holds that can exist on an account at any time. + #[pallet::constant] + type MaxHolds: Get; + + /// The maximum number of individual freeze locks that can exist on an account at any time. + #[pallet::constant] + type MaxFreezes: Get; } /// The current storage version. @@ -256,197 +275,6 @@ pub mod pallet { #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(PhantomData<(T, I)>); - #[pallet::call] - impl, I: 'static> Pallet { - /// Transfer some liquid free balance to another account. - /// - /// `transfer` will set the `FreeBalance` of the sender and receiver. - /// If the sender's account is below the existential deposit as a result - /// of the transfer, the account will be reaped. - /// - /// The dispatch origin for this call must be `Signed` by the transactor. - /// - /// ## Complexity - /// - Dependent on arguments but not critical, given proper implementations for input config - /// types. See related functions below. - /// - It contains a limited number of reads and writes internally and no complex - /// computation. - /// - /// Related functions: - /// - /// - `ensure_can_withdraw` is always called internally but has a bounded complexity. - /// - Transferring balances to accounts that did not exist before will cause - /// `T::OnNewAccount::on_new_account` to be called. - /// - Removing enough funds from an account will trigger `T::DustRemoval::on_unbalanced`. - /// - `transfer_keep_alive` works the same way as `transfer`, but has an additional check - /// that the transfer will not kill the origin account. - #[pallet::call_index(0)] - #[pallet::weight(T::WeightInfo::transfer())] - pub fn transfer( - origin: OriginFor, - dest: AccountIdLookupOf, - #[pallet::compact] value: T::Balance, - ) -> DispatchResultWithPostInfo { - let transactor = ensure_signed(origin)?; - let dest = T::Lookup::lookup(dest)?; - >::transfer( - &transactor, - &dest, - value, - ExistenceRequirement::AllowDeath, - )?; - Ok(().into()) - } - - /// Set the balances of a given account. - /// - /// This will alter `FreeBalance` and `ReservedBalance` in storage. it will - /// also alter the total issuance of the system (`TotalIssuance`) appropriately. - /// If the new free or reserved balance is below the existential deposit, - /// it will reset the account nonce (`frame_system::AccountNonce`). - /// - /// The dispatch origin for this call is `root`. - #[pallet::call_index(1)] - #[pallet::weight( - T::WeightInfo::set_balance_creating() // Creates a new account. - .max(T::WeightInfo::set_balance_killing()) // Kills an existing account. - )] - pub fn set_balance( - origin: OriginFor, - who: AccountIdLookupOf, - #[pallet::compact] new_free: T::Balance, - #[pallet::compact] new_reserved: T::Balance, - ) -> DispatchResultWithPostInfo { - ensure_root(origin)?; - let who = T::Lookup::lookup(who)?; - let existential_deposit = T::ExistentialDeposit::get(); - - let wipeout = new_free + new_reserved < existential_deposit; - let new_free = if wipeout { Zero::zero() } else { new_free }; - let new_reserved = if wipeout { Zero::zero() } else { new_reserved }; - - // First we try to modify the account's balance to the forced balance. - let (old_free, old_reserved) = Self::mutate_account(&who, |account| { - let old_free = account.free; - let old_reserved = account.reserved; - - account.free = new_free; - account.reserved = new_reserved; - - (old_free, old_reserved) - })?; - - // This will adjust the total issuance, which was not done by the `mutate_account` - // above. - if new_free > old_free { - mem::drop(PositiveImbalance::::new(new_free - old_free)); - } else if new_free < old_free { - mem::drop(NegativeImbalance::::new(old_free - new_free)); - } - - if new_reserved > old_reserved { - mem::drop(PositiveImbalance::::new(new_reserved - old_reserved)); - } else if new_reserved < old_reserved { - mem::drop(NegativeImbalance::::new(old_reserved - new_reserved)); - } - - Self::deposit_event(Event::BalanceSet { who, free: new_free, reserved: new_reserved }); - Ok(().into()) - } - - /// Exactly as `transfer`, except the origin must be root and the source account may be - /// specified. - /// ## Complexity - /// - Same as transfer, but additional read and write because the source account is not - /// assumed to be in the overlay. - #[pallet::call_index(2)] - #[pallet::weight(T::WeightInfo::force_transfer())] - pub fn force_transfer( - origin: OriginFor, - source: AccountIdLookupOf, - dest: AccountIdLookupOf, - #[pallet::compact] value: T::Balance, - ) -> DispatchResultWithPostInfo { - ensure_root(origin)?; - let source = T::Lookup::lookup(source)?; - let dest = T::Lookup::lookup(dest)?; - >::transfer( - &source, - &dest, - value, - ExistenceRequirement::AllowDeath, - )?; - Ok(().into()) - } - - /// Same as the [`transfer`] call, but with a check that the transfer will not kill the - /// origin account. - /// - /// 99% of the time you want [`transfer`] instead. - /// - /// [`transfer`]: struct.Pallet.html#method.transfer - #[pallet::call_index(3)] - #[pallet::weight(T::WeightInfo::transfer_keep_alive())] - pub fn transfer_keep_alive( - origin: OriginFor, - dest: AccountIdLookupOf, - #[pallet::compact] value: T::Balance, - ) -> DispatchResultWithPostInfo { - let transactor = ensure_signed(origin)?; - let dest = T::Lookup::lookup(dest)?; - >::transfer(&transactor, &dest, value, KeepAlive)?; - Ok(().into()) - } - - /// Transfer the entire transferable balance from the caller account. - /// - /// NOTE: This function only attempts to transfer _transferable_ balances. This means that - /// any locked, reserved, or existential deposits (when `keep_alive` is `true`), will not be - /// transferred by this function. To ensure that this function results in a killed account, - /// you might need to prepare the account by removing any reference counters, storage - /// deposits, etc... - /// - /// The dispatch origin of this call must be Signed. - /// - /// - `dest`: The recipient of the transfer. - /// - `keep_alive`: A boolean to determine if the `transfer_all` operation should send all - /// of the funds the account has, causing the sender account to be killed (false), or - /// transfer everything except at least the existential deposit, which will guarantee to - /// keep the sender account alive (true). ## Complexity - /// - O(1). Just like transfer, but reading the user's transferable balance first. - #[pallet::call_index(4)] - #[pallet::weight(T::WeightInfo::transfer_all())] - pub fn transfer_all( - origin: OriginFor, - dest: AccountIdLookupOf, - keep_alive: bool, - ) -> DispatchResult { - use fungible::Inspect; - let transactor = ensure_signed(origin)?; - let reducible_balance = Self::reducible_balance(&transactor, keep_alive); - let dest = T::Lookup::lookup(dest)?; - let keep_alive = if keep_alive { KeepAlive } else { AllowDeath }; - >::transfer(&transactor, &dest, reducible_balance, keep_alive)?; - Ok(()) - } - - /// Unreserve some balance from a user by force. - /// - /// Can only be called by ROOT. - #[pallet::call_index(5)] - #[pallet::weight(T::WeightInfo::force_unreserve())] - pub fn force_unreserve( - origin: OriginFor, - who: AccountIdLookupOf, - amount: T::Balance, - ) -> DispatchResult { - ensure_root(origin)?; - let who = T::Lookup::lookup(who)?; - let _leftover = >::unreserve(&who, amount); - Ok(()) - } - } - #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event, I: 'static = ()> { @@ -458,7 +286,7 @@ pub mod pallet { /// Transfer succeeded. Transfer { from: T::AccountId, to: T::AccountId, amount: T::Balance }, /// A balance was set by root. - BalanceSet { who: T::AccountId, free: T::Balance, reserved: T::Balance }, + BalanceSet { who: T::AccountId, free: T::Balance }, /// Some balance was reserved (moved from free to reserved). Reserved { who: T::AccountId, amount: T::Balance }, /// Some balance was unreserved (moved from reserved to free). @@ -477,26 +305,44 @@ pub mod pallet { Withdraw { who: T::AccountId, amount: T::Balance }, /// Some amount was removed from the account (e.g. for misbehavior). Slashed { who: T::AccountId, amount: T::Balance }, + /// Some amount was minted into an account. + Minted { who: T::AccountId, amount: T::Balance }, + /// Some amount was burned from an account. + Burned { who: T::AccountId, amount: T::Balance }, + /// Some amount was suspended from an account (it can be restored later). + Suspended { who: T::AccountId, amount: T::Balance }, + /// Some amount was restored into an account. + Restored { who: T::AccountId, amount: T::Balance }, + /// An account was upgraded. + Upgraded { who: T::AccountId }, + /// Total issuance was increased by `amount`, creating a credit to be balanced. + Issued { amount: T::Balance }, + /// Total issuance was decreased by `amount`, creating a debt to be balanced. + Rescinded { amount: T::Balance }, } #[pallet::error] pub enum Error { - /// Vesting balance too high to send value + /// Vesting balance too high to send value. VestingBalance, - /// Account liquidity restrictions prevent withdrawal + /// Account liquidity restrictions prevent withdrawal. LiquidityRestrictions, /// Balance too low to send value. InsufficientBalance, - /// Value too low to create account due to existential deposit + /// Value too low to create account due to existential deposit. ExistentialDeposit, - /// Transfer/payment would kill account - KeepAlive, - /// A vesting schedule already exists for this account + /// Transfer/payment would kill account. + Expendability, + /// A vesting schedule already exists for this account. ExistingVestingSchedule, - /// Beneficiary account must pre-exist + /// Beneficiary account must pre-exist. DeadAccount, - /// Number of named reserves exceed MaxReserves + /// Number of named reserves exceed `MaxReserves`. TooManyReserves, + /// Number of holds exceed `MaxHolds`. + TooManyHolds, + /// Number of freezes exceed `MaxFreezes`. + TooManyFreezes, } /// The total units issued in the system. @@ -563,6 +409,26 @@ pub mod pallet { ValueQuery, >; + /// Holds on account balances. + #[pallet::storage] + pub type Holds, I: 'static = ()> = StorageMap< + _, + Blake2_128Concat, + T::AccountId, + BoundedVec, T::MaxHolds>, + ValueQuery, + >; + + /// Freeze locks on account balances. + #[pallet::storage] + pub type Freezes, I: 'static = ()> = StorageMap< + _, + Blake2_128Concat, + T::AccountId, + BoundedVec, T::MaxFreezes>, + ValueQuery, + >; + #[pallet::genesis_config] pub struct GenesisConfig, I: 'static = ()> { pub balances: Vec<(T::AccountId, T::Balance)>, @@ -602,1601 +468,646 @@ pub mod pallet { ); for &(ref who, free) in self.balances.iter() { + frame_system::Pallet::::inc_providers(who); assert!(T::AccountStore::insert(who, AccountData { free, ..Default::default() }) .is_ok()); } } } -} - -#[cfg(feature = "std")] -impl, I: 'static> GenesisConfig { - /// Direct implementation of `GenesisBuild::build_storage`. - /// - /// Kept in order not to break dependency. - pub fn build_storage(&self) -> Result { - >::build_storage(self) - } - - /// Direct implementation of `GenesisBuild::assimilate_storage`. - /// - /// Kept in order not to break dependency. - pub fn assimilate_storage(&self, storage: &mut sp_runtime::Storage) -> Result<(), String> { - >::assimilate_storage(self, storage) - } -} - -/// Simplified reasons for withdrawing balance. -#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)] -pub enum Reasons { - /// Paying system transaction fees. - Fee = 0, - /// Any reason other than paying system transaction fees. - Misc = 1, - /// Any reason at all. - All = 2, -} - -impl From for Reasons { - fn from(r: WithdrawReasons) -> Reasons { - if r == WithdrawReasons::TRANSACTION_PAYMENT { - Reasons::Fee - } else if r.contains(WithdrawReasons::TRANSACTION_PAYMENT) { - Reasons::All - } else { - Reasons::Misc - } - } -} -impl BitOr for Reasons { - type Output = Reasons; - fn bitor(self, other: Reasons) -> Reasons { - if self == other { - return self + #[cfg(feature = "std")] + impl, I: 'static> GenesisConfig { + /// Direct implementation of `GenesisBuild::build_storage`. + /// + /// Kept in order not to break dependency. + pub fn build_storage(&self) -> Result { + >::build_storage(self) } - Reasons::All - } -} - -/// A single lock on a balance. There can be many of these on an account and they "overlap", so the -/// same balance is frozen by multiple locks. -#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)] -pub struct BalanceLock { - /// An identifier for this lock. Only one lock may be in existence for each identifier. - pub id: LockIdentifier, - /// The amount which the free balance may not drop below when this lock is in effect. - pub amount: Balance, - /// If true, then the lock remains in effect even for payment of transaction fees. - pub reasons: Reasons, -} - -/// Store named reserved balance. -#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)] -pub struct ReserveData { - /// The identifier for the named reserve. - pub id: ReserveIdentifier, - /// The amount of the named reserve. - pub amount: Balance, -} - -/// All balance information for an account. -#[derive(Encode, Decode, Clone, PartialEq, Eq, Default, RuntimeDebug, MaxEncodedLen, TypeInfo)] -pub struct AccountData { - /// Non-reserved part of the balance. There may still be restrictions on this, but it is the - /// total pool what may in principle be transferred, reserved and used for tipping. - /// - /// This is the only balance that matters in terms of most operations on tokens. It - /// alone is used to determine the balance when in the contract execution environment. - pub free: Balance, - /// Balance which is reserved and may not be used at all. - /// - /// This can still get slashed, but gets slashed last of all. - /// - /// This balance is a 'reserve' balance that other subsystems use in order to set aside tokens - /// that are still 'owned' by the account holder, but which are suspendable. - /// This includes named reserve and unnamed reserve. - pub reserved: Balance, - /// The amount that `free` may not drop below when withdrawing for *anything except transaction - /// fee payment*. - pub misc_frozen: Balance, - /// The amount that `free` may not drop below when withdrawing specifically for transaction - /// fee payment. - pub fee_frozen: Balance, -} -impl AccountData { - /// How much this account's balance can be reduced for the given `reasons`. - fn usable(&self, reasons: Reasons) -> Balance { - self.free.saturating_sub(self.frozen(reasons)) - } - /// The amount that this account's free balance may not be reduced beyond for the given - /// `reasons`. - fn frozen(&self, reasons: Reasons) -> Balance { - match reasons { - Reasons::All => self.misc_frozen.max(self.fee_frozen), - Reasons::Misc => self.misc_frozen, - Reasons::Fee => self.fee_frozen, + /// Direct implementation of `GenesisBuild::assimilate_storage`. + /// + /// Kept in order not to break dependency. + pub fn assimilate_storage(&self, storage: &mut sp_runtime::Storage) -> Result<(), String> { + >::assimilate_storage(self, storage) } } - /// The total balance in this account including any that is reserved and ignoring any frozen. - fn total(&self) -> Balance { - self.free.saturating_add(self.reserved) - } -} -pub struct DustCleaner, I: 'static = ()>( - Option<(T::AccountId, NegativeImbalance)>, -); - -impl, I: 'static> Drop for DustCleaner { - fn drop(&mut self) { - if let Some((who, dust)) = self.0.take() { - Pallet::::deposit_event(Event::DustLost { account: who, amount: dust.peek() }); - T::DustRemoval::on_unbalanced(dust); + #[pallet::call] + impl, I: 'static> Pallet { + /// Transfer some liquid free balance to another account. + /// + /// `transfer_allow_death` will set the `FreeBalance` of the sender and receiver. + /// If the sender's account is below the existential deposit as a result + /// of the transfer, the account will be reaped. + /// + /// The dispatch origin for this call must be `Signed` by the transactor. + #[pallet::call_index(0)] + #[pallet::weight(T::WeightInfo::transfer_allow_death())] + pub fn transfer_allow_death( + origin: OriginFor, + dest: AccountIdLookupOf, + #[pallet::compact] value: T::Balance, + ) -> DispatchResultWithPostInfo { + let source = ensure_signed(origin)?; + let dest = T::Lookup::lookup(dest)?; + >::transfer(&source, &dest, value, Expendable)?; + Ok(().into()) } - } -} -impl, I: 'static> Pallet { - /// Get the free balance of an account. - pub fn free_balance(who: impl sp_std::borrow::Borrow) -> T::Balance { - Self::account(who.borrow()).free - } + /// Set the regular balance of a given account; it also takes a reserved balance but this + /// must be the same as the account's current reserved balance. + /// + /// The dispatch origin for this call is `root`. + /// + /// WARNING: This call is DEPRECATED! Use `force_set_balance` instead. + #[pallet::call_index(1)] + #[pallet::weight( + T::WeightInfo::force_set_balance_creating() // Creates a new account. + .max(T::WeightInfo::force_set_balance_killing()) // Kills an existing account. + )] + pub fn set_balance_deprecated( + origin: OriginFor, + who: AccountIdLookupOf, + #[pallet::compact] new_free: T::Balance, + #[pallet::compact] old_reserved: T::Balance, + ) -> DispatchResultWithPostInfo { + ensure_root(origin)?; + let who = T::Lookup::lookup(who)?; + let existential_deposit = T::ExistentialDeposit::get(); - /// Get the balance of an account that can be used for transfers, reservations, or any other - /// non-locking, non-transaction-fee activity. Will be at most `free_balance`. - pub fn usable_balance(who: impl sp_std::borrow::Borrow) -> T::Balance { - Self::account(who.borrow()).usable(Reasons::Misc) - } + let wipeout = new_free < existential_deposit; + let new_free = if wipeout { Zero::zero() } else { new_free }; - /// Get the balance of an account that can be used for paying transaction fees (not tipping, - /// or any other kind of fees, though). Will be at most `free_balance`. - pub fn usable_balance_for_fees(who: impl sp_std::borrow::Borrow) -> T::Balance { - Self::account(who.borrow()).usable(Reasons::Fee) - } + // First we try to modify the account's balance to the forced balance. + let old_free = Self::try_mutate_account_handling_dust( + &who, + |account, _is_new| -> Result { + let old_free = account.free; + ensure!(account.reserved == old_reserved, TokenError::Unsupported); + account.free = new_free; + Ok(old_free) + }, + )?; - /// Get the reserved balance of an account. - pub fn reserved_balance(who: impl sp_std::borrow::Borrow) -> T::Balance { - Self::account(who.borrow()).reserved - } + // This will adjust the total issuance, which was not done by the `mutate_account` + // above. + if new_free > old_free { + mem::drop(PositiveImbalance::::new(new_free - old_free)); + } else if new_free < old_free { + mem::drop(NegativeImbalance::::new(old_free - new_free)); + } - /// Get both the free and reserved balances of an account. - fn account(who: &T::AccountId) -> AccountData { - T::AccountStore::get(who) - } + Self::deposit_event(Event::BalanceSet { who, free: new_free }); + Ok(().into()) + } - /// Handles any steps needed after mutating an account. - /// - /// This includes DustRemoval unbalancing, in the case than the `new` account's total balance - /// is non-zero but below ED. - /// - /// Returns two values: - /// - `Some` containing the the `new` account, iff the account has sufficient balance. - /// - `Some` containing the dust to be dropped, iff some dust should be dropped. - fn post_mutation( - _who: &T::AccountId, - new: AccountData, - ) -> (Option>, Option>) { - let total = new.total(); - if total < T::ExistentialDeposit::get() { - if total.is_zero() { - (None, None) - } else { - (None, Some(NegativeImbalance::new(total))) - } - } else { - (Some(new), None) - } - } - - fn deposit_consequence( - _who: &T::AccountId, - amount: T::Balance, - account: &AccountData, - mint: bool, - ) -> DepositConsequence { - if amount.is_zero() { - return DepositConsequence::Success - } - - if mint && TotalIssuance::::get().checked_add(&amount).is_none() { - return DepositConsequence::Overflow - } - - let new_total_balance = match account.total().checked_add(&amount) { - Some(x) => x, - None => return DepositConsequence::Overflow, - }; - - if new_total_balance < T::ExistentialDeposit::get() { - return DepositConsequence::BelowMinimum - } - - // NOTE: We assume that we are a provider, so don't need to do any checks in the - // case of account creation. - - DepositConsequence::Success - } - - fn withdraw_consequence( - who: &T::AccountId, - amount: T::Balance, - account: &AccountData, - ) -> WithdrawConsequence { - if amount.is_zero() { - return WithdrawConsequence::Success - } - - if TotalIssuance::::get().checked_sub(&amount).is_none() { - return WithdrawConsequence::Underflow + /// Exactly as `transfer_allow_death`, except the origin must be root and the source account + /// may be specified. + #[pallet::call_index(2)] + #[pallet::weight(T::WeightInfo::force_transfer())] + pub fn force_transfer( + origin: OriginFor, + source: AccountIdLookupOf, + dest: AccountIdLookupOf, + #[pallet::compact] value: T::Balance, + ) -> DispatchResultWithPostInfo { + ensure_root(origin)?; + let source = T::Lookup::lookup(source)?; + let dest = T::Lookup::lookup(dest)?; + >::transfer(&source, &dest, value, Expendable)?; + Ok(().into()) } - let new_total_balance = match account.total().checked_sub(&amount) { - Some(x) => x, - None => return WithdrawConsequence::NoFunds, - }; - - // Provider restriction - total account balance cannot be reduced to zero if it cannot - // sustain the loss of a provider reference. - // NOTE: This assumes that the pallet is a provider (which is true). Is this ever changes, - // then this will need to adapt accordingly. - let ed = T::ExistentialDeposit::get(); - let success = if new_total_balance < ed { - if frame_system::Pallet::::can_dec_provider(who) { - WithdrawConsequence::ReducedToZero(new_total_balance) - } else { - return WithdrawConsequence::WouldDie - } - } else { - WithdrawConsequence::Success - }; - - // Enough free funds to have them be reduced. - let new_free_balance = match account.free.checked_sub(&amount) { - Some(b) => b, - None => return WithdrawConsequence::NoFunds, - }; - - // Eventual free funds must be no less than the frozen balance. - let min_balance = account.frozen(Reasons::All); - if new_free_balance < min_balance { - return WithdrawConsequence::Frozen + /// Same as the [`transfer_allow_death`] call, but with a check that the transfer will not + /// kill the origin account. + /// + /// 99% of the time you want [`transfer_allow_death`] instead. + /// + /// [`transfer_allow_death`]: struct.Pallet.html#method.transfer + #[pallet::call_index(3)] + #[pallet::weight(T::WeightInfo::transfer_keep_alive())] + pub fn transfer_keep_alive( + origin: OriginFor, + dest: AccountIdLookupOf, + #[pallet::compact] value: T::Balance, + ) -> DispatchResultWithPostInfo { + let source = ensure_signed(origin)?; + let dest = T::Lookup::lookup(dest)?; + >::transfer(&source, &dest, value, Preserve)?; + Ok(().into()) } - success - } - - /// Mutate an account to some new value, or delete it entirely with `None`. Will enforce - /// `ExistentialDeposit` law, annulling the account as needed. - /// - /// NOTE: Doesn't do any preparatory work for creating a new account, so should only be used - /// when it is known that the account already exists. - /// - /// NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that - /// the caller will do this. - pub fn mutate_account( - who: &T::AccountId, - f: impl FnOnce(&mut AccountData) -> R, - ) -> Result { - Self::try_mutate_account(who, |a, _| -> Result { Ok(f(a)) }) - } - - /// Mutate an account to some new value, or delete it entirely with `None`. Will enforce - /// `ExistentialDeposit` law, annulling the account as needed. This will do nothing if the - /// result of `f` is an `Err`. - /// - /// NOTE: Doesn't do any preparatory work for creating a new account, so should only be used - /// when it is known that the account already exists. - /// - /// NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that - /// the caller will do this. - fn try_mutate_account>( - who: &T::AccountId, - f: impl FnOnce(&mut AccountData, bool) -> Result, - ) -> Result { - Self::try_mutate_account_with_dust(who, f).map(|(result, dust_cleaner)| { - drop(dust_cleaner); - result - }) - } - - /// Mutate an account to some new value, or delete it entirely with `None`. Will enforce - /// `ExistentialDeposit` law, annulling the account as needed. This will do nothing if the - /// result of `f` is an `Err`. - /// - /// It returns both the result from the closure, and an optional `DustCleaner` instance which - /// should be dropped once it is known that all nested mutates that could affect storage items - /// what the dust handler touches have completed. - /// - /// NOTE: Doesn't do any preparatory work for creating a new account, so should only be used - /// when it is known that the account already exists. - /// - /// NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that - /// the caller will do this. - fn try_mutate_account_with_dust>( - who: &T::AccountId, - f: impl FnOnce(&mut AccountData, bool) -> Result, - ) -> Result<(R, DustCleaner), E> { - let result = T::AccountStore::try_mutate_exists(who, |maybe_account| { - let is_new = maybe_account.is_none(); - let mut account = maybe_account.take().unwrap_or_default(); - f(&mut account, is_new).map(move |result| { - let maybe_endowed = if is_new { Some(account.free) } else { None }; - let maybe_account_maybe_dust = Self::post_mutation(who, account); - *maybe_account = maybe_account_maybe_dust.0; - (maybe_endowed, maybe_account_maybe_dust.1, result) - }) - }); - result.map(|(maybe_endowed, maybe_dust, result)| { - if let Some(endowed) = maybe_endowed { - Self::deposit_event(Event::Endowed { account: who.clone(), free_balance: endowed }); - } - let dust_cleaner = DustCleaner(maybe_dust.map(|dust| (who.clone(), dust))); - (result, dust_cleaner) - }) - } - - /// Update the account entry for `who`, given the locks. - fn update_locks(who: &T::AccountId, locks: &[BalanceLock]) { - let bounded_locks = WeakBoundedVec::<_, T::MaxLocks>::force_from( - locks.to_vec(), - Some("Balances Update Locks"), - ); - - if locks.len() as u32 > T::MaxLocks::get() { - log::warn!( - target: LOG_TARGET, - "Warning: A user has more currency locks than expected. \ - A runtime configuration adjustment may be needed." + /// Transfer the entire transferable balance from the caller account. + /// + /// NOTE: This function only attempts to transfer _transferable_ balances. This means that + /// any locked, reserved, or existential deposits (when `keep_alive` is `true`), will not be + /// transferred by this function. To ensure that this function results in a killed account, + /// you might need to prepare the account by removing any reference counters, storage + /// deposits, etc... + /// + /// The dispatch origin of this call must be Signed. + /// + /// - `dest`: The recipient of the transfer. + /// - `keep_alive`: A boolean to determine if the `transfer_all` operation should send all + /// of the funds the account has, causing the sender account to be killed (false), or + /// transfer everything except at least the existential deposit, which will guarantee to + /// keep the sender account alive (true). + #[pallet::call_index(4)] + #[pallet::weight(T::WeightInfo::transfer_all())] + pub fn transfer_all( + origin: OriginFor, + dest: AccountIdLookupOf, + keep_alive: bool, + ) -> DispatchResult { + let transactor = ensure_signed(origin)?; + let keep_alive = if keep_alive { Preserve } else { Expendable }; + let reducible_balance = >::reducible_balance( + &transactor, + keep_alive, + Fortitude::Polite, ); - } - // No way this can fail since we do not alter the existential balances. - let res = Self::mutate_account(who, |b| { - b.misc_frozen = Zero::zero(); - b.fee_frozen = Zero::zero(); - for l in locks.iter() { - if l.reasons == Reasons::All || l.reasons == Reasons::Misc { - b.misc_frozen = b.misc_frozen.max(l.amount); - } - if l.reasons == Reasons::All || l.reasons == Reasons::Fee { - b.fee_frozen = b.fee_frozen.max(l.amount); - } - } - }); - debug_assert!(res.is_ok()); - - let existed = Locks::::contains_key(who); - if locks.is_empty() { - Locks::::remove(who); - if existed { - // TODO: use Locks::::hashed_key - // https://github.com/paritytech/substrate/issues/4969 - system::Pallet::::dec_consumers(who); - } - } else { - Locks::::insert(who, bounded_locks); - if !existed && system::Pallet::::inc_consumers_without_limit(who).is_err() { - // No providers for the locks. This is impossible under normal circumstances - // since the funds that are under the lock will themselves be stored in the - // account and therefore will need a reference. - log::warn!( - target: LOG_TARGET, - "Warning: Attempt to introduce lock consumer reference, yet no providers. \ - This is unexpected but should be safe." - ); - } - } - } - - /// Move the reserved balance of one account into the balance of another, according to `status`. - /// - /// Is a no-op if: - /// - the value to be moved is zero; or - /// - the `slashed` id equal to `beneficiary` and the `status` is `Reserved`. - /// - /// NOTE: returns actual amount of transferred value in `Ok` case. - fn do_transfer_reserved( - slashed: &T::AccountId, - beneficiary: &T::AccountId, - value: T::Balance, - best_effort: bool, - status: Status, - ) -> Result { - if value.is_zero() { - return Ok(Zero::zero()) - } - - if slashed == beneficiary { - return match status { - Status::Free => Ok(value.saturating_sub(Self::unreserve(slashed, value))), - Status::Reserved => Ok(value.saturating_sub(Self::reserved_balance(slashed))), - } - } - - let ((actual, _maybe_one_dust), _maybe_other_dust) = Self::try_mutate_account_with_dust( - beneficiary, - |to_account, is_new| -> Result<(T::Balance, DustCleaner), DispatchError> { - ensure!(!is_new, Error::::DeadAccount); - Self::try_mutate_account_with_dust( - slashed, - |from_account, _| -> Result { - let actual = cmp::min(from_account.reserved, value); - ensure!(best_effort || actual == value, Error::::InsufficientBalance); - match status { - Status::Free => - to_account.free = to_account - .free - .checked_add(&actual) - .ok_or(ArithmeticError::Overflow)?, - Status::Reserved => - to_account.reserved = to_account - .reserved - .checked_add(&actual) - .ok_or(ArithmeticError::Overflow)?, - } - from_account.reserved -= actual; - Ok(actual) - }, - ) - }, - )?; - - Self::deposit_event(Event::ReserveRepatriated { - from: slashed.clone(), - to: beneficiary.clone(), - amount: actual, - destination_status: status, - }); - Ok(actual) - } -} - -impl, I: 'static> fungible::Inspect for Pallet { - type Balance = T::Balance; - - fn total_issuance() -> Self::Balance { - TotalIssuance::::get() - } - fn active_issuance() -> Self::Balance { - TotalIssuance::::get().saturating_sub(InactiveIssuance::::get()) - } - fn minimum_balance() -> Self::Balance { - T::ExistentialDeposit::get() - } - fn balance(who: &T::AccountId) -> Self::Balance { - Self::account(who).total() - } - fn reducible_balance(who: &T::AccountId, keep_alive: bool) -> Self::Balance { - let a = Self::account(who); - // Liquid balance is what is neither reserved nor locked/frozen. - let liquid = a.free.saturating_sub(a.fee_frozen.max(a.misc_frozen)); - if frame_system::Pallet::::can_dec_provider(who) && !keep_alive { - liquid - } else { - // `must_remain_to_exist` is the part of liquid balance which must remain to keep total - // over ED. - let must_remain_to_exist = - T::ExistentialDeposit::get().saturating_sub(a.total() - liquid); - liquid.saturating_sub(must_remain_to_exist) - } - } - fn can_deposit(who: &T::AccountId, amount: Self::Balance, mint: bool) -> DepositConsequence { - Self::deposit_consequence(who, amount, &Self::account(who), mint) - } - fn can_withdraw( - who: &T::AccountId, - amount: Self::Balance, - ) -> WithdrawConsequence { - Self::withdraw_consequence(who, amount, &Self::account(who)) - } -} - -impl, I: 'static> fungible::Mutate for Pallet { - fn mint_into(who: &T::AccountId, amount: Self::Balance) -> DispatchResult { - if amount.is_zero() { - return Ok(()) - } - Self::try_mutate_account(who, |account, _is_new| -> DispatchResult { - Self::deposit_consequence(who, amount, account, true).into_result()?; - account.free += amount; + let dest = T::Lookup::lookup(dest)?; + >::transfer( + &transactor, + &dest, + reducible_balance, + keep_alive, + )?; Ok(()) - })?; - TotalIssuance::::mutate(|t| *t += amount); - Self::deposit_event(Event::Deposit { who: who.clone(), amount }); - Ok(()) - } - - fn burn_from( - who: &T::AccountId, - amount: Self::Balance, - ) -> Result { - if amount.is_zero() { - return Ok(Self::Balance::zero()) } - let actual = Self::try_mutate_account( - who, - |account, _is_new| -> Result { - let extra = Self::withdraw_consequence(who, amount, account).into_result()?; - let actual = amount + extra; - account.free -= actual; - Ok(actual) - }, - )?; - TotalIssuance::::mutate(|t| *t -= actual); - Self::deposit_event(Event::Withdraw { who: who.clone(), amount }); - Ok(actual) - } -} - -impl, I: 'static> fungible::Transfer for Pallet { - fn transfer( - source: &T::AccountId, - dest: &T::AccountId, - amount: T::Balance, - keep_alive: bool, - ) -> Result { - let er = if keep_alive { KeepAlive } else { AllowDeath }; - >::transfer(source, dest, amount, er).map(|_| amount) - } - - fn deactivate(amount: Self::Balance) { - InactiveIssuance::::mutate(|b| b.saturating_accrue(amount)); - } - - fn reactivate(amount: Self::Balance) { - InactiveIssuance::::mutate(|b| b.saturating_reduce(amount)); - } -} - -impl, I: 'static> fungible::Unbalanced for Pallet { - fn set_balance(who: &T::AccountId, amount: Self::Balance) -> DispatchResult { - Self::mutate_account(who, |account| -> DispatchResult { - // fungibles::Unbalanced::decrease_balance didn't check account.reserved - // free = new_balance - reserved - account.free = - amount.checked_sub(&account.reserved).ok_or(ArithmeticError::Underflow)?; - Self::deposit_event(Event::BalanceSet { - who: who.clone(), - free: account.free, - reserved: account.reserved, - }); + /// Unreserve some balance from a user by force. + /// + /// Can only be called by ROOT. + #[pallet::call_index(5)] + #[pallet::weight(T::WeightInfo::force_unreserve())] + pub fn force_unreserve( + origin: OriginFor, + who: AccountIdLookupOf, + amount: T::Balance, + ) -> DispatchResult { + ensure_root(origin)?; + let who = T::Lookup::lookup(who)?; + let _leftover = >::unreserve(&who, amount); Ok(()) - })? - } - - fn set_total_issuance(amount: Self::Balance) { - TotalIssuance::::mutate(|t| *t = amount); - } -} - -impl, I: 'static> fungible::InspectHold for Pallet { - fn balance_on_hold(who: &T::AccountId) -> T::Balance { - Self::account(who).reserved - } - fn can_hold(who: &T::AccountId, amount: T::Balance) -> bool { - let a = Self::account(who); - let min_balance = T::ExistentialDeposit::get().max(a.frozen(Reasons::All)); - if a.reserved.checked_add(&amount).is_none() { - return false - } - // We require it to be min_balance + amount to ensure that the full reserved funds may be - // slashed without compromising locked funds or destroying the account. - let required_free = match min_balance.checked_add(&amount) { - Some(x) => x, - None => return false, - }; - a.free >= required_free - } -} -impl, I: 'static> fungible::MutateHold for Pallet { - fn hold(who: &T::AccountId, amount: Self::Balance) -> DispatchResult { - if amount.is_zero() { - return Ok(()) - } - ensure!(Self::can_reserve(who, amount), Error::::InsufficientBalance); - Self::mutate_account(who, |a| { - a.free -= amount; - a.reserved += amount; - })?; - Ok(()) - } - fn release( - who: &T::AccountId, - amount: Self::Balance, - best_effort: bool, - ) -> Result { - if amount.is_zero() { - return Ok(amount) } - // Done on a best-effort basis. - Self::try_mutate_account(who, |a, _| { - let new_free = a.free.saturating_add(amount.min(a.reserved)); - let actual = new_free - a.free; - ensure!(best_effort || actual == amount, Error::::InsufficientBalance); - // ^^^ Guaranteed to be <= amount and <= a.reserved - a.free = new_free; - a.reserved = a.reserved.saturating_sub(actual); - Ok(actual) - }) - } - fn transfer_held( - source: &T::AccountId, - dest: &T::AccountId, - amount: Self::Balance, - best_effort: bool, - on_hold: bool, - ) -> Result { - let status = if on_hold { Status::Reserved } else { Status::Free }; - Self::do_transfer_reserved(source, dest, amount, best_effort, status) - } -} - -// wrapping these imbalances in a private module is necessary to ensure absolute privacy -// of the inner member. -mod imbalances { - use super::{result, Config, Imbalance, RuntimeDebug, Saturating, TryDrop, Zero}; - use frame_support::traits::SameOrOther; - use sp_std::mem; - - /// Opaque, move-only struct with private fields that serves as a token denoting that - /// funds have been created without any equal and opposite accounting. - #[must_use] - #[derive(RuntimeDebug, PartialEq, Eq)] - pub struct PositiveImbalance, I: 'static = ()>(T::Balance); - - impl, I: 'static> PositiveImbalance { - /// Create a new positive imbalance from a balance. - pub fn new(amount: T::Balance) -> Self { - PositiveImbalance(amount) - } - } - /// Opaque, move-only struct with private fields that serves as a token denoting that - /// funds have been destroyed without any equal and opposite accounting. - #[must_use] - #[derive(RuntimeDebug, PartialEq, Eq)] - pub struct NegativeImbalance, I: 'static = ()>(T::Balance); - - impl, I: 'static> NegativeImbalance { - /// Create a new negative imbalance from a balance. - pub fn new(amount: T::Balance) -> Self { - NegativeImbalance(amount) - } - } - - impl, I: 'static> TryDrop for PositiveImbalance { - fn try_drop(self) -> result::Result<(), Self> { - self.drop_zero() - } - } - - impl, I: 'static> Default for PositiveImbalance { - fn default() -> Self { - Self::zero() - } - } - - impl, I: 'static> Imbalance for PositiveImbalance { - type Opposite = NegativeImbalance; - - fn zero() -> Self { - Self(Zero::zero()) - } - fn drop_zero(self) -> result::Result<(), Self> { - if self.0.is_zero() { - Ok(()) - } else { - Err(self) + /// Upgrade a specified account. + /// + /// - `origin`: Must be `Signed`. + /// - `who`: The account to be upgraded. + /// + /// This will waive the transaction fee if at least all but 10% of the accounts needed to + /// be upgraded. (We let some not have to be upgraded just in order to allow for the + /// possibililty of churn). + #[pallet::call_index(6)] + #[pallet::weight(T::WeightInfo::upgrade_accounts(who.len() as u32))] + pub fn upgrade_accounts( + origin: OriginFor, + who: Vec, + ) -> DispatchResultWithPostInfo { + ensure_signed(origin)?; + if who.is_empty() { + return Ok(Pays::Yes.into()) } - } - fn split(self, amount: T::Balance) -> (Self, Self) { - let first = self.0.min(amount); - let second = self.0 - first; - - mem::forget(self); - (Self(first), Self(second)) - } - fn merge(mut self, other: Self) -> Self { - self.0 = self.0.saturating_add(other.0); - mem::forget(other); - - self - } - fn subsume(&mut self, other: Self) { - self.0 = self.0.saturating_add(other.0); - mem::forget(other); - } - fn offset(self, other: Self::Opposite) -> SameOrOther { - let (a, b) = (self.0, other.0); - mem::forget((self, other)); - - if a > b { - SameOrOther::Same(Self(a - b)) - } else if b > a { - SameOrOther::Other(NegativeImbalance::new(b - a)) + let mut upgrade_count = 0; + for i in &who { + let upgraded = Self::ensure_upgraded(i); + if upgraded { + upgrade_count.saturating_inc(); + } + } + let proportion_upgraded = Perbill::from_rational(upgrade_count, who.len() as u32); + if proportion_upgraded >= Perbill::from_percent(90) { + Ok(Pays::No.into()) } else { - SameOrOther::None + Ok(Pays::Yes.into()) } } - fn peek(&self) -> T::Balance { - self.0 - } - } - - impl, I: 'static> TryDrop for NegativeImbalance { - fn try_drop(self) -> result::Result<(), Self> { - self.drop_zero() - } - } - impl, I: 'static> Default for NegativeImbalance { - fn default() -> Self { - Self::zero() + /// Alias for `transfer_allow_death`, provided only for name-wise compatibility. + /// + /// WARNING: DEPRECATED! Will be released in approximately 3 months. + #[pallet::call_index(7)] + #[pallet::weight(T::WeightInfo::transfer_allow_death())] + pub fn transfer( + origin: OriginFor, + dest: AccountIdLookupOf, + #[pallet::compact] value: T::Balance, + ) -> DispatchResultWithPostInfo { + let source = ensure_signed(origin)?; + let dest = T::Lookup::lookup(dest)?; + >::transfer(&source, &dest, value, Expendable)?; + Ok(().into()) } - } - impl, I: 'static> Imbalance for NegativeImbalance { - type Opposite = PositiveImbalance; + /// Set the regular balance of a given account. + /// + /// The dispatch origin for this call is `root`. + #[pallet::call_index(8)] + #[pallet::weight( + T::WeightInfo::force_set_balance_creating() // Creates a new account. + .max(T::WeightInfo::force_set_balance_killing()) // Kills an existing account. + )] + pub fn force_set_balance( + origin: OriginFor, + who: AccountIdLookupOf, + #[pallet::compact] new_free: T::Balance, + ) -> DispatchResultWithPostInfo { + ensure_root(origin)?; + let who = T::Lookup::lookup(who)?; + let existential_deposit = T::ExistentialDeposit::get(); - fn zero() -> Self { - Self(Zero::zero()) - } - fn drop_zero(self) -> result::Result<(), Self> { - if self.0.is_zero() { - Ok(()) - } else { - Err(self) - } - } - fn split(self, amount: T::Balance) -> (Self, Self) { - let first = self.0.min(amount); - let second = self.0 - first; + let wipeout = new_free < existential_deposit; + let new_free = if wipeout { Zero::zero() } else { new_free }; - mem::forget(self); - (Self(first), Self(second)) - } - fn merge(mut self, other: Self) -> Self { - self.0 = self.0.saturating_add(other.0); - mem::forget(other); + // First we try to modify the account's balance to the forced balance. + let old_free = Self::mutate_account_handling_dust(&who, |account| { + let old_free = account.free; + account.free = new_free; + old_free + })?; - self - } - fn subsume(&mut self, other: Self) { - self.0 = self.0.saturating_add(other.0); - mem::forget(other); - } - fn offset(self, other: Self::Opposite) -> SameOrOther { - let (a, b) = (self.0, other.0); - mem::forget((self, other)); - - if a > b { - SameOrOther::Same(Self(a - b)) - } else if b > a { - SameOrOther::Other(PositiveImbalance::new(b - a)) - } else { - SameOrOther::None + // This will adjust the total issuance, which was not done by the `mutate_account` + // above. + if new_free > old_free { + mem::drop(PositiveImbalance::::new(new_free - old_free)); + } else if new_free < old_free { + mem::drop(NegativeImbalance::::new(old_free - new_free)); } - } - fn peek(&self) -> T::Balance { - self.0 - } - } - impl, I: 'static> Drop for PositiveImbalance { - /// Basic drop handler will just square up the total issuance. - fn drop(&mut self) { - >::mutate(|v| *v = v.saturating_add(self.0)); - } - } - - impl, I: 'static> Drop for NegativeImbalance { - /// Basic drop handler will just square up the total issuance. - fn drop(&mut self) { - >::mutate(|v| *v = v.saturating_sub(self.0)); + Self::deposit_event(Event::BalanceSet { who, free: new_free }); + Ok(().into()) } } -} - -impl, I: 'static> Currency for Pallet -where - T::Balance: MaybeSerializeDeserialize + Debug, -{ - type Balance = T::Balance; - type PositiveImbalance = PositiveImbalance; - type NegativeImbalance = NegativeImbalance; - - fn total_balance(who: &T::AccountId) -> Self::Balance { - Self::account(who).total() - } - // Check if `value` amount of free balance can be slashed from `who`. - fn can_slash(who: &T::AccountId, value: Self::Balance) -> bool { - if value.is_zero() { + impl, I: 'static> Pallet { + /// Ensure the account `who` is using the new logic. + /// + /// Returns `true` if the account did get upgraded, `false` if it didn't need upgrading. + pub fn ensure_upgraded(who: &T::AccountId) -> bool { + let mut a = T::AccountStore::get(who); + if a.flags.is_new_logic() { + return false + } + a.flags.set_new_logic(); + if !a.reserved.is_zero() || !a.frozen.is_zero() { + if !system::Pallet::::can_inc_consumer(who) { + // Gah!! We have a non-zero reserve balance but no provider refs :( + // This shouldn't practically happen, but we need a failsafe anyway: let's give + // them enough for an ED. + a.free = a.free.min(T::ExistentialDeposit::get()); + system::Pallet::::inc_providers(who); + } + let _ = system::Pallet::::inc_consumers(who).defensive(); + } + // Should never fail - we're only setting a bit. + let _ = T::AccountStore::try_mutate_exists(who, |account| -> DispatchResult { + *account = Some(a); + Ok(()) + }); + Self::deposit_event(Event::Upgraded { who: who.clone() }); return true } - Self::free_balance(who) >= value - } - - fn total_issuance() -> Self::Balance { - TotalIssuance::::get() - } - - fn active_issuance() -> Self::Balance { - >::active_issuance() - } - - fn deactivate(amount: Self::Balance) { - >::deactivate(amount); - } - - fn reactivate(amount: Self::Balance) { - >::reactivate(amount); - } - fn minimum_balance() -> Self::Balance { - T::ExistentialDeposit::get() - } - - // Burn funds from the total issuance, returning a positive imbalance for the amount burned. - // Is a no-op if amount to be burned is zero. - fn burn(mut amount: Self::Balance) -> Self::PositiveImbalance { - if amount.is_zero() { - return PositiveImbalance::zero() + /// Get the free balance of an account. + pub fn free_balance(who: impl sp_std::borrow::Borrow) -> T::Balance { + Self::account(who.borrow()).free } - >::mutate(|issued| { - *issued = issued.checked_sub(&amount).unwrap_or_else(|| { - amount = *issued; - Zero::zero() - }); - }); - PositiveImbalance::new(amount) - } - // Create new funds into the total issuance, returning a negative imbalance - // for the amount issued. - // Is a no-op if amount to be issued it zero. - fn issue(mut amount: Self::Balance) -> Self::NegativeImbalance { - if amount.is_zero() { - return NegativeImbalance::zero() + /// Get the balance of an account that can be used for transfers, reservations, or any other + /// non-locking, non-transaction-fee activity. Will be at most `free_balance`. + pub fn usable_balance(who: impl sp_std::borrow::Borrow) -> T::Balance { + >::reducible_balance(who.borrow(), Expendable, Polite) } - >::mutate(|issued| { - *issued = issued.checked_add(&amount).unwrap_or_else(|| { - amount = Self::Balance::max_value() - *issued; - Self::Balance::max_value() - }) - }); - NegativeImbalance::new(amount) - } - - fn free_balance(who: &T::AccountId) -> Self::Balance { - Self::account(who).free - } - // Ensure that an account can withdraw from their free balance given any existing withdrawal - // restrictions like locks and vesting balance. - // Is a no-op if amount to be withdrawn is zero. - // - // ## Complexity - // Despite iterating over a list of locks, they are limited by the number of - // lock IDs, which means the number of runtime pallets that intend to use and create locks. - fn ensure_can_withdraw( - who: &T::AccountId, - amount: T::Balance, - reasons: WithdrawReasons, - new_balance: T::Balance, - ) -> DispatchResult { - if amount.is_zero() { - return Ok(()) + /// Get the balance of an account that can be used for paying transaction fees (not tipping, + /// or any other kind of fees, though). Will be at most `free_balance`. + /// + /// This requires that the account stays alive. + pub fn usable_balance_for_fees( + who: impl sp_std::borrow::Borrow, + ) -> T::Balance { + >::reducible_balance(who.borrow(), Protect, Polite) } - let min_balance = Self::account(who).frozen(reasons.into()); - ensure!(new_balance >= min_balance, Error::::LiquidityRestrictions); - Ok(()) - } - // Transfer some free balance from `transactor` to `dest`, respecting existence requirements. - // Is a no-op if value to be transferred is zero or the `transactor` is the same as `dest`. - fn transfer( - transactor: &T::AccountId, - dest: &T::AccountId, - value: Self::Balance, - existence_requirement: ExistenceRequirement, - ) -> DispatchResult { - if value.is_zero() || transactor == dest { - return Ok(()) + /// Get the reserved balance of an account. + pub fn reserved_balance(who: impl sp_std::borrow::Borrow) -> T::Balance { + Self::account(who.borrow()).reserved } - Self::try_mutate_account_with_dust( - dest, - |to_account, _| -> Result, DispatchError> { - Self::try_mutate_account_with_dust( - transactor, - |from_account, _| -> DispatchResult { - from_account.free = from_account - .free - .checked_sub(&value) - .ok_or(Error::::InsufficientBalance)?; - - // NOTE: total stake being stored in the same type means that this could - // never overflow but better to be safe than sorry. - to_account.free = - to_account.free.checked_add(&value).ok_or(ArithmeticError::Overflow)?; - - let ed = T::ExistentialDeposit::get(); - ensure!(to_account.total() >= ed, Error::::ExistentialDeposit); - - Self::ensure_can_withdraw( - transactor, - value, - WithdrawReasons::TRANSFER, - from_account.free, - ) - .map_err(|_| Error::::LiquidityRestrictions)?; - - // TODO: This is over-conservative. There may now be other providers, and - // this pallet may not even be a provider. - let allow_death = existence_requirement == ExistenceRequirement::AllowDeath; - let allow_death = - allow_death && system::Pallet::::can_dec_provider(transactor); - ensure!( - allow_death || from_account.total() >= ed, - Error::::KeepAlive - ); - - Ok(()) - }, - ) - .map(|(_, maybe_dust_cleaner)| maybe_dust_cleaner) - }, - )?; - - // Emit transfer event. - Self::deposit_event(Event::Transfer { - from: transactor.clone(), - to: dest.clone(), - amount: value, - }); - - Ok(()) - } - - /// Slash a target account `who`, returning the negative imbalance created and any left over - /// amount that could not be slashed. - /// - /// Is a no-op if `value` to be slashed is zero or the account does not exist. - /// - /// NOTE: `slash()` prefers free balance, but assumes that reserve balance can be drawn - /// from in extreme circumstances. `can_slash()` should be used prior to `slash()` to avoid - /// having to draw from reserved funds, however we err on the side of punishment if things are - /// inconsistent or `can_slash` wasn't used appropriately. - fn slash(who: &T::AccountId, value: Self::Balance) -> (Self::NegativeImbalance, Self::Balance) { - if value.is_zero() { - return (NegativeImbalance::zero(), Zero::zero()) - } - if Self::total_balance(who).is_zero() { - return (NegativeImbalance::zero(), value) + /// Get both the free and reserved balances of an account. + pub(crate) fn account(who: &T::AccountId) -> AccountData { + T::AccountStore::get(who) } - for attempt in 0..2 { - match Self::try_mutate_account( - who, - |account, - _is_new| - -> Result<(Self::NegativeImbalance, Self::Balance), DispatchError> { - // Best value is the most amount we can slash following liveness rules. - let best_value = match attempt { - // First attempt we try to slash the full amount, and see if liveness issues - // happen. - 0 => value, - // If acting as a critical provider (i.e. first attempt failed), then slash - // as much as possible while leaving at least at ED. - _ => value.min( - (account.free + account.reserved) - .saturating_sub(T::ExistentialDeposit::get()), - ), - }; - - let free_slash = cmp::min(account.free, best_value); - account.free -= free_slash; // Safe because of above check - let remaining_slash = best_value - free_slash; // Safe because of above check - - if !remaining_slash.is_zero() { - // If we have remaining slash, take it from reserved balance. - let reserved_slash = cmp::min(account.reserved, remaining_slash); - account.reserved -= reserved_slash; // Safe because of above check - Ok(( - NegativeImbalance::new(free_slash + reserved_slash), - value - free_slash - reserved_slash, /* Safe because value is gt or - * eq total slashed */ - )) - } else { - // Else we are done! - Ok(( - NegativeImbalance::new(free_slash), - value - free_slash, // Safe because value is gt or eq to total slashed - )) - } - }, - ) { - Ok((imbalance, not_slashed)) => { - Self::deposit_event(Event::Slashed { - who: who.clone(), - amount: value.saturating_sub(not_slashed), - }); - return (imbalance, not_slashed) - }, - Err(_) => (), + /// Mutate an account to some new value, or delete it entirely with `None`. Will enforce + /// `ExistentialDeposit` law, annulling the account as needed. + /// + /// It returns the result from the closure. Any dust is handled through the low-level + /// `fungible::Unbalanced` trap-door for legacy dust management. + /// + /// NOTE: Doesn't do any preparatory work for creating a new account, so should only be used + /// when it is known that the account already exists. + /// + /// NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that + /// the caller will do this. + pub(crate) fn mutate_account_handling_dust( + who: &T::AccountId, + f: impl FnOnce(&mut AccountData) -> R, + ) -> Result { + let (r, maybe_dust) = Self::mutate_account(who, f)?; + if let Some(dust) = maybe_dust { + >::handle_raw_dust(dust); } + Ok(r) } - // Should never get here. But we'll be defensive anyway. - (Self::NegativeImbalance::zero(), value) - } - - /// Deposit some `value` into the free balance of an existing target account `who`. - /// - /// Is a no-op if the `value` to be deposited is zero. - fn deposit_into_existing( - who: &T::AccountId, - value: Self::Balance, - ) -> Result { - if value.is_zero() { - return Ok(PositiveImbalance::zero()) - } - - Self::try_mutate_account( - who, - |account, is_new| -> Result { - ensure!(!is_new, Error::::DeadAccount); - account.free = account.free.checked_add(&value).ok_or(ArithmeticError::Overflow)?; - Self::deposit_event(Event::Deposit { who: who.clone(), amount: value }); - Ok(PositiveImbalance::new(value)) - }, - ) - } - - /// Deposit some `value` into the free balance of `who`, possibly creating a new account. - /// - /// This function is a no-op if: - /// - the `value` to be deposited is zero; or - /// - the `value` to be deposited is less than the required ED and the account does not yet - /// exist; or - /// - the deposit would necessitate the account to exist and there are no provider references; - /// or - /// - `value` is so large it would cause the balance of `who` to overflow. - fn deposit_creating(who: &T::AccountId, value: Self::Balance) -> Self::PositiveImbalance { - if value.is_zero() { - return Self::PositiveImbalance::zero() - } - - Self::try_mutate_account( - who, - |account, is_new| -> Result { - let ed = T::ExistentialDeposit::get(); - ensure!(value >= ed || !is_new, Error::::ExistentialDeposit); - - // defensive only: overflow should never happen, however in case it does, then this - // operation is a no-op. - account.free = match account.free.checked_add(&value) { - Some(x) => x, - None => return Ok(Self::PositiveImbalance::zero()), - }; - - Self::deposit_event(Event::Deposit { who: who.clone(), amount: value }); - Ok(PositiveImbalance::new(value)) - }, - ) - .unwrap_or_else(|_| Self::PositiveImbalance::zero()) - } - - /// Withdraw some free balance from an account, respecting existence requirements. - /// - /// Is a no-op if value to be withdrawn is zero. - fn withdraw( - who: &T::AccountId, - value: Self::Balance, - reasons: WithdrawReasons, - liveness: ExistenceRequirement, - ) -> result::Result { - if value.is_zero() { - return Ok(NegativeImbalance::zero()) + /// Mutate an account to some new value, or delete it entirely with `None`. Will enforce + /// `ExistentialDeposit` law, annulling the account as needed. + /// + /// It returns the result from the closure. Any dust is handled through the low-level + /// `fungible::Unbalanced` trap-door for legacy dust management. + /// + /// NOTE: Doesn't do any preparatory work for creating a new account, so should only be used + /// when it is known that the account already exists. + /// + /// NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that + /// the caller will do this. + pub(crate) fn try_mutate_account_handling_dust>( + who: &T::AccountId, + f: impl FnOnce(&mut AccountData, bool) -> Result, + ) -> Result { + let (r, maybe_dust) = Self::try_mutate_account(who, f)?; + if let Some(dust) = maybe_dust { + >::handle_raw_dust(dust); + } + Ok(r) } - Self::try_mutate_account( - who, - |account, _| -> Result { - let new_free_account = - account.free.checked_sub(&value).ok_or(Error::::InsufficientBalance)?; - - // bail if we need to keep the account alive and this would kill it. - let ed = T::ExistentialDeposit::get(); - let would_be_dead = new_free_account + account.reserved < ed; - let would_kill = would_be_dead && account.free + account.reserved >= ed; - ensure!(liveness == AllowDeath || !would_kill, Error::::KeepAlive); - - Self::ensure_can_withdraw(who, value, reasons, new_free_account)?; - - account.free = new_free_account; + /// Mutate an account to some new value, or delete it entirely with `None`. Will enforce + /// `ExistentialDeposit` law, annulling the account as needed. + /// + /// It returns both the result from the closure, and an optional amount of dust + /// which should be handled once it is known that all nested mutates that could affect + /// storage items what the dust handler touches have completed. + /// + /// NOTE: Doesn't do any preparatory work for creating a new account, so should only be used + /// when it is known that the account already exists. + /// + /// NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that + /// the caller will do this. + pub(crate) fn mutate_account( + who: &T::AccountId, + f: impl FnOnce(&mut AccountData) -> R, + ) -> Result<(R, Option), DispatchError> { + Self::try_mutate_account(who, |a, _| -> Result { Ok(f(a)) }) + } + + /// Mutate an account to some new value, or delete it entirely with `None`. Will enforce + /// `ExistentialDeposit` law, annulling the account as needed. This will do nothing if the + /// result of `f` is an `Err`. + /// + /// It returns both the result from the closure, and an optional amount of dust + /// which should be handled once it is known that all nested mutates that could affect + /// storage items what the dust handler touches have completed. + /// + /// NOTE: Doesn't do any preparatory work for creating a new account, so should only be used + /// when it is known that the account already exists. + /// + /// NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that + /// the caller will do this. + pub(crate) fn try_mutate_account>( + who: &T::AccountId, + f: impl FnOnce(&mut AccountData, bool) -> Result, + ) -> Result<(R, Option), E> { + Self::ensure_upgraded(who); + let result = T::AccountStore::try_mutate_exists(who, |maybe_account| { + let is_new = maybe_account.is_none(); + let mut account = maybe_account.take().unwrap_or_default(); + let did_provide = account.free >= T::ExistentialDeposit::get(); + let did_consume = + !is_new && (!account.reserved.is_zero() || !account.frozen.is_zero()); + + let result = f(&mut account, is_new)?; + + let does_provide = account.free >= T::ExistentialDeposit::get(); + let does_consume = !account.reserved.is_zero() || !account.frozen.is_zero(); + + if !did_provide && does_provide { + frame_system::Pallet::::inc_providers(who); + } + if did_consume && !does_consume { + frame_system::Pallet::::dec_consumers(who); + } + if !did_consume && does_consume { + frame_system::Pallet::::inc_consumers(who)?; + } + if did_provide && !does_provide { + // This could reap the account so must go last. + frame_system::Pallet::::dec_providers(who).map_err(|r| { + if did_consume && !does_consume { + // best-effort revert consumer change. + let _ = frame_system::Pallet::::inc_consumers(who).defensive(); + } + if !did_consume && does_consume { + let _ = frame_system::Pallet::::dec_consumers(who); + } + r + })?; + } - Self::deposit_event(Event::Withdraw { who: who.clone(), amount: value }); - Ok(NegativeImbalance::new(value)) - }, - ) - } + let maybe_endowed = if is_new { Some(account.free) } else { None }; - /// Force the new free balance of a target account `who` to some new value `balance`. - fn make_free_balance_be( - who: &T::AccountId, - value: Self::Balance, - ) -> SignedImbalance { - Self::try_mutate_account( - who, - |account, - is_new| - -> Result, DispatchError> { + // Handle any steps needed after mutating an account. + // + // This includes DustRemoval unbalancing, in the case than the `new` account's total + // balance is non-zero but below ED. + // + // Updates `maybe_account` to `Some` iff the account has sufficient balance. + // Evaluates `maybe_dust`, which is `Some` containing the dust to be dropped, iff + // some dust should be dropped. + // + // We should never be dropping if reserved is non-zero. Reserved being non-zero + // should imply that we have a consumer ref, so this is economically safe. let ed = T::ExistentialDeposit::get(); - let total = value.saturating_add(account.reserved); - // If we're attempting to set an existing account to less than ED, then - // bypass the entire operation. It's a no-op if you follow it through, but - // since this is an instance where we might account for a negative imbalance - // (in the dust cleaner of set_account) before we account for its actual - // equal and opposite cause (returned as an Imbalance), then in the - // instance that there's no other accounts on the system at all, we might - // underflow the issuance and our arithmetic will be off. - ensure!(total >= ed || !is_new, Error::::ExistentialDeposit); - - let imbalance = if account.free <= value { - SignedImbalance::Positive(PositiveImbalance::new(value - account.free)) + let maybe_dust = if account.free < ed && account.reserved.is_zero() { + if account.free.is_zero() { + None + } else { + Some(account.free) + } } else { - SignedImbalance::Negative(NegativeImbalance::new(account.free - value)) - }; - account.free = value; - Self::deposit_event(Event::BalanceSet { - who: who.clone(), - free: account.free, - reserved: account.reserved, - }); - Ok(imbalance) - }, - ) - .unwrap_or_else(|_| SignedImbalance::Positive(Self::PositiveImbalance::zero())) - } -} - -impl, I: 'static> ReservableCurrency for Pallet -where - T::Balance: MaybeSerializeDeserialize + Debug, -{ - /// Check if `who` can reserve `value` from their free balance. - /// - /// Always `true` if value to be reserved is zero. - fn can_reserve(who: &T::AccountId, value: Self::Balance) -> bool { - if value.is_zero() { - return true - } - Self::account(who).free.checked_sub(&value).map_or(false, |new_balance| { - Self::ensure_can_withdraw(who, value, WithdrawReasons::RESERVE, new_balance).is_ok() - }) - } - - fn reserved_balance(who: &T::AccountId) -> Self::Balance { - Self::account(who).reserved - } - - /// Move `value` from the free balance from `who` to their reserved balance. - /// - /// Is a no-op if value to be reserved is zero. - fn reserve(who: &T::AccountId, value: Self::Balance) -> DispatchResult { - if value.is_zero() { - return Ok(()) - } - - Self::try_mutate_account(who, |account, _| -> DispatchResult { - account.free = - account.free.checked_sub(&value).ok_or(Error::::InsufficientBalance)?; - account.reserved = - account.reserved.checked_add(&value).ok_or(ArithmeticError::Overflow)?; - Self::ensure_can_withdraw(&who, value, WithdrawReasons::RESERVE, account.free) - })?; - - Self::deposit_event(Event::Reserved { who: who.clone(), amount: value }); - Ok(()) - } - - /// Unreserve some funds, returning any amount that was unable to be unreserved. - /// - /// Is a no-op if the value to be unreserved is zero or the account does not exist. - /// - /// NOTE: returns amount value which wasn't successfully unreserved. - fn unreserve(who: &T::AccountId, value: Self::Balance) -> Self::Balance { - if value.is_zero() { - return Zero::zero() - } - if Self::total_balance(who).is_zero() { - return value - } - - let actual = match Self::mutate_account(who, |account| { - let actual = cmp::min(account.reserved, value); - account.reserved -= actual; - // defensive only: this can never fail since total issuance which is at least - // free+reserved fits into the same data type. - account.free = account.free.defensive_saturating_add(actual); - actual - }) { - Ok(x) => x, - Err(_) => { - // This should never happen since we don't alter the total amount in the account. - // If it ever does, then we should fail gracefully though, indicating that nothing - // could be done. - return value - }, - }; - - Self::deposit_event(Event::Unreserved { who: who.clone(), amount: actual }); - value - actual - } - - /// Slash from reserved balance, returning the negative imbalance created, - /// and any amount that was unable to be slashed. - /// - /// Is a no-op if the value to be slashed is zero or the account does not exist. - fn slash_reserved( - who: &T::AccountId, - value: Self::Balance, - ) -> (Self::NegativeImbalance, Self::Balance) { - if value.is_zero() { - return (NegativeImbalance::zero(), Zero::zero()) - } - if Self::total_balance(who).is_zero() { - return (NegativeImbalance::zero(), value) - } - - // NOTE: `mutate_account` may fail if it attempts to reduce the balance to the point that an - // account is attempted to be illegally destroyed. - - for attempt in 0..2 { - match Self::mutate_account(who, |account| { - let best_value = match attempt { - 0 => value, - // If acting as a critical provider (i.e. first attempt failed), then ensure - // slash leaves at least the ED. - _ => value.min( - (account.free + account.reserved) - .saturating_sub(T::ExistentialDeposit::get()), - ), + assert!( + account.free.is_zero() || account.free >= ed || !account.reserved.is_zero() + ); + *maybe_account = Some(account); + None }; - - let actual = cmp::min(account.reserved, best_value); - account.reserved -= actual; - - // underflow should never happen, but it if does, there's nothing to be done here. - (NegativeImbalance::new(actual), value - actual) - }) { - Ok((imbalance, not_slashed)) => { - Self::deposit_event(Event::Slashed { - who: who.clone(), - amount: value.saturating_sub(not_slashed), + Ok((maybe_endowed, maybe_dust, result)) + }); + result.map(|(maybe_endowed, maybe_dust, result)| { + if let Some(endowed) = maybe_endowed { + Self::deposit_event(Event::Endowed { + account: who.clone(), + free_balance: endowed, }); - return (imbalance, not_slashed) - }, - Err(_) => (), - } - } - // Should never get here as we ensure that ED is left in the second attempt. - // In case we do, though, then we fail gracefully. - (Self::NegativeImbalance::zero(), value) - } - - /// Move the reserved balance of one account into the balance of another, according to `status`. - /// - /// Is a no-op if: - /// - the value to be moved is zero; or - /// - the `slashed` id equal to `beneficiary` and the `status` is `Reserved`. - fn repatriate_reserved( - slashed: &T::AccountId, - beneficiary: &T::AccountId, - value: Self::Balance, - status: Status, - ) -> Result { - let actual = Self::do_transfer_reserved(slashed, beneficiary, value, true, status)?; - Ok(value.saturating_sub(actual)) - } -} - -impl, I: 'static> NamedReservableCurrency for Pallet -where - T::Balance: MaybeSerializeDeserialize + Debug, -{ - type ReserveIdentifier = T::ReserveIdentifier; - - fn reserved_balance_named(id: &Self::ReserveIdentifier, who: &T::AccountId) -> Self::Balance { - let reserves = Self::reserves(who); - reserves - .binary_search_by_key(id, |data| data.id) - .map(|index| reserves[index].amount) - .unwrap_or_default() - } - - /// Move `value` from the free balance from `who` to a named reserve balance. - /// - /// Is a no-op if value to be reserved is zero. - fn reserve_named( - id: &Self::ReserveIdentifier, - who: &T::AccountId, - value: Self::Balance, - ) -> DispatchResult { - if value.is_zero() { - return Ok(()) - } - - Reserves::::try_mutate(who, |reserves| -> DispatchResult { - match reserves.binary_search_by_key(id, |data| data.id) { - Ok(index) => { - // this add can't overflow but just to be defensive. - reserves[index].amount = reserves[index].amount.defensive_saturating_add(value); - }, - Err(index) => { - reserves - .try_insert(index, ReserveData { id: *id, amount: value }) - .map_err(|_| Error::::TooManyReserves)?; - }, - }; - >::reserve(who, value)?; - Ok(()) - }) - } - - /// Unreserve some funds, returning any amount that was unable to be unreserved. - /// - /// Is a no-op if the value to be unreserved is zero. - fn unreserve_named( - id: &Self::ReserveIdentifier, - who: &T::AccountId, - value: Self::Balance, - ) -> Self::Balance { - if value.is_zero() { - return Zero::zero() + } + if let Some(amount) = maybe_dust { + Pallet::::deposit_event(Event::DustLost { account: who.clone(), amount }); + } + (result, maybe_dust) + }) } - Reserves::::mutate_exists(who, |maybe_reserves| -> Self::Balance { - if let Some(reserves) = maybe_reserves.as_mut() { - match reserves.binary_search_by_key(id, |data| data.id) { - Ok(index) => { - let to_change = cmp::min(reserves[index].amount, value); - - let remain = >::unreserve(who, to_change); - - // remain should always be zero but just to be defensive here. - let actual = to_change.defensive_saturating_sub(remain); - - // `actual <= to_change` and `to_change <= amount`; qed; - reserves[index].amount -= actual; + /// Update the account entry for `who`, given the locks. + pub(crate) fn update_locks(who: &T::AccountId, locks: &[BalanceLock]) { + let bounded_locks = WeakBoundedVec::<_, T::MaxLocks>::force_from( + locks.to_vec(), + Some("Balances Update Locks"), + ); - if reserves[index].amount.is_zero() { - if reserves.len() == 1 { - // no more named reserves - *maybe_reserves = None; - } else { - // remove this named reserve - reserves.remove(index); - } - } + if locks.len() as u32 > T::MaxLocks::get() { + log::warn!( + target: LOG_TARGET, + "Warning: A user has more currency locks than expected. \ + A runtime configuration adjustment may be needed." + ); + } + let freezes = Freezes::::get(who); + // TODO: Revisit this assumption. We no manipulate consumer/provider refs. + // No way this can fail since we do not alter the existential balances. + let res = Self::mutate_account(who, |b| { + b.frozen = Zero::zero(); + for l in locks.iter() { + b.frozen = b.frozen.max(l.amount); + } + for l in freezes.iter() { + b.frozen = b.frozen.max(l.amount); + } + }); + debug_assert!(res.is_ok()); + if let Ok((_, maybe_dust)) = res { + debug_assert!(maybe_dust.is_none(), "Not altering main balance; qed"); + } - value - actual - }, - Err(_) => value, + let existed = Locks::::contains_key(who); + if locks.is_empty() { + Locks::::remove(who); + if existed { + // TODO: use Locks::::hashed_key + // https://github.com/paritytech/substrate/issues/4969 + system::Pallet::::dec_consumers(who); } } else { - value + Locks::::insert(who, bounded_locks); + if !existed && system::Pallet::::inc_consumers_without_limit(who).is_err() { + // No providers for the locks. This is impossible under normal circumstances + // since the funds that are under the lock will themselves be stored in the + // account and therefore will need a reference. + log::warn!( + target: LOG_TARGET, + "Warning: Attempt to introduce lock consumer reference, yet no providers. \ + This is unexpected but should be safe." + ); + } } - }) - } - - /// Slash from reserved balance, returning the negative imbalance created, - /// and any amount that was unable to be slashed. - /// - /// Is a no-op if the value to be slashed is zero. - fn slash_reserved_named( - id: &Self::ReserveIdentifier, - who: &T::AccountId, - value: Self::Balance, - ) -> (Self::NegativeImbalance, Self::Balance) { - if value.is_zero() { - return (NegativeImbalance::zero(), Zero::zero()) } - Reserves::::mutate(who, |reserves| -> (Self::NegativeImbalance, Self::Balance) { - match reserves.binary_search_by_key(id, |data| data.id) { - Ok(index) => { - let to_change = cmp::min(reserves[index].amount, value); - - let (imb, remain) = - >::slash_reserved(who, to_change); - - // remain should always be zero but just to be defensive here. - let actual = to_change.defensive_saturating_sub(remain); - - // `actual <= to_change` and `to_change <= amount`; qed; - reserves[index].amount -= actual; - - Self::deposit_event(Event::Slashed { who: who.clone(), amount: actual }); - (imb, value - actual) - }, - Err(_) => (NegativeImbalance::zero(), value), + /// Update the account entry for `who`, given the locks. + pub(crate) fn update_freezes( + who: &T::AccountId, + freezes: BoundedSlice, T::MaxFreezes>, + ) -> DispatchResult { + let (_, maybe_dust) = Self::mutate_account(who, |b| { + b.frozen = Zero::zero(); + for l in Locks::::get(who).iter() { + b.frozen = b.frozen.max(l.amount); + } + for l in freezes.iter() { + b.frozen = b.frozen.max(l.amount); + } + })?; + debug_assert!(maybe_dust.is_none(), "Not altering main balance; qed"); + if freezes.is_empty() { + Freezes::::remove(who); + } else { + Freezes::::insert(who, freezes); } - }) - } - - /// Move the reserved balance of one account into the balance of another, according to `status`. - /// If `status` is `Reserved`, the balance will be reserved with given `id`. - /// - /// Is a no-op if: - /// - the value to be moved is zero; or - /// - the `slashed` id equal to `beneficiary` and the `status` is `Reserved`. - fn repatriate_reserved_named( - id: &Self::ReserveIdentifier, - slashed: &T::AccountId, - beneficiary: &T::AccountId, - value: Self::Balance, - status: Status, - ) -> Result { - if value.is_zero() { - return Ok(Zero::zero()) + Ok(()) } - if slashed == beneficiary { - return match status { - Status::Free => Ok(Self::unreserve_named(id, slashed, value)), - Status::Reserved => - Ok(value.saturating_sub(Self::reserved_balance_named(id, slashed))), + /// Move the reserved balance of one account into the balance of another, according to + /// `status`. + /// + /// Is a no-op if: + /// - the value to be moved is zero; or + /// - the `slashed` id equal to `beneficiary` and the `status` is `Reserved`. + /// + /// NOTE: returns actual amount of transferred value in `Ok` case. + pub(crate) fn do_transfer_reserved( + slashed: &T::AccountId, + beneficiary: &T::AccountId, + value: T::Balance, + best_effort: bool, + status: Status, + ) -> Result { + if value.is_zero() { + return Ok(Zero::zero()) } - } - - Reserves::::try_mutate(slashed, |reserves| -> Result { - match reserves.binary_search_by_key(id, |data| data.id) { - Ok(index) => { - let to_change = cmp::min(reserves[index].amount, value); - - let actual = if status == Status::Reserved { - // make it the reserved under same identifier - Reserves::::try_mutate( - beneficiary, - |reserves| -> Result { - match reserves.binary_search_by_key(id, |data| data.id) { - Ok(index) => { - let remain = - >::repatriate_reserved( - slashed, - beneficiary, - to_change, - status, - )?; - - // remain should always be zero but just to be defensive - // here. - let actual = to_change.defensive_saturating_sub(remain); - - // this add can't overflow but just to be defensive. - reserves[index].amount = - reserves[index].amount.defensive_saturating_add(actual); - - Ok(actual) - }, - Err(index) => { - let remain = - >::repatriate_reserved( - slashed, - beneficiary, - to_change, - status, - )?; - - // remain should always be zero but just to be defensive - // here - let actual = to_change.defensive_saturating_sub(remain); - - reserves - .try_insert( - index, - ReserveData { id: *id, amount: actual }, - ) - .map_err(|_| Error::::TooManyReserves)?; - - Ok(actual) - }, - } - }, - )? - } else { - let remain = >::repatriate_reserved( - slashed, - beneficiary, - to_change, - status, - )?; - - // remain should always be zero but just to be defensive here - to_change.defensive_saturating_sub(remain) - }; - // `actual <= to_change` and `to_change <= amount`; qed; - reserves[index].amount -= actual; + if slashed == beneficiary { + return match status { + Status::Free => Ok(value.saturating_sub(Self::unreserve(slashed, value))), + Status::Reserved => Ok(value.saturating_sub(Self::reserved_balance(slashed))), + } + } - Ok(value - actual) + let ((actual, maybe_dust_1), maybe_dust_2) = Self::try_mutate_account( + beneficiary, + |to_account, is_new| -> Result<(T::Balance, Option), DispatchError> { + ensure!(!is_new, Error::::DeadAccount); + Self::try_mutate_account( + slashed, + |from_account, _| -> Result { + let actual = cmp::min(from_account.reserved, value); + ensure!( + best_effort || actual == value, + Error::::InsufficientBalance + ); + match status { + Status::Free => + to_account.free = to_account + .free + .checked_add(&actual) + .ok_or(ArithmeticError::Overflow)?, + Status::Reserved => + to_account.reserved = to_account + .reserved + .checked_add(&actual) + .ok_or(ArithmeticError::Overflow)?, + } + from_account.reserved -= actual; + Ok(actual) + }, + ) }, - Err(_) => Ok(value), - } - }) - } -} + )?; -impl, I: 'static> LockableCurrency for Pallet -where - T::Balance: MaybeSerializeDeserialize + Debug, -{ - type Moment = T::BlockNumber; - - type MaxLocks = T::MaxLocks; - - // Set a lock on the balance of `who`. - // Is a no-op if lock amount is zero or `reasons` `is_none()`. - fn set_lock( - id: LockIdentifier, - who: &T::AccountId, - amount: T::Balance, - reasons: WithdrawReasons, - ) { - if amount.is_zero() || reasons.is_empty() { - return - } - let mut new_lock = Some(BalanceLock { id, amount, reasons: reasons.into() }); - let mut locks = Self::locks(who) - .into_iter() - .filter_map(|l| if l.id == id { new_lock.take() } else { Some(l) }) - .collect::>(); - if let Some(lock) = new_lock { - locks.push(lock) - } - Self::update_locks(who, &locks[..]); - } + if let Some(dust) = maybe_dust_1 { + >::handle_raw_dust(dust); + } + if let Some(dust) = maybe_dust_2 { + >::handle_raw_dust(dust); + } - // Extend a lock on the balance of `who`. - // Is a no-op if lock amount is zero or `reasons` `is_none()`. - fn extend_lock( - id: LockIdentifier, - who: &T::AccountId, - amount: T::Balance, - reasons: WithdrawReasons, - ) { - if amount.is_zero() || reasons.is_empty() { - return - } - let mut new_lock = Some(BalanceLock { id, amount, reasons: reasons.into() }); - let mut locks = Self::locks(who) - .into_iter() - .filter_map(|l| { - if l.id == id { - new_lock.take().map(|nl| BalanceLock { - id: l.id, - amount: l.amount.max(nl.amount), - reasons: l.reasons | nl.reasons, - }) - } else { - Some(l) - } - }) - .collect::>(); - if let Some(lock) = new_lock { - locks.push(lock) + Self::deposit_event(Event::ReserveRepatriated { + from: slashed.clone(), + to: beneficiary.clone(), + amount: actual, + destination_status: status, + }); + Ok(actual) } - Self::update_locks(who, &locks[..]); - } - - fn remove_lock(id: LockIdentifier, who: &T::AccountId) { - let mut locks = Self::locks(who); - locks.retain(|l| l.id != id); - Self::update_locks(who, &locks[..]); } } diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs deleted file mode 100644 index b4233a6c3a85c..0000000000000 --- a/frame/balances/src/tests.rs +++ /dev/null @@ -1,1460 +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. - -//! Macro for creating the tests for the module. - -#![cfg(test)] - -#[macro_export] -macro_rules! decl_tests { - ($test:ty, $ext_builder:ty, $existential_deposit:expr) => { - - use crate::*; - use sp_runtime::{ArithmeticError, TokenError, FixedPointNumber, traits::{SignedExtension, BadOrigin}}; - use frame_support::{ - assert_noop, assert_storage_noop, assert_ok, assert_err, - traits::{ - LockableCurrency, LockIdentifier, WithdrawReasons, - Currency, ReservableCurrency, ExistenceRequirement::AllowDeath - } - }; - use pallet_transaction_payment::{ChargeTransactionPayment, Multiplier}; - use frame_system::RawOrigin; - - const ID_1: LockIdentifier = *b"1 "; - const ID_2: LockIdentifier = *b"2 "; - - pub const CALL: &<$test as frame_system::Config>::RuntimeCall = - &RuntimeCall::Balances(pallet_balances::Call::transfer { dest: 0, value: 0 }); - - /// create a transaction info struct from weight. Handy to avoid building the whole struct. - pub fn info_from_weight(w: Weight) -> DispatchInfo { - DispatchInfo { weight: w, ..Default::default() } - } - - fn events() -> Vec { - let evt = System::events().into_iter().map(|evt| evt.event).collect::>(); - - System::reset_events(); - - evt - } - - #[test] - fn basic_locking_should_work() { - <$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| { - assert_eq!(Balances::free_balance(1), 10); - Balances::set_lock(ID_1, &1, 9, WithdrawReasons::all()); - assert_noop!( - >::transfer(&1, &2, 5, AllowDeath), - Error::<$test, _>::LiquidityRestrictions - ); - }); - } - - #[test] - fn account_should_be_reaped() { - <$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| { - assert_eq!(Balances::free_balance(1), 10); - assert_ok!(>::transfer(&1, &2, 10, AllowDeath)); - // Check that the account is dead. - assert!(!frame_system::Account::::contains_key(&1)); - }); - } - - #[test] - fn reap_failed_due_to_provider_and_consumer() { - <$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| { - // SCENARIO: only one provider and there are remaining consumers. - assert_ok!(System::inc_consumers(&1)); - assert!(!System::can_dec_provider(&1)); - assert_noop!( - >::transfer(&1, &2, 10, AllowDeath), - Error::<$test, _>::KeepAlive - ); - assert!(System::account_exists(&1)); - assert_eq!(Balances::free_balance(1), 10); - - // SCENARIO: more than one provider, but will not kill account due to other provider. - assert_eq!(System::inc_providers(&1), frame_system::IncRefStatus::Existed); - assert_eq!(System::providers(&1), 2); - assert!(System::can_dec_provider(&1)); - assert_ok!(>::transfer(&1, &2, 10, AllowDeath)); - assert_eq!(System::providers(&1), 1); - assert!(System::account_exists(&1)); - assert_eq!(Balances::free_balance(1), 0); - }); - } - - #[test] - fn partial_locking_should_work() { - <$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| { - Balances::set_lock(ID_1, &1, 5, WithdrawReasons::all()); - assert_ok!(>::transfer(&1, &2, 1, AllowDeath)); - }); - } - - #[test] - fn lock_removal_should_work() { - <$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| { - Balances::set_lock(ID_1, &1, u64::MAX, WithdrawReasons::all()); - Balances::remove_lock(ID_1, &1); - assert_ok!(>::transfer(&1, &2, 1, AllowDeath)); - }); - } - - #[test] - fn lock_replacement_should_work() { - <$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| { - Balances::set_lock(ID_1, &1, u64::MAX, WithdrawReasons::all()); - Balances::set_lock(ID_1, &1, 5, WithdrawReasons::all()); - assert_ok!(>::transfer(&1, &2, 1, AllowDeath)); - }); - } - - #[test] - fn double_locking_should_work() { - <$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| { - Balances::set_lock(ID_1, &1, 5, WithdrawReasons::all()); - Balances::set_lock(ID_2, &1, 5, WithdrawReasons::all()); - assert_ok!(>::transfer(&1, &2, 1, AllowDeath)); - }); - } - - #[test] - fn combination_locking_should_work() { - <$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| { - Balances::set_lock(ID_1, &1, u64::MAX, WithdrawReasons::empty()); - Balances::set_lock(ID_2, &1, 0, WithdrawReasons::all()); - assert_ok!(>::transfer(&1, &2, 1, AllowDeath)); - }); - } - - #[test] - fn lock_value_extension_should_work() { - <$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| { - Balances::set_lock(ID_1, &1, 5, WithdrawReasons::all()); - assert_noop!( - >::transfer(&1, &2, 6, AllowDeath), - Error::<$test, _>::LiquidityRestrictions - ); - Balances::extend_lock(ID_1, &1, 2, WithdrawReasons::all()); - assert_noop!( - >::transfer(&1, &2, 6, AllowDeath), - Error::<$test, _>::LiquidityRestrictions - ); - Balances::extend_lock(ID_1, &1, 8, WithdrawReasons::all()); - assert_noop!( - >::transfer(&1, &2, 3, AllowDeath), - Error::<$test, _>::LiquidityRestrictions - ); - }); - } - - #[test] - fn lock_reasons_should_work() { - <$ext_builder>::default() - .existential_deposit(1) - .monied(true) - .build() - .execute_with(|| { - pallet_transaction_payment::NextFeeMultiplier::<$test>::put( - Multiplier::saturating_from_integer(1) - ); - Balances::set_lock(ID_1, &1, 10, WithdrawReasons::RESERVE); - assert_noop!( - >::transfer(&1, &2, 1, AllowDeath), - Error::<$test, _>::LiquidityRestrictions - ); - assert_noop!( - >::reserve(&1, 1), - Error::<$test, _>::LiquidityRestrictions, - ); - assert!( as SignedExtension>::pre_dispatch( - ChargeTransactionPayment::from(1), - &1, - CALL, - &info_from_weight(Weight::from_parts(1, 0)), - 1, - ).is_err()); - assert_ok!( as SignedExtension>::pre_dispatch( - ChargeTransactionPayment::from(0), - &1, - CALL, - &info_from_weight(Weight::from_parts(1, 0)), - 1, - )); - - Balances::set_lock(ID_1, &1, 10, WithdrawReasons::TRANSACTION_PAYMENT); - assert_ok!(>::transfer(&1, &2, 1, AllowDeath)); - assert_ok!(>::reserve(&1, 1)); - assert!( as SignedExtension>::pre_dispatch( - ChargeTransactionPayment::from(1), - &1, - CALL, - &info_from_weight(Weight::from_parts(1, 0)), - 1, - ).is_err()); - assert!( as SignedExtension>::pre_dispatch( - ChargeTransactionPayment::from(0), - &1, - CALL, - &info_from_weight(Weight::from_parts(1, 0)), - 1, - ).is_err()); - }); - } - - #[test] - fn lock_block_number_extension_should_work() { - <$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| { - Balances::set_lock(ID_1, &1, 10, WithdrawReasons::all()); - assert_noop!( - >::transfer(&1, &2, 6, AllowDeath), - Error::<$test, _>::LiquidityRestrictions - ); - Balances::extend_lock(ID_1, &1, 10, WithdrawReasons::all()); - assert_noop!( - >::transfer(&1, &2, 6, AllowDeath), - Error::<$test, _>::LiquidityRestrictions - ); - System::set_block_number(2); - Balances::extend_lock(ID_1, &1, 10, WithdrawReasons::all()); - assert_noop!( - >::transfer(&1, &2, 3, AllowDeath), - Error::<$test, _>::LiquidityRestrictions - ); - }); - } - - #[test] - fn lock_reasons_extension_should_work() { - <$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| { - Balances::set_lock(ID_1, &1, 10, WithdrawReasons::TRANSFER); - assert_noop!( - >::transfer(&1, &2, 6, AllowDeath), - Error::<$test, _>::LiquidityRestrictions - ); - Balances::extend_lock(ID_1, &1, 10, WithdrawReasons::empty()); - assert_noop!( - >::transfer(&1, &2, 6, AllowDeath), - Error::<$test, _>::LiquidityRestrictions - ); - Balances::extend_lock(ID_1, &1, 10, WithdrawReasons::RESERVE); - assert_noop!( - >::transfer(&1, &2, 6, AllowDeath), - Error::<$test, _>::LiquidityRestrictions - ); - }); - } - - #[test] - fn default_indexing_on_new_accounts_should_not_work2() { - <$ext_builder>::default() - .existential_deposit(10) - .monied(true) - .build() - .execute_with(|| { - // account 5 should not exist - // ext_deposit is 10, value is 9, not satisfies for ext_deposit - assert_noop!( - Balances::transfer(Some(1).into(), 5, 9), - Error::<$test, _>::ExistentialDeposit, - ); - assert_eq!(Balances::free_balance(1), 100); - }); - } - - #[test] - fn reserved_balance_should_prevent_reclaim_count() { - <$ext_builder>::default() - .existential_deposit(256 * 1) - .monied(true) - .build() - .execute_with(|| { - System::inc_account_nonce(&2); - assert_eq!(Balances::total_balance(&2), 256 * 20); - - assert_ok!(Balances::reserve(&2, 256 * 19 + 1)); // account 2 becomes mostly reserved - assert_eq!(Balances::free_balance(2), 255); // "free" account deleted." - assert_eq!(Balances::total_balance(&2), 256 * 20); // reserve still exists. - assert_eq!(System::account_nonce(&2), 1); - - // account 4 tries to take index 1 for account 5. - assert_ok!(Balances::transfer(Some(4).into(), 5, 256 * 1 + 0x69)); - assert_eq!(Balances::total_balance(&5), 256 * 1 + 0x69); - - assert!(Balances::slash(&2, 256 * 19 + 2).1.is_zero()); // account 2 gets slashed - // "reserve" account reduced to 255 (below ED) so account deleted - assert_eq!(Balances::total_balance(&2), 0); - assert_eq!(System::account_nonce(&2), 0); // nonce zero - - // account 4 tries to take index 1 again for account 6. - assert_ok!(Balances::transfer(Some(4).into(), 6, 256 * 1 + 0x69)); - assert_eq!(Balances::total_balance(&6), 256 * 1 + 0x69); - }); - } - - #[test] - fn reward_should_work() { - <$ext_builder>::default().monied(true).build().execute_with(|| { - assert_eq!(Balances::total_balance(&1), 10); - assert_ok!(Balances::deposit_into_existing(&1, 10).map(drop)); - System::assert_last_event(RuntimeEvent::Balances(crate::Event::Deposit { who: 1, amount: 10 })); - assert_eq!(Balances::total_balance(&1), 20); - assert_eq!(>::get(), 120); - }); - } - - #[test] - fn dust_account_removal_should_work() { - <$ext_builder>::default() - .existential_deposit(100) - .monied(true) - .build() - .execute_with(|| { - System::inc_account_nonce(&2); - assert_eq!(System::account_nonce(&2), 1); - assert_eq!(Balances::total_balance(&2), 2000); - // index 1 (account 2) becomes zombie - assert_ok!(Balances::transfer(Some(2).into(), 5, 1901)); - assert_eq!(Balances::total_balance(&2), 0); - assert_eq!(Balances::total_balance(&5), 1901); - assert_eq!(System::account_nonce(&2), 0); - }); - } - - #[test] - fn balance_works() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 42); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { who: 1, amount: 42 })); - assert_eq!(Balances::free_balance(1), 42); - assert_eq!(Balances::reserved_balance(1), 0); - assert_eq!(Balances::total_balance(&1), 42); - assert_eq!(Balances::free_balance(2), 0); - assert_eq!(Balances::reserved_balance(2), 0); - assert_eq!(Balances::total_balance(&2), 0); - }); - } - - #[test] - fn balance_transfer_works() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - assert_ok!(Balances::transfer(Some(1).into(), 2, 69)); - assert_eq!(Balances::total_balance(&1), 42); - assert_eq!(Balances::total_balance(&2), 69); - }); - } - - #[test] - fn force_transfer_works() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - assert_noop!( - Balances::force_transfer(Some(2).into(), 1, 2, 69), - BadOrigin, - ); - assert_ok!(Balances::force_transfer(RawOrigin::Root.into(), 1, 2, 69)); - assert_eq!(Balances::total_balance(&1), 42); - assert_eq!(Balances::total_balance(&2), 69); - }); - } - - #[test] - fn reserving_balance_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - - assert_eq!(Balances::total_balance(&1), 111); - assert_eq!(Balances::free_balance(1), 111); - assert_eq!(Balances::reserved_balance(1), 0); - - assert_ok!(Balances::reserve(&1, 69)); - - assert_eq!(Balances::total_balance(&1), 111); - assert_eq!(Balances::free_balance(1), 42); - assert_eq!(Balances::reserved_balance(1), 69); - }); - } - - #[test] - fn balance_transfer_when_reserved_should_not_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - assert_ok!(Balances::reserve(&1, 69)); - assert_noop!( - Balances::transfer(Some(1).into(), 2, 69), - Error::<$test, _>::InsufficientBalance, - ); - }); - } - - #[test] - fn deducting_balance_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - assert_ok!(Balances::reserve(&1, 69)); - assert_eq!(Balances::free_balance(1), 42); - }); - } - - #[test] - fn refunding_balance_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 42); - assert_ok!(Balances::mutate_account(&1, |a| a.reserved = 69)); - Balances::unreserve(&1, 69); - assert_eq!(Balances::free_balance(1), 111); - assert_eq!(Balances::reserved_balance(1), 0); - }); - } - - #[test] - fn slashing_balance_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - assert_ok!(Balances::reserve(&1, 69)); - assert!(Balances::slash(&1, 69).1.is_zero()); - assert_eq!(Balances::free_balance(1), 0); - assert_eq!(Balances::reserved_balance(1), 42); - assert_eq!(>::get(), 42); - }); - } - - #[test] - fn withdrawing_balance_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&2, 111); - let _ = Balances::withdraw( - &2, 11, WithdrawReasons::TRANSFER, ExistenceRequirement::KeepAlive - ); - System::assert_last_event(RuntimeEvent::Balances(crate::Event::Withdraw { who: 2, amount: 11 })); - assert_eq!(Balances::free_balance(2), 100); - assert_eq!(>::get(), 100); - }); - } - - #[test] - fn slashing_incomplete_balance_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 42); - assert_ok!(Balances::reserve(&1, 21)); - assert_eq!(Balances::slash(&1, 69).1, 27); - assert_eq!(Balances::free_balance(1), 0); - assert_eq!(Balances::reserved_balance(1), 0); - assert_eq!(>::get(), 0); - }); - } - - #[test] - fn unreserving_balance_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - assert_ok!(Balances::reserve(&1, 111)); - Balances::unreserve(&1, 42); - assert_eq!(Balances::reserved_balance(1), 69); - assert_eq!(Balances::free_balance(1), 42); - }); - } - - #[test] - fn slashing_reserved_balance_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - assert_ok!(Balances::reserve(&1, 111)); - assert_eq!(Balances::slash_reserved(&1, 42).1, 0); - assert_eq!(Balances::reserved_balance(1), 69); - assert_eq!(Balances::free_balance(1), 0); - assert_eq!(>::get(), 69); - }); - } - - #[test] - fn slashing_incomplete_reserved_balance_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - assert_ok!(Balances::reserve(&1, 42)); - assert_eq!(Balances::slash_reserved(&1, 69).1, 27); - assert_eq!(Balances::free_balance(1), 69); - assert_eq!(Balances::reserved_balance(1), 0); - assert_eq!(>::get(), 69); - }); - } - - #[test] - fn repatriating_reserved_balance_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 110); - let _ = Balances::deposit_creating(&2, 1); - assert_ok!(Balances::reserve(&1, 110)); - assert_ok!(Balances::repatriate_reserved(&1, &2, 41, Status::Free), 0); - System::assert_last_event( - RuntimeEvent::Balances(crate::Event::ReserveRepatriated { from: 1, to: 2, amount: 41, destination_status: Status::Free }) - ); - assert_eq!(Balances::reserved_balance(1), 69); - assert_eq!(Balances::free_balance(1), 0); - assert_eq!(Balances::reserved_balance(2), 0); - assert_eq!(Balances::free_balance(2), 42); - }); - } - - #[test] - fn transferring_reserved_balance_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 110); - let _ = Balances::deposit_creating(&2, 1); - assert_ok!(Balances::reserve(&1, 110)); - assert_ok!(Balances::repatriate_reserved(&1, &2, 41, Status::Reserved), 0); - assert_eq!(Balances::reserved_balance(1), 69); - assert_eq!(Balances::free_balance(1), 0); - assert_eq!(Balances::reserved_balance(2), 41); - assert_eq!(Balances::free_balance(2), 1); - }); - } - - #[test] - fn transferring_reserved_balance_to_yourself_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 110); - assert_ok!(Balances::reserve(&1, 50)); - assert_ok!(Balances::repatriate_reserved(&1, &1, 50, Status::Free), 0); - assert_eq!(Balances::free_balance(1), 110); - assert_eq!(Balances::reserved_balance(1), 0); - - assert_ok!(Balances::reserve(&1, 50)); - assert_ok!(Balances::repatriate_reserved(&1, &1, 60, Status::Free), 10); - assert_eq!(Balances::free_balance(1), 110); - assert_eq!(Balances::reserved_balance(1), 0); - }); - } - - #[test] - fn transferring_reserved_balance_to_nonexistent_should_fail() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - assert_ok!(Balances::reserve(&1, 111)); - assert_noop!(Balances::repatriate_reserved(&1, &2, 42, Status::Free), Error::<$test, _>::DeadAccount); - }); - } - - #[test] - fn transferring_incomplete_reserved_balance_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 110); - let _ = Balances::deposit_creating(&2, 1); - assert_ok!(Balances::reserve(&1, 41)); - assert_ok!(Balances::repatriate_reserved(&1, &2, 69, Status::Free), 28); - assert_eq!(Balances::reserved_balance(1), 0); - assert_eq!(Balances::free_balance(1), 69); - assert_eq!(Balances::reserved_balance(2), 0); - assert_eq!(Balances::free_balance(2), 42); - }); - } - - #[test] - fn transferring_too_high_value_should_not_panic() { - <$ext_builder>::default().build().execute_with(|| { - Balances::make_free_balance_be(&1, u64::MAX); - Balances::make_free_balance_be(&2, 1); - - assert_err!( - Balances::transfer(Some(1).into(), 2, u64::MAX), - ArithmeticError::Overflow, - ); - - assert_eq!(Balances::free_balance(1), u64::MAX); - assert_eq!(Balances::free_balance(2), 1); - }); - } - - #[test] - fn account_create_on_free_too_low_with_other() { - <$ext_builder>::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 100); - assert_eq!(>::get(), 100); - - // No-op. - let _ = Balances::deposit_creating(&2, 50); - assert_eq!(Balances::free_balance(2), 0); - assert_eq!(>::get(), 100); - }) - } - - #[test] - fn account_create_on_free_too_low() { - <$ext_builder>::default().existential_deposit(100).build().execute_with(|| { - // No-op. - let _ = Balances::deposit_creating(&2, 50); - assert_eq!(Balances::free_balance(2), 0); - assert_eq!(>::get(), 0); - }) - } - - #[test] - fn account_removal_on_free_too_low() { - <$ext_builder>::default().existential_deposit(100).build().execute_with(|| { - assert_eq!(>::get(), 0); - - // Setup two accounts with free balance above the existential threshold. - let _ = Balances::deposit_creating(&1, 110); - let _ = Balances::deposit_creating(&2, 110); - - assert_eq!(Balances::free_balance(1), 110); - assert_eq!(Balances::free_balance(2), 110); - assert_eq!(>::get(), 220); - - // Transfer funds from account 1 of such amount that after this transfer - // the balance of account 1 will be below the existential threshold. - // This should lead to the removal of all balance of this account. - assert_ok!(Balances::transfer(Some(1).into(), 2, 20)); - - // Verify free balance removal of account 1. - assert_eq!(Balances::free_balance(1), 0); - assert_eq!(Balances::free_balance(2), 130); - - // Verify that TotalIssuance tracks balance removal when free balance is too low. - assert_eq!(>::get(), 130); - }); - } - - #[test] - fn burn_must_work() { - <$ext_builder>::default().monied(true).build().execute_with(|| { - let init_total_issuance = Balances::total_issuance(); - let imbalance = Balances::burn(10); - assert_eq!(Balances::total_issuance(), init_total_issuance - 10); - drop(imbalance); - assert_eq!(Balances::total_issuance(), init_total_issuance); - }); - } - - #[test] - fn transfer_keep_alive_works() { - <$ext_builder>::default().existential_deposit(1).build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 100); - assert_noop!( - Balances::transfer_keep_alive(Some(1).into(), 2, 100), - Error::<$test, _>::KeepAlive - ); - assert_eq!(Balances::total_balance(&1), 100); - assert_eq!(Balances::total_balance(&2), 0); - }); - } - - #[test] - #[should_panic = "the balance of any account should always be at least the existential deposit."] - fn cannot_set_genesis_value_below_ed() { - ($existential_deposit).with(|v| *v.borrow_mut() = 11); - let mut t = frame_system::GenesisConfig::default().build_storage::<$test>().unwrap(); - let _ = pallet_balances::GenesisConfig::<$test> { - balances: vec![(1, 10)], - }.assimilate_storage(&mut t).unwrap(); - } - - #[test] - #[should_panic = "duplicate balances in genesis."] - fn cannot_set_genesis_value_twice() { - let mut t = frame_system::GenesisConfig::default().build_storage::<$test>().unwrap(); - let _ = pallet_balances::GenesisConfig::<$test> { - balances: vec![(1, 10), (2, 20), (1, 15)], - }.assimilate_storage(&mut t).unwrap(); - } - - #[test] - fn dust_moves_between_free_and_reserved() { - <$ext_builder>::default() - .existential_deposit(100) - .build() - .execute_with(|| { - // Set balance to free and reserved at the existential deposit - assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 1, 100, 0)); - // Check balance - assert_eq!(Balances::free_balance(1), 100); - assert_eq!(Balances::reserved_balance(1), 0); - - // Reserve some free balance - assert_ok!(Balances::reserve(&1, 50)); - // Check balance, the account should be ok. - assert_eq!(Balances::free_balance(1), 50); - assert_eq!(Balances::reserved_balance(1), 50); - - // Reserve the rest of the free balance - assert_ok!(Balances::reserve(&1, 50)); - // Check balance, the account should be ok. - assert_eq!(Balances::free_balance(1), 0); - assert_eq!(Balances::reserved_balance(1), 100); - - // Unreserve everything - Balances::unreserve(&1, 100); - // Check balance, all 100 should move to free_balance - assert_eq!(Balances::free_balance(1), 100); - assert_eq!(Balances::reserved_balance(1), 0); - }); - } - - #[test] - fn account_deleted_when_just_dust() { - <$ext_builder>::default() - .existential_deposit(100) - .build() - .execute_with(|| { - // Set balance to free and reserved at the existential deposit - assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 1, 50, 50)); - // Check balance - assert_eq!(Balances::free_balance(1), 50); - assert_eq!(Balances::reserved_balance(1), 50); - - // Reserve some free balance - let res = Balances::slash(&1, 1); - assert_eq!(res, (NegativeImbalance::new(1), 0)); - - // The account should be dead. - assert_eq!(Balances::free_balance(1), 0); - assert_eq!(Balances::reserved_balance(1), 0); - }); - } - - #[test] - fn emit_events_with_reserve_and_unreserve() { - <$ext_builder>::default() - .build() - .execute_with(|| { - let _ = Balances::deposit_creating(&1, 100); - - System::set_block_number(2); - assert_ok!(Balances::reserve(&1, 10)); - - System::assert_last_event(RuntimeEvent::Balances(crate::Event::Reserved { who: 1, amount: 10 })); - - System::set_block_number(3); - assert!(Balances::unreserve(&1, 5).is_zero()); - - System::assert_last_event(RuntimeEvent::Balances(crate::Event::Unreserved { who: 1, amount: 5 })); - - System::set_block_number(4); - assert_eq!(Balances::unreserve(&1, 6), 1); - - // should only unreserve 5 - System::assert_last_event(RuntimeEvent::Balances(crate::Event::Unreserved { who: 1, amount: 5 })); - }); - } - - #[test] - fn emit_events_with_existential_deposit() { - <$ext_builder>::default() - .existential_deposit(100) - .build() - .execute_with(|| { - assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 1, 100, 0)); - - assert_eq!( - events(), - [ - RuntimeEvent::System(system::Event::NewAccount { account: 1 }), - RuntimeEvent::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }), - RuntimeEvent::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }), - ] - ); - - let res = Balances::slash(&1, 1); - assert_eq!(res, (NegativeImbalance::new(1), 0)); - - assert_eq!( - events(), - [ - RuntimeEvent::System(system::Event::KilledAccount { account: 1 }), - RuntimeEvent::Balances(crate::Event::DustLost { account: 1, amount: 99 }), - RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 1 }), - ] - ); - }); - } - - #[test] - fn emit_events_with_no_existential_deposit_suicide() { - <$ext_builder>::default() - .existential_deposit(1) - .build() - .execute_with(|| { - assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 1, 100, 0)); - - assert_eq!( - events(), - [ - RuntimeEvent::System(system::Event::NewAccount { account: 1 }), - RuntimeEvent::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }), - RuntimeEvent::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }), - ] - ); - - let res = Balances::slash(&1, 100); - assert_eq!(res, (NegativeImbalance::new(100), 0)); - - assert_eq!( - events(), - [ - RuntimeEvent::System(system::Event::KilledAccount { account: 1 }), - RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 100 }), - ] - ); - }); - } - - #[test] - fn slash_loop_works() { - <$ext_builder>::default() - .existential_deposit(100) - .build() - .execute_with(|| { - /* User has no reference counter, so they can die in these scenarios */ - - // SCENARIO: Slash would not kill account. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 0)); - // Slashed completed in full - assert_eq!(Balances::slash(&1, 900), (NegativeImbalance::new(900), 0)); - // Account is still alive - assert!(System::account_exists(&1)); - System::assert_last_event(RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 900 })); - - // SCENARIO: Slash will kill account because not enough balance left. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 0)); - // Slashed completed in full - assert_eq!(Balances::slash(&1, 950), (NegativeImbalance::new(950), 0)); - // Account is killed - assert!(!System::account_exists(&1)); - - // SCENARIO: Over-slash will kill account, and report missing slash amount. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 0)); - // Slashed full free_balance, and reports 300 not slashed - assert_eq!(Balances::slash(&1, 1_300), (NegativeImbalance::new(1000), 300)); - // Account is dead - assert!(!System::account_exists(&1)); - - // SCENARIO: Over-slash can take from reserved, but keep alive. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 400)); - // Slashed full free_balance and 300 of reserved balance - assert_eq!(Balances::slash(&1, 1_300), (NegativeImbalance::new(1300), 0)); - // Account is still alive - assert!(System::account_exists(&1)); - - // SCENARIO: Over-slash can take from reserved, and kill. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 350)); - // Slashed full free_balance and 300 of reserved balance - assert_eq!(Balances::slash(&1, 1_300), (NegativeImbalance::new(1300), 0)); - // Account is dead because 50 reserved balance is not enough to keep alive - assert!(!System::account_exists(&1)); - - // SCENARIO: Over-slash can take as much as possible from reserved, kill, and report missing amount. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 250)); - // Slashed full free_balance and 300 of reserved balance - assert_eq!(Balances::slash(&1, 1_300), (NegativeImbalance::new(1250), 50)); - // Account is super dead - assert!(!System::account_exists(&1)); - - /* User will now have a reference counter on them, keeping them alive in these scenarios */ - - // SCENARIO: Slash would not kill account. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 0)); - assert_ok!(System::inc_consumers(&1)); // <-- Reference counter added here is enough for all tests - // Slashed completed in full - assert_eq!(Balances::slash(&1, 900), (NegativeImbalance::new(900), 0)); - // Account is still alive - assert!(System::account_exists(&1)); - - // SCENARIO: Slash will take as much as possible without killing account. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 0)); - // Slashed completed in full - assert_eq!(Balances::slash(&1, 950), (NegativeImbalance::new(900), 50)); - // Account is still alive - assert!(System::account_exists(&1)); - - // SCENARIO: Over-slash will not kill account, and report missing slash amount. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 0)); - // Slashed full free_balance minus ED, and reports 400 not slashed - assert_eq!(Balances::slash(&1, 1_300), (NegativeImbalance::new(900), 400)); - // Account is still alive - assert!(System::account_exists(&1)); - - // SCENARIO: Over-slash can take from reserved, but keep alive. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 400)); - // Slashed full free_balance and 300 of reserved balance - assert_eq!(Balances::slash(&1, 1_300), (NegativeImbalance::new(1300), 0)); - // Account is still alive - assert!(System::account_exists(&1)); - - // SCENARIO: Over-slash can take from reserved, but keep alive. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 350)); - // Slashed full free_balance and 250 of reserved balance to leave ED - assert_eq!(Balances::slash(&1, 1_300), (NegativeImbalance::new(1250), 50)); - // Account is still alive - assert!(System::account_exists(&1)); - - // SCENARIO: Over-slash can take as much as possible from reserved and report missing amount. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 250)); - // Slashed full free_balance and 300 of reserved balance - assert_eq!(Balances::slash(&1, 1_300), (NegativeImbalance::new(1150), 150)); - // Account is still alive - assert!(System::account_exists(&1)); - - // Slash on non-existent account is okay. - assert_eq!(Balances::slash(&12345, 1_300), (NegativeImbalance::new(0), 1300)); - }); - } - - #[test] - fn slash_reserved_loop_works() { - <$ext_builder>::default() - .existential_deposit(100) - .build() - .execute_with(|| { - /* User has no reference counter, so they can die in these scenarios */ - - // SCENARIO: Slash would not kill account. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 50, 1_000)); - // Slashed completed in full - assert_eq!(Balances::slash_reserved(&1, 900), (NegativeImbalance::new(900), 0)); - // Account is still alive - assert!(System::account_exists(&1)); - - // SCENARIO: Slash would kill account. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 50, 1_000)); - // Slashed completed in full - assert_eq!(Balances::slash_reserved(&1, 1_000), (NegativeImbalance::new(1_000), 0)); - // Account is dead - assert!(!System::account_exists(&1)); - - // SCENARIO: Over-slash would kill account, and reports left over slash. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 50, 1_000)); - // Slashed completed in full - assert_eq!(Balances::slash_reserved(&1, 1_300), (NegativeImbalance::new(1_000), 300)); - // Account is dead - assert!(!System::account_exists(&1)); - - // SCENARIO: Over-slash does not take from free balance. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 300, 1_000)); - // Slashed completed in full - assert_eq!(Balances::slash_reserved(&1, 1_300), (NegativeImbalance::new(1_000), 300)); - // Account is alive because of free balance - assert!(System::account_exists(&1)); - - /* User has a reference counter, so they cannot die */ - - // SCENARIO: Slash would not kill account. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 50, 1_000)); - assert_ok!(System::inc_consumers(&1)); // <-- Reference counter added here is enough for all tests - // Slashed completed in full - assert_eq!(Balances::slash_reserved(&1, 900), (NegativeImbalance::new(900), 0)); - // Account is still alive - assert!(System::account_exists(&1)); - - // SCENARIO: Slash as much as possible without killing. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 50, 1_000)); - // Slashed as much as possible - assert_eq!(Balances::slash_reserved(&1, 1_000), (NegativeImbalance::new(950), 50)); - // Account is still alive - assert!(System::account_exists(&1)); - - // SCENARIO: Over-slash reports correctly, where reserved is needed to keep alive. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 50, 1_000)); - // Slashed as much as possible - assert_eq!(Balances::slash_reserved(&1, 1_300), (NegativeImbalance::new(950), 350)); - // Account is still alive - assert!(System::account_exists(&1)); - - // SCENARIO: Over-slash reports correctly, where full reserved is removed. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 200, 1_000)); - // Slashed as much as possible - assert_eq!(Balances::slash_reserved(&1, 1_300), (NegativeImbalance::new(1_000), 300)); - // Account is still alive - assert!(System::account_exists(&1)); - - // Slash on non-existent account is okay. - assert_eq!(Balances::slash_reserved(&12345, 1_300), (NegativeImbalance::new(0), 1300)); - }); - } - - #[test] - fn operations_on_dead_account_should_not_change_state() { - // These functions all use `mutate_account` which may introduce a storage change when - // the account never existed to begin with, and shouldn't exist in the end. - <$ext_builder>::default() - .existential_deposit(0) - .build() - .execute_with(|| { - assert!(!frame_system::Account::::contains_key(&1337)); - - // Unreserve - assert_storage_noop!(assert_eq!(Balances::unreserve(&1337, 42), 42)); - // Reserve - assert_noop!(Balances::reserve(&1337, 42), Error::::InsufficientBalance); - // Slash Reserve - assert_storage_noop!(assert_eq!(Balances::slash_reserved(&1337, 42).1, 42)); - // Repatriate Reserve - assert_noop!(Balances::repatriate_reserved(&1337, &1338, 42, Status::Free), Error::::DeadAccount); - // Slash - assert_storage_noop!(assert_eq!(Balances::slash(&1337, 42).1, 42)); - }); - } - - #[test] - fn transfer_keep_alive_all_free_succeed() { - <$ext_builder>::default() - .existential_deposit(100) - .build() - .execute_with(|| { - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 100, 100)); - assert_ok!(Balances::transfer_keep_alive(Some(1).into(), 2, 100)); - assert_eq!(Balances::total_balance(&1), 100); - assert_eq!(Balances::total_balance(&2), 100); - }); - } - - #[test] - fn transfer_all_works() { - <$ext_builder>::default() - .existential_deposit(100) - .build() - .execute_with(|| { - // setup - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 200, 0)); - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 2, 0, 0)); - // transfer all and allow death - assert_ok!(Balances::transfer_all(Some(1).into(), 2, false)); - assert_eq!(Balances::total_balance(&1), 0); - assert_eq!(Balances::total_balance(&2), 200); - - // setup - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 200, 0)); - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 2, 0, 0)); - // transfer all and keep alive - assert_ok!(Balances::transfer_all(Some(1).into(), 2, true)); - assert_eq!(Balances::total_balance(&1), 100); - assert_eq!(Balances::total_balance(&2), 100); - - // setup - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 200, 10)); - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 2, 0, 0)); - // transfer all and allow death w/ reserved - assert_ok!(Balances::transfer_all(Some(1).into(), 2, false)); - assert_eq!(Balances::total_balance(&1), 0); - assert_eq!(Balances::total_balance(&2), 200); - - // setup - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 200, 10)); - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 2, 0, 0)); - // transfer all and keep alive w/ reserved - assert_ok!(Balances::transfer_all(Some(1).into(), 2, true)); - assert_eq!(Balances::total_balance(&1), 100); - assert_eq!(Balances::total_balance(&2), 110); - }); - } - - #[test] - fn named_reserve_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - - let id_1 = [1u8; 8]; - let id_2 = [2u8; 8]; - let id_3 = [3u8; 8]; - - // reserve - - assert_noop!(Balances::reserve_named(&id_1, &1, 112), Error::::InsufficientBalance); - - assert_ok!(Balances::reserve_named(&id_1, &1, 12)); - - assert_eq!(Balances::reserved_balance(1), 12); - assert_eq!(Balances::reserved_balance_named(&id_1, &1), 12); - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 0); - - assert_ok!(Balances::reserve_named(&id_1, &1, 2)); - - assert_eq!(Balances::reserved_balance(1), 14); - assert_eq!(Balances::reserved_balance_named(&id_1, &1), 14); - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 0); - - assert_ok!(Balances::reserve_named(&id_2, &1, 23)); - - assert_eq!(Balances::reserved_balance(1), 37); - assert_eq!(Balances::reserved_balance_named(&id_1, &1), 14); - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 23); - - assert_ok!(Balances::reserve(&1, 34)); - - assert_eq!(Balances::reserved_balance(1), 71); - assert_eq!(Balances::reserved_balance_named(&id_1, &1), 14); - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 23); - - assert_eq!(Balances::total_balance(&1), 111); - assert_eq!(Balances::free_balance(1), 40); - - assert_noop!(Balances::reserve_named(&id_3, &1, 2), Error::::TooManyReserves); - - // unreserve - - assert_eq!(Balances::unreserve_named(&id_1, &1, 10), 0); - - assert_eq!(Balances::reserved_balance(1), 61); - assert_eq!(Balances::reserved_balance_named(&id_1, &1), 4); - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 23); - - assert_eq!(Balances::unreserve_named(&id_1, &1, 5), 1); - - assert_eq!(Balances::reserved_balance(1), 57); - assert_eq!(Balances::reserved_balance_named(&id_1, &1), 0); - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 23); - - assert_eq!(Balances::unreserve_named(&id_2, &1, 3), 0); - - assert_eq!(Balances::reserved_balance(1), 54); - assert_eq!(Balances::reserved_balance_named(&id_1, &1), 0); - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 20); - - assert_eq!(Balances::total_balance(&1), 111); - assert_eq!(Balances::free_balance(1), 57); - - // slash_reserved_named - - assert_ok!(Balances::reserve_named(&id_1, &1, 10)); - - assert_eq!(Balances::slash_reserved_named(&id_1, &1, 25).1, 15); - - assert_eq!(Balances::reserved_balance(1), 54); - assert_eq!(Balances::reserved_balance_named(&id_1, &1), 0); - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 20); - assert_eq!(Balances::total_balance(&1), 101); - - assert_eq!(Balances::slash_reserved_named(&id_2, &1, 5).1, 0); - - assert_eq!(Balances::reserved_balance(1), 49); - assert_eq!(Balances::reserved_balance_named(&id_1, &1), 0); - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 15); - assert_eq!(Balances::total_balance(&1), 96); - - // repatriate_reserved_named - - let _ = Balances::deposit_creating(&2, 100); - - assert_eq!(Balances::repatriate_reserved_named(&id_2, &1, &2, 10, Status::Reserved).unwrap(), 0); - - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 5); - assert_eq!(Balances::reserved_balance_named(&id_2, &2), 10); - assert_eq!(Balances::reserved_balance(&2), 10); - - assert_eq!(Balances::repatriate_reserved_named(&id_2, &2, &1, 11, Status::Reserved).unwrap(), 1); - - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 15); - assert_eq!(Balances::reserved_balance_named(&id_2, &2), 0); - assert_eq!(Balances::reserved_balance(&2), 0); - - assert_eq!(Balances::repatriate_reserved_named(&id_2, &1, &2, 10, Status::Free).unwrap(), 0); - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 5); - assert_eq!(Balances::reserved_balance_named(&id_2, &2), 0); - assert_eq!(Balances::free_balance(&2), 110); - - // repatriate_reserved_named to self - - assert_eq!(Balances::repatriate_reserved_named(&id_2, &1, &1, 10, Status::Reserved).unwrap(), 5); - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 5); - - assert_eq!(Balances::free_balance(&1), 47); - - assert_eq!(Balances::repatriate_reserved_named(&id_2, &1, &1, 15, Status::Free).unwrap(), 10); - assert_eq!(Balances::reserved_balance_named(&id_2, &1), 0); - - assert_eq!(Balances::free_balance(&1), 52); - }); - } - - #[test] - fn reserved_named_to_yourself_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 110); - - let id = [1u8; 8]; - - assert_ok!(Balances::reserve_named(&id, &1, 50)); - assert_ok!(Balances::repatriate_reserved_named(&id, &1, &1, 50, Status::Free), 0); - assert_eq!(Balances::free_balance(1), 110); - assert_eq!(Balances::reserved_balance_named(&id, &1), 0); - - assert_ok!(Balances::reserve_named(&id, &1, 50)); - assert_ok!(Balances::repatriate_reserved_named(&id, &1, &1, 60, Status::Free), 10); - assert_eq!(Balances::free_balance(1), 110); - assert_eq!(Balances::reserved_balance_named(&id, &1), 0); - }); - } - - #[test] - fn ensure_reserved_named_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - - let id = [1u8; 8]; - - assert_ok!(Balances::ensure_reserved_named(&id, &1, 15)); - assert_eq!(Balances::reserved_balance_named(&id, &1), 15); - - assert_ok!(Balances::ensure_reserved_named(&id, &1, 10)); - assert_eq!(Balances::reserved_balance_named(&id, &1), 10); - - assert_ok!(Balances::ensure_reserved_named(&id, &1, 20)); - assert_eq!(Balances::reserved_balance_named(&id, &1), 20); - }); - } - - #[test] - fn unreserve_all_named_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - - let id = [1u8; 8]; - - assert_ok!(Balances::reserve_named(&id, &1, 15)); - - assert_eq!(Balances::unreserve_all_named(&id, &1), 15); - assert_eq!(Balances::reserved_balance_named(&id, &1), 0); - assert_eq!(Balances::free_balance(&1), 111); - - assert_eq!(Balances::unreserve_all_named(&id, &1), 0); - }); - } - - #[test] - fn slash_all_reserved_named_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - - let id = [1u8; 8]; - - assert_ok!(Balances::reserve_named(&id, &1, 15)); - - assert_eq!(Balances::slash_all_reserved_named(&id, &1).peek(), 15); - assert_eq!(Balances::reserved_balance_named(&id, &1), 0); - assert_eq!(Balances::free_balance(&1), 96); - - assert_eq!(Balances::slash_all_reserved_named(&id, &1).peek(), 0); - }); - } - - #[test] - fn repatriate_all_reserved_named_should_work() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - let _ = Balances::deposit_creating(&2, 10); - let _ = Balances::deposit_creating(&3, 10); - - let id = [1u8; 8]; - - assert_ok!(Balances::reserve_named(&id, &1, 15)); - - assert_ok!(Balances::repatriate_all_reserved_named(&id, &1, &2, Status::Reserved)); - assert_eq!(Balances::reserved_balance_named(&id, &1), 0); - assert_eq!(Balances::reserved_balance_named(&id, &2), 15); - - assert_ok!(Balances::repatriate_all_reserved_named(&id, &2, &3, Status::Free)); - assert_eq!(Balances::reserved_balance_named(&id, &2), 0); - assert_eq!(Balances::free_balance(&3), 25); - }); - } - - #[test] - fn set_balance_handles_killing_account() { - <$ext_builder>::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&1, 111); - assert_ok!(frame_system::Pallet::::inc_consumers(&1)); - assert_noop!( - Balances::set_balance(RuntimeOrigin::root(), 1, 0, 0), - DispatchError::ConsumerRemaining, - ); - }); - } - - #[test] - fn set_balance_handles_total_issuance() { - <$ext_builder>::default().build().execute_with(|| { - let old_total_issuance = Balances::total_issuance(); - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1337, 69, 42)); - assert_eq!(Balances::total_issuance(), old_total_issuance + 69 + 42); - assert_eq!(Balances::total_balance(&1337), 69 + 42); - assert_eq!(Balances::free_balance(&1337), 69); - assert_eq!(Balances::reserved_balance(&1337), 42); - }); - } - - #[test] - fn fungible_unbalanced_trait_set_balance_works() { - <$ext_builder>::default().build().execute_with(|| { - assert_eq!(>::balance(&1337), 0); - assert_ok!(>::set_balance(&1337, 100)); - assert_eq!(>::balance(&1337), 100); - - assert_ok!(Balances::reserve(&1337, 60)); - assert_eq!(Balances::free_balance(1337) , 40); - assert_eq!(Balances::reserved_balance(1337), 60); - - assert_noop!(>::set_balance(&1337, 0), ArithmeticError::Underflow); - - assert_ok!(>::set_balance(&1337, 60)); - assert_eq!(Balances::free_balance(1337) , 0); - assert_eq!(Balances::reserved_balance(1337), 60); - }); - } - - #[test] - fn fungible_unbalanced_trait_set_total_issuance_works() { - <$ext_builder>::default().build().execute_with(|| { - assert_eq!(>::total_issuance(), 0); - >::set_total_issuance(100); - assert_eq!(>::total_issuance(), 100); - }); - } - - #[test] - fn fungible_unbalanced_trait_decrease_balance_simple_works() { - <$ext_builder>::default().build().execute_with(|| { - // An Account that starts at 100 - assert_ok!(>::set_balance(&1337, 100)); - // and reserves 50 - assert_ok!(Balances::reserve(&1337, 50)); - // and is decreased by 20 - assert_ok!(>::decrease_balance(&1337, 20)); - // should end up at 80. - assert_eq!(>::balance(&1337), 80); - }); - } - - #[test] - fn fungible_unbalanced_trait_decrease_balance_works() { - <$ext_builder>::default().build().execute_with(|| { - assert_ok!(>::set_balance(&1337, 100)); - assert_eq!(>::balance(&1337), 100); - - assert_noop!( - >::decrease_balance(&1337, 101), - TokenError::NoFunds - ); - assert_eq!( - >::decrease_balance(&1337, 100), - Ok(100) - ); - assert_eq!(>::balance(&1337), 0); - - // free: 40, reserved: 60 - assert_ok!(>::set_balance(&1337, 100)); - assert_ok!(Balances::reserve(&1337, 60)); - assert_eq!(Balances::free_balance(1337) , 40); - assert_eq!(Balances::reserved_balance(1337), 60); - assert_noop!( - >::decrease_balance(&1337, 41), - TokenError::NoFunds - ); - assert_eq!( - >::decrease_balance(&1337, 40), - Ok(40) - ); - assert_eq!(>::balance(&1337), 60); - assert_eq!(Balances::free_balance(1337), 0); - assert_eq!(Balances::reserved_balance(1337), 60); - }); - } - - #[test] - fn fungible_unbalanced_trait_decrease_balance_at_most_works() { - <$ext_builder>::default().build().execute_with(|| { - assert_ok!(>::set_balance(&1337, 100)); - assert_eq!(>::balance(&1337), 100); - - assert_eq!( - >::decrease_balance_at_most(&1337, 101), - 100 - ); - assert_eq!(>::balance(&1337), 0); - - assert_ok!(>::set_balance(&1337, 100)); - assert_eq!( - >::decrease_balance_at_most(&1337, 100), - 100 - ); - assert_eq!(>::balance(&1337), 0); - - // free: 40, reserved: 60 - assert_ok!(>::set_balance(&1337, 100)); - assert_ok!(Balances::reserve(&1337, 60)); - assert_eq!(Balances::free_balance(1337) , 40); - assert_eq!(Balances::reserved_balance(1337), 60); - assert_eq!( - >::decrease_balance_at_most(&1337, 0), - 0 - ); - assert_eq!(Balances::free_balance(1337) , 40); - assert_eq!(Balances::reserved_balance(1337), 60); - assert_eq!( - >::decrease_balance_at_most(&1337, 10), - 10 - ); - assert_eq!(Balances::free_balance(1337), 30); - assert_eq!( - >::decrease_balance_at_most(&1337, 200), - 30 - ); - assert_eq!(>::balance(&1337), 60); - assert_eq!(Balances::free_balance(1337), 0); - assert_eq!(Balances::reserved_balance(1337), 60); - }); - } - - #[test] - fn fungible_unbalanced_trait_increase_balance_works() { - <$ext_builder>::default().build().execute_with(|| { - assert_noop!( - >::increase_balance(&1337, 0), - TokenError::BelowMinimum - ); - assert_eq!( - >::increase_balance(&1337, 1), - Ok(1) - ); - assert_noop!( - >::increase_balance(&1337, u64::MAX), - ArithmeticError::Overflow - ); - }); - } - - #[test] - fn fungible_unbalanced_trait_increase_balance_at_most_works() { - <$ext_builder>::default().build().execute_with(|| { - assert_eq!( - >::increase_balance_at_most(&1337, 0), - 0 - ); - assert_eq!( - >::increase_balance_at_most(&1337, 1), - 1 - ); - assert_eq!( - >::increase_balance_at_most(&1337, u64::MAX), - u64::MAX - 1 - ); - }); - } - } -} diff --git a/frame/balances/src/tests/currency_tests.rs b/frame/balances/src/tests/currency_tests.rs new file mode 100644 index 0000000000000..b0a38f4ac4ed7 --- /dev/null +++ b/frame/balances/src/tests/currency_tests.rs @@ -0,0 +1,1231 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2022 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. + +//! Tests regarding the functionality of the `Currency` trait set implementations. + +use super::*; +use crate::NegativeImbalance; +use frame_support::traits::{ + BalanceStatus::{Free, Reserved}, + Currency, + ExistenceRequirement::{self, AllowDeath}, + LockIdentifier, LockableCurrency, NamedReservableCurrency, ReservableCurrency, WithdrawReasons, +}; + +const ID_1: LockIdentifier = *b"1 "; +const ID_2: LockIdentifier = *b"2 "; + +pub const CALL: &::RuntimeCall = + &RuntimeCall::Balances(crate::Call::transfer_allow_death { dest: 0, value: 0 }); + +#[test] +fn basic_locking_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + assert_eq!(Balances::free_balance(1), 10); + Balances::set_lock(ID_1, &1, 9, WithdrawReasons::all()); + assert_noop!( + >::transfer(&1, &2, 5, AllowDeath), + TokenError::Frozen + ); + }); +} + +#[test] +fn account_should_be_reaped() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + assert_eq!(Balances::free_balance(1), 10); + assert_ok!(>::transfer(&1, &2, 10, AllowDeath)); + assert_eq!(System::providers(&1), 0); + assert_eq!(System::consumers(&1), 0); + // Check that the account is dead. + assert!(!frame_system::Account::::contains_key(&1)); + }); +} + +#[test] +fn reap_failed_due_to_provider_and_consumer() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + // SCENARIO: only one provider and there are remaining consumers. + assert_ok!(System::inc_consumers(&1)); + assert!(!System::can_dec_provider(&1)); + assert_noop!( + >::transfer(&1, &2, 10, AllowDeath), + TokenError::Frozen + ); + assert!(System::account_exists(&1)); + assert_eq!(Balances::free_balance(1), 10); + + // SCENARIO: more than one provider, but will not kill account due to other provider. + assert_eq!(System::inc_providers(&1), frame_system::IncRefStatus::Existed); + assert_eq!(System::providers(&1), 2); + assert!(System::can_dec_provider(&1)); + assert_ok!(>::transfer(&1, &2, 10, AllowDeath)); + assert_eq!(System::providers(&1), 1); + assert!(System::account_exists(&1)); + assert_eq!(Balances::free_balance(1), 0); + }); +} + +#[test] +fn partial_locking_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + Balances::set_lock(ID_1, &1, 5, WithdrawReasons::all()); + assert_ok!(>::transfer(&1, &2, 1, AllowDeath)); + }); +} + +#[test] +fn lock_removal_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + Balances::set_lock(ID_1, &1, u64::MAX, WithdrawReasons::all()); + Balances::remove_lock(ID_1, &1); + assert_ok!(>::transfer(&1, &2, 1, AllowDeath)); + }); +} + +#[test] +fn lock_replacement_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + Balances::set_lock(ID_1, &1, u64::MAX, WithdrawReasons::all()); + Balances::set_lock(ID_1, &1, 5, WithdrawReasons::all()); + assert_ok!(>::transfer(&1, &2, 1, AllowDeath)); + }); +} + +#[test] +fn double_locking_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + Balances::set_lock(ID_1, &1, 5, WithdrawReasons::all()); + Balances::set_lock(ID_2, &1, 5, WithdrawReasons::all()); + assert_ok!(>::transfer(&1, &2, 1, AllowDeath)); + }); +} + +#[test] +fn combination_locking_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + Balances::set_lock(ID_1, &1, u64::MAX, WithdrawReasons::empty()); + Balances::set_lock(ID_2, &1, 0, WithdrawReasons::all()); + assert_ok!(>::transfer(&1, &2, 1, AllowDeath)); + }); +} + +#[test] +fn lock_value_extension_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + Balances::set_lock(ID_1, &1, 5, WithdrawReasons::all()); + assert_noop!( + >::transfer(&1, &2, 6, AllowDeath), + TokenError::Frozen + ); + Balances::extend_lock(ID_1, &1, 2, WithdrawReasons::all()); + assert_noop!( + >::transfer(&1, &2, 6, AllowDeath), + TokenError::Frozen + ); + Balances::extend_lock(ID_1, &1, 8, WithdrawReasons::all()); + assert_noop!( + >::transfer(&1, &2, 3, AllowDeath), + TokenError::Frozen + ); + }); +} + +#[test] +fn lock_should_work_reserve() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + pallet_transaction_payment::NextFeeMultiplier::::put( + Multiplier::saturating_from_integer(1), + ); + Balances::set_lock(ID_1, &1, 10, WithdrawReasons::RESERVE); + assert_noop!( + >::transfer(&1, &2, 1, AllowDeath), + TokenError::Frozen + ); + assert_noop!(Balances::reserve(&1, 1), Error::::LiquidityRestrictions,); + assert!( as SignedExtension>::pre_dispatch( + ChargeTransactionPayment::from(1), + &1, + CALL, + &info_from_weight(Weight::from_parts(1, 0)), + 1, + ) + .is_err()); + assert!( as SignedExtension>::pre_dispatch( + ChargeTransactionPayment::from(0), + &1, + CALL, + &info_from_weight(Weight::from_parts(1, 0)), + 1, + ) + .is_err()); + }); +} + +#[test] +fn lock_should_work_tx_fee() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + Balances::set_lock(ID_1, &1, 10, WithdrawReasons::TRANSACTION_PAYMENT); + assert_noop!( + >::transfer(&1, &2, 1, AllowDeath), + TokenError::Frozen + ); + assert_noop!(Balances::reserve(&1, 1), Error::::LiquidityRestrictions,); + assert!( as SignedExtension>::pre_dispatch( + ChargeTransactionPayment::from(1), + &1, + CALL, + &info_from_weight(Weight::from_parts(1, 0)), + 1, + ) + .is_err()); + assert!( as SignedExtension>::pre_dispatch( + ChargeTransactionPayment::from(0), + &1, + CALL, + &info_from_weight(Weight::from_parts(1, 0)), + 1, + ) + .is_err()); + }); +} + +#[test] +fn lock_block_number_extension_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + Balances::set_lock(ID_1, &1, 10, WithdrawReasons::all()); + assert_noop!( + >::transfer(&1, &2, 6, AllowDeath), + TokenError::Frozen + ); + Balances::extend_lock(ID_1, &1, 10, WithdrawReasons::all()); + assert_noop!( + >::transfer(&1, &2, 6, AllowDeath), + TokenError::Frozen + ); + System::set_block_number(2); + Balances::extend_lock(ID_1, &1, 10, WithdrawReasons::all()); + assert_noop!( + >::transfer(&1, &2, 3, AllowDeath), + TokenError::Frozen + ); + }); +} + +#[test] +fn lock_reasons_extension_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + Balances::set_lock(ID_1, &1, 10, WithdrawReasons::TRANSFER); + assert_noop!( + >::transfer(&1, &2, 6, AllowDeath), + TokenError::Frozen + ); + Balances::extend_lock(ID_1, &1, 10, WithdrawReasons::empty()); + assert_noop!( + >::transfer(&1, &2, 6, AllowDeath), + TokenError::Frozen + ); + Balances::extend_lock(ID_1, &1, 10, WithdrawReasons::RESERVE); + assert_noop!( + >::transfer(&1, &2, 6, AllowDeath), + TokenError::Frozen + ); + }); +} + +#[test] +fn reserved_balance_should_prevent_reclaim_count() { + ExtBuilder::default() + .existential_deposit(256 * 1) + .monied(true) + .build_and_execute_with(|| { + System::inc_account_nonce(&2); + assert_eq!(Balances::total_balance(&2), 256 * 20); + assert_eq!(System::providers(&2), 1); + System::inc_providers(&2); + assert_eq!(System::providers(&2), 2); + + assert_ok!(Balances::reserve(&2, 256 * 19 + 1)); // account 2 becomes mostly reserved + assert_eq!(System::providers(&2), 1); + assert_eq!(Balances::free_balance(2), 255); // "free" account would be deleted. + assert_eq!(Balances::total_balance(&2), 256 * 20); // reserve still exists. + assert_eq!(System::account_nonce(&2), 1); + + // account 4 tries to take index 1 for account 5. + assert_ok!(Balances::transfer_allow_death(Some(4).into(), 5, 256 * 1 + 0x69)); + assert_eq!(Balances::total_balance(&5), 256 * 1 + 0x69); + + assert!(Balances::slash_reserved(&2, 256 * 19 + 1).1.is_zero()); // account 2 gets slashed + + // "reserve" account reduced to 255 (below ED) so account no longer consuming + assert_ok!(System::dec_providers(&2)); + assert_eq!(System::providers(&2), 0); + // account deleted + assert_eq!(System::account_nonce(&2), 0); // nonce zero + assert_eq!(Balances::total_balance(&2), 0); + + // account 4 tries to take index 1 again for account 6. + assert_ok!(Balances::transfer_allow_death(Some(4).into(), 6, 256 * 1 + 0x69)); + assert_eq!(Balances::total_balance(&6), 256 * 1 + 0x69); + }); +} + +#[test] +fn reward_should_work() { + ExtBuilder::default().monied(true).build_and_execute_with(|| { + assert_eq!(Balances::total_balance(&1), 10); + assert_ok!(Balances::deposit_into_existing(&1, 10).map(drop)); + System::assert_last_event(RuntimeEvent::Balances(crate::Event::Deposit { + who: 1, + amount: 10, + })); + assert_eq!(Balances::total_balance(&1), 20); + assert_eq!(Balances::total_issuance(), 120); + }); +} + +#[test] +fn balance_works() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 42); + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { + who: 1, + amount: 42, + })); + assert_eq!(Balances::free_balance(1), 42); + assert_eq!(Balances::reserved_balance(1), 0); + assert_eq!(Balances::total_balance(&1), 42); + assert_eq!(Balances::free_balance(2), 0); + assert_eq!(Balances::reserved_balance(2), 0); + assert_eq!(Balances::total_balance(&2), 0); + }); +} + +#[test] +fn reserving_balance_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 111); + + assert_eq!(Balances::total_balance(&1), 111); + assert_eq!(Balances::free_balance(1), 111); + assert_eq!(Balances::reserved_balance(1), 0); + + assert_ok!(Balances::reserve(&1, 69)); + + assert_eq!(Balances::total_balance(&1), 111); + assert_eq!(Balances::free_balance(1), 42); + assert_eq!(Balances::reserved_balance(1), 69); + }); +} + +#[test] +fn deducting_balance_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 111); + assert_ok!(Balances::reserve(&1, 69)); + assert_eq!(Balances::free_balance(1), 42); + }); +} + +#[test] +fn refunding_balance_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 42); + assert_ok!(Balances::mutate_account(&1, |a| a.reserved = 69)); + Balances::unreserve(&1, 69); + assert_eq!(Balances::free_balance(1), 111); + assert_eq!(Balances::reserved_balance(1), 0); + }); +} + +#[test] +fn slashing_balance_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 112); + assert_ok!(Balances::reserve(&1, 69)); + assert!(Balances::slash(&1, 42).1.is_zero()); + assert_eq!(Balances::free_balance(1), 1); + assert_eq!(Balances::reserved_balance(1), 69); + assert_eq!(Balances::total_issuance(), 70); + }); +} + +#[test] +fn withdrawing_balance_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&2, 111); + let _ = + Balances::withdraw(&2, 11, WithdrawReasons::TRANSFER, ExistenceRequirement::KeepAlive); + System::assert_last_event(RuntimeEvent::Balances(crate::Event::Withdraw { + who: 2, + amount: 11, + })); + assert_eq!(Balances::free_balance(2), 100); + assert_eq!(Balances::total_issuance(), 100); + }); +} + +#[test] +fn withdrawing_balance_should_fail_when_not_expendable() { + ExtBuilder::default().build_and_execute_with(|| { + ExistentialDeposit::set(10); + let _ = Balances::deposit_creating(&2, 20); + assert_ok!(Balances::reserve(&2, 5)); + assert_noop!( + Balances::withdraw(&2, 6, WithdrawReasons::TRANSFER, ExistenceRequirement::KeepAlive), + Error::::Expendability, + ); + assert_ok!(Balances::withdraw( + &2, + 5, + WithdrawReasons::TRANSFER, + ExistenceRequirement::KeepAlive + ),); + }); +} + +#[test] +fn slashing_incomplete_balance_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 42); + assert_ok!(Balances::reserve(&1, 21)); + assert_eq!(Balances::slash(&1, 69).1, 49); + assert_eq!(Balances::free_balance(1), 1); + assert_eq!(Balances::reserved_balance(1), 21); + assert_eq!(Balances::total_issuance(), 22); + }); +} + +#[test] +fn unreserving_balance_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 111); + assert_ok!(Balances::reserve(&1, 110)); + Balances::unreserve(&1, 41); + assert_eq!(Balances::reserved_balance(1), 69); + assert_eq!(Balances::free_balance(1), 42); + }); +} + +#[test] +fn slashing_reserved_balance_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 112); + assert_ok!(Balances::reserve(&1, 111)); + assert_eq!(Balances::slash_reserved(&1, 42).1, 0); + assert_eq!(Balances::reserved_balance(1), 69); + assert_eq!(Balances::free_balance(1), 1); + assert_eq!(Balances::total_issuance(), 70); + }); +} + +#[test] +fn slashing_incomplete_reserved_balance_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 111); + assert_ok!(Balances::reserve(&1, 42)); + assert_eq!(Balances::slash_reserved(&1, 69).1, 27); + assert_eq!(Balances::free_balance(1), 69); + assert_eq!(Balances::reserved_balance(1), 0); + assert_eq!(Balances::total_issuance(), 69); + }); +} + +#[test] +fn repatriating_reserved_balance_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 111); + let _ = Balances::deposit_creating(&2, 1); + assert_ok!(Balances::reserve(&1, 110)); + assert_ok!(Balances::repatriate_reserved(&1, &2, 41, Free), 0); + System::assert_last_event(RuntimeEvent::Balances(crate::Event::ReserveRepatriated { + from: 1, + to: 2, + amount: 41, + destination_status: Free, + })); + assert_eq!(Balances::reserved_balance(1), 69); + assert_eq!(Balances::free_balance(1), 1); + assert_eq!(Balances::reserved_balance(2), 0); + assert_eq!(Balances::free_balance(2), 42); + }); +} + +#[test] +fn transferring_reserved_balance_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 111); + let _ = Balances::deposit_creating(&2, 1); + assert_ok!(Balances::reserve(&1, 110)); + assert_ok!(Balances::repatriate_reserved(&1, &2, 41, Reserved), 0); + assert_eq!(Balances::reserved_balance(1), 69); + assert_eq!(Balances::free_balance(1), 1); + assert_eq!(Balances::reserved_balance(2), 41); + assert_eq!(Balances::free_balance(2), 1); + }); +} + +#[test] +fn transferring_reserved_balance_to_yourself_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 110); + assert_ok!(Balances::reserve(&1, 50)); + assert_ok!(Balances::repatriate_reserved(&1, &1, 50, Free), 0); + assert_eq!(Balances::free_balance(1), 110); + assert_eq!(Balances::reserved_balance(1), 0); + + assert_ok!(Balances::reserve(&1, 50)); + assert_ok!(Balances::repatriate_reserved(&1, &1, 60, Free), 10); + assert_eq!(Balances::free_balance(1), 110); + assert_eq!(Balances::reserved_balance(1), 0); + }); +} + +#[test] +fn transferring_reserved_balance_to_nonexistent_should_fail() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 111); + assert_ok!(Balances::reserve(&1, 110)); + assert_noop!( + Balances::repatriate_reserved(&1, &2, 42, Free), + Error::::DeadAccount + ); + }); +} + +#[test] +fn transferring_incomplete_reserved_balance_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 110); + let _ = Balances::deposit_creating(&2, 1); + assert_ok!(Balances::reserve(&1, 41)); + assert_ok!(Balances::repatriate_reserved(&1, &2, 69, Free), 28); + assert_eq!(Balances::reserved_balance(1), 0); + assert_eq!(Balances::free_balance(1), 69); + assert_eq!(Balances::reserved_balance(2), 0); + assert_eq!(Balances::free_balance(2), 42); + }); +} + +#[test] +fn transferring_too_high_value_should_not_panic() { + ExtBuilder::default().build_and_execute_with(|| { + Balances::make_free_balance_be(&1, u64::MAX); + Balances::make_free_balance_be(&2, 1); + + assert_err!( + >::transfer(&1, &2, u64::MAX, AllowDeath), + ArithmeticError::Overflow, + ); + + assert_eq!(Balances::free_balance(1), u64::MAX); + assert_eq!(Balances::free_balance(2), 1); + }); +} + +#[test] +fn account_create_on_free_too_low_with_other() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 100); + assert_eq!(Balances::total_issuance(), 100); + + // No-op. + let _ = Balances::deposit_creating(&2, 50); + assert_eq!(Balances::free_balance(2), 0); + assert_eq!(Balances::total_issuance(), 100); + }) +} + +#[test] +fn account_create_on_free_too_low() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + // No-op. + let _ = Balances::deposit_creating(&2, 50); + assert_eq!(Balances::free_balance(2), 0); + assert_eq!(Balances::total_issuance(), 0); + }) +} + +#[test] +fn account_removal_on_free_too_low() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + assert_eq!(Balances::total_issuance(), 0); + + // Setup two accounts with free balance above the existential threshold. + let _ = Balances::deposit_creating(&1, 110); + let _ = Balances::deposit_creating(&2, 110); + + assert_eq!(Balances::free_balance(1), 110); + assert_eq!(Balances::free_balance(2), 110); + assert_eq!(Balances::total_issuance(), 220); + + // Transfer funds from account 1 of such amount that after this transfer + // the balance of account 1 will be below the existential threshold. + // This should lead to the removal of all balance of this account. + assert_ok!(Balances::transfer_allow_death(Some(1).into(), 2, 20)); + + // Verify free balance removal of account 1. + assert_eq!(Balances::free_balance(1), 0); + assert_eq!(Balances::free_balance(2), 130); + + // Verify that TotalIssuance tracks balance removal when free balance is too low. + assert_eq!(Balances::total_issuance(), 130); + }); +} + +#[test] +fn burn_must_work() { + ExtBuilder::default().monied(true).build_and_execute_with(|| { + let init_total_issuance = Balances::total_issuance(); + let imbalance = Balances::burn(10); + assert_eq!(Balances::total_issuance(), init_total_issuance - 10); + drop(imbalance); + assert_eq!(Balances::total_issuance(), init_total_issuance); + }); +} + +#[test] +#[should_panic = "the balance of any account should always be at least the existential deposit."] +fn cannot_set_genesis_value_below_ed() { + EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = 11); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let _ = crate::GenesisConfig:: { balances: vec![(1, 10)] } + .assimilate_storage(&mut t) + .unwrap(); +} + +#[test] +#[should_panic = "duplicate balances in genesis."] +fn cannot_set_genesis_value_twice() { + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let _ = crate::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (1, 15)] } + .assimilate_storage(&mut t) + .unwrap(); +} + +#[test] +fn existential_deposit_respected_when_reserving() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + // Set balance to free and reserved at the existential deposit + assert_ok!(Balances::force_set_balance(RawOrigin::Root.into(), 1, 101)); + // Check balance + assert_eq!(Balances::free_balance(1), 101); + assert_eq!(Balances::reserved_balance(1), 0); + + // Reserve some free balance + assert_ok!(Balances::reserve(&1, 1)); + // Check balance, the account should be ok. + assert_eq!(Balances::free_balance(1), 100); + assert_eq!(Balances::reserved_balance(1), 1); + + // Cannot reserve any more of the free balance. + assert_noop!(Balances::reserve(&1, 1), DispatchError::ConsumerRemaining); + }); +} + +#[test] +fn slash_fails_when_account_needed() { + ExtBuilder::default().existential_deposit(50).build_and_execute_with(|| { + // Set balance to free and reserved at the existential deposit + assert_ok!(Balances::force_set_balance(RawOrigin::Root.into(), 1, 52)); + assert_ok!(Balances::reserve(&1, 1)); + // Check balance + assert_eq!(Balances::free_balance(1), 51); + assert_eq!(Balances::reserved_balance(1), 1); + + // Slash a small amount + let res = Balances::slash(&1, 1); + assert_eq!(res, (NegativeImbalance::new(1), 0)); + + // The account should be dead. + assert_eq!(Balances::free_balance(1), 50); + assert_eq!(Balances::reserved_balance(1), 1); + + // Slashing again doesn't work since we require the ED + let res = Balances::slash(&1, 1); + assert_eq!(res, (NegativeImbalance::new(0), 1)); + + // The account should be dead. + assert_eq!(Balances::free_balance(1), 50); + assert_eq!(Balances::reserved_balance(1), 1); + }); +} + +#[test] +fn account_deleted_when_just_dust() { + ExtBuilder::default().existential_deposit(50).build_and_execute_with(|| { + // Set balance to free and reserved at the existential deposit + assert_ok!(Balances::force_set_balance(RawOrigin::Root.into(), 1, 50)); + // Check balance + assert_eq!(Balances::free_balance(1), 50); + + // Slash a small amount + let res = Balances::slash(&1, 1); + assert_eq!(res, (NegativeImbalance::new(1), 0)); + + // The account should be dead. + assert_eq!(Balances::free_balance(1), 0); + }); +} + +#[test] +fn emit_events_with_reserve_and_unreserve() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 100); + + System::set_block_number(2); + assert_ok!(Balances::reserve(&1, 10)); + + System::assert_last_event(RuntimeEvent::Balances(crate::Event::Reserved { + who: 1, + amount: 10, + })); + + System::set_block_number(3); + assert!(Balances::unreserve(&1, 5).is_zero()); + + System::assert_last_event(RuntimeEvent::Balances(crate::Event::Unreserved { + who: 1, + amount: 5, + })); + + System::set_block_number(4); + assert_eq!(Balances::unreserve(&1, 6), 1); + + // should only unreserve 5 + System::assert_last_event(RuntimeEvent::Balances(crate::Event::Unreserved { + who: 1, + amount: 5, + })); + }); +} + +#[test] +fn emit_events_with_existential_deposit() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + assert_ok!(Balances::force_set_balance(RawOrigin::Root.into(), 1, 100)); + + assert_eq!( + events(), + [ + RuntimeEvent::System(system::Event::NewAccount { account: 1 }), + RuntimeEvent::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }), + RuntimeEvent::Balances(crate::Event::BalanceSet { who: 1, free: 100 }), + ] + ); + + let res = Balances::slash(&1, 1); + assert_eq!(res, (NegativeImbalance::new(1), 0)); + + assert_eq!( + events(), + [ + RuntimeEvent::System(system::Event::KilledAccount { account: 1 }), + RuntimeEvent::Balances(crate::Event::DustLost { account: 1, amount: 99 }), + RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 1 }), + ] + ); + }); +} + +#[test] +fn emit_events_with_no_existential_deposit_suicide() { + ExtBuilder::default().existential_deposit(1).build_and_execute_with(|| { + Balances::make_free_balance_be(&1, 100); + + assert_eq!( + events(), + [ + RuntimeEvent::Balances(crate::Event::BalanceSet { who: 1, free: 100 }), + RuntimeEvent::System(system::Event::NewAccount { account: 1 }), + RuntimeEvent::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }), + ] + ); + + let res = Balances::slash(&1, 100); + assert_eq!(res, (NegativeImbalance::new(100), 0)); + + assert_eq!( + events(), + [ + RuntimeEvent::System(system::Event::KilledAccount { account: 1 }), + RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 100 }), + ] + ); + }); +} + +#[test] +fn slash_over_works() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + // SCENARIO: Over-slash will kill account, and report missing slash amount. + Balances::make_free_balance_be(&1, 1_000); + // Slashed full free_balance, and reports 300 not slashed + assert_eq!(Balances::slash(&1, 1_300), (NegativeImbalance::new(1000), 300)); + // Account is dead + assert!(!System::account_exists(&1)); + }); +} + +#[test] +fn slash_full_works() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + Balances::make_free_balance_be(&1, 1_000); + // Slashed completed in full + assert_eq!(Balances::slash(&1, 1_000), (NegativeImbalance::new(1000), 0)); + // Account is still alive + assert!(!System::account_exists(&1)); + System::assert_last_event(RuntimeEvent::Balances(crate::Event::Slashed { + who: 1, + amount: 1000, + })); + }); +} + +#[test] +fn slash_partial_works() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + Balances::make_free_balance_be(&1, 1_000); + // Slashed completed in full + assert_eq!(Balances::slash(&1, 900), (NegativeImbalance::new(900), 0)); + // Account is still alive + assert!(System::account_exists(&1)); + System::assert_last_event(RuntimeEvent::Balances(crate::Event::Slashed { + who: 1, + amount: 900, + })); + }); +} + +#[test] +fn slash_dusting_works() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + Balances::make_free_balance_be(&1, 1_000); + // Slashed completed in full + assert_eq!(Balances::slash(&1, 950), (NegativeImbalance::new(950), 0)); + assert!(!System::account_exists(&1)); + System::assert_last_event(RuntimeEvent::Balances(crate::Event::Slashed { + who: 1, + amount: 950, + })); + }); +} + +#[test] +fn slash_does_not_take_from_reserve() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + Balances::make_free_balance_be(&1, 1_000); + assert_ok!(Balances::reserve(&1, 100)); + // Slashed completed in full + assert_eq!(Balances::slash(&1, 900), (NegativeImbalance::new(800), 100)); + assert_eq!(Balances::reserved_balance(&1), 100); + System::assert_last_event(RuntimeEvent::Balances(crate::Event::Slashed { + who: 1, + amount: 800, + })); + }); +} + +#[test] +fn slash_consumed_slash_full_works() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + Balances::make_free_balance_be(&1, 1_000); + assert_ok!(System::inc_consumers(&1)); // <-- Reference counter added here is enough for all tests + // Slashed completed in full + assert_eq!(Balances::slash(&1, 900), (NegativeImbalance::new(900), 0)); + // Account is still alive + assert!(System::account_exists(&1)); + }); +} + +#[test] +fn slash_consumed_slash_over_works() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + Balances::make_free_balance_be(&1, 1_000); + assert_ok!(System::inc_consumers(&1)); // <-- Reference counter added here is enough for all tests + // Slashed completed in full + assert_eq!(Balances::slash(&1, 1_000), (NegativeImbalance::new(900), 100)); + // Account is still alive + assert!(System::account_exists(&1)); + }); +} + +#[test] +fn slash_consumed_slash_partial_works() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + Balances::make_free_balance_be(&1, 1_000); + assert_ok!(System::inc_consumers(&1)); // <-- Reference counter added here is enough for all tests + // Slashed completed in full + assert_eq!(Balances::slash(&1, 800), (NegativeImbalance::new(800), 0)); + // Account is still alive + assert!(System::account_exists(&1)); + }); +} + +#[test] +fn slash_on_non_existant_works() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + // Slash on non-existent account is okay. + assert_eq!(Balances::slash(&12345, 1_300), (NegativeImbalance::new(0), 1300)); + }); +} + +#[test] +fn slash_reserved_slash_partial_works() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + Balances::make_free_balance_be(&1, 1_000); + assert_ok!(Balances::reserve(&1, 900)); + // Slashed completed in full + assert_eq!(Balances::slash_reserved(&1, 800), (NegativeImbalance::new(800), 0)); + assert_eq!(System::consumers(&1), 1); + assert_eq!(Balances::reserved_balance(&1), 100); + assert_eq!(Balances::free_balance(&1), 100); + }); +} + +#[test] +fn slash_reserved_slash_everything_works() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + Balances::make_free_balance_be(&1, 1_000); + assert_ok!(Balances::reserve(&1, 900)); + assert_eq!(System::consumers(&1), 1); + // Slashed completed in full + assert_eq!(Balances::slash_reserved(&1, 900), (NegativeImbalance::new(900), 0)); + assert_eq!(System::consumers(&1), 0); + // Account is still alive + assert!(System::account_exists(&1)); + }); +} + +#[test] +fn slash_reserved_overslash_does_not_touch_free_balance() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + // SCENARIO: Over-slash doesn't touch free balance. + Balances::make_free_balance_be(&1, 1_000); + assert_ok!(Balances::reserve(&1, 800)); + // Slashed done + assert_eq!(Balances::slash_reserved(&1, 900), (NegativeImbalance::new(800), 100)); + assert_eq!(Balances::free_balance(&1), 200); + }); +} + +#[test] +fn slash_reserved_on_non_existant_works() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + // Slash on non-existent account is okay. + assert_eq!(Balances::slash_reserved(&12345, 1_300), (NegativeImbalance::new(0), 1300)); + }); +} + +#[test] +fn operations_on_dead_account_should_not_change_state() { + // These functions all use `mutate_account` which may introduce a storage change when + // the account never existed to begin with, and shouldn't exist in the end. + ExtBuilder::default().existential_deposit(0).build_and_execute_with(|| { + assert!(!frame_system::Account::::contains_key(&1337)); + + // Unreserve + assert_storage_noop!(assert_eq!(Balances::unreserve(&1337, 42), 42)); + // Reserve + assert_noop!(Balances::reserve(&1337, 42), Error::::InsufficientBalance); + // Slash Reserve + assert_storage_noop!(assert_eq!(Balances::slash_reserved(&1337, 42).1, 42)); + // Repatriate Reserve + assert_noop!( + Balances::repatriate_reserved(&1337, &1338, 42, Free), + Error::::DeadAccount + ); + // Slash + assert_storage_noop!(assert_eq!(Balances::slash(&1337, 42).1, 42)); + }); +} + +#[test] +fn named_reserve_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 111); + + let id_1 = TestId::Foo; + let id_2 = TestId::Bar; + let id_3 = TestId::Baz; + + // reserve + + assert_noop!( + Balances::reserve_named(&id_1, &1, 112), + Error::::InsufficientBalance + ); + + assert_ok!(Balances::reserve_named(&id_1, &1, 12)); + + assert_eq!(Balances::reserved_balance(1), 12); + assert_eq!(Balances::reserved_balance_named(&id_1, &1), 12); + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 0); + + assert_ok!(Balances::reserve_named(&id_1, &1, 2)); + + assert_eq!(Balances::reserved_balance(1), 14); + assert_eq!(Balances::reserved_balance_named(&id_1, &1), 14); + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 0); + + assert_ok!(Balances::reserve_named(&id_2, &1, 23)); + + assert_eq!(Balances::reserved_balance(1), 37); + assert_eq!(Balances::reserved_balance_named(&id_1, &1), 14); + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 23); + + assert_ok!(Balances::reserve(&1, 34)); + + assert_eq!(Balances::reserved_balance(1), 71); + assert_eq!(Balances::reserved_balance_named(&id_1, &1), 14); + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 23); + + assert_eq!(Balances::total_balance(&1), 111); + assert_eq!(Balances::free_balance(1), 40); + + assert_noop!(Balances::reserve_named(&id_3, &1, 2), Error::::TooManyReserves); + + // unreserve + + assert_eq!(Balances::unreserve_named(&id_1, &1, 10), 0); + + assert_eq!(Balances::reserved_balance(1), 61); + assert_eq!(Balances::reserved_balance_named(&id_1, &1), 4); + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 23); + + assert_eq!(Balances::unreserve_named(&id_1, &1, 5), 1); + + assert_eq!(Balances::reserved_balance(1), 57); + assert_eq!(Balances::reserved_balance_named(&id_1, &1), 0); + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 23); + + assert_eq!(Balances::unreserve_named(&id_2, &1, 3), 0); + + assert_eq!(Balances::reserved_balance(1), 54); + assert_eq!(Balances::reserved_balance_named(&id_1, &1), 0); + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 20); + + assert_eq!(Balances::total_balance(&1), 111); + assert_eq!(Balances::free_balance(1), 57); + + // slash_reserved_named + + assert_ok!(Balances::reserve_named(&id_1, &1, 10)); + + assert_eq!(Balances::slash_reserved_named(&id_1, &1, 25).1, 15); + + assert_eq!(Balances::reserved_balance(1), 54); + assert_eq!(Balances::reserved_balance_named(&id_1, &1), 0); + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 20); + assert_eq!(Balances::total_balance(&1), 101); + + assert_eq!(Balances::slash_reserved_named(&id_2, &1, 5).1, 0); + + assert_eq!(Balances::reserved_balance(1), 49); + assert_eq!(Balances::reserved_balance_named(&id_1, &1), 0); + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 15); + assert_eq!(Balances::total_balance(&1), 96); + + // repatriate_reserved_named + + let _ = Balances::deposit_creating(&2, 100); + + assert_eq!(Balances::repatriate_reserved_named(&id_2, &1, &2, 10, Reserved).unwrap(), 0); + + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 5); + assert_eq!(Balances::reserved_balance_named(&id_2, &2), 10); + assert_eq!(Balances::reserved_balance(&2), 10); + + assert_eq!(Balances::repatriate_reserved_named(&id_2, &2, &1, 11, Reserved).unwrap(), 1); + + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 15); + assert_eq!(Balances::reserved_balance_named(&id_2, &2), 0); + assert_eq!(Balances::reserved_balance(&2), 0); + + assert_eq!(Balances::repatriate_reserved_named(&id_2, &1, &2, 10, Free).unwrap(), 0); + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 5); + assert_eq!(Balances::reserved_balance_named(&id_2, &2), 0); + assert_eq!(Balances::free_balance(&2), 110); + + // repatriate_reserved_named to self + + assert_eq!(Balances::repatriate_reserved_named(&id_2, &1, &1, 10, Reserved).unwrap(), 5); + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 5); + + assert_eq!(Balances::free_balance(&1), 47); + + assert_eq!(Balances::repatriate_reserved_named(&id_2, &1, &1, 15, Free).unwrap(), 10); + assert_eq!(Balances::reserved_balance_named(&id_2, &1), 0); + + assert_eq!(Balances::free_balance(&1), 52); + }); +} + +#[test] +fn reserved_named_to_yourself_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 110); + + let id = TestId::Foo; + + assert_ok!(Balances::reserve_named(&id, &1, 50)); + assert_ok!(Balances::repatriate_reserved_named(&id, &1, &1, 50, Free), 0); + assert_eq!(Balances::free_balance(1), 110); + assert_eq!(Balances::reserved_balance_named(&id, &1), 0); + + assert_ok!(Balances::reserve_named(&id, &1, 50)); + assert_ok!(Balances::repatriate_reserved_named(&id, &1, &1, 60, Free), 10); + assert_eq!(Balances::free_balance(1), 110); + assert_eq!(Balances::reserved_balance_named(&id, &1), 0); + }); +} + +#[test] +fn ensure_reserved_named_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 111); + + let id = TestId::Foo; + + assert_ok!(Balances::ensure_reserved_named(&id, &1, 15)); + assert_eq!(Balances::reserved_balance_named(&id, &1), 15); + + assert_ok!(Balances::ensure_reserved_named(&id, &1, 10)); + assert_eq!(Balances::reserved_balance_named(&id, &1), 10); + + assert_ok!(Balances::ensure_reserved_named(&id, &1, 20)); + assert_eq!(Balances::reserved_balance_named(&id, &1), 20); + }); +} + +#[test] +fn unreserve_all_named_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 111); + + let id = TestId::Foo; + + assert_ok!(Balances::reserve_named(&id, &1, 15)); + + assert_eq!(Balances::unreserve_all_named(&id, &1), 15); + assert_eq!(Balances::reserved_balance_named(&id, &1), 0); + assert_eq!(Balances::free_balance(&1), 111); + + assert_eq!(Balances::unreserve_all_named(&id, &1), 0); + }); +} + +#[test] +fn slash_all_reserved_named_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 111); + + let id = TestId::Foo; + + assert_ok!(Balances::reserve_named(&id, &1, 15)); + + assert_eq!(Balances::slash_all_reserved_named(&id, &1).peek(), 15); + assert_eq!(Balances::reserved_balance_named(&id, &1), 0); + assert_eq!(Balances::free_balance(&1), 96); + + assert_eq!(Balances::slash_all_reserved_named(&id, &1).peek(), 0); + }); +} + +#[test] +fn repatriate_all_reserved_named_should_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 111); + let _ = Balances::deposit_creating(&2, 10); + let _ = Balances::deposit_creating(&3, 10); + + let id = TestId::Foo; + + assert_ok!(Balances::reserve_named(&id, &1, 15)); + + assert_ok!(Balances::repatriate_all_reserved_named(&id, &1, &2, Reserved)); + assert_eq!(Balances::reserved_balance_named(&id, &1), 0); + assert_eq!(Balances::reserved_balance_named(&id, &2), 15); + + assert_ok!(Balances::repatriate_all_reserved_named(&id, &2, &3, Free)); + assert_eq!(Balances::reserved_balance_named(&id, &2), 0); + assert_eq!(Balances::free_balance(&3), 25); + }); +} + +#[test] +fn freezing_and_locking_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + assert_ok!(>::set_freeze(&TestId::Foo, &1, 4)); + Balances::set_lock(ID_1, &1, 5, WithdrawReasons::all()); + assert_eq!(System::consumers(&1), 2); + assert_eq!(Balances::account(&1).frozen, 5); + assert_ok!(>::set_freeze(&TestId::Foo, &1, 6)); + assert_eq!(Balances::account(&1).frozen, 6); + assert_ok!(>::set_freeze(&TestId::Foo, &1, 4)); + assert_eq!(Balances::account(&1).frozen, 5); + Balances::set_lock(ID_1, &1, 3, WithdrawReasons::all()); + assert_eq!(Balances::account(&1).frozen, 4); + Balances::set_lock(ID_1, &1, 5, WithdrawReasons::all()); + assert_eq!(Balances::account(&1).frozen, 5); + Balances::remove_lock(ID_1, &1); + assert_eq!(Balances::account(&1).frozen, 4); + assert_eq!(System::consumers(&1), 1); + }); +} diff --git a/frame/balances/src/tests/dispatchable_tests.rs b/frame/balances/src/tests/dispatchable_tests.rs new file mode 100644 index 0000000000000..76d0961e577d2 --- /dev/null +++ b/frame/balances/src/tests/dispatchable_tests.rs @@ -0,0 +1,224 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2022 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. + +//! Tests regarding the functionality of the dispatchables/extrinsics. + +use super::*; +use frame_support::traits::tokens::Preservation::Expendable; +use fungible::{hold::Mutate as HoldMutate, Inspect, Mutate}; + +#[test] +fn default_indexing_on_new_accounts_should_not_work2() { + ExtBuilder::default() + .existential_deposit(10) + .monied(true) + .build_and_execute_with(|| { + // account 5 should not exist + // ext_deposit is 10, value is 9, not satisfies for ext_deposit + assert_noop!( + Balances::transfer_allow_death(Some(1).into(), 5, 9), + TokenError::BelowMinimum, + ); + assert_eq!(Balances::free_balance(1), 100); + }); +} + +#[test] +fn dust_account_removal_should_work() { + ExtBuilder::default() + .existential_deposit(100) + .monied(true) + .build_and_execute_with(|| { + System::inc_account_nonce(&2); + assert_eq!(System::account_nonce(&2), 1); + assert_eq!(Balances::total_balance(&2), 2000); + // index 1 (account 2) becomes zombie + assert_ok!(Balances::transfer_allow_death(Some(2).into(), 5, 1901)); + assert_eq!(Balances::total_balance(&2), 0); + assert_eq!(Balances::total_balance(&5), 1901); + assert_eq!(System::account_nonce(&2), 0); + }); +} + +#[test] +fn balance_transfer_works() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::mint_into(&1, 111); + assert_ok!(Balances::transfer_allow_death(Some(1).into(), 2, 69)); + assert_eq!(Balances::total_balance(&1), 42); + assert_eq!(Balances::total_balance(&2), 69); + }); +} + +#[test] +fn force_transfer_works() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::mint_into(&1, 111); + assert_noop!(Balances::force_transfer(Some(2).into(), 1, 2, 69), BadOrigin,); + assert_ok!(Balances::force_transfer(RawOrigin::Root.into(), 1, 2, 69)); + assert_eq!(Balances::total_balance(&1), 42); + assert_eq!(Balances::total_balance(&2), 69); + }); +} + +#[test] +fn balance_transfer_when_on_hold_should_not_work() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::mint_into(&1, 111); + assert_ok!(Balances::hold(&TestId::Foo, &1, 69)); + assert_noop!( + Balances::transfer_allow_death(Some(1).into(), 2, 69), + TokenError::FundsUnavailable, + ); + }); +} + +#[test] +fn transfer_keep_alive_works() { + ExtBuilder::default().existential_deposit(1).build_and_execute_with(|| { + let _ = Balances::mint_into(&1, 100); + assert_noop!( + Balances::transfer_keep_alive(Some(1).into(), 2, 100), + TokenError::NotExpendable + ); + assert_eq!(Balances::total_balance(&1), 100); + assert_eq!(Balances::total_balance(&2), 0); + }); +} + +#[test] +fn transfer_keep_alive_all_free_succeed() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + assert_ok!(Balances::force_set_balance(RuntimeOrigin::root(), 1, 300)); + assert_ok!(Balances::hold(&TestId::Foo, &1, 100)); + assert_ok!(Balances::transfer_keep_alive(Some(1).into(), 2, 100)); + assert_eq!(Balances::total_balance(&1), 200); + assert_eq!(Balances::total_balance(&2), 100); + }); +} + +#[test] +fn transfer_all_works_1() { + ExtBuilder::default().existential_deposit(100).build().execute_with(|| { + // setup + assert_ok!(Balances::force_set_balance(RuntimeOrigin::root(), 1, 200)); + assert_ok!(Balances::force_set_balance(RuntimeOrigin::root(), 2, 0)); + // transfer all and allow death + assert_ok!(Balances::transfer_all(Some(1).into(), 2, false)); + assert_eq!(Balances::total_balance(&1), 0); + assert_eq!(Balances::total_balance(&2), 200); + }); +} + +#[test] +fn transfer_all_works_2() { + ExtBuilder::default().existential_deposit(100).build().execute_with(|| { + // setup + assert_ok!(Balances::force_set_balance(RuntimeOrigin::root(), 1, 200)); + assert_ok!(Balances::force_set_balance(RuntimeOrigin::root(), 2, 0)); + // transfer all and keep alive + assert_ok!(Balances::transfer_all(Some(1).into(), 2, true)); + assert_eq!(Balances::total_balance(&1), 100); + assert_eq!(Balances::total_balance(&2), 100); + }); +} + +#[test] +fn transfer_all_works_3() { + ExtBuilder::default().existential_deposit(100).build().execute_with(|| { + // setup + assert_ok!(Balances::force_set_balance(RuntimeOrigin::root(), 1, 210)); + assert_ok!(Balances::hold(&TestId::Foo, &1, 10)); + assert_ok!(Balances::force_set_balance(RuntimeOrigin::root(), 2, 0)); + // transfer all and allow death w/ reserved + assert_ok!(Balances::transfer_all(Some(1).into(), 2, false)); + assert_eq!(Balances::total_balance(&1), 110); + assert_eq!(Balances::total_balance(&2), 100); + }); +} + +#[test] +fn transfer_all_works_4() { + ExtBuilder::default().existential_deposit(100).build().execute_with(|| { + // setup + assert_ok!(Balances::force_set_balance(RuntimeOrigin::root(), 1, 210)); + assert_ok!(Balances::hold(&TestId::Foo, &1, 10)); + assert_ok!(Balances::force_set_balance(RuntimeOrigin::root(), 2, 0)); + // transfer all and keep alive w/ reserved + assert_ok!(Balances::transfer_all(Some(1).into(), 2, true)); + assert_eq!(Balances::total_balance(&1), 110); + assert_eq!(Balances::total_balance(&2), 100); + }); +} + +#[test] +fn set_balance_handles_killing_account() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::mint_into(&1, 111); + assert_ok!(frame_system::Pallet::::inc_consumers(&1)); + assert_noop!( + Balances::force_set_balance(RuntimeOrigin::root(), 1, 0), + DispatchError::ConsumerRemaining, + ); + }); +} + +#[test] +fn set_balance_handles_total_issuance() { + ExtBuilder::default().build_and_execute_with(|| { + let old_total_issuance = Balances::total_issuance(); + assert_ok!(Balances::force_set_balance(RuntimeOrigin::root(), 1337, 69)); + assert_eq!(Balances::total_issuance(), old_total_issuance + 69); + assert_eq!(Balances::total_balance(&1337), 69); + assert_eq!(Balances::free_balance(&1337), 69); + }); +} + +#[test] +fn upgrade_accounts_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + System::inc_providers(&7); + assert_ok!(::AccountStore::try_mutate_exists( + &7, + |a| -> DispatchResult { + *a = Some(AccountData { + free: 5, + reserved: 5, + frozen: Zero::zero(), + flags: crate::types::ExtraFlags::old_logic(), + }); + Ok(()) + } + )); + assert!(!Balances::account(&7).flags.is_new_logic()); + assert_eq!(System::providers(&7), 1); + assert_eq!(System::consumers(&7), 0); + assert_ok!(Balances::upgrade_accounts(Some(1).into(), vec![7])); + assert!(Balances::account(&7).flags.is_new_logic()); + assert_eq!(System::providers(&7), 1); + assert_eq!(System::consumers(&7), 1); + + >::unreserve(&7, 5); + assert_ok!(>::transfer(&7, &1, 10, Expendable)); + assert_eq!(Balances::total_balance(&7), 0); + assert_eq!(System::providers(&7), 0); + assert_eq!(System::consumers(&7), 0); + }); +} diff --git a/frame/balances/src/tests/fungible_tests.rs b/frame/balances/src/tests/fungible_tests.rs new file mode 100644 index 0000000000000..128086885391f --- /dev/null +++ b/frame/balances/src/tests/fungible_tests.rs @@ -0,0 +1,399 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2022 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. + +//! Tests regarding the functionality of the `fungible` trait set implementations. + +use super::*; +use frame_support::traits::tokens::{ + Fortitude::{Force, Polite}, + Precision::{BestEffort, Exact}, + Preservation::{Expendable, Preserve, Protect}, + Restriction::Free, +}; +use fungible::{Inspect, InspectFreeze, InspectHold, Mutate, MutateFreeze, MutateHold, Unbalanced}; + +#[test] +fn inspect_trait_reducible_balance_basic_works() { + ExtBuilder::default().existential_deposit(10).build_and_execute_with(|| { + Balances::set_balance(&1, 100); + assert_eq!(Balances::reducible_balance(&1, Expendable, Polite), 100); + assert_eq!(Balances::reducible_balance(&1, Protect, Polite), 90); + assert_eq!(Balances::reducible_balance(&1, Preserve, Polite), 90); + assert_eq!(Balances::reducible_balance(&1, Expendable, Force), 100); + assert_eq!(Balances::reducible_balance(&1, Protect, Force), 90); + assert_eq!(Balances::reducible_balance(&1, Preserve, Force), 90); + }); +} + +#[test] +fn inspect_trait_reducible_balance_other_provide_works() { + ExtBuilder::default().existential_deposit(10).build_and_execute_with(|| { + Balances::set_balance(&1, 100); + System::inc_providers(&1); + assert_eq!(Balances::reducible_balance(&1, Expendable, Polite), 100); + assert_eq!(Balances::reducible_balance(&1, Protect, Polite), 100); + assert_eq!(Balances::reducible_balance(&1, Preserve, Polite), 90); + assert_eq!(Balances::reducible_balance(&1, Expendable, Force), 100); + assert_eq!(Balances::reducible_balance(&1, Protect, Force), 100); + assert_eq!(Balances::reducible_balance(&1, Preserve, Force), 90); + }); +} + +#[test] +fn inspect_trait_reducible_balance_frozen_works() { + ExtBuilder::default().existential_deposit(10).build_and_execute_with(|| { + Balances::set_balance(&1, 100); + assert_ok!(Balances::set_freeze(&TestId::Foo, &1, 50)); + assert_eq!(Balances::reducible_balance(&1, Expendable, Polite), 50); + assert_eq!(Balances::reducible_balance(&1, Protect, Polite), 50); + assert_eq!(Balances::reducible_balance(&1, Preserve, Polite), 50); + assert_eq!(Balances::reducible_balance(&1, Expendable, Force), 90); + assert_eq!(Balances::reducible_balance(&1, Protect, Force), 90); + assert_eq!(Balances::reducible_balance(&1, Preserve, Force), 90); + }); +} + +#[test] +fn unbalanced_trait_set_balance_works() { + ExtBuilder::default().build_and_execute_with(|| { + assert_eq!(>::balance(&1337), 0); + assert_ok!(Balances::write_balance(&1337, 100)); + assert_eq!(>::balance(&1337), 100); + + assert_ok!(>::hold(&TestId::Foo, &1337, 60)); + assert_eq!(>::balance(&1337), 40); + assert_eq!(>::total_balance_on_hold(&1337), 60); + assert_eq!( + >::balance_on_hold(&TestId::Foo, &1337), + 60 + ); + + assert_noop!(Balances::write_balance(&1337, 0), Error::::InsufficientBalance); + + assert_ok!(Balances::write_balance(&1337, 1)); + assert_eq!(>::balance(&1337), 1); + assert_eq!( + >::balance_on_hold(&TestId::Foo, &1337), + 60 + ); + + assert_ok!(>::release(&TestId::Foo, &1337, 60, Exact)); + assert_eq!(>::balance_on_hold(&TestId::Foo, &1337), 0); + assert_eq!(>::total_balance_on_hold(&1337), 0); + }); +} + +#[test] +fn unbalanced_trait_set_total_issuance_works() { + ExtBuilder::default().build_and_execute_with(|| { + assert_eq!(>::total_issuance(), 0); + Balances::set_total_issuance(100); + assert_eq!(>::total_issuance(), 100); + }); +} + +#[test] +fn unbalanced_trait_decrease_balance_simple_works() { + ExtBuilder::default().build_and_execute_with(|| { + // An Account that starts at 100 + assert_ok!(Balances::write_balance(&1337, 100)); + assert_eq!(>::balance(&1337), 100); + // and reserves 50 + assert_ok!(>::hold(&TestId::Foo, &1337, 50)); + assert_eq!(>::balance(&1337), 50); + // and is decreased by 20 + assert_ok!(Balances::decrease_balance(&1337, 20, Exact, Expendable, Polite)); + assert_eq!(>::balance(&1337), 30); + }); +} + +#[test] +fn unbalanced_trait_decrease_balance_works_1() { + ExtBuilder::default().build_and_execute_with(|| { + assert_ok!(Balances::write_balance(&1337, 100)); + assert_eq!(>::balance(&1337), 100); + + assert_noop!( + Balances::decrease_balance(&1337, 101, Exact, Expendable, Polite), + TokenError::FundsUnavailable + ); + assert_eq!(Balances::decrease_balance(&1337, 100, Exact, Expendable, Polite), Ok(100)); + assert_eq!(>::balance(&1337), 0); + }); +} + +#[test] +fn unbalanced_trait_decrease_balance_works_2() { + ExtBuilder::default().build_and_execute_with(|| { + // free: 40, reserved: 60 + assert_ok!(Balances::write_balance(&1337, 100)); + assert_ok!(Balances::hold(&TestId::Foo, &1337, 60)); + assert_eq!(>::balance(&1337), 40); + assert_eq!(Balances::total_balance_on_hold(&1337), 60); + assert_noop!( + Balances::decrease_balance(&1337, 40, Exact, Expendable, Polite), + Error::::InsufficientBalance + ); + assert_eq!(Balances::decrease_balance(&1337, 39, Exact, Expendable, Polite), Ok(39)); + assert_eq!(>::balance(&1337), 1); + assert_eq!(Balances::total_balance_on_hold(&1337), 60); + }); +} + +#[test] +fn unbalanced_trait_decrease_balance_at_most_works_1() { + ExtBuilder::default().build_and_execute_with(|| { + assert_ok!(Balances::write_balance(&1337, 100)); + assert_eq!(>::balance(&1337), 100); + + assert_eq!(Balances::decrease_balance(&1337, 101, BestEffort, Expendable, Polite), Ok(100)); + assert_eq!(>::balance(&1337), 0); + }); +} + +#[test] +fn unbalanced_trait_decrease_balance_at_most_works_2() { + ExtBuilder::default().build_and_execute_with(|| { + assert_ok!(Balances::write_balance(&1337, 99)); + assert_eq!(Balances::decrease_balance(&1337, 99, BestEffort, Expendable, Polite), Ok(99)); + assert_eq!(>::balance(&1337), 0); + }); +} + +#[test] +fn unbalanced_trait_decrease_balance_at_most_works_3() { + ExtBuilder::default().build_and_execute_with(|| { + // free: 40, reserved: 60 + assert_ok!(Balances::write_balance(&1337, 100)); + assert_ok!(Balances::hold(&TestId::Foo, &1337, 60)); + assert_eq!(Balances::free_balance(1337), 40); + assert_eq!(Balances::total_balance_on_hold(&1337), 60); + assert_eq!(Balances::decrease_balance(&1337, 0, BestEffort, Expendable, Polite), Ok(0)); + assert_eq!(Balances::free_balance(1337), 40); + assert_eq!(Balances::total_balance_on_hold(&1337), 60); + assert_eq!(Balances::decrease_balance(&1337, 10, BestEffort, Expendable, Polite), Ok(10)); + assert_eq!(Balances::free_balance(1337), 30); + assert_eq!(Balances::decrease_balance(&1337, 200, BestEffort, Expendable, Polite), Ok(29)); + assert_eq!(>::balance(&1337), 1); + assert_eq!(Balances::free_balance(1337), 1); + assert_eq!(Balances::total_balance_on_hold(&1337), 60); + }); +} + +#[test] +fn unbalanced_trait_increase_balance_works() { + ExtBuilder::default().build_and_execute_with(|| { + assert_noop!(Balances::increase_balance(&1337, 0, Exact), TokenError::BelowMinimum); + assert_eq!(Balances::increase_balance(&1337, 1, Exact), Ok(1)); + assert_noop!(Balances::increase_balance(&1337, u64::MAX, Exact), ArithmeticError::Overflow); + }); +} + +#[test] +fn unbalanced_trait_increase_balance_at_most_works() { + ExtBuilder::default().build_and_execute_with(|| { + assert_eq!(Balances::increase_balance(&1337, 0, BestEffort), Ok(0)); + assert_eq!(Balances::increase_balance(&1337, 1, BestEffort), Ok(1)); + assert_eq!(Balances::increase_balance(&1337, u64::MAX, BestEffort), Ok(u64::MAX - 1)); + }); +} + +#[test] +fn freezing_and_holds_should_overlap() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + assert_ok!(Balances::set_freeze(&TestId::Foo, &1, 10)); + assert_ok!(Balances::hold(&TestId::Foo, &1, 9)); + assert_eq!(Balances::account(&1).free, 1); + assert_eq!(System::consumers(&1), 1); + assert_eq!(Balances::account(&1).free, 1); + assert_eq!(Balances::account(&1).frozen, 10); + assert_eq!(Balances::account(&1).reserved, 9); + assert_eq!(Balances::total_balance_on_hold(&1), 9); + }); +} + +#[test] +fn frozen_hold_balance_cannot_be_moved_without_force() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + assert_ok!(Balances::set_freeze(&TestId::Foo, &1, 10)); + assert_ok!(Balances::hold(&TestId::Foo, &1, 9)); + assert_eq!(Balances::reducible_total_balance_on_hold(&1, Force), 9); + assert_eq!(Balances::reducible_total_balance_on_hold(&1, Polite), 0); + let e = TokenError::Frozen; + assert_noop!( + Balances::transfer_on_hold(&TestId::Foo, &1, &2, 1, Exact, Free, Polite), + e + ); + assert_ok!(Balances::transfer_on_hold(&TestId::Foo, &1, &2, 1, Exact, Free, Force)); + }); +} + +#[test] +fn frozen_hold_balance_best_effort_transfer_works() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + assert_ok!(Balances::set_freeze(&TestId::Foo, &1, 5)); + assert_ok!(Balances::hold(&TestId::Foo, &1, 9)); + assert_eq!(Balances::reducible_total_balance_on_hold(&1, Force), 9); + assert_eq!(Balances::reducible_total_balance_on_hold(&1, Polite), 5); + assert_ok!(Balances::transfer_on_hold( + &TestId::Foo, + &1, + &2, + 10, + BestEffort, + Free, + Polite + )); + assert_eq!(Balances::total_balance(&1), 5); + assert_eq!(Balances::total_balance(&2), 25); + }); +} + +#[test] +fn partial_freezing_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + assert_ok!(Balances::set_freeze(&TestId::Foo, &1, 5)); + assert_eq!(System::consumers(&1), 1); + assert_ok!(>::transfer(&1, &2, 5, Expendable)); + assert_noop!( + >::transfer(&1, &2, 1, Expendable), + TokenError::Frozen + ); + }); +} + +#[test] +fn thaw_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + assert_ok!(Balances::set_freeze(&TestId::Foo, &1, u64::MAX)); + assert_ok!(Balances::thaw(&TestId::Foo, &1)); + assert_eq!(System::consumers(&1), 0); + assert_eq!(Balances::balance_frozen(&TestId::Foo, &1), 0); + assert_eq!(Balances::account(&1).frozen, 0); + assert_ok!(>::transfer(&1, &2, 10, Expendable)); + }); +} + +#[test] +fn set_freeze_zero_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + assert_ok!(Balances::set_freeze(&TestId::Foo, &1, u64::MAX)); + assert_ok!(Balances::set_freeze(&TestId::Foo, &1, 0)); + assert_eq!(System::consumers(&1), 0); + assert_eq!(Balances::balance_frozen(&TestId::Foo, &1), 0); + assert_eq!(Balances::account(&1).frozen, 0); + assert_ok!(>::transfer(&1, &2, 10, Expendable)); + }); +} + +#[test] +fn set_freeze_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + assert_ok!(Balances::set_freeze(&TestId::Foo, &1, u64::MAX)); + assert_ok!(Balances::set_freeze(&TestId::Foo, &1, 5)); + assert_ok!(>::transfer(&1, &2, 5, Expendable)); + assert_noop!( + >::transfer(&1, &2, 1, Expendable), + TokenError::Frozen + ); + }); +} + +#[test] +fn extend_freeze_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + assert_ok!(Balances::set_freeze(&TestId::Foo, &1, 5)); + assert_ok!(Balances::extend_freeze(&TestId::Foo, &1, 10)); + assert_eq!(Balances::account(&1).frozen, 10); + assert_eq!(Balances::balance_frozen(&TestId::Foo, &1), 10); + assert_noop!( + >::transfer(&1, &2, 1, Expendable), + TokenError::Frozen + ); + }); +} + +#[test] +fn double_freezing_should_work() { + ExtBuilder::default() + .existential_deposit(1) + .monied(true) + .build_and_execute_with(|| { + assert_ok!(Balances::set_freeze(&TestId::Foo, &1, 5)); + assert_ok!(Balances::set_freeze(&TestId::Bar, &1, 5)); + assert_eq!(System::consumers(&1), 1); + assert_ok!(>::transfer(&1, &2, 5, Expendable)); + assert_noop!( + >::transfer(&1, &2, 1, Expendable), + TokenError::Frozen + ); + }); +} + +#[test] +fn can_hold_entire_balance_when_second_provider() { + ExtBuilder::default() + .existential_deposit(1) + .monied(false) + .build_and_execute_with(|| { + >::set_balance(&1, 100); + assert_noop!(Balances::hold(&TestId::Foo, &1, 100), TokenError::FundsUnavailable); + System::inc_providers(&1); + assert_eq!(System::providers(&1), 2); + assert_ok!(Balances::hold(&TestId::Foo, &1, 100)); + assert_eq!(System::providers(&1), 1); + assert_noop!(System::dec_providers(&1), DispatchError::ConsumerRemaining); + }); +} + +#[test] +fn unholding_frees_hold_slot() { + ExtBuilder::default() + .existential_deposit(1) + .monied(false) + .build_and_execute_with(|| { + >::set_balance(&1, 100); + assert_ok!(Balances::hold(&TestId::Foo, &1, 10)); + assert_ok!(Balances::hold(&TestId::Bar, &1, 10)); + assert_ok!(Balances::release(&TestId::Foo, &1, 10, Exact)); + assert_ok!(Balances::hold(&TestId::Baz, &1, 10)); + }); +} diff --git a/frame/balances/src/tests/mod.rs b/frame/balances/src/tests/mod.rs new file mode 100644 index 0000000000000..c4a8a631cad20 --- /dev/null +++ b/frame/balances/src/tests/mod.rs @@ -0,0 +1,296 @@ +// This file is part of Substrate. + +// Copyright (C) 2018-2022 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. + +//! Tests. + +#![cfg(test)] + +use crate::{self as pallet_balances, AccountData, Config, CreditOf, Error, Pallet}; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{ + assert_err, assert_noop, assert_ok, assert_storage_noop, + dispatch::DispatchInfo, + parameter_types, + traits::{ + tokens::fungible, ConstU32, ConstU64, ConstU8, Imbalance as ImbalanceT, OnUnbalanced, + StorageMapShim, StoredMap, + }, + weights::{IdentityFee, Weight}, + RuntimeDebug, +}; +use frame_system::{self as system, RawOrigin}; +use pallet_transaction_payment::{ChargeTransactionPayment, CurrencyAdapter, Multiplier}; +use scale_info::TypeInfo; +use sp_core::H256; +use sp_io; +use sp_runtime::{ + testing::Header, + traits::{BadOrigin, IdentityLookup, SignedExtension, Zero}, + ArithmeticError, DispatchError, DispatchResult, FixedPointNumber, TokenError, +}; + +mod currency_tests; +mod dispatchable_tests; +mod fungible_tests; +mod reentrancy_tests; + +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Block = frame_system::mocking::MockBlock; + +#[derive( + Encode, + Decode, + Copy, + Clone, + Eq, + PartialEq, + Ord, + PartialOrd, + MaxEncodedLen, + TypeInfo, + RuntimeDebug, +)] +pub enum TestId { + Foo, + Bar, + Baz, +} + +frame_support::construct_runtime!( + pub struct Test where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, + } +); + +parameter_types! { + pub BlockWeights: frame_system::limits::BlockWeights = + frame_system::limits::BlockWeights::simple_max( + frame_support::weights::Weight::from_parts(1024, u64::MAX), + ); + pub static ExistentialDeposit: u64 = 0; +} +impl frame_system::Config for Test { + type BaseCallFilter = frame_support::traits::Everything; + type BlockWeights = BlockWeights; + type BlockLength = (); + type DbWeight = (); + type RuntimeOrigin = RuntimeOrigin; + type Index = u64; + type BlockNumber = u64; + type RuntimeCall = RuntimeCall; + type Hash = H256; + type Hashing = ::sp_runtime::traits::BlakeTwo256; + type AccountId = u64; + type Lookup = IdentityLookup; + type Header = Header; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = ConstU64<250>; + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = super::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +impl pallet_transaction_payment::Config for Test { + type RuntimeEvent = RuntimeEvent; + type OnChargeTransaction = CurrencyAdapter, ()>; + type OperationalFeeMultiplier = ConstU8<5>; + type WeightToFee = IdentityFee; + type LengthToFee = IdentityFee; + type FeeMultiplierUpdate = (); +} + +impl Config for Test { + type Balance = u64; + type DustRemoval = DustTrap; + type RuntimeEvent = RuntimeEvent; + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = TestAccountStore; + type MaxLocks = ConstU32<50>; + type MaxReserves = ConstU32<2>; + type ReserveIdentifier = TestId; + type WeightInfo = (); + type HoldIdentifier = TestId; + type FreezeIdentifier = TestId; + type MaxFreezes = ConstU32<2>; + type MaxHolds = ConstU32<2>; +} + +#[derive(Clone)] +pub struct ExtBuilder { + existential_deposit: u64, + monied: bool, + dust_trap: Option, +} +impl Default for ExtBuilder { + fn default() -> Self { + Self { existential_deposit: 1, monied: false, dust_trap: None } + } +} +impl ExtBuilder { + pub fn existential_deposit(mut self, existential_deposit: u64) -> Self { + self.existential_deposit = existential_deposit; + self + } + pub fn monied(mut self, monied: bool) -> Self { + self.monied = monied; + if self.existential_deposit == 0 { + self.existential_deposit = 1; + } + self + } + pub fn dust_trap(mut self, account: u64) -> Self { + self.dust_trap = Some(account); + self + } + pub fn set_associated_consts(&self) { + DUST_TRAP_TARGET.with(|v| v.replace(self.dust_trap)); + EXISTENTIAL_DEPOSIT.with(|v| v.replace(self.existential_deposit)); + } + pub fn build(self) -> sp_io::TestExternalities { + self.set_associated_consts(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + pallet_balances::GenesisConfig:: { + balances: if self.monied { + vec![ + (1, 10 * self.existential_deposit), + (2, 20 * self.existential_deposit), + (3, 30 * self.existential_deposit), + (4, 40 * self.existential_deposit), + (12, 10 * self.existential_deposit), + ] + } else { + vec![] + }, + } + .assimilate_storage(&mut t) + .unwrap(); + + let mut ext = sp_io::TestExternalities::new(t); + ext.execute_with(|| System::set_block_number(1)); + ext + } + pub fn build_and_execute_with(self, f: impl Fn()) { + let other = self.clone(); + UseSystem::set(false); + other.build().execute_with(|| f()); + UseSystem::set(true); + self.build().execute_with(|| f()); + } +} + +parameter_types! { + static DustTrapTarget: Option = None; +} + +pub struct DustTrap; + +impl OnUnbalanced> for DustTrap { + fn on_nonzero_unbalanced(amount: CreditOf) { + match DustTrapTarget::get() { + None => drop(amount), + Some(a) => { + let result = >::resolve(&a, amount); + debug_assert!(result.is_ok()); + }, + } + } +} + +parameter_types! { + pub static UseSystem: bool = false; +} + +type BalancesAccountStore = StorageMapShim, u64, super::AccountData>; +type SystemAccountStore = frame_system::Pallet; + +pub struct TestAccountStore; +impl StoredMap> for TestAccountStore { + fn get(k: &u64) -> super::AccountData { + if UseSystem::get() { + >::get(k) + } else { + >::get(k) + } + } + fn try_mutate_exists>( + k: &u64, + f: impl FnOnce(&mut Option>) -> Result, + ) -> Result { + if UseSystem::get() { + >::try_mutate_exists(k, f) + } else { + >::try_mutate_exists(k, f) + } + } + fn mutate( + k: &u64, + f: impl FnOnce(&mut super::AccountData) -> R, + ) -> Result { + if UseSystem::get() { + >::mutate(k, f) + } else { + >::mutate(k, f) + } + } + fn mutate_exists( + k: &u64, + f: impl FnOnce(&mut Option>) -> R, + ) -> Result { + if UseSystem::get() { + >::mutate_exists(k, f) + } else { + >::mutate_exists(k, f) + } + } + fn insert(k: &u64, t: super::AccountData) -> Result<(), DispatchError> { + if UseSystem::get() { + >::insert(k, t) + } else { + >::insert(k, t) + } + } + fn remove(k: &u64) -> Result<(), DispatchError> { + if UseSystem::get() { + >::remove(k) + } else { + >::remove(k) + } + } +} + +pub fn events() -> Vec { + let evt = System::events().into_iter().map(|evt| evt.event).collect::>(); + System::reset_events(); + evt +} + +/// create a transaction info struct from weight. Handy to avoid building the whole struct. +pub fn info_from_weight(w: Weight) -> DispatchInfo { + DispatchInfo { weight: w, ..Default::default() } +} diff --git a/frame/balances/src/tests/reentrancy_tests.rs b/frame/balances/src/tests/reentrancy_tests.rs new file mode 100644 index 0000000000000..e97bf2ed2b706 --- /dev/null +++ b/frame/balances/src/tests/reentrancy_tests.rs @@ -0,0 +1,195 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2022 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. + +//! Tests regarding the reentrancy functionality. + +use super::*; +use frame_support::traits::tokens::{ + Fortitude::Force, + Precision::BestEffort, + Preservation::{Expendable, Protect}, +}; +use fungible::Balanced; + +#[test] +fn transfer_dust_removal_tst1_should_work() { + ExtBuilder::default() + .existential_deposit(100) + .dust_trap(1) + .build_and_execute_with(|| { + // Verification of reentrancy in dust removal + assert_ok!(Balances::force_set_balance(RawOrigin::Root.into(), 1, 1000)); + assert_ok!(Balances::force_set_balance(RawOrigin::Root.into(), 2, 500)); + + // In this transaction, account 2 free balance + // drops below existential balance + // and dust balance is removed from account 2 + assert_ok!(Balances::transfer_allow_death(RawOrigin::Signed(2).into(), 3, 450)); + + // As expected dust balance is removed. + assert_eq!(Balances::free_balance(&2), 0); + + // As expected beneficiary account 3 + // received the transfered fund. + assert_eq!(Balances::free_balance(&3), 450); + + // Dust balance is deposited to account 1 + // during the process of dust removal. + assert_eq!(Balances::free_balance(&1), 1050); + + // Verify the events + assert_eq!(System::events().len(), 12); + + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Transfer { + from: 2, + to: 3, + amount: 450, + })); + System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost { + account: 2, + amount: 50, + })); + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { + who: 1, + amount: 50, + })); + }); +} + +#[test] +fn transfer_dust_removal_tst2_should_work() { + ExtBuilder::default() + .existential_deposit(100) + .dust_trap(1) + .build_and_execute_with(|| { + // Verification of reentrancy in dust removal + assert_ok!(Balances::force_set_balance(RawOrigin::Root.into(), 1, 1000)); + assert_ok!(Balances::force_set_balance(RawOrigin::Root.into(), 2, 500)); + + // In this transaction, account 2 free balance + // drops below existential balance + // and dust balance is removed from account 2 + assert_ok!(Balances::transfer_allow_death(RawOrigin::Signed(2).into(), 1, 450)); + + // As expected dust balance is removed. + assert_eq!(Balances::free_balance(&2), 0); + + // Dust balance is deposited to account 1 + // during the process of dust removal. + assert_eq!(Balances::free_balance(&1), 1500); + + // Verify the events + assert_eq!(System::events().len(), 10); + + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Transfer { + from: 2, + to: 1, + amount: 450, + })); + System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost { + account: 2, + amount: 50, + })); + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { + who: 1, + amount: 50, + })); + }); +} + +#[test] +fn repatriating_reserved_balance_dust_removal_should_work() { + ExtBuilder::default() + .existential_deposit(100) + .dust_trap(1) + .build_and_execute_with(|| { + // Verification of reentrancy in dust removal + assert_ok!(Balances::force_set_balance(RawOrigin::Root.into(), 1, 1000)); + assert_ok!(Balances::force_set_balance(RawOrigin::Root.into(), 2, 500)); + + // Reserve a value on account 2, + // Such that free balance is lower than + // Exestintial deposit. + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(2), 1, 450)); + + // Since free balance of account 2 is lower than + // existential deposit, dust amount is + // removed from the account 2 + assert_eq!(Balances::reserved_balance(2), 0); + assert_eq!(Balances::free_balance(2), 0); + + // account 1 is credited with reserved amount + // together with dust balance during dust + // removal. + assert_eq!(Balances::reserved_balance(1), 0); + assert_eq!(Balances::free_balance(1), 1500); + + // Verify the events + assert_eq!(System::events().len(), 10); + + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Transfer { + from: 2, + to: 1, + amount: 450, + })); + System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost { + account: 2, + amount: 50, + })); + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { + who: 1, + amount: 50, + })); + }); +} + +#[test] +fn emit_events_with_no_existential_deposit_suicide_with_dust() { + ExtBuilder::default().existential_deposit(2).build_and_execute_with(|| { + assert_ok!(Balances::force_set_balance(RawOrigin::Root.into(), 1, 100)); + + assert_eq!( + events(), + [ + RuntimeEvent::System(system::Event::NewAccount { account: 1 }), + RuntimeEvent::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }), + RuntimeEvent::Balances(crate::Event::BalanceSet { who: 1, free: 100 }), + ] + ); + + let res = Balances::withdraw(&1, 98, BestEffort, Protect, Force); + assert_eq!(res.unwrap().peek(), 98); + + // no events + assert_eq!( + events(), + [RuntimeEvent::Balances(crate::Event::Withdraw { who: 1, amount: 98 })] + ); + + let res = Balances::withdraw(&1, 1, BestEffort, Expendable, Force); + assert_eq!(res.unwrap().peek(), 1); + + assert_eq!( + events(), + [ + RuntimeEvent::System(system::Event::KilledAccount { account: 1 }), + RuntimeEvent::Balances(crate::Event::DustLost { account: 1, amount: 1 }), + RuntimeEvent::Balances(crate::Event::Withdraw { who: 1, amount: 1 }) + ] + ); + }); +} diff --git a/frame/balances/src/tests_composite.rs b/frame/balances/src/tests_composite.rs deleted file mode 100644 index 765ab194d2011..0000000000000 --- a/frame/balances/src/tests_composite.rs +++ /dev/null @@ -1,149 +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. - -//! Test utilities - -#![cfg(test)] - -use crate::{self as pallet_balances, decl_tests, Config, Pallet}; -use frame_support::{ - dispatch::DispatchInfo, - parameter_types, - traits::{ConstU32, ConstU64, ConstU8}, - weights::{IdentityFee, Weight}, -}; -use pallet_transaction_payment::CurrencyAdapter; -use sp_core::H256; -use sp_io; -use sp_runtime::{testing::Header, traits::IdentityLookup}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; - -frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, - } -); - -parameter_types! { - pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max( - frame_support::weights::Weight::from_parts(1024, u64::MAX), - ); - pub static ExistentialDeposit: u64 = 0; -} -impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = BlockWeights; - type BlockLength = (); - type DbWeight = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u64; - type RuntimeCall = RuntimeCall; - type Hash = H256; - type Hashing = ::sp_runtime::traits::BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU64<250>; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = super::AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -impl pallet_transaction_payment::Config for Test { - type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = CurrencyAdapter, ()>; - type OperationalFeeMultiplier = ConstU8<5>; - type WeightToFee = IdentityFee; - type LengthToFee = IdentityFee; - type FeeMultiplierUpdate = (); -} - -impl Config for Test { - type Balance = u64; - type DustRemoval = (); - type RuntimeEvent = RuntimeEvent; - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = frame_system::Pallet; - type MaxLocks = (); - type MaxReserves = ConstU32<2>; - type ReserveIdentifier = [u8; 8]; - type WeightInfo = (); -} - -pub struct ExtBuilder { - existential_deposit: u64, - monied: bool, -} -impl Default for ExtBuilder { - fn default() -> Self { - Self { existential_deposit: 1, monied: false } - } -} -impl ExtBuilder { - pub fn existential_deposit(mut self, existential_deposit: u64) -> Self { - self.existential_deposit = existential_deposit; - self - } - pub fn monied(mut self, monied: bool) -> Self { - self.monied = monied; - self - } - pub fn set_associated_consts(&self) { - EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = self.existential_deposit); - } - pub fn build(self) -> sp_io::TestExternalities { - self.set_associated_consts(); - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - pallet_balances::GenesisConfig:: { - balances: if self.monied { - vec![ - (1, 10 * self.existential_deposit), - (2, 20 * self.existential_deposit), - (3, 30 * self.existential_deposit), - (4, 40 * self.existential_deposit), - (12, 10 * self.existential_deposit), - ] - } else { - vec![] - }, - } - .assimilate_storage(&mut t) - .unwrap(); - - let mut ext = sp_io::TestExternalities::new(t); - ext.execute_with(|| System::set_block_number(1)); - ext - } -} - -decl_tests! { Test, ExtBuilder, EXISTENTIAL_DEPOSIT } diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs deleted file mode 100644 index 929f77b540fe1..0000000000000 --- a/frame/balances/src/tests_local.rs +++ /dev/null @@ -1,191 +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. - -//! Test utilities - -#![cfg(test)] - -use crate::{self as pallet_balances, decl_tests, Config, Pallet}; -use frame_support::{ - dispatch::DispatchInfo, - parameter_types, - traits::{ConstU32, ConstU64, ConstU8, StorageMapShim}, - weights::{IdentityFee, Weight}, -}; -use pallet_transaction_payment::CurrencyAdapter; -use sp_core::H256; -use sp_io; -use sp_runtime::{testing::Header, traits::IdentityLookup}; - -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; - -frame_support::construct_runtime!( - pub struct Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, - } -); - -parameter_types! { - pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max( - frame_support::weights::Weight::from_parts(1024, u64::MAX), - ); - pub static ExistentialDeposit: u64 = 0; -} -impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = BlockWeights; - type BlockLength = (); - type DbWeight = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u64; - type RuntimeCall = RuntimeCall; - type Hash = H256; - type Hashing = ::sp_runtime::traits::BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU64<250>; - 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_transaction_payment::Config for Test { - type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = CurrencyAdapter, ()>; - type OperationalFeeMultiplier = ConstU8<5>; - type WeightToFee = IdentityFee; - type LengthToFee = IdentityFee; - type FeeMultiplierUpdate = (); -} - -impl Config for Test { - type Balance = u64; - type DustRemoval = (); - type RuntimeEvent = RuntimeEvent; - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = - StorageMapShim, system::Provider, u64, super::AccountData>; - type MaxLocks = ConstU32<50>; - type MaxReserves = ConstU32<2>; - type ReserveIdentifier = [u8; 8]; - type WeightInfo = (); -} - -pub struct ExtBuilder { - existential_deposit: u64, - monied: bool, -} -impl Default for ExtBuilder { - fn default() -> Self { - Self { existential_deposit: 1, monied: false } - } -} -impl ExtBuilder { - pub fn existential_deposit(mut self, existential_deposit: u64) -> Self { - self.existential_deposit = existential_deposit; - self - } - pub fn monied(mut self, monied: bool) -> Self { - self.monied = monied; - if self.existential_deposit == 0 { - self.existential_deposit = 1; - } - self - } - pub fn set_associated_consts(&self) { - EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = self.existential_deposit); - } - pub fn build(self) -> sp_io::TestExternalities { - self.set_associated_consts(); - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - pallet_balances::GenesisConfig:: { - balances: if self.monied { - vec![ - (1, 10 * self.existential_deposit), - (2, 20 * self.existential_deposit), - (3, 30 * self.existential_deposit), - (4, 40 * self.existential_deposit), - (12, 10 * self.existential_deposit), - ] - } else { - vec![] - }, - } - .assimilate_storage(&mut t) - .unwrap(); - - let mut ext = sp_io::TestExternalities::new(t); - ext.execute_with(|| System::set_block_number(1)); - ext - } -} - -decl_tests! { Test, ExtBuilder, EXISTENTIAL_DEPOSIT } - -#[test] -fn emit_events_with_no_existential_deposit_suicide_with_dust() { - ::default().existential_deposit(2).build().execute_with(|| { - assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 1, 100, 0)); - - assert_eq!( - events(), - [ - RuntimeEvent::System(system::Event::NewAccount { account: 1 }), - RuntimeEvent::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }), - RuntimeEvent::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }), - ] - ); - - let res = Balances::slash(&1, 98); - assert_eq!(res, (NegativeImbalance::new(98), 0)); - - // no events - assert_eq!( - events(), - [RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 98 })] - ); - - let res = Balances::slash(&1, 1); - assert_eq!(res, (NegativeImbalance::new(1), 0)); - - assert_eq!( - events(), - [ - RuntimeEvent::System(system::Event::KilledAccount { account: 1 }), - RuntimeEvent::Balances(crate::Event::DustLost { account: 1, amount: 1 }), - RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 1 }) - ] - ); - }); -} diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs deleted file mode 100644 index 828dfa23707d0..0000000000000 --- a/frame/balances/src/tests_reentrancy.rs +++ /dev/null @@ -1,264 +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. - -//! Test setup for potential reentracy and lost updates of nested mutations. - -#![cfg(test)] - -use crate::{self as pallet_balances, Config}; -use frame_support::{ - parameter_types, - traits::{ConstU32, ConstU64, StorageMapShim}, -}; -use sp_core::H256; -use sp_io; -use sp_runtime::{testing::Header, traits::IdentityLookup}; - -use crate::*; -use frame_support::{ - assert_ok, - traits::{Currency, ReservableCurrency}, -}; -use frame_system::RawOrigin; - -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; - -frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - } -); - -parameter_types! { - pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max( - frame_support::weights::Weight::from_parts(1024, u64::MAX), - ); - pub static ExistentialDeposit: u64 = 0; -} -impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = BlockWeights; - type BlockLength = (); - type DbWeight = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u64; - type RuntimeCall = RuntimeCall; - type Hash = H256; - type Hashing = ::sp_runtime::traits::BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU64<250>; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -pub struct OnDustRemoval; -impl OnUnbalanced> for OnDustRemoval { - fn on_nonzero_unbalanced(amount: NegativeImbalance) { - assert_ok!(Balances::resolve_into_existing(&1, amount)); - } -} - -impl Config for Test { - type Balance = u64; - type DustRemoval = OnDustRemoval; - type RuntimeEvent = RuntimeEvent; - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = - StorageMapShim, system::Provider, u64, super::AccountData>; - type MaxLocks = ConstU32<50>; - type MaxReserves = ConstU32<2>; - type ReserveIdentifier = [u8; 8]; - type WeightInfo = (); -} - -pub struct ExtBuilder { - existential_deposit: u64, -} -impl Default for ExtBuilder { - fn default() -> Self { - Self { existential_deposit: 1 } - } -} -impl ExtBuilder { - pub fn existential_deposit(mut self, existential_deposit: u64) -> Self { - self.existential_deposit = existential_deposit; - self - } - - pub fn set_associated_consts(&self) { - EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = self.existential_deposit); - } - - pub fn build(self) -> sp_io::TestExternalities { - self.set_associated_consts(); - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![] } - .assimilate_storage(&mut t) - .unwrap(); - let mut ext = sp_io::TestExternalities::new(t); - ext.execute_with(|| System::set_block_number(1)); - ext - } -} - -#[test] -fn transfer_dust_removal_tst1_should_work() { - ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - // Verification of reentrancy in dust removal - assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 1, 1000, 0)); - assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 2, 500, 0)); - - // In this transaction, account 2 free balance - // drops below existential balance - // and dust balance is removed from account 2 - assert_ok!(Balances::transfer(RawOrigin::Signed(2).into(), 3, 450)); - - // As expected dust balance is removed. - assert_eq!(Balances::free_balance(&2), 0); - - // As expected beneficiary account 3 - // received the transfered fund. - assert_eq!(Balances::free_balance(&3), 450); - - // Dust balance is deposited to account 1 - // during the process of dust removal. - assert_eq!(Balances::free_balance(&1), 1050); - - // Verify the events - assert_eq!(System::events().len(), 12); - - System::assert_has_event(RuntimeEvent::Balances(crate::Event::Transfer { - from: 2, - to: 3, - amount: 450, - })); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost { - account: 2, - amount: 50, - })); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { - who: 1, - amount: 50, - })); - }); -} - -#[test] -fn transfer_dust_removal_tst2_should_work() { - ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - // Verification of reentrancy in dust removal - assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 1, 1000, 0)); - assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 2, 500, 0)); - - // In this transaction, account 2 free balance - // drops below existential balance - // and dust balance is removed from account 2 - assert_ok!(Balances::transfer(RawOrigin::Signed(2).into(), 1, 450)); - - // As expected dust balance is removed. - assert_eq!(Balances::free_balance(&2), 0); - - // Dust balance is deposited to account 1 - // during the process of dust removal. - assert_eq!(Balances::free_balance(&1), 1500); - - // Verify the events - assert_eq!(System::events().len(), 10); - - System::assert_has_event(RuntimeEvent::Balances(crate::Event::Transfer { - from: 2, - to: 1, - amount: 450, - })); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost { - account: 2, - amount: 50, - })); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { - who: 1, - amount: 50, - })); - }); -} - -#[test] -fn repatriating_reserved_balance_dust_removal_should_work() { - ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - // Verification of reentrancy in dust removal - assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 1, 1000, 0)); - assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 2, 500, 0)); - - // Reserve a value on account 2, - // Such that free balance is lower than - // Exestintial deposit. - assert_ok!(Balances::reserve(&2, 450)); - - // Transfer of reserved fund from slashed account 2 to - // beneficiary account 1 - assert_ok!(Balances::repatriate_reserved(&2, &1, 450, Status::Free), 0); - - // Since free balance of account 2 is lower than - // existential deposit, dust amount is - // removed from the account 2 - assert_eq!(Balances::reserved_balance(2), 0); - assert_eq!(Balances::free_balance(2), 0); - - // account 1 is credited with reserved amount - // together with dust balance during dust - // removal. - assert_eq!(Balances::reserved_balance(1), 0); - assert_eq!(Balances::free_balance(1), 1500); - - // Verify the events - assert_eq!(System::events().len(), 11); - - System::assert_has_event(RuntimeEvent::Balances(crate::Event::ReserveRepatriated { - from: 2, - to: 1, - amount: 450, - destination_status: Status::Free, - })); - - System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost { - account: 2, - amount: 50, - })); - - System::assert_last_event(RuntimeEvent::Balances(crate::Event::Deposit { - who: 1, - amount: 50, - })); - }); -} diff --git a/frame/balances/src/types.rs b/frame/balances/src/types.rs new file mode 100644 index 0000000000000..c96e1e44b4165 --- /dev/null +++ b/frame/balances/src/types.rs @@ -0,0 +1,157 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2022 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. + +//! Types used in the pallet. + +use crate::{Config, CreditOf, Event, Pallet}; +use codec::{Decode, Encode, MaxEncodedLen}; +use core::ops::BitOr; +use frame_support::{ + traits::{Imbalance, LockIdentifier, OnUnbalanced, WithdrawReasons}, + RuntimeDebug, +}; +use scale_info::TypeInfo; +use sp_runtime::Saturating; + +/// Simplified reasons for withdrawing balance. +#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)] +pub enum Reasons { + /// Paying system transaction fees. + Fee = 0, + /// Any reason other than paying system transaction fees. + Misc = 1, + /// Any reason at all. + All = 2, +} + +impl From for Reasons { + fn from(r: WithdrawReasons) -> Reasons { + if r == WithdrawReasons::TRANSACTION_PAYMENT { + Reasons::Fee + } else if r.contains(WithdrawReasons::TRANSACTION_PAYMENT) { + Reasons::All + } else { + Reasons::Misc + } + } +} + +impl BitOr for Reasons { + type Output = Reasons; + fn bitor(self, other: Reasons) -> Reasons { + if self == other { + return self + } + Reasons::All + } +} + +/// A single lock on a balance. There can be many of these on an account and they "overlap", so the +/// same balance is frozen by multiple locks. +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)] +pub struct BalanceLock { + /// An identifier for this lock. Only one lock may be in existence for each identifier. + pub id: LockIdentifier, + /// The amount which the free balance may not drop below when this lock is in effect. + pub amount: Balance, + /// If true, then the lock remains in effect even for payment of transaction fees. + pub reasons: Reasons, +} + +/// Store named reserved balance. +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)] +pub struct ReserveData { + /// The identifier for the named reserve. + pub id: ReserveIdentifier, + /// The amount of the named reserve. + pub amount: Balance, +} + +/// An identifier and balance. +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)] +pub struct IdAmount { + /// An identifier for this item. + pub id: Id, + /// Some amount for this item. + pub amount: Balance, +} + +/// All balance information for an account. +#[derive(Encode, Decode, Clone, PartialEq, Eq, Default, RuntimeDebug, MaxEncodedLen, TypeInfo)] +pub struct AccountData { + /// Non-reserved part of the balance which the account holder may be able to control. + /// + /// This is the only balance that matters in terms of most operations on tokens. + pub free: Balance, + /// Balance which is has active holds on it and may not be used at all. + /// + /// This is the sum of all individual holds together with any sums still under the (deprecated) + /// reserves API. + pub reserved: Balance, + /// The amount that `free` may not drop below when reducing the balance, except for actions + /// where the account owner cannot reasonably benefit from thr balance reduction, such as + /// slashing. + pub frozen: Balance, + /// Extra information about this account. The MSB is a flag indicating whether the new ref- + /// counting logic is in place for this account. + pub flags: ExtraFlags, +} + +const IS_NEW_LOGIC: u128 = 0x80000000_00000000_00000000_00000000u128; + +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)] +pub struct ExtraFlags(u128); +impl Default for ExtraFlags { + fn default() -> Self { + Self(IS_NEW_LOGIC) + } +} +impl ExtraFlags { + pub fn old_logic() -> Self { + Self(0) + } + pub fn set_new_logic(&mut self) { + self.0 = self.0 | IS_NEW_LOGIC + } + pub fn is_new_logic(&self) -> bool { + (self.0 & IS_NEW_LOGIC) == IS_NEW_LOGIC + } +} + +impl AccountData { + pub fn usable(&self) -> Balance { + self.free.saturating_sub(self.frozen) + } + + /// The total balance in this account including any that is reserved and ignoring any frozen. + pub fn total(&self) -> Balance { + self.free.saturating_add(self.reserved) + } +} + +pub struct DustCleaner, I: 'static = ()>( + pub(crate) Option<(T::AccountId, CreditOf)>, +); + +impl, I: 'static> Drop for DustCleaner { + fn drop(&mut self) { + if let Some((who, dust)) = self.0.take() { + Pallet::::deposit_event(Event::DustLost { account: who, amount: dust.peek() }); + T::DustRemoval::on_unbalanced(dust); + } + } +} diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index e7fd539c061aa..a2a9f0019b931 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -49,13 +49,14 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_balances. pub trait WeightInfo { - fn transfer() -> Weight; + fn transfer_allow_death() -> Weight; fn transfer_keep_alive() -> Weight; - fn set_balance_creating() -> Weight; - fn set_balance_killing() -> Weight; + fn force_set_balance_creating() -> Weight; + fn force_set_balance_killing() -> Weight; fn force_transfer() -> Weight; fn transfer_all() -> Weight; fn force_unreserve() -> Weight; + fn upgrade_accounts(u: u32, ) -> Weight; } /// Weights for pallet_balances using the Substrate node and recommended hardware. @@ -63,7 +64,7 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn transfer() -> Weight { + fn transfer_allow_death() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` @@ -85,7 +86,7 @@ impl WeightInfo for SubstrateWeight { } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn set_balance_creating() -> Weight { + fn force_set_balance_creating() -> Weight { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` @@ -96,7 +97,7 @@ impl WeightInfo for SubstrateWeight { } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn set_balance_killing() -> Weight { + fn force_set_balance_killing() -> Weight { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` @@ -138,13 +139,28 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } + /// Storage: System Account (r:999 w:999) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + u * (135 ±0)` + // Estimated: `990 + u * (2603 ±0)` + // Minimum execution time: 19_851_000 picoseconds. + Weight::from_parts(20_099_000, 990) + // Standard Error: 15_586 + .saturating_add(Weight::from_parts(14_892_860, 0).saturating_mul(u.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) + } } // For backwards compatibility and tests impl WeightInfo for () { /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn transfer() -> Weight { + fn transfer_allow_death() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` @@ -166,7 +182,7 @@ impl WeightInfo for () { } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn set_balance_creating() -> Weight { + fn force_set_balance_creating() -> Weight { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` @@ -177,7 +193,7 @@ impl WeightInfo for () { } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn set_balance_killing() -> Weight { + fn force_set_balance_killing() -> Weight { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` @@ -219,4 +235,19 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } + /// Storage: System Account (r:999 w:999) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + u * (135 ±0)` + // Estimated: `990 + u * (2603 ±0)` + // Minimum execution time: 19_851_000 picoseconds. + Weight::from_parts(20_099_000, 990) + // Standard Error: 15_586 + .saturating_add(Weight::from_parts(14_892_860, 0).saturating_mul(u.into())) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(u.into()))) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) + } } diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index c92966235118e..ceb95263e2436 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -161,6 +161,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU128<1>; type AccountStore = System; type WeightInfo = (); + type HoldIdentifier = (); + type MaxHolds = (); + type FreezeIdentifier = (); + type MaxFreezes = (); } impl pallet_timestamp::Config for Test { diff --git a/frame/bounties/src/benchmarking.rs b/frame/bounties/src/benchmarking.rs index 04465a25eb891..0675328c3d3c2 100644 --- a/frame/bounties/src/benchmarking.rs +++ b/frame/bounties/src/benchmarking.rs @@ -57,9 +57,12 @@ fn setup_bounty, I: 'static>( let fee = value / 2u32.into(); let deposit = T::BountyDepositBase::get() + T::DataDepositPerByte::get() * T::MaximumReasonLength::get().into(); - let _ = T::Currency::make_free_balance_be(&caller, deposit); + let _ = T::Currency::make_free_balance_be(&caller, deposit + T::Currency::minimum_balance()); let curator = account("curator", u, SEED); - let _ = T::Currency::make_free_balance_be(&curator, fee / 2u32.into()); + let _ = T::Currency::make_free_balance_be( + &curator, + fee / 2u32.into() + T::Currency::minimum_balance(), + ); let reason = vec![0; d as usize]; (caller, curator, fee, value, reason) } diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 27aa0858523ec..ef3da7564874e 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -100,6 +100,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); @@ -754,7 +758,7 @@ fn award_and_claim_bounty_works() { System::set_block_number(5); >::on_initialize(5); - assert_ok!(Balances::transfer( + assert_ok!(Balances::transfer_allow_death( RuntimeOrigin::signed(0), Bounties::bounty_account_id(0), 10 @@ -832,7 +836,7 @@ fn cancel_and_refund() { System::set_block_number(2); >::on_initialize(2); - assert_ok!(Balances::transfer( + assert_ok!(Balances::transfer_allow_death( RuntimeOrigin::signed(0), Bounties::bounty_account_id(0), 10 diff --git a/frame/child-bounties/src/benchmarking.rs b/frame/child-bounties/src/benchmarking.rs index 0a83f7c394905..e49d9c836125d 100644 --- a/frame/child-bounties/src/benchmarking.rs +++ b/frame/child-bounties/src/benchmarking.rs @@ -63,9 +63,12 @@ fn setup_bounty( let fee = value / 2u32.into(); let deposit = T::BountyDepositBase::get() + T::DataDepositPerByte::get() * T::MaximumReasonLength::get().into(); - let _ = T::Currency::make_free_balance_be(&caller, deposit); + let _ = T::Currency::make_free_balance_be(&caller, deposit + T::Currency::minimum_balance()); let curator = account("curator", user, SEED); - let _ = T::Currency::make_free_balance_be(&curator, fee / 2u32.into()); + let _ = T::Currency::make_free_balance_be( + &curator, + fee / 2u32.into() + T::Currency::minimum_balance(), + ); let reason = vec![0; description as usize]; (caller, curator, fee, value, reason) } @@ -73,7 +76,10 @@ fn setup_bounty( fn setup_child_bounty(user: u32, description: u32) -> BenchmarkChildBounty { let (caller, curator, fee, value, reason) = setup_bounty::(user, description); let child_curator = account("child-curator", user, SEED); - let _ = T::Currency::make_free_balance_be(&child_curator, fee / 2u32.into()); + let _ = T::Currency::make_free_balance_be( + &child_curator, + fee / 2u32.into() + T::Currency::minimum_balance(), + ); let child_bounty_value = (value - fee) / 4u32.into(); let child_bounty_fee = child_bounty_value / 2u32.into(); diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 0172468ec55d6..a936312aec868 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -35,7 +35,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BadOrigin, BlakeTwo256, IdentityLookup}, - Perbill, Permill, + Perbill, Permill, TokenError, }; use super::Event as ChildBountiesEvent; @@ -103,6 +103,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); @@ -248,7 +252,7 @@ fn add_child_bounty() { assert_noop!( ChildBounties::add_child_bounty(RuntimeOrigin::signed(4), 0, 50, b"12345-p1".to_vec()), - pallet_balances::Error::::KeepAlive, + TokenError::NotExpendable, ); assert_noop!( diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 2fb033cf85d8c..fb8e4ac4b3634 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -798,15 +798,15 @@ benchmarks! { let instance = Contract::::new(code, vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); let deposit_account = instance.info()?.deposit_account().clone(); - assert_eq!(T::Currency::total_balance(&beneficiary), 0u32.into()); + assert_eq!(>::total_balance(&beneficiary), 0u32.into()); assert_eq!(T::Currency::free_balance(&instance.account_id), Pallet::::min_balance() * 2u32.into()); assert_ne!(T::Currency::free_balance(&deposit_account), 0u32.into()); }: call(origin, instance.addr.clone(), 0u32.into(), Weight::MAX, None, vec![]) verify { if r > 0 { - assert_eq!(T::Currency::total_balance(&instance.account_id), 0u32.into()); - assert_eq!(T::Currency::total_balance(&deposit_account), 0u32.into()); - assert_eq!(T::Currency::total_balance(&beneficiary), Pallet::::min_balance() * 2u32.into()); + assert_eq!(>::total_balance(&instance.account_id), 0u32.into()); + assert_eq!(>::total_balance(&deposit_account), 0u32.into()); + assert_eq!(>::total_balance(&beneficiary), Pallet::::min_balance() * 2u32.into()); } } @@ -1573,12 +1573,12 @@ benchmarks! { instance.set_balance(value * (r + 1).into()); let origin = RawOrigin::Signed(instance.caller.clone()); for account in &accounts { - assert_eq!(T::Currency::total_balance(account), 0u32.into()); + assert_eq!(>::total_balance(account), 0u32.into()); } }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) verify { for account in &accounts { - assert_eq!(T::Currency::total_balance(account), value); + assert_eq!(>::total_balance(account), value); } } diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index bd63c524c6152..6a053712e66e7 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -25,7 +25,10 @@ use frame_support::{ crypto::ecdsa::ECDSAExt, dispatch::{DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable}, storage::{with_transaction, TransactionOutcome}, - traits::{Contains, Currency, ExistenceRequirement, OriginTrait, Randomness, Time}, + traits::{ + tokens::{Fortitude::Polite, Preservation::Expendable}, + Contains, Currency, ExistenceRequirement, OriginTrait, Randomness, Time, + }, weights::Weight, Blake2_128Concat, BoundedVec, StorageHasher, }; @@ -1198,7 +1201,7 @@ where T::Currency::transfer( &frame.account_id, beneficiary, - T::Currency::reducible_balance(&frame.account_id, false), + T::Currency::reducible_balance(&frame.account_id, Expendable, Polite), ExistenceRequirement::AllowDeath, )?; info.queue_trie_for_deletion()?; @@ -2751,8 +2754,10 @@ mod tests { RuntimeCall::System(SysCall::remark_with_event { remark: b"Hello".to_vec() }); // transfers are disallowed by the `TestFiler` (see below) - let forbidden_call = - RuntimeCall::Balances(BalanceCall::transfer { dest: CHARLIE, value: 22 }); + let forbidden_call = RuntimeCall::Balances(BalanceCall::transfer_allow_death { + dest: CHARLIE, + value: 22, + }); // simple cases: direct call assert_err!( @@ -2772,7 +2777,7 @@ mod tests { }); TestFilter::set_filter(|call| match call { - RuntimeCall::Balances(pallet_balances::Call::transfer { .. }) => false, + RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. }) => false, _ => true, }); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 7aac94d11148b..d3369b6c290bf 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -187,7 +187,7 @@ pub mod pallet { type Randomness: Randomness; /// The currency in which fees are paid and contract balances are held. - type Currency: ReservableCurrency + type Currency: ReservableCurrency // TODO: Move to fungible traits + Inspect>; /// The overarching event type. diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index b4fc443fe7f35..ef3e01f6d6c4f 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -25,7 +25,10 @@ use codec::Encode; use frame_support::{ dispatch::DispatchError, ensure, - traits::{tokens::WithdrawConsequence, Currency, ExistenceRequirement, Get}, + traits::{ + tokens::{Fortitude::Polite, Preservation::Protect, WithdrawConsequence}, + Currency, ExistenceRequirement, Get, + }, DefaultNoBound, RuntimeDebugNoBound, }; use pallet_contracts_primitives::StorageDeposit as Deposit; @@ -456,7 +459,7 @@ impl Ext for ReservingExt { // We are sending the `min_leftover` and the `min_balance` from the origin // account as part of a contract call. Hence origin needs to have those left over // as free balance after accounting for all deposits. - let max = T::Currency::reducible_balance(origin, true) + let max = T::Currency::reducible_balance(origin, Protect, Polite) .saturating_sub(min_leftover) .saturating_sub(Pallet::::min_balance()); let limit = limit.unwrap_or(max); diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 30a39eebfcfdd..185945b71e5be 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -37,7 +37,7 @@ use frame_support::{ storage::child, traits::{ ConstU32, ConstU64, Contains, Currency, ExistenceRequirement, Get, LockableCurrency, - OnIdle, OnInitialize, ReservableCurrency, WithdrawReasons, + OnIdle, OnInitialize, WithdrawReasons, }, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, }; @@ -48,7 +48,7 @@ use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ testing::{Header, H256}, traits::{BlakeTwo256, Convert, Hash, IdentityLookup}, - AccountId32, + AccountId32, TokenError, }; use std::{ops::Deref, sync::Arc}; @@ -318,6 +318,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl pallet_timestamp::Config for Test { @@ -1054,7 +1058,7 @@ fn transfer_allow_death_cannot_kill_account() { total_balance, ExistenceRequirement::AllowDeath, ), - pallet_balances::Error::::KeepAlive, + TokenError::Frozen, ); assert_eq!(::Currency::total_balance(&addr), total_balance); @@ -1474,25 +1478,6 @@ fn transfer_return_code() { .result .unwrap(); assert_return_code!(result, RuntimeReturnCode::TransferFailed); - - // Contract has enough total balance in order to not go below the min balance - // threshold when transfering 100 balance but this balance is reserved so - // the transfer still fails. - Balances::make_free_balance_be(&addr, min_balance + 100); - Balances::reserve(&addr, min_balance + 100).unwrap(); - let result = Contracts::bare_call( - ALICE, - addr, - 0, - GAS_LIMIT, - None, - vec![], - false, - Determinism::Deterministic, - ) - .result - .unwrap(); - assert_return_code!(result, RuntimeReturnCode::TransferFailed); }); } @@ -1569,29 +1554,6 @@ fn call_return_code() { .unwrap(); assert_return_code!(result, RuntimeReturnCode::TransferFailed); - // Contract has enough total balance in order to not go below the min balance - // threshold when transfering 100 balance but this balance is reserved so - // the transfer still fails. - Balances::make_free_balance_be(&addr_bob, min_balance + 100); - Balances::reserve(&addr_bob, min_balance + 100).unwrap(); - let result = Contracts::bare_call( - ALICE, - addr_bob.clone(), - 0, - GAS_LIMIT, - None, - AsRef::<[u8]>::as_ref(&addr_django) - .iter() - .chain(&0u32.to_le_bytes()) - .cloned() - .collect(), - false, - Determinism::Deterministic, - ) - .result - .unwrap(); - assert_return_code!(result, RuntimeReturnCode::TransferFailed); - // Contract has enough balance but callee reverts because "1" is passed. Balances::make_free_balance_be(&addr_bob, min_balance + 1000); let result = Contracts::bare_call( @@ -1683,25 +1645,6 @@ fn instantiate_return_code() { .unwrap(); assert_return_code!(result, RuntimeReturnCode::TransferFailed); - // Contract has enough total balance in order to not go below the min_balance - // threshold when transfering the balance but this balance is reserved so - // the transfer still fails. - Balances::make_free_balance_be(&addr, min_balance + 10_000); - Balances::reserve(&addr, min_balance + 10_000).unwrap(); - let result = Contracts::bare_call( - ALICE, - addr.clone(), - 0, - GAS_LIMIT, - None, - callee_hash.clone(), - false, - Determinism::Deterministic, - ) - .result - .unwrap(); - assert_return_code!(result, RuntimeReturnCode::TransferFailed); - // Contract has enough balance but the passed code hash is invalid Balances::make_free_balance_be(&addr, min_balance + 10_000); let result = Contracts::bare_call( @@ -2805,7 +2748,7 @@ fn gas_estimation_call_runtime() { // Call something trivial with a huge gas limit so that we can observe the effects // of pre-charging. This should create a difference between consumed and required. - let call = RuntimeCall::Balances(pallet_balances::Call::transfer { + let call = RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { dest: addr_callee, value: min_balance * 10, }); diff --git a/frame/conviction-voting/src/benchmarking.rs b/frame/conviction-voting/src/benchmarking.rs index 27f46507d6078..8701ed7ebb074 100644 --- a/frame/conviction-voting/src/benchmarking.rs +++ b/frame/conviction-voting/src/benchmarking.rs @@ -23,7 +23,11 @@ use assert_matches::assert_matches; use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelist_account}; use frame_support::{ dispatch::RawOrigin, - traits::{fungible, Currency, Get}, + traits::{ + fungible, + tokens::{Fortitude::Polite, Preservation::Expendable}, + Currency, Get, + }, }; use sp_runtime::traits::Bounded; use sp_std::collections::btree_map::BTreeMap; @@ -257,13 +261,13 @@ benchmarks_instance_pallet! { } } - let orig_usable = >::reducible_balance(&caller, false); + let orig_usable = >::reducible_balance(&caller, Expendable, Polite); let polls = &all_polls[&class]; // Vote big on the class with the most ongoing votes of them to bump the lock and make it // hard to recompute when removed. ConvictionVoting::::vote(RawOrigin::Signed(caller.clone()).into(), polls[0], big_account_vote)?; - let now_usable = >::reducible_balance(&caller, false); + let now_usable = >::reducible_balance(&caller, Expendable, Polite); assert_eq!(orig_usable - now_usable, 100u32.into()); // Remove the vote @@ -272,7 +276,7 @@ benchmarks_instance_pallet! { // We can now unlock on `class` from 200 to 100... }: _(RawOrigin::Signed(caller.clone()), class, caller_lookup) verify { - assert_eq!(orig_usable, >::reducible_balance(&caller, false)); + assert_eq!(orig_usable, >::reducible_balance(&caller, Expendable, Polite)); } impl_benchmark_test_suite!( diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index f28953c4a35b9..072e57035484d 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -388,7 +388,10 @@ impl, I: 'static> Pallet { poll_index: PollIndexOf, vote: AccountVote>, ) -> DispatchResult { - ensure!(vote.balance() <= T::Currency::free_balance(who), Error::::InsufficientFunds); + ensure!( + vote.balance() <= T::Currency::total_balance(who), + Error::::InsufficientFunds + ); T::Polls::try_access_poll(poll_index, |poll_status| { let (tally, class) = poll_status.ensure_ongoing().ok_or(Error::::NotOngoing)?; VotingFor::::try_mutate(who, &class, |voting| { @@ -548,7 +551,7 @@ impl, I: 'static> Pallet { ) -> Result { ensure!(who != target, Error::::Nonsense); T::Polls::classes().binary_search(&class).map_err(|_| Error::::BadClass)?; - ensure!(balance <= T::Currency::free_balance(&who), Error::::InsufficientFunds); + ensure!(balance <= T::Currency::total_balance(&who), Error::::InsufficientFunds); let votes = VotingFor::::try_mutate(&who, &class, |voting| -> Result { let old = sp_std::mem::replace( diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index e01931d7ad24a..f33e511a164f6 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -51,7 +51,7 @@ frame_support::construct_runtime!( pub struct BaseFilter; impl Contains for BaseFilter { fn contains(call: &RuntimeCall) -> bool { - !matches!(call, &RuntimeCall::Balances(pallet_balances::Call::set_balance { .. })) + !matches!(call, &RuntimeCall::Balances(pallet_balances::Call::force_set_balance { .. })) } } @@ -92,6 +92,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } #[derive(Clone, PartialEq, Eq, Debug)] diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 9e735765905d6..06fde5129c6d0 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -72,7 +72,7 @@ frame_support::construct_runtime!( pub struct BaseFilter; impl Contains for BaseFilter { fn contains(call: &RuntimeCall) -> bool { - !matches!(call, &RuntimeCall::Balances(pallet_balances::Call::set_balance { .. })) + !matches!(call, &RuntimeCall::Balances(pallet_balances::Call::force_set_balance { .. })) } } @@ -144,6 +144,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { pub static PreimageByteDeposit: u64 = 0; @@ -223,7 +227,7 @@ fn params_should_work() { } fn set_balance_proposal(value: u64) -> BoundedCallOf { - let inner = pallet_balances::Call::set_balance { who: 42, new_free: value, new_reserved: 0 }; + let inner = pallet_balances::Call::force_set_balance { who: 42, new_free: value }; let outer = RuntimeCall::Balances(inner); Preimage::bound(outer).unwrap() } diff --git a/frame/election-provider-multi-phase/src/benchmarking.rs b/frame/election-provider-multi-phase/src/benchmarking.rs index 4d48f17909c0e..a5946c6a1d3c1 100644 --- a/frame/election-provider-multi-phase/src/benchmarking.rs +++ b/frame/election-provider-multi-phase/src/benchmarking.rs @@ -219,7 +219,7 @@ frame_benchmarking::benchmarks! { finalize_signed_phase_accept_solution { let receiver = account("receiver", 0, SEED); - let initial_balance = T::Currency::minimum_balance() * 10u32.into(); + let initial_balance = T::Currency::minimum_balance() + 10u32.into(); T::Currency::make_free_balance_be(&receiver, initial_balance); let ready = Default::default(); let deposit: BalanceOf = 10u32.into(); @@ -228,7 +228,7 @@ frame_benchmarking::benchmarks! { let call_fee: BalanceOf = 30u32.into(); assert_ok!(T::Currency::reserve(&receiver, deposit)); - assert_eq!(T::Currency::free_balance(&receiver), initial_balance - 10u32.into()); + assert_eq!(T::Currency::free_balance(&receiver), T::Currency::minimum_balance()); }: { >::finalize_signed_phase_accept_solution( ready, @@ -246,17 +246,17 @@ frame_benchmarking::benchmarks! { finalize_signed_phase_reject_solution { let receiver = account("receiver", 0, SEED); - let initial_balance = T::Currency::minimum_balance().max(One::one()) * 10u32.into(); + let initial_balance = T::Currency::minimum_balance() + 10u32.into(); let deposit: BalanceOf = 10u32.into(); T::Currency::make_free_balance_be(&receiver, initial_balance); assert_ok!(T::Currency::reserve(&receiver, deposit)); - assert_eq!(T::Currency::free_balance(&receiver), initial_balance - 10u32.into()); + assert_eq!(T::Currency::free_balance(&receiver), T::Currency::minimum_balance()); assert_eq!(T::Currency::reserved_balance(&receiver), 10u32.into()); }: { >::finalize_signed_phase_reject_solution(&receiver, deposit) } verify { - assert_eq!(T::Currency::free_balance(&receiver), initial_balance - 10u32.into()); + assert_eq!(T::Currency::free_balance(&receiver), T::Currency::minimum_balance()); assert_eq!(T::Currency::reserved_balance(&receiver), 0u32.into()); } diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index da7a0cf1dd263..8c18777606048 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -254,6 +254,10 @@ impl pallet_balances::Config for Runtime { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } #[derive(Default, Eq, PartialEq, Debug, Clone, Copy)] diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index e3eed6ec4bcc4..d83c94db139a4 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1248,6 +1248,10 @@ mod tests { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } frame_support::parameter_types! { @@ -2121,7 +2125,8 @@ mod tests { assert_ok!(submit_candidacy(RuntimeOrigin::signed(4))); // User has 100 free and 50 reserved. - assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 2, 100, 50)); + assert_ok!(Balances::force_set_balance(RuntimeOrigin::root(), 2, 150)); + assert_ok!(Balances::reserve(&2, 50)); // User tries to vote with 150 tokens. assert_ok!(vote(RuntimeOrigin::signed(2), vec![4, 5], 150)); // We truncate to only their free balance, after reserving additional for voting. diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index 2e6a03bdd857c..d9a8a4e8e1cdc 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -87,6 +87,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl Config for Test { diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 7a8de43140c35..10cf6e06b3431 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -688,13 +688,10 @@ mod tests { use frame_support::{ assert_err, parameter_types, - traits::{ - ConstU32, ConstU64, ConstU8, Currency, LockIdentifier, LockableCurrency, - WithdrawReasons, - }, + traits::{fungible, ConstU32, ConstU64, ConstU8, Currency}, weights::{ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight, WeightToFee}, }; - use frame_system::{Call as SystemCall, ChainContext, LastRuntimeUpgradeInfo}; + use frame_system::{ChainContext, LastRuntimeUpgradeInfo}; use pallet_balances::Call as BalancesCall; use pallet_transaction_payment::CurrencyAdapter; @@ -899,6 +896,10 @@ mod tests { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = ConstU32<1>; + type HoldIdentifier = (); + type MaxHolds = ConstU32<1>; } parameter_types! { @@ -972,7 +973,7 @@ mod tests { } fn call_transfer(dest: u64, value: u64) -> RuntimeCall { - RuntimeCall::Balances(BalancesCall::transfer { dest, value }) + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest, value }) } #[test] @@ -1025,13 +1026,13 @@ mod tests { block_import_works_inner( new_test_ext_v0(1), array_bytes::hex_n_into_unchecked( - "216e61b2689d1243eb56d89c9084db48e50ebebc4871d758db131432c675d7c0", + "65e953676859e7a33245908af7ad3637d6861eb90416d433d485e95e2dd174a1", ), ); block_import_works_inner( new_test_ext(1), array_bytes::hex_n_into_unchecked( - "4738b4c0aab02d6ddfa62a2a6831ccc975a9f978f7db8d7ea8e68eba8639530a", + "5a19b3d6fdb7241836349fdcbe2d9df4d4f945b949d979e31ad50bff1cbcd1c2", ), ); } @@ -1116,7 +1117,7 @@ mod tests { let mut t = new_test_ext(10000); // given: TestXt uses the encoded len as fixed Len: let xt = TestXt::new( - RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }), sign_extra(1, 0, 0), ); let encoded = xt.encode(); @@ -1139,7 +1140,10 @@ mod tests { for nonce in 0..=num_to_exhaust_block { let xt = TestXt::new( - RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { + dest: 33, + value: 0, + }), sign_extra(1, nonce.into(), 0), ); let res = Executive::apply_extrinsic(xt); @@ -1164,15 +1168,15 @@ mod tests { #[test] fn block_weight_and_size_is_stored_per_tx() { let xt = TestXt::new( - RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }), sign_extra(1, 0, 0), ); let x1 = TestXt::new( - RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }), sign_extra(1, 1, 0), ); let x2 = TestXt::new( - RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }), sign_extra(1, 2, 0), ); let len = xt.clone().encode().len() as u32; @@ -1258,50 +1262,30 @@ mod tests { } #[test] - fn can_pay_for_tx_fee_on_full_lock() { - let id: LockIdentifier = *b"0 "; - let execute_with_lock = |lock: WithdrawReasons| { - let mut t = new_test_ext(1); - t.execute_with(|| { - as LockableCurrency>::set_lock( - id, &1, 110, lock, - ); - let xt = TestXt::new( - RuntimeCall::System(SystemCall::remark { remark: vec![1u8] }), - sign_extra(1, 0, 0), - ); - let weight = xt.get_dispatch_info().weight + - ::BlockWeights::get() - .get(DispatchClass::Normal) - .base_extrinsic; - let fee: Balance = - ::WeightToFee::weight_to_fee( - &weight, - ); - Executive::initialize_block(&Header::new( - 1, - H256::default(), - H256::default(), - [69u8; 32].into(), - Digest::default(), - )); - - if lock == WithdrawReasons::except(WithdrawReasons::TRANSACTION_PAYMENT) { - assert!(Executive::apply_extrinsic(xt).unwrap().is_ok()); - // tx fee has been deducted. - assert_eq!(>::total_balance(&1), 111 - fee); - } else { - assert_eq!( - Executive::apply_extrinsic(xt), - Err(InvalidTransaction::Payment.into()), - ); - assert_eq!(>::total_balance(&1), 111); - } - }); - }; + fn can_not_pay_for_tx_fee_on_full_lock() { + let mut t = new_test_ext(1); + t.execute_with(|| { + as fungible::MutateFreeze>::set_freeze( + &(), + &1, + 110, + ) + .unwrap(); + let xt = TestXt::new( + RuntimeCall::System(frame_system::Call::remark { remark: vec![1u8] }), + sign_extra(1, 0, 0), + ); + Executive::initialize_block(&Header::new( + 1, + H256::default(), + H256::default(), + [69u8; 32].into(), + Digest::default(), + )); - execute_with_lock(WithdrawReasons::all()); - execute_with_lock(WithdrawReasons::except(WithdrawReasons::TRANSACTION_PAYMENT)); + assert_eq!(Executive::apply_extrinsic(xt), Err(InvalidTransaction::Payment.into()),); + assert_eq!(>::total_balance(&1), 111); + }); } #[test] @@ -1443,7 +1427,7 @@ mod tests { #[test] fn custom_runtime_upgrade_is_called_when_using_execute_block_trait() { let xt = TestXt::new( - RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }), sign_extra(1, 0, 0), ); @@ -1569,7 +1553,7 @@ mod tests { #[should_panic(expected = "Invalid inherent position for extrinsic at index 1")] fn invalid_inherent_position_fail() { let xt1 = TestXt::new( - RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }), sign_extra(1, 0, 0), ); let xt2 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent_call {}), None); diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index c9a1d6d517308..fbe6c4592bf67 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -89,6 +89,10 @@ impl pallet_balances::Config for Runtime { type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } pallet_staking_reward_curve::build! { diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 4e4f2f79d040e..a7359f6896db7 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -142,6 +142,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU128<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl pallet_timestamp::Config for Test { diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 0e15f08ddd7e6..ba9749172e5f6 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -85,6 +85,10 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 6cf1f9d9740c9..8bd05d04ab4e1 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -76,6 +76,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl Config for Test { diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 9b1a933d0a4ac..7afd0e319db34 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -89,6 +89,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { diff --git a/frame/lottery/src/tests.rs b/frame/lottery/src/tests.rs index 09386c7e348d8..ae3a6c858f242 100644 --- a/frame/lottery/src/tests.rs +++ b/frame/lottery/src/tests.rs @@ -23,8 +23,7 @@ use mock::{ new_test_ext, run_to_block, Balances, BalancesCall, Lottery, RuntimeCall, RuntimeOrigin, SystemCall, Test, }; -use pallet_balances::Error as BalancesError; -use sp_runtime::traits::BadOrigin; +use sp_runtime::{traits::BadOrigin, TokenError}; #[test] fn initial_state() { @@ -45,7 +44,7 @@ fn basic_end_to_end_works() { let delay = 5; let calls = vec![ RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), - RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 }), ]; // Set calls for the lottery @@ -56,7 +55,10 @@ fn basic_end_to_end_works() { assert!(crate::Lottery::::get().is_some()); assert_eq!(Balances::free_balance(&1), 100); - let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 20 })); + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer_allow_death { + dest: 2, + value: 20, + })); assert_ok!(Lottery::buy_ticket(RuntimeOrigin::signed(1), call.clone())); // 20 from the transfer, 10 from buying a ticket assert_eq!(Balances::free_balance(&1), 100 - 20 - 10); @@ -129,7 +131,7 @@ fn set_calls_works() { let calls = vec![ RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), - RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 }), ]; assert_ok!(Lottery::set_calls(RuntimeOrigin::root(), calls)); @@ -137,7 +139,7 @@ fn set_calls_works() { let too_many_calls = vec![ RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), - RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 }), RuntimeCall::System(SystemCall::remark { remark: vec![] }), ]; @@ -157,7 +159,7 @@ fn call_to_indices_works() { new_test_ext().execute_with(|| { let calls = vec![ RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), - RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 }), ]; let indices = Lottery::calls_to_indices(&calls).unwrap().into_inner(); // Only comparing the length since it is otherwise dependant on the API @@ -166,7 +168,7 @@ fn call_to_indices_works() { let too_many_calls = vec![ RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), - RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 }), RuntimeCall::System(SystemCall::remark { remark: vec![] }), ]; assert_noop!(Lottery::calls_to_indices(&too_many_calls), Error::::TooManyCalls); @@ -203,7 +205,10 @@ fn buy_ticket_works_as_simple_passthrough() { // as a simple passthrough to the real call. new_test_ext().execute_with(|| { // No lottery set up - let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 20 })); + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer_allow_death { + dest: 2, + value: 20, + })); // This is just a basic transfer then assert_ok!(Lottery::buy_ticket(RuntimeOrigin::signed(1), call.clone())); assert_eq!(Balances::free_balance(&1), 100 - 20); @@ -212,7 +217,7 @@ fn buy_ticket_works_as_simple_passthrough() { // Lottery is set up, but too expensive to enter, so `do_buy_ticket` fails. let calls = vec![ RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), - RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 }), ]; assert_ok!(Lottery::set_calls(RuntimeOrigin::root(), calls)); @@ -223,11 +228,13 @@ fn buy_ticket_works_as_simple_passthrough() { assert_eq!(TicketsCount::::get(), 0); // If call would fail, the whole thing still fails the same - let fail_call = - Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 1000 })); + let fail_call = Box::new(RuntimeCall::Balances(BalancesCall::transfer_allow_death { + dest: 2, + value: 1000, + })); assert_noop!( Lottery::buy_ticket(RuntimeOrigin::signed(1), fail_call), - BalancesError::::InsufficientBalance, + ArithmeticError::Underflow, ); let bad_origin_call = Box::new(RuntimeCall::Balances(BalancesCall::force_transfer { @@ -243,8 +250,10 @@ fn buy_ticket_works_as_simple_passthrough() { assert_ok!(Lottery::buy_ticket(RuntimeOrigin::signed(2), remark_call)); assert_eq!(TicketsCount::::get(), 0); - let successful_call = - Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 1 })); + let successful_call = Box::new(RuntimeCall::Balances(BalancesCall::transfer_allow_death { + dest: 2, + value: 1, + })); assert_ok!(Lottery::buy_ticket(RuntimeOrigin::signed(2), successful_call)); assert_eq!(TicketsCount::::get(), 1); }); @@ -256,12 +265,15 @@ fn buy_ticket_works() { // Set calls for the lottery. let calls = vec![ RuntimeCall::System(SystemCall::remark { remark: vec![] }), - RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 }), ]; assert_ok!(Lottery::set_calls(RuntimeOrigin::root(), calls)); // Can't buy ticket before start - let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 1 })); + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer_allow_death { + dest: 2, + value: 1, + })); assert_ok!(Lottery::buy_ticket(RuntimeOrigin::signed(1), call.clone())); assert_eq!(TicketsCount::::get(), 0); @@ -274,7 +286,10 @@ fn buy_ticket_works() { assert_eq!(TicketsCount::::get(), 1); // Can't buy another of the same ticket (even if call is slightly changed) - let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 3, value: 30 })); + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer_allow_death { + dest: 3, + value: 30, + })); assert_ok!(Lottery::buy_ticket(RuntimeOrigin::signed(1), call)); assert_eq!(TicketsCount::::get(), 1); @@ -302,7 +317,8 @@ fn buy_ticket_works() { #[test] fn do_buy_ticket_already_participating() { new_test_ext().execute_with(|| { - let calls = vec![RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; + let calls = + vec![RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 })]; assert_ok!(Lottery::set_calls(RuntimeOrigin::root(), calls.clone())); assert_ok!(Lottery::start_lottery(RuntimeOrigin::root(), 1, 10, 10, false)); @@ -317,7 +333,8 @@ fn do_buy_ticket_already_participating() { #[test] fn buy_ticket_already_participating() { new_test_ext().execute_with(|| { - let calls = vec![RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; + let calls = + vec![RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 })]; assert_ok!(Lottery::set_calls(RuntimeOrigin::root(), calls.clone())); assert_ok!(Lottery::start_lottery(RuntimeOrigin::root(), 1, 10, 10, false)); @@ -337,7 +354,8 @@ fn buy_ticket_already_participating() { #[test] fn buy_ticket_insufficient_balance() { new_test_ext().execute_with(|| { - let calls = vec![RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; + let calls = + vec![RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 })]; assert_ok!(Lottery::set_calls(RuntimeOrigin::root(), calls.clone())); // Price set to 100. assert_ok!(Lottery::start_lottery(RuntimeOrigin::root(), 100, 10, 10, false)); @@ -352,16 +370,14 @@ fn buy_ticket_insufficient_balance() { #[test] fn do_buy_ticket_insufficient_balance() { new_test_ext().execute_with(|| { - let calls = vec![RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; + let calls = + vec![RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 })]; assert_ok!(Lottery::set_calls(RuntimeOrigin::root(), calls.clone())); // Price set to 101. assert_ok!(Lottery::start_lottery(RuntimeOrigin::root(), 101, 10, 10, false)); // Buying fails with InsufficientBalance. - assert_noop!( - Lottery::do_buy_ticket(&1, &calls[0]), - BalancesError::::InsufficientBalance - ); + assert_noop!(Lottery::do_buy_ticket(&1, &calls[0]), TokenError::FundsUnavailable,); assert!(TicketsCount::::get().is_zero()); }); } @@ -369,13 +385,13 @@ fn do_buy_ticket_insufficient_balance() { #[test] fn do_buy_ticket_keep_alive() { new_test_ext().execute_with(|| { - let calls = vec![RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; + let calls = + vec![RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 })]; assert_ok!(Lottery::set_calls(RuntimeOrigin::root(), calls.clone())); // Price set to 100. assert_ok!(Lottery::start_lottery(RuntimeOrigin::root(), 100, 10, 10, false)); - // Buying fails with KeepAlive. - assert_noop!(Lottery::do_buy_ticket(&1, &calls[0]), BalancesError::::KeepAlive); + assert_noop!(Lottery::do_buy_ticket(&1, &calls[0]), TokenError::NotExpendable); assert!(TicketsCount::::get().is_zero()); }); } @@ -421,7 +437,8 @@ fn choose_ticket_trivial_cases() { #[test] fn choose_account_one_participant() { new_test_ext().execute_with(|| { - let calls = vec![RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; + let calls = + vec![RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 0, value: 0 })]; assert_ok!(Lottery::set_calls(RuntimeOrigin::root(), calls.clone())); assert_ok!(Lottery::start_lottery(RuntimeOrigin::root(), 10, 10, 10, false)); let call = Box::new(calls[0].clone()); diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index c5517195d149f..7e7f1668026a2 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -30,6 +30,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + TokenError, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -84,6 +85,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } pub struct TestBaseCallFilter; @@ -107,7 +112,7 @@ impl Config for Test { type WeightInfo = (); } -use pallet_balances::{Call as BalancesCall, Error as BalancesError}; +use pallet_balances::Call as BalancesCall; pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); @@ -126,16 +131,16 @@ fn now() -> Timepoint { } fn call_transfer(dest: u64, value: u64) -> Box { - Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest, value })) + Box::new(RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest, value })) } #[test] fn multisig_deposit_is_taken_and_returned() { new_test_ext().execute_with(|| { let multi = Multisig::multi_account_id(&[1, 2, 3][..], 2); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(2), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(3), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(2), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(3), multi, 5)); let call = call_transfer(6, 15); let call_weight = call.get_dispatch_info().weight; @@ -196,9 +201,9 @@ fn cancel_multisig_returns_deposit() { fn timepoint_checking_works() { new_test_ext().execute_with(|| { let multi = Multisig::multi_account_id(&[1, 2, 3][..], 2); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(2), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(3), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(2), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(3), multi, 5)); let call = call_transfer(6, 15); let hash = blake2_256(&call.encode()); @@ -254,9 +259,9 @@ fn timepoint_checking_works() { fn multisig_2_of_3_works() { new_test_ext().execute_with(|| { let multi = Multisig::multi_account_id(&[1, 2, 3][..], 2); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(2), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(3), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(2), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(3), multi, 5)); let call = call_transfer(6, 15); let call_weight = call.get_dispatch_info().weight; @@ -287,9 +292,9 @@ fn multisig_2_of_3_works() { fn multisig_3_of_3_works() { new_test_ext().execute_with(|| { let multi = Multisig::multi_account_id(&[1, 2, 3][..], 3); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(2), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(3), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(2), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(3), multi, 5)); let call = call_transfer(6, 15); let call_weight = call.get_dispatch_info().weight; @@ -357,9 +362,9 @@ fn cancel_multisig_works() { fn multisig_2_of_3_as_multi_works() { new_test_ext().execute_with(|| { let multi = Multisig::multi_account_id(&[1, 2, 3][..], 2); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(2), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(3), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(2), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(3), multi, 5)); let call = call_transfer(6, 15); let call_weight = call.get_dispatch_info().weight; @@ -389,9 +394,9 @@ fn multisig_2_of_3_as_multi_works() { fn multisig_2_of_3_as_multi_with_many_calls_works() { new_test_ext().execute_with(|| { let multi = Multisig::multi_account_id(&[1, 2, 3][..], 2); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(2), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(3), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(2), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(3), multi, 5)); let call1 = call_transfer(6, 10); let call1_weight = call1.get_dispatch_info().weight; @@ -440,9 +445,9 @@ fn multisig_2_of_3_as_multi_with_many_calls_works() { fn multisig_2_of_3_cannot_reissue_same_call() { new_test_ext().execute_with(|| { let multi = Multisig::multi_account_id(&[1, 2, 3][..], 2); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(2), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(3), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(2), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(3), multi, 5)); let call = call_transfer(6, 10); let call_weight = call.get_dispatch_info().weight; @@ -482,14 +487,13 @@ fn multisig_2_of_3_cannot_reissue_same_call() { call_weight )); - let err = DispatchError::from(BalancesError::::InsufficientBalance).stripped(); System::assert_last_event( pallet_multisig::Event::MultisigExecuted { approving: 3, timepoint: now(), multisig: multi, call_hash: hash, - result: Err(err), + result: Err(TokenError::FundsUnavailable.into()), } .into(), ); @@ -593,9 +597,9 @@ fn duplicate_approvals_are_ignored() { fn multisig_1_of_3_works() { new_test_ext().execute_with(|| { let multi = Multisig::multi_account_id(&[1, 2, 3][..], 1); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(2), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(3), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(2), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(3), multi, 5)); let call = call_transfer(6, 15); let hash = blake2_256(&call.encode()); @@ -646,9 +650,9 @@ fn multisig_filters() { fn weight_check_works() { new_test_ext().execute_with(|| { let multi = Multisig::multi_account_id(&[1, 2, 3][..], 2); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(2), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(3), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(2), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(3), multi, 5)); let call = call_transfer(6, 15); assert_ok!(Multisig::as_multi( @@ -682,9 +686,9 @@ fn multisig_handles_no_preimage_after_all_approve() { // the call will go through. new_test_ext().execute_with(|| { let multi = Multisig::multi_account_id(&[1, 2, 3][..], 3); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(2), multi, 5)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(3), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(2), multi, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(3), multi, 5)); let call = call_transfer(6, 15); let call_weight = call.get_dispatch_info().weight; diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index f21547b720c34..91ac5d6a72203 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -89,6 +89,10 @@ impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index b74d2e6ee40b2..5f510ce8e4cc0 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -295,6 +295,10 @@ mod tests { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } ord_parameter_types! { diff --git a/frame/nis/README.md b/frame/nis/README.md index 4eaddae1786e7..0c3f0c383a16c 100644 --- a/frame/nis/README.md +++ b/frame/nis/README.md @@ -1,2 +1,5 @@ +# NIS Module -License: Apache-2.0 +Provides a non-interactiove variant of staking. + +License: Apache-2.0 \ No newline at end of file diff --git a/frame/nis/src/benchmarking.rs b/frame/nis/src/benchmarking.rs index 6fc9fbc2bffa2..0cc9e7421d0e6 100644 --- a/frame/nis/src/benchmarking.rs +++ b/frame/nis/src/benchmarking.rs @@ -21,7 +21,9 @@ use super::*; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller, BenchmarkError}; -use frame_support::traits::{nonfungible::Inspect, Currency, EnsureOrigin, Get}; +use frame_support::traits::{ + fungible::Inspect as FunInspect, nonfungible::Inspect, EnsureOrigin, Get, +}; use frame_system::RawOrigin; use sp_arithmetic::Perquintill; use sp_runtime::{ @@ -35,7 +37,7 @@ use crate::Pallet as Nis; const SEED: u32 = 0; type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; + <::Currency as FunInspect<::AccountId>>::Balance; fn fill_queues() -> Result<(), DispatchError> { // filling queues involves filling the first queue entirely and placing a single item in all @@ -45,10 +47,7 @@ fn fill_queues() -> Result<(), DispatchError> { let bids = T::MaxQueueLen::get(); let caller: T::AccountId = whitelisted_caller(); - T::Currency::make_free_balance_be( - &caller, - T::MinBid::get() * BalanceOf::::from(queues + bids), - ); + T::Currency::set_balance(&caller, T::MinBid::get() * BalanceOf::::from(queues + bids)); for _ in 0..bids { Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; @@ -63,7 +62,9 @@ benchmarks! { place_bid { let l in 0..(T::MaxQueueLen::get() - 1); let caller: T::AccountId = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); + let ed = T::Currency::minimum_balance(); + let bid = T::MinBid::get(); + T::Currency::set_balance(&caller, (ed + bid) * BalanceOf::::from(l + 1) + bid); for i in 0..l { Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; } @@ -75,7 +76,10 @@ benchmarks! { place_bid_max { let caller: T::AccountId = whitelisted_caller(); let origin = RawOrigin::Signed(caller.clone()); - T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); + let ed = T::Currency::minimum_balance(); + let bid = T::MinBid::get(); + let ql = T::MaxQueueLen::get(); + T::Currency::set_balance(&caller, (ed + bid) * BalanceOf::::from(ql + 1) + bid); for i in 0..T::MaxQueueLen::get() { Nis::::place_bid(origin.clone().into(), T::MinBid::get(), 1)?; } @@ -90,7 +94,9 @@ benchmarks! { retract_bid { let l in 1..T::MaxQueueLen::get(); let caller: T::AccountId = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); + let ed = T::Currency::minimum_balance(); + let bid = T::MinBid::get(); + T::Currency::set_balance(&caller, (ed + bid) * BalanceOf::::from(l + 1) + bid); for i in 0..l { Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; } @@ -104,66 +110,81 @@ benchmarks! { T::FundOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let caller: T::AccountId = whitelisted_caller(); let bid = T::MinBid::get().max(One::one()); - T::Currency::make_free_balance_be(&caller, bid); + let ed = T::Currency::minimum_balance(); + T::Currency::set_balance(&caller, ed + bid); Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), bid, 1)?; Nis::::process_queues(Perquintill::one(), 1, 1, &mut WeightCounter::unlimited()); Nis::::communify(RawOrigin::Signed(caller.clone()).into(), 0)?; - let original = T::Currency::free_balance(&Nis::::account_id()); - T::Currency::make_free_balance_be(&Nis::::account_id(), BalanceOf::::min_value()); + let original = T::Currency::balance(&Nis::::account_id()); + T::Currency::set_balance(&Nis::::account_id(), BalanceOf::::min_value()); }: _(origin) verify { // Must fund at least 99.999% of the required amount. let missing = Perquintill::from_rational( - T::Currency::free_balance(&Nis::::account_id()), original).left_from_one(); + T::Currency::balance(&Nis::::account_id()), original).left_from_one(); assert!(missing <= Perquintill::one() / 100_000); } - thaw_private { + communify { let caller: T::AccountId = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, T::MinBid::get() * BalanceOf::::from(3u32)); - Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; - Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; + let bid = T::MinBid::get().max(One::one()) * 100u32.into(); + let ed = T::Currency::minimum_balance(); + T::Currency::set_balance(&caller, ed + bid + bid); + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), bid, 1)?; + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), bid, 1)?; Nis::::process_queues(Perquintill::one(), 1, 2, &mut WeightCounter::unlimited()); - Receipts::::mutate(0, |m_g| if let Some(ref mut g) = m_g { g.expiry = Zero::zero() }); - }: _(RawOrigin::Signed(caller.clone()), 0, None) + }: _(RawOrigin::Signed(caller.clone()), 0) verify { - assert!(Receipts::::get(0).is_none()); + assert_eq!(Nis::::owner(&0), None); } - thaw_communal { + privatize { let caller: T::AccountId = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, T::MinBid::get() * BalanceOf::::from(3u32)); - Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; - Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; + let bid = T::MinBid::get().max(One::one()); + let ed = T::Currency::minimum_balance(); + T::Currency::set_balance(&caller, ed + bid + bid); + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), bid, 1)?; + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), bid, 1)?; Nis::::process_queues(Perquintill::one(), 1, 2, &mut WeightCounter::unlimited()); - Receipts::::mutate(0, |m_g| if let Some(ref mut g) = m_g { g.expiry = Zero::zero() }); Nis::::communify(RawOrigin::Signed(caller.clone()).into(), 0)?; }: _(RawOrigin::Signed(caller.clone()), 0) verify { - assert!(Receipts::::get(0).is_none()); + assert_eq!(Nis::::owner(&0), Some(caller)); } - privatize { + thaw_private { + let whale: T::AccountId = account("whale", 0, SEED); let caller: T::AccountId = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, T::MinBid::get() * BalanceOf::::from(3u32)); - Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; - Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; + let bid = T::MinBid::get().max(One::one()); + let ed = T::Currency::minimum_balance(); + T::Currency::set_balance(&caller, ed + bid + bid); + // Ensure we don't get throttled. + T::Currency::set_balance(&whale, T::ThawThrottle::get().0.saturating_reciprocal_mul_ceil(T::Currency::balance(&caller))); + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), bid, 1)?; + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), bid, 1)?; Nis::::process_queues(Perquintill::one(), 1, 2, &mut WeightCounter::unlimited()); - Nis::::communify(RawOrigin::Signed(caller.clone()).into(), 0)?; - }: _(RawOrigin::Signed(caller.clone()), 0) + frame_system::Pallet::::set_block_number(Receipts::::get(0).unwrap().expiry); + }: _(RawOrigin::Signed(caller.clone()), 0, None) verify { - assert_eq!(Nis::::owner(&0), Some(caller)); + assert!(Receipts::::get(0).is_none()); } - communify { + thaw_communal { + let whale: T::AccountId = account("whale", 0, SEED); let caller: T::AccountId = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, T::MinBid::get() * BalanceOf::::from(3u32)); - Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; - Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; + let bid = T::MinBid::get().max(One::one()); + let ed = T::Currency::minimum_balance(); + T::Currency::set_balance(&caller, ed + bid + bid); + // Ensure we don't get throttled. + T::Currency::set_balance(&whale, T::ThawThrottle::get().0.saturating_reciprocal_mul_ceil(T::Currency::balance(&caller))); + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), bid, 1)?; + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), bid, 1)?; Nis::::process_queues(Perquintill::one(), 1, 2, &mut WeightCounter::unlimited()); + frame_system::Pallet::::set_block_number(Receipts::::get(0).unwrap().expiry); + Nis::::communify(RawOrigin::Signed(caller.clone()).into(), 0)?; }: _(RawOrigin::Signed(caller.clone()), 0) verify { - assert_eq!(Nis::::owner(&0), None); + assert!(Receipts::::get(0).is_none()); } process_queues { @@ -197,6 +218,9 @@ benchmarks! { process_bid { let who = account::("bidder", 0, SEED); + let min_bid = T::MinBid::get().max(One::one()); + let ed = T::Currency::minimum_balance(); + T::Currency::set_balance(&who, ed + min_bid); let bid = Bid { amount: T::MinBid::get(), who, @@ -216,5 +240,5 @@ benchmarks! { ) } - impl_benchmark_test_suite!(Nis, crate::mock::new_test_ext(), crate::mock::Test); + impl_benchmark_test_suite!(Nis, crate::mock::new_test_ext_empty(), crate::mock::Test); } diff --git a/frame/nis/src/lib.rs b/frame/nis/src/lib.rs index 6fd9c60a89836..0b8d292ec5f45 100644 --- a/frame/nis/src/lib.rs +++ b/frame/nis/src/lib.rs @@ -71,21 +71,21 @@ //! //! ## Terms //! -//! - *Effective total issuance*: The total issuance of balances in the system, including all claims -//! of all outstanding receipts but excluding `IgnoredIssuance`. +//! - *Effective total issuance*: The total issuance of balances in the system, equal to the active +//! issuance plus the value of all outstanding receipts, less `IgnoredIssuance`. #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::{ - dispatch::{DispatchError, DispatchResult}, - traits::fungible::{Inspect as FungibleInspect, Mutate as FungibleMutate}, +use frame_support::traits::{ + fungible::{self, Inspect as FunInspect, Mutate as FunMutate}, + tokens::{DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence}, }; pub use pallet::*; use sp_arithmetic::{traits::Unsigned, RationalArg}; use sp_core::TypedGet; use sp_runtime::{ traits::{Convert, ConvertBack}, - Perquintill, + DispatchError, Perquintill, }; mod benchmarking; @@ -117,7 +117,7 @@ where } pub struct NoCounterpart(sp_std::marker::PhantomData); -impl FungibleInspect for NoCounterpart { +impl FunInspect for NoCounterpart { type Balance = u32; fn total_issuance() -> u32 { 0 @@ -125,34 +125,30 @@ impl FungibleInspect for NoCounterpart { fn minimum_balance() -> u32 { 0 } - fn balance(_who: &T) -> u32 { + fn balance(_: &T) -> u32 { 0 } - fn reducible_balance(_who: &T, _keep_alive: bool) -> u32 { + fn total_balance(_: &T) -> u32 { 0 } - fn can_deposit( - _who: &T, - _amount: u32, - _mint: bool, - ) -> frame_support::traits::tokens::DepositConsequence { - frame_support::traits::tokens::DepositConsequence::Success + fn reducible_balance(_: &T, _: Preservation, _: Fortitude) -> u32 { + 0 } - fn can_withdraw( - _who: &T, - _amount: u32, - ) -> frame_support::traits::tokens::WithdrawConsequence { - frame_support::traits::tokens::WithdrawConsequence::Success + fn can_deposit(_: &T, _: u32, _: Provenance) -> DepositConsequence { + DepositConsequence::Success } -} -impl FungibleMutate for NoCounterpart { - fn mint_into(_who: &T, _amount: u32) -> DispatchResult { - Ok(()) + fn can_withdraw(_: &T, _: u32) -> WithdrawConsequence { + WithdrawConsequence::Success } - fn burn_from(_who: &T, _amount: u32) -> Result { - Ok(0) +} +impl fungible::Unbalanced for NoCounterpart { + fn handle_dust(_: fungible::Dust) {} + fn write_balance(_: &T, _: Self::Balance) -> Result, DispatchError> { + Ok(None) } + fn set_total_issuance(_: Self::Balance) {} } +impl FunMutate for NoCounterpart {} impl Convert for NoCounterpart { fn convert(_: Perquintill) -> u32 { 0 @@ -161,15 +157,24 @@ impl Convert for NoCounterpart { #[frame_support::pallet] pub mod pallet { - use super::{FungibleInspect, FungibleMutate}; + use super::{FunInspect, FunMutate}; pub use crate::weights::WeightInfo; use frame_support::{ pallet_prelude::*, traits::{ - nonfungible::{Inspect as NonfungibleInspect, Transfer as NonfungibleTransfer}, - Currency, Defensive, DefensiveSaturating, - ExistenceRequirement::AllowDeath, - NamedReservableCurrency, OnUnbalanced, + fungible::{ + self, + hold::{Inspect as FunHoldInspect, Mutate as FunHoldMutate}, + Balanced as FunBalanced, + }, + nonfungible::{Inspect as NftInspect, Transfer as NftTransfer}, + tokens::{ + Fortitude::Polite, + Precision::{BestEffort, Exact}, + Preservation::Expendable, + Restriction::{Free, OnHold}, + }, + Defensive, DefensiveSaturating, OnUnbalanced, }, PalletId, }; @@ -177,15 +182,14 @@ pub mod pallet { use sp_arithmetic::{PerThing, Perquintill}; use sp_runtime::{ traits::{AccountIdConversion, Bounded, Convert, ConvertBack, Saturating, Zero}, - TokenError, + Rounding, TokenError, }; use sp_std::prelude::*; type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; - type PositiveImbalanceOf = <::Currency as Currency< - ::AccountId, - >>::PositiveImbalance; + <::Currency as FunInspect<::AccountId>>::Balance; + type DebtOf = + fungible::Debt<::AccountId, ::Currency>; type ReceiptRecordOf = ReceiptRecord< ::AccountId, ::BlockNumber, @@ -209,7 +213,16 @@ pub mod pallet { type PalletId: Get; /// Currency type that this works on. - type Currency: NamedReservableCurrency; + type Currency: FunInspect + + FunMutate + + FunBalanced + + FunHoldInspect + + FunHoldMutate; + + /// The identifier of the hold reason. + + #[pallet::constant] + type HoldReason: Get<>::Reason>; /// Just the `Currency::Balance` type; we have this item to allow us to constrain it to /// `From`. @@ -231,7 +244,7 @@ pub mod pallet { type IgnoredIssuance: Get>; /// The accounting system for the fungible counterpart tokens. - type Counterpart: FungibleMutate; + type Counterpart: FunMutate; /// The system to convert an overall proportion of issuance into a number of fungible /// counterpart tokens. @@ -239,12 +252,12 @@ pub mod pallet { /// In general it's best to use `WithMaximumOf`. type CounterpartAmount: ConvertBack< Perquintill, - >::Balance, + >::Balance, >; /// Unbalanced handler to account for funds created (in case of a higher total issuance over /// freezing period). - type Deficit: OnUnbalanced>; + type Deficit: OnUnbalanced>; /// The target sum of all receipts' proportions. type Target: Get; @@ -301,12 +314,6 @@ pub mod pallet { /// The maximum proportion which may be thawed and the period over which it is reset. #[pallet::constant] type ThawThrottle: Get<(Perquintill, Self::BlockNumber)>; - - /// The name for the reserve ID. - #[pallet::constant] - type ReserveId: Get< - >::ReserveIdentifier, - >; } #[pallet::pallet] @@ -348,7 +355,7 @@ pub mod pallet { /// /// `issuance - frozen + proportion * issuance` /// - /// where `issuance = total_issuance - IgnoredIssuance` + /// where `issuance = active_issuance - IgnoredIssuance` #[derive( Clone, Eq, PartialEq, Default, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen, )] @@ -473,6 +480,9 @@ pub mod pallet { AlreadyCommunal, /// The receipt is already private. AlreadyPrivate, + Release1, + Release2, + Tah, } pub(crate) struct WeightCounter { @@ -554,16 +564,17 @@ pub mod pallet { |q| -> Result<(u32, BalanceOf), DispatchError> { let queue_full = q.len() == T::MaxQueueLen::get() as usize; ensure!(!queue_full || q[0].amount < amount, Error::::BidTooLow); - T::Currency::reserve_named(&T::ReserveId::get(), &who, amount)?; + T::Currency::hold(&T::HoldReason::get(), &who, amount)?; // queue is let mut bid = Bid { amount, who: who.clone() }; let net = if queue_full { sp_std::mem::swap(&mut q[0], &mut bid); - let _ = T::Currency::unreserve_named( - &T::ReserveId::get(), + let _ = T::Currency::release( + &T::HoldReason::get(), &bid.who, bid.amount, + BestEffort, ); Self::deposit_event(Event::::BidDropped { who: bid.who, @@ -615,19 +626,21 @@ pub mod pallet { ensure!(queue_index < queue_count, Error::::DurationTooBig); let bid = Bid { amount, who }; - let new_len = Queues::::try_mutate(duration, |q| -> Result { - let pos = q.iter().position(|i| i == &bid).ok_or(Error::::UnknownBid)?; - q.remove(pos); - Ok(q.len() as u32) - })?; + let mut queue = Queues::::get(duration); + let pos = queue.iter().position(|i| i == &bid).ok_or(Error::::UnknownBid)?; + queue.remove(pos); + let new_len = queue.len() as u32; + + T::Currency::release(&T::HoldReason::get(), &bid.who, bid.amount, BestEffort)?; + + Queues::::insert(duration, queue); QueueTotals::::mutate(|qs| { qs.bounded_resize(queue_count, (0, Zero::zero())); qs[queue_index].0 = new_len; qs[queue_index].1.saturating_reduce(bid.amount); }); - T::Currency::unreserve_named(&T::ReserveId::get(), &bid.who, bid.amount); Self::deposit_event(Event::BidRetracted { who: bid.who, amount: bid.amount, duration }); Ok(()) @@ -645,7 +658,7 @@ pub mod pallet { let issuance = Self::issuance_with(&our_account, &summary); let deficit = issuance.required.saturating_sub(issuance.holdings); ensure!(!deficit.is_zero(), Error::::AlreadyFunded); - T::Deficit::on_unbalanced(T::Currency::deposit_creating(&our_account, deficit)); + T::Deficit::on_unbalanced(T::Currency::deposit(&our_account, deficit, Exact)?); Self::deposit_event(Event::::Funded { deficit }); Ok(()) } @@ -702,6 +715,7 @@ pub mod pallet { // Multiply the proportion it is by the total issued. let our_account = Self::account_id(); let effective_issuance = Self::issuance_with(&our_account, &summary).effective; + // let amount = proportion.mul_ceil(effective_issuance); let amount = proportion * effective_issuance; receipt.proportion.saturating_reduce(proportion); @@ -710,46 +724,40 @@ pub mod pallet { let dropped = receipt.proportion.is_zero(); if amount > on_hold { - T::Currency::unreserve_named(&T::ReserveId::get(), &who, on_hold); + T::Currency::release(&T::HoldReason::get(), &who, on_hold, Exact) + .map_err(|_| Error::::Release1)?; let deficit = amount - on_hold; // Try to transfer deficit from pot to receipt owner. summary.receipts_on_hold.saturating_reduce(on_hold); on_hold = Zero::zero(); - T::Currency::transfer(&our_account, &who, deficit, AllowDeath) + T::Currency::transfer(&our_account, &who, deficit, Expendable) .map_err(|_| Error::::Unfunded)?; } else { - T::Currency::unreserve_named(&T::ReserveId::get(), &who, amount); on_hold.saturating_reduce(amount); summary.receipts_on_hold.saturating_reduce(amount); if dropped && !on_hold.is_zero() { // Reclaim any remainder: - // Transfer `excess` to the pot if we have now fully compensated for the - // receipt. - // - // This will legitimately fail if there is no pot account in existance. - // There's nothing we can do about this so we just swallow the error. - // This code is not ideal and could fail in the second phase leaving - // the system in an invalid state. It can be fixed properly with the - // new API in https://github.com/paritytech/substrate/pull/12951 - // - // Below is what it should look like then: - // let _ = T::Currency::repatriate_reserved_named( - // &T::ReserveId::get(), - // &who, - // &our_account, - // excess, - // BalanceStatus::Free, - // ).defensive(); - T::Currency::unreserve_named(&T::ReserveId::get(), &who, on_hold); - // It could theoretically be locked, so really we should be using a more - // forceful variant. But the alternative `repatriate_reserved_named` will - // fail if the destination account doesn't exist. This should be fixed when - // we move to the `fungible::*` traits, which should include a force - // transfer function to transfer the reserved balance into free balance in - // the destination regardless of locks and create it if it doesn't exist. - let _ = T::Currency::transfer(&who, &Self::account_id(), on_hold, AllowDeath); + // Transfer excess of `on_hold` to the pot if we have now fully compensated for + // the receipt. + T::Currency::transfer_on_hold( + &T::HoldReason::get(), + &who, + &our_account, + on_hold, + Exact, + Free, + Polite, + ) + .map(|_| ()) + // We ignore this error as it just means the amount we're trying to deposit is + // dust and the beneficiary account doesn't exist. + .or_else( + |e| if e == TokenError::CannotCreate.into() { Ok(()) } else { Err(e) }, + )?; summary.receipts_on_hold.saturating_reduce(on_hold); } + T::Currency::release(&T::HoldReason::get(), &who, amount, Exact) + .map_err(|_| Error::::Release2)?; } if dropped { @@ -797,7 +805,8 @@ pub mod pallet { summary.thawed.saturating_accrue(receipt.proportion); ensure!(summary.thawed <= throttle, Error::::Throttled); - T::Counterpart::burn_from(&who, T::CounterpartAmount::convert(receipt.proportion))?; + let cp_amount = T::CounterpartAmount::convert(receipt.proportion); + T::Counterpart::burn_from(&who, cp_amount, Exact, Polite)?; // Multiply the proportion it is by the total issued. let our_account = Self::account_id(); @@ -807,7 +816,7 @@ pub mod pallet { summary.proportion_owed.saturating_reduce(receipt.proportion); // Try to transfer amount owed from pot to receipt owner. - T::Currency::transfer(&our_account, &who, amount, AllowDeath) + T::Currency::transfer(&our_account, &who, amount, Expendable) .map_err(|_| Error::::Unfunded)?; Receipts::::remove(index); @@ -840,11 +849,10 @@ pub mod pallet { ensure!(owner == who, Error::::NotOwner); // Unreserve and transfer the funds to the pot. - T::Currency::unreserve_named(&T::ReserveId::get(), &who, on_hold); - // Transfer `excess` to the pot if we have now fully compensated for the receipt. - T::Currency::transfer(&who, &Self::account_id(), on_hold, AllowDeath) + let reason = T::HoldReason::get(); + let us = Self::account_id(); + T::Currency::transfer_on_hold(&reason, &who, &us, on_hold, Exact, Free, Polite) .map_err(|_| Error::::Unfunded)?; - // TODO #12951: ^^^ The above should be done in a single operation `transfer_on_hold`. // Record that we've moved the amount reserved. let mut summary: SummaryRecordOf = Summary::::get(); @@ -881,16 +889,20 @@ pub mod pallet { let effective_issuance = Self::issuance_with(&our_account, &summary).effective; let max_amount = receipt.proportion * effective_issuance; // Avoid trying to place more in the account's reserve than we have available in the pot - let amount = max_amount.min(T::Currency::free_balance(&our_account)); + let amount = max_amount.min(T::Currency::balance(&our_account)); // Burn fungible counterparts. - T::Counterpart::burn_from(&who, T::CounterpartAmount::convert(receipt.proportion))?; + T::Counterpart::burn_from( + &who, + T::CounterpartAmount::convert(receipt.proportion), + Exact, + Polite, + )?; // Transfer the funds from the pot to the owner and reserve - T::Currency::transfer(&Self::account_id(), &who, amount, AllowDeath) - .map_err(|_| Error::::Unfunded)?; - T::Currency::reserve_named(&T::ReserveId::get(), &who, amount)?; - // TODO: ^^^ The above should be done in a single operation `transfer_and_hold`. + let reason = T::HoldReason::get(); + let us = Self::account_id(); + T::Currency::transfer_and_hold(&reason, &us, &who, amount, Exact, Expendable, Polite)?; // Record that we've moved the amount reserved. summary.receipts_on_hold.saturating_accrue(amount); @@ -920,7 +932,7 @@ pub mod pallet { pub required: Balance, } - impl NonfungibleInspect for Pallet { + impl NftInspect for Pallet { type ItemId = ReceiptIndex; fn owner(item: &ReceiptIndex) -> Option { @@ -939,31 +951,19 @@ pub mod pallet { } } - impl NonfungibleTransfer for Pallet { - fn transfer(index: &ReceiptIndex, destination: &T::AccountId) -> DispatchResult { + impl NftTransfer for Pallet { + fn transfer(index: &ReceiptIndex, dest: &T::AccountId) -> DispatchResult { let mut item = Receipts::::get(index).ok_or(TokenError::UnknownAsset)?; let (owner, on_hold) = item.owner.take().ok_or(Error::::AlreadyCommunal)?; - // TODO: This should all be replaced by a single call `transfer_held`. - let shortfall = T::Currency::unreserve_named(&T::ReserveId::get(), &owner, on_hold); - if !shortfall.is_zero() { - let _ = - T::Currency::reserve_named(&T::ReserveId::get(), &owner, on_hold - shortfall); - return Err(TokenError::NoFunds.into()) - } - if let Err(e) = T::Currency::transfer(&owner, destination, on_hold, AllowDeath) { - let _ = T::Currency::reserve_named(&T::ReserveId::get(), &owner, on_hold); - return Err(e) - } - // This can never fail, and if it somehow does, then we can't handle this gracefully. - let _ = - T::Currency::reserve_named(&T::ReserveId::get(), destination, on_hold).defensive(); + let reason = T::HoldReason::get(); + T::Currency::transfer_on_hold(&reason, &owner, dest, on_hold, Exact, OnHold, Polite)?; - item.owner = Some((destination.clone(), on_hold)); + item.owner = Some((dest.clone(), on_hold)); Receipts::::insert(&index, &item); Pallet::::deposit_event(Event::::Transferred { from: owner, - to: destination.clone(), + to: dest.clone(), index: *index, }); Ok(()) @@ -997,9 +997,9 @@ pub mod pallet { summary: &SummaryRecordOf, ) -> IssuanceInfo> { let total_issuance = - T::Currency::total_issuance().saturating_sub(T::IgnoredIssuance::get()); + T::Currency::active_issuance().saturating_sub(T::IgnoredIssuance::get()); let holdings = - T::Currency::free_balance(our_account).saturating_add(summary.receipts_on_hold); + T::Currency::balance(our_account).saturating_add(summary.receipts_on_hold); let other = total_issuance.saturating_sub(holdings); let effective = summary.proportion_owed.left_from_one().saturating_reciprocal_mul(other); @@ -1136,7 +1136,9 @@ pub mod pallet { // Now to activate the bid... let n = amount; let d = issuance.effective; - let proportion = Perquintill::from_rational(n, d); + let proportion = + Perquintill::from_rational_with_rounding(n, d, Rounding::NearestPrefDown) + .defensive_unwrap_or_default(); let who = bid.who; let index = summary.index; summary.proportion_owed.defensive_saturating_accrue(proportion); diff --git a/frame/nis/src/mock.rs b/frame/nis/src/mock.rs index 8594c88a5927d..0ca6690936818 100644 --- a/frame/nis/src/mock.rs +++ b/frame/nis/src/mock.rs @@ -19,13 +19,18 @@ use crate::{self as pallet_nis, Perquintill, WithMaximumOf}; +use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ ord_parameter_types, parameter_types, - traits::{ConstU16, ConstU32, ConstU64, Currency, OnFinalize, OnInitialize, StorageMapShim}, + traits::{ + fungible::Inspect, ConstU16, ConstU32, ConstU64, Everything, OnFinalize, OnInitialize, + StorageMapShim, + }, weights::Weight, PalletId, }; use pallet_balances::{Instance1, Instance2}; +use scale_info::TypeInfo; use sp_core::{ConstU128, H256}; use sp_runtime::{ testing::Header, @@ -35,6 +40,8 @@ use sp_runtime::{ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; +pub type Balance = u64; + // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( pub enum Test where @@ -50,7 +57,7 @@ frame_support::construct_runtime!( ); impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::Everything; + type BaseCallFilter = Everything; type BlockWeights = (); type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; @@ -67,35 +74,45 @@ impl frame_system::Config for Test { type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; + type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); type SS58Prefix = ConstU16<42>; type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Test { - type Balance = u64; + type Balance = Balance; type DustRemoval = (); type RuntimeEvent = RuntimeEvent; - type ExistentialDeposit = frame_support::traits::ConstU64<1>; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); type MaxLocks = (); type MaxReserves = ConstU32<1>; type ReserveIdentifier = [u8; 8]; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = HoldIdentifier; + type MaxHolds = ConstU32<1>; +} + +#[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, Debug, TypeInfo, +)] +pub enum HoldIdentifier { + Nis, } impl pallet_balances::Config for Test { type Balance = u128; type DustRemoval = (); type RuntimeEvent = RuntimeEvent; - type ExistentialDeposit = frame_support::traits::ConstU128<1>; + type ExistentialDeposit = ConstU128<1>; type AccountStore = StorageMapShim< pallet_balances::Account, - frame_system::Provider, u64, pallet_balances::AccountData, >; @@ -103,16 +120,20 @@ impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); type ReserveIdentifier = [u8; 8]; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { - pub IgnoredIssuance: u64 = Balances::total_balance(&0); // Account zero is ignored. + pub IgnoredIssuance: Balance = Balances::total_balance(&0); // Account zero is ignored. pub const NisPalletId: PalletId = PalletId(*b"py/nis "); pub static Target: Perquintill = Perquintill::zero(); pub const MinReceipt: Perquintill = Perquintill::from_percent(1); pub const ThawThrottle: (Perquintill, u64) = (Perquintill::from_percent(25), 5); pub static MaxIntakeWeight: Weight = Weight::from_parts(2_000_000_000_000, 0); - pub const ReserveId: [u8; 8] = *b"py/nis "; + pub const HoldReason: HoldIdentifier = HoldIdentifier::Nis; } ord_parameter_types! { @@ -140,7 +161,7 @@ impl pallet_nis::Config for Test { type MaxIntakeWeight = MaxIntakeWeight; type MinReceipt = MinReceipt; type ThawThrottle = ThawThrottle; - type ReserveId = ReserveId; + type HoldReason = HoldReason; } // This function basically just builds a genesis storage key/value store according to @@ -155,6 +176,13 @@ pub fn new_test_ext() -> sp_io::TestExternalities { t.into() } +// This function basically just builds a genesis storage key/value store according to +// our desired mockup, but without any balances. +#[cfg(feature = "runtime-benchmarks")] +pub fn new_test_ext_empty() -> sp_io::TestExternalities { + frame_system::GenesisConfig::default().build_storage::().unwrap().into() +} + pub fn run_to_block(n: u64) { while System::block_number() < n { Nis::on_finalize(System::block_number()); diff --git a/frame/nis/src/tests.rs b/frame/nis/src/tests.rs index d0808367ee08c..7350da97dc60a 100644 --- a/frame/nis/src/tests.rs +++ b/frame/nis/src/tests.rs @@ -22,19 +22,22 @@ use crate::{mock::*, Error}; use frame_support::{ assert_noop, assert_ok, traits::{ + fungible::{hold::Inspect as InspectHold, Inspect as FunInspect, Mutate as FunMutate}, nonfungible::{Inspect, Transfer}, - Currency, + tokens::{Fortitude::Force, Precision::Exact}, }, }; -use pallet_balances::{Error as BalancesError, Instance1}; use sp_arithmetic::Perquintill; -use sp_runtime::{Saturating, TokenError}; +use sp_runtime::{ + Saturating, + TokenError::{self, FundsUnavailable}, +}; -fn pot() -> u64 { +fn pot() -> Balance { Balances::free_balance(&Nis::account_id()) } -fn holdings() -> u64 { +fn holdings() -> Balance { Nis::issuance().holdings } @@ -42,8 +45,8 @@ fn signed(who: u64) -> RuntimeOrigin { RuntimeOrigin::signed(who) } -fn enlarge(amount: u64, max_bids: u32) { - let summary: SummaryRecord = Summary::::get(); +fn enlarge(amount: Balance, max_bids: u32) { + let summary: SummaryRecord = Summary::::get(); let increase_in_proportion_owed = Perquintill::from_rational(amount, Nis::issuance().effective); let target = summary.proportion_owed.saturating_add(increase_in_proportion_owed); Nis::process_queues(target, u32::max_value(), max_bids, &mut WeightCounter::unlimited()); @@ -75,10 +78,7 @@ fn place_bid_works() { new_test_ext().execute_with(|| { run_to_block(1); assert_noop!(Nis::place_bid(signed(1), 1, 2), Error::::AmountTooSmall); - assert_noop!( - Nis::place_bid(signed(1), 101, 2), - BalancesError::::InsufficientBalance - ); + assert_noop!(Nis::place_bid(signed(1), 101, 2), FundsUnavailable); assert_noop!(Nis::place_bid(signed(1), 10, 4), Error::::DurationTooBig); assert_ok!(Nis::place_bid(signed(1), 10, 2)); assert_eq!(Balances::reserved_balance(1), 10); @@ -451,16 +451,16 @@ fn communify_works() { assert_noop!(Nis::thaw_communal(signed(1), 1), Error::::UnknownReceipt); // Transfer some of the fungibles away. - assert_ok!(NisBalances::transfer(signed(1), 2, 100_000)); + assert_ok!(NisBalances::transfer_allow_death(signed(1), 2, 100_000)); assert_eq!(NisBalances::free_balance(&1), 2_000_000); assert_eq!(NisBalances::free_balance(&2), 100_000); // Communal thawing with the correct index is not possible now. - assert_noop!(Nis::thaw_communal(signed(1), 0), TokenError::NoFunds); - assert_noop!(Nis::thaw_communal(signed(2), 0), TokenError::NoFunds); + assert_noop!(Nis::thaw_communal(signed(1), 0), TokenError::FundsUnavailable); + assert_noop!(Nis::thaw_communal(signed(2), 0), TokenError::FundsUnavailable); // Transfer the rest to 2... - assert_ok!(NisBalances::transfer(signed(1), 2, 2_000_000)); + assert_ok!(NisBalances::transfer_allow_death(signed(1), 2, 2_000_000)); assert_eq!(NisBalances::free_balance(&1), 0); assert_eq!(NisBalances::free_balance(&2), 2_100_000); @@ -487,8 +487,8 @@ fn privatize_works() { assert_ok!(Nis::communify(signed(1), 0)); // Transfer the fungibles to #2 - assert_ok!(NisBalances::transfer(signed(1), 2, 2_100_000)); - assert_noop!(Nis::privatize(signed(1), 0), TokenError::NoFunds); + assert_ok!(NisBalances::transfer_allow_death(signed(1), 2, 2_100_000)); + assert_noop!(Nis::privatize(signed(1), 0), TokenError::FundsUnavailable); // Privatize assert_ok!(Nis::privatize(signed(2), 0)); @@ -513,16 +513,16 @@ fn privatize_and_thaw_with_another_receipt_works() { assert_ok!(Nis::communify(signed(2), 1)); // Transfer half of fungibles to #3 from each of #1 and #2, and the other half from #2 to #4 - assert_ok!(NisBalances::transfer(signed(1), 3, 1_050_000)); - assert_ok!(NisBalances::transfer(signed(2), 3, 1_050_000)); - assert_ok!(NisBalances::transfer(signed(2), 4, 1_050_000)); + assert_ok!(NisBalances::transfer_allow_death(signed(1), 3, 1_050_000)); + assert_ok!(NisBalances::transfer_allow_death(signed(2), 3, 1_050_000)); + assert_ok!(NisBalances::transfer_allow_death(signed(2), 4, 1_050_000)); // #3 privatizes, partially thaws, then re-communifies with #0, then transfers the fungibles // to #2 assert_ok!(Nis::privatize(signed(3), 0)); assert_ok!(Nis::thaw_private(signed(3), 0, Some(Perquintill::from_percent(5)))); assert_ok!(Nis::communify(signed(3), 0)); - assert_ok!(NisBalances::transfer(signed(3), 1, 1_050_000)); + assert_ok!(NisBalances::transfer_allow_death(signed(3), 1, 1_050_000)); // #1 now has enough to thaw using receipt 1 assert_ok!(Nis::thaw_communal(signed(1), 1)); @@ -536,17 +536,21 @@ fn privatize_and_thaw_with_another_receipt_works() { fn communal_thaw_when_issuance_higher_works() { new_test_ext().execute_with(|| { run_to_block(1); + assert_ok!(Balances::transfer_allow_death(signed(2), 1, 1)); assert_ok!(Nis::place_bid(signed(1), 100, 1)); enlarge(100, 1); + assert_eq!(Balances::total_balance(&1), 101); assert_ok!(Nis::communify(signed(1), 0)); + assert_eq!(Balances::total_balance_on_hold(&1), 0); + assert_eq!(Balances::total_balance(&1), 1); - assert_eq!(NisBalances::free_balance(1), 5_250_000); // (25% of 21m) + assert_eq!(NisBalances::free_balance(1), 5_250_000); // (12.5% of 21m) // Everybody else's balances goes up by 50% - Balances::make_free_balance_be(&2, 150); - Balances::make_free_balance_be(&3, 150); - Balances::make_free_balance_be(&4, 150); + assert_ok!(Balances::mint_into(&2, 50)); + assert_ok!(Balances::mint_into(&3, 50)); + assert_ok!(Balances::mint_into(&4, 50)); run_to_block(4); @@ -556,16 +560,20 @@ fn communal_thaw_when_issuance_higher_works() { assert_ok!(Nis::fund_deficit(signed(1))); // Transfer counterparts away... - assert_ok!(NisBalances::transfer(signed(1), 2, 250_000)); + assert_ok!(NisBalances::transfer_allow_death(signed(1), 2, 125_000)); // ...and it's not thawable. - assert_noop!(Nis::thaw_communal(signed(1), 0), TokenError::NoFunds); + assert_noop!(Nis::thaw_communal(signed(1), 0), TokenError::FundsUnavailable); // Transfer counterparts back... - assert_ok!(NisBalances::transfer(signed(2), 1, 250_000)); + assert_ok!(NisBalances::transfer_allow_death(signed(2), 1, 125_000)); // ...and it is. assert_ok!(Nis::thaw_communal(signed(1), 0)); + assert_eq!(Balances::total_balance(&1), 151); + assert_ok!(Balances::transfer_allow_death(signed(1), 2, 1)); + assert_eq!(Balances::total_balance(&1), 150); assert_eq!(Balances::free_balance(1), 150); + assert_eq!(Balances::total_balance_on_hold(&1), 0); assert_eq!(Balances::reserved_balance(1), 0); }); } @@ -574,13 +582,14 @@ fn communal_thaw_when_issuance_higher_works() { fn private_thaw_when_issuance_higher_works() { new_test_ext().execute_with(|| { run_to_block(1); + assert_ok!(Balances::transfer_allow_death(signed(2), 1, 1)); assert_ok!(Nis::place_bid(signed(1), 100, 1)); enlarge(100, 1); // Everybody else's balances goes up by 50% - Balances::make_free_balance_be(&2, 150); - Balances::make_free_balance_be(&3, 150); - Balances::make_free_balance_be(&4, 150); + assert_ok!(Balances::mint_into(&2, 50)); + assert_ok!(Balances::mint_into(&3, 50)); + assert_ok!(Balances::mint_into(&4, 50)); run_to_block(4); @@ -591,6 +600,7 @@ fn private_thaw_when_issuance_higher_works() { assert_ok!(Nis::thaw_private(signed(1), 0, None)); + assert_ok!(Balances::transfer_allow_death(signed(1), 2, 1)); assert_eq!(Balances::free_balance(1), 150); assert_eq!(Balances::reserved_balance(1), 0); }); @@ -601,15 +611,16 @@ fn thaw_with_ignored_issuance_works() { new_test_ext().execute_with(|| { run_to_block(1); // Give account zero some balance. - Balances::make_free_balance_be(&0, 200); + assert_ok!(Balances::mint_into(&0, 200)); + assert_ok!(Balances::transfer_allow_death(signed(2), 1, 1)); assert_ok!(Nis::place_bid(signed(1), 100, 1)); enlarge(100, 1); // Account zero transfers 50 into everyone else's accounts. - assert_ok!(Balances::transfer(signed(0), 2, 50)); - assert_ok!(Balances::transfer(signed(0), 3, 50)); - assert_ok!(Balances::transfer(signed(0), 4, 50)); + assert_ok!(Balances::transfer_allow_death(signed(0), 2, 50)); + assert_ok!(Balances::transfer_allow_death(signed(0), 3, 50)); + assert_ok!(Balances::transfer_allow_death(signed(0), 4, 50)); run_to_block(4); // Unfunded initially... @@ -620,6 +631,7 @@ fn thaw_with_ignored_issuance_works() { assert_ok!(Nis::thaw_private(signed(1), 0, None)); // Account zero changes have been ignored. + assert_ok!(Balances::transfer_allow_death(signed(1), 2, 1)); assert_eq!(Balances::free_balance(1), 150); assert_eq!(Balances::reserved_balance(1), 0); }); @@ -629,17 +641,19 @@ fn thaw_with_ignored_issuance_works() { fn thaw_when_issuance_lower_works() { new_test_ext().execute_with(|| { run_to_block(1); + assert_ok!(Balances::transfer_allow_death(signed(2), 1, 1)); assert_ok!(Nis::place_bid(signed(1), 100, 1)); enlarge(100, 1); // Everybody else's balances goes down by 25% - Balances::make_free_balance_be(&2, 75); - Balances::make_free_balance_be(&3, 75); - Balances::make_free_balance_be(&4, 75); + assert_ok!(Balances::burn_from(&2, 25, Exact, Force)); + assert_ok!(Balances::burn_from(&3, 25, Exact, Force)); + assert_ok!(Balances::burn_from(&4, 25, Exact, Force)); run_to_block(4); assert_ok!(Nis::thaw_private(signed(1), 0, None)); + assert_ok!(Balances::transfer_allow_death(signed(1), 2, 1)); assert_eq!(Balances::free_balance(1), 75); assert_eq!(Balances::reserved_balance(1), 0); }); @@ -649,15 +663,16 @@ fn thaw_when_issuance_lower_works() { fn multiple_thaws_works() { new_test_ext().execute_with(|| { run_to_block(1); + assert_ok!(Balances::transfer_allow_death(signed(3), 1, 1)); assert_ok!(Nis::place_bid(signed(1), 40, 1)); assert_ok!(Nis::place_bid(signed(1), 60, 1)); assert_ok!(Nis::place_bid(signed(2), 50, 1)); enlarge(200, 3); // Double everyone's free balances. - Balances::make_free_balance_be(&2, 100); - Balances::make_free_balance_be(&3, 200); - Balances::make_free_balance_be(&4, 200); + assert_ok!(Balances::mint_into(&2, 50)); + assert_ok!(Balances::mint_into(&3, 100)); + assert_ok!(Balances::mint_into(&4, 100)); assert_ok!(Nis::fund_deficit(signed(1))); run_to_block(4); @@ -667,8 +682,11 @@ fn multiple_thaws_works() { run_to_block(5); assert_ok!(Nis::thaw_private(signed(2), 2, None)); + assert_ok!(Balances::transfer_allow_death(signed(1), 3, 1)); assert_eq!(Balances::free_balance(1), 200); assert_eq!(Balances::free_balance(2), 200); + assert_eq!(Balances::total_balance(&1), 200); + assert_eq!(Balances::total_balance(&2), 200); }); } @@ -676,15 +694,16 @@ fn multiple_thaws_works() { fn multiple_thaws_works_in_alternative_thaw_order() { new_test_ext().execute_with(|| { run_to_block(1); + assert_ok!(Balances::transfer_allow_death(signed(3), 1, 1)); assert_ok!(Nis::place_bid(signed(1), 40, 1)); assert_ok!(Nis::place_bid(signed(1), 60, 1)); assert_ok!(Nis::place_bid(signed(2), 50, 1)); enlarge(200, 3); // Double everyone's free balances. - Balances::make_free_balance_be(&2, 100); - Balances::make_free_balance_be(&3, 200); - Balances::make_free_balance_be(&4, 200); + assert_ok!(Balances::mint_into(&2, 50)); + assert_ok!(Balances::mint_into(&3, 100)); + assert_ok!(Balances::mint_into(&4, 100)); assert_ok!(Nis::fund_deficit(signed(1))); run_to_block(4); @@ -695,8 +714,11 @@ fn multiple_thaws_works_in_alternative_thaw_order() { run_to_block(5); assert_ok!(Nis::thaw_private(signed(1), 1, None)); + assert_ok!(Balances::transfer_allow_death(signed(1), 3, 1)); assert_eq!(Balances::free_balance(1), 200); assert_eq!(Balances::free_balance(2), 200); + assert_eq!(Balances::total_balance(&1), 200); + assert_eq!(Balances::total_balance(&2), 200); }); } diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index 4a1a52868e367..cffb712ea2ae5 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -75,6 +75,10 @@ impl pallet_balances::Config for Runtime { type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } pallet_staking_reward_curve::build! { diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index c6b094f0aa0f1..6d83ef61de793 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -196,6 +196,10 @@ impl pallet_balances::Config for Runtime { type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } pub struct BalanceToU256; diff --git a/frame/nomination-pools/src/tests.rs b/frame/nomination-pools/src/tests.rs index a4fda2e5d91b3..4cb255e23b4b8 100644 --- a/frame/nomination-pools/src/tests.rs +++ b/frame/nomination-pools/src/tests.rs @@ -39,6 +39,16 @@ macro_rules! member_unbonding_eras { pub const DEFAULT_ROLES: PoolRoles = PoolRoles { depositor: 10, root: Some(900), nominator: Some(901), bouncer: Some(902) }; +fn deposit_rewards(r: u128) { + let b = Balances::free_balance(&default_reward_account()).checked_add(r).unwrap(); + Balances::make_free_balance_be(&default_reward_account(), b); +} + +fn remove_rewards(r: u128) { + let b = Balances::free_balance(&default_reward_account()).checked_sub(r).unwrap(); + Balances::make_free_balance_be(&default_reward_account(), b); +} + #[test] fn test_setup_works() { ExtBuilder::default().build_and_execute(|| { @@ -469,6 +479,8 @@ mod sub_pools { } mod join { + use sp_runtime::TokenError; + use super::*; #[test] @@ -592,7 +604,7 @@ mod join { // Balance needs to be gt Balance::MAX / `MaxPointsToBalance` assert_noop!( Pools::join(RuntimeOrigin::signed(11), 5, 123), - pallet_balances::Error::::InsufficientBalance, + TokenError::FundsUnavailable, ); StakingMock::set_bonded_balance(Pools::create_bonded_account(1), max_points_to_balance); @@ -749,7 +761,7 @@ mod claim_payout { // and the reward pool has earned 100 in rewards assert_eq!(Balances::free_balance(default_reward_account()), ed); - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 100)); + deposit_rewards(100); let _ = pool_events_since_last_call(); @@ -796,7 +808,7 @@ mod claim_payout { assert_eq!(Balances::free_balance(&default_reward_account()), ed); // Given the reward pool has some new rewards - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 50)); + deposit_rewards(50); // When assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -825,7 +837,7 @@ mod claim_payout { assert_eq!(Balances::free_balance(&default_reward_account()), ed + 25); // Given del 50 hasn't claimed and the reward pools has just earned 50 - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 50)); + deposit_rewards(50); assert_eq!(Balances::free_balance(&default_reward_account()), ed + 75); // When @@ -855,7 +867,7 @@ mod claim_payout { assert_eq!(Balances::free_balance(&default_reward_account()), ed + 20); // Given del 40 hasn't claimed and the reward pool has just earned 400 - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 400)); + deposit_rewards(400); assert_eq!(Balances::free_balance(&default_reward_account()), ed + 420); // When @@ -874,7 +886,7 @@ mod claim_payout { assert_eq!(Balances::free_balance(&default_reward_account()), ed + 380); // Given del 40 + del 50 haven't claimed and the reward pool has earned 20 - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 20)); + deposit_rewards(20); assert_eq!(Balances::free_balance(&default_reward_account()), ed + 400); // When @@ -974,7 +986,7 @@ mod claim_payout { ); // The pool earns 10 points - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 10)); + deposit_rewards(10); assert_ok!(Pools::do_reward_payout( &10, @@ -1010,7 +1022,7 @@ mod claim_payout { assert_eq!(reward_pool, rew(0, 0, 0)); // Given the pool has earned some rewards for the first time - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 5)); + deposit_rewards(5); // When let payout = @@ -1031,7 +1043,7 @@ mod claim_payout { assert_eq!(member, del(0.5)); // Given the pool has earned rewards again - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 10)); + deposit_rewards(10); // When let payout = @@ -1090,7 +1102,7 @@ mod claim_payout { assert_eq!(bonded_pool.points, 100); // and the reward pool has earned 100 in rewards - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 100)); + deposit_rewards(100); // When let payout = @@ -1135,7 +1147,7 @@ mod claim_payout { assert_eq!(reward_pool, rew(0, 0, 100)); // Given the reward pool has some new rewards - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 50)); + deposit_rewards(50); // When let payout = @@ -1166,7 +1178,7 @@ mod claim_payout { assert_eq!(reward_pool, rew(0, 0, 125)); // Given del_50 hasn't claimed and the reward pools has just earned 50 - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 50)); + deposit_rewards(50); // When let payout = @@ -1197,7 +1209,7 @@ mod claim_payout { assert_eq!(reward_pool, rew(0, 0, 180)); // Given del_40 hasn't claimed and the reward pool has just earned 400 - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 400)); + deposit_rewards(400); // When let payout = @@ -1214,7 +1226,7 @@ mod claim_payout { assert_eq!(reward_pool, rew(0, 0, 220)); // Given del_40 + del_50 haven't claimed and the reward pool has earned 20 - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 20)); + deposit_rewards(20); // When let payout = @@ -1252,14 +1264,14 @@ mod claim_payout { fn rewards_distribution_is_fair_basic() { ExtBuilder::default().build_and_execute(|| { // reward pool by 10. - Balances::mutate_account(&default_reward_account(), |f| f.free += 10).unwrap(); + deposit_rewards(10); // 20 joins afterwards. Balances::make_free_balance_be(&20, Balances::minimum_balance() + 10); assert_ok!(Pools::join(RuntimeOrigin::signed(20), 10, 1)); // reward by another 20 - Balances::mutate_account(&default_reward_account(), |f| f.free += 20).unwrap(); + deposit_rewards(20); // 10 should claim 10 + 10, 20 should claim 20 / 2. assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -1276,7 +1288,7 @@ mod claim_payout { ); // any upcoming rewards are shared equally. - Balances::mutate_account(&default_reward_account(), |f| f.free += 20).unwrap(); + deposit_rewards(20); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(20))); @@ -1296,12 +1308,12 @@ mod claim_payout { // basically checks the case where the amount of rewards is less than the pool shares. for // this, we have to rely on fixed point arithmetic. ExtBuilder::default().build_and_execute(|| { - Balances::mutate_account(&default_reward_account(), |f| f.free += 3).unwrap(); + deposit_rewards(3); Balances::make_free_balance_be(&20, Balances::minimum_balance() + 10); assert_ok!(Pools::join(RuntimeOrigin::signed(20), 10, 1)); - Balances::mutate_account(&default_reward_account(), |f| f.free += 6).unwrap(); + deposit_rewards(6); // 10 should claim 3, 20 should claim 3 + 3. assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -1319,7 +1331,7 @@ mod claim_payout { ); // any upcoming rewards are shared equally. - Balances::mutate_account(&default_reward_account(), |f| f.free += 8).unwrap(); + deposit_rewards(8); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(20))); @@ -1333,7 +1345,7 @@ mod claim_payout { ); // uneven upcoming rewards are shared equally, rounded down. - Balances::mutate_account(&default_reward_account(), |f| f.free += 7).unwrap(); + deposit_rewards(7); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(20))); @@ -1353,17 +1365,17 @@ mod claim_payout { ExtBuilder::default().build_and_execute(|| { let ed = Balances::minimum_balance(); - Balances::mutate_account(&default_reward_account(), |f| f.free += 30).unwrap(); + deposit_rewards(30); Balances::make_free_balance_be(&20, ed + 10); assert_ok!(Pools::join(RuntimeOrigin::signed(20), 10, 1)); - Balances::mutate_account(&default_reward_account(), |f| f.free += 100).unwrap(); + deposit_rewards(100); Balances::make_free_balance_be(&30, ed + 10); assert_ok!(Pools::join(RuntimeOrigin::signed(30), 10, 1)); - Balances::mutate_account(&default_reward_account(), |f| f.free += 60).unwrap(); + deposit_rewards(60); // 10 should claim 10, 20 should claim nothing. assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -1384,7 +1396,7 @@ mod claim_payout { ); // any upcoming rewards are shared equally. - Balances::mutate_account(&default_reward_account(), |f| f.free += 30).unwrap(); + deposit_rewards(30); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(20))); @@ -1407,7 +1419,7 @@ mod claim_payout { let ed = Balances::minimum_balance(); assert_eq!(Pools::api_pending_rewards(10), Some(0)); - Balances::mutate_account(&default_reward_account(), |f| f.free += 30).unwrap(); + deposit_rewards(30); assert_eq!(Pools::api_pending_rewards(10), Some(30)); assert_eq!(Pools::api_pending_rewards(20), None); @@ -1417,7 +1429,7 @@ mod claim_payout { assert_eq!(Pools::api_pending_rewards(10), Some(30)); assert_eq!(Pools::api_pending_rewards(20), Some(0)); - Balances::mutate_account(&default_reward_account(), |f| f.free += 100).unwrap(); + deposit_rewards(100); assert_eq!(Pools::api_pending_rewards(10), Some(30 + 50)); assert_eq!(Pools::api_pending_rewards(20), Some(50)); @@ -1430,7 +1442,7 @@ mod claim_payout { assert_eq!(Pools::api_pending_rewards(20), Some(50)); assert_eq!(Pools::api_pending_rewards(30), Some(0)); - Balances::mutate_account(&default_reward_account(), |f| f.free += 60).unwrap(); + deposit_rewards(60); assert_eq!(Pools::api_pending_rewards(10), Some(30 + 50 + 20)); assert_eq!(Pools::api_pending_rewards(20), Some(50 + 20)); @@ -1464,7 +1476,7 @@ mod claim_payout { Balances::make_free_balance_be(&30, ed + 20); assert_ok!(Pools::join(RuntimeOrigin::signed(30), 10, 1)); - Balances::mutate_account(&default_reward_account(), |f| f.free += 40).unwrap(); + deposit_rewards(40); // everyone claims. assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -1488,7 +1500,7 @@ mod claim_payout { assert_ok!(Pools::bond_extra(RuntimeOrigin::signed(30), BondExtra::FreeBalance(10))); // more rewards come in. - Balances::mutate_account(&default_reward_account(), |f| f.free += 100).unwrap(); + deposit_rewards(100); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(20))); @@ -1514,7 +1526,7 @@ mod claim_payout { Balances::make_free_balance_be(&20, ed + 20); assert_ok!(Pools::join(RuntimeOrigin::signed(20), 20, 1)); - Balances::mutate_account(&default_reward_account(), |f| f.free += 30).unwrap(); + deposit_rewards(30); // everyone claims. assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -1535,7 +1547,7 @@ mod claim_payout { assert_ok!(Pools::unbond(RuntimeOrigin::signed(20), 20, 10)); // more rewards come in. - Balances::mutate_account(&default_reward_account(), |f| f.free += 100).unwrap(); + deposit_rewards(100); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(20))); @@ -1562,7 +1574,7 @@ mod claim_payout { assert_ok!(Pools::join(RuntimeOrigin::signed(30), 10, 1)); // 10 gets 10, 20 gets 20, 30 gets 10 - Balances::mutate_account(&default_reward_account(), |f| f.free += 40).unwrap(); + deposit_rewards(40); // some claim. assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -1581,7 +1593,7 @@ mod claim_payout { ); // 10 gets 20, 20 gets 40, 30 gets 20 - Balances::mutate_account(&default_reward_account(), |f| f.free += 80).unwrap(); + deposit_rewards(80); // some claim. assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -1596,7 +1608,7 @@ mod claim_payout { ); // 10 gets 20, 20 gets 40, 30 gets 20 - Balances::mutate_account(&default_reward_account(), |f| f.free += 80).unwrap(); + deposit_rewards(80); // some claim. assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -1629,7 +1641,7 @@ mod claim_payout { assert_ok!(Pools::join(RuntimeOrigin::signed(20), 20, 1)); // 10 gets 10, 20 gets 20, 30 gets 10 - Balances::mutate_account(&default_reward_account(), |f| f.free += 30).unwrap(); + deposit_rewards(30); // some claim. assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -1645,7 +1657,7 @@ mod claim_payout { ); // 20 has not claimed yet, more reward comes - Balances::mutate_account(&default_reward_account(), |f| f.free += 60).unwrap(); + deposit_rewards(60); // and 20 bonds more -- they should not have more share of this reward. assert_ok!(Pools::bond_extra(RuntimeOrigin::signed(20), BondExtra::FreeBalance(10))); @@ -1665,7 +1677,7 @@ mod claim_payout { ); // but in the next round of rewards, the extra10 they bonded has an impact. - Balances::mutate_account(&default_reward_account(), |f| f.free += 60).unwrap(); + deposit_rewards(60); // everyone claim. assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -1695,7 +1707,7 @@ mod claim_payout { assert_eq!(member_10.last_recorded_reward_counter, 0.into()); // transfer some reward to pool 1. - Balances::mutate_account(&default_reward_account(), |f| f.free += 60).unwrap(); + deposit_rewards(60); // create pool 2 Balances::make_free_balance_be(&20, 100); @@ -1779,7 +1791,7 @@ mod claim_payout { } // transfer some reward to pool 1. - Balances::mutate_account(&default_reward_account(), |f| f.free += 60).unwrap(); + deposit_rewards(60); { join(30, 10); @@ -1849,7 +1861,7 @@ mod claim_payout { // 10 bonds extra again with some rewards. This reward should be split equally between // 10 and 20, as they both have equal points now. - Balances::mutate_account(&default_reward_account(), |f| f.free += 30).unwrap(); + deposit_rewards(30); { assert_ok!(Pools::bond_extra( @@ -1905,7 +1917,7 @@ mod claim_payout { MaxPoolMembersPerPool::::set(None); // pool receives some rewards. - Balances::mutate_account(&default_reward_account(), |f| f.free += 30).unwrap(); + deposit_rewards(30); System::reset_events(); // 10 cashes it out, and bonds it. @@ -1975,7 +1987,7 @@ mod claim_payout { } // some rewards come in. - Balances::mutate_account(&default_reward_account(), |f| f.free += 30).unwrap(); + deposit_rewards(30); // and 30 also unbonds half. { @@ -2058,7 +2070,7 @@ mod claim_payout { ); // some rewards come in. - Balances::mutate_account(&default_reward_account(), |f| f.free += 40).unwrap(); + deposit_rewards(40); // everyone claims assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -2120,8 +2132,7 @@ mod claim_payout { .build_and_execute(|| { // some rewards come in. assert_eq!(Balances::free_balance(&default_reward_account()), unit); - Balances::mutate_account(&default_reward_account(), |f| f.free += unit / 1000) - .unwrap(); + deposit_rewards(unit / 1000); // everyone claims assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -3329,11 +3340,7 @@ mod withdraw_unbonded { ); assert_eq!( balances_events_since_last_call(), - vec![BEvent::BalanceSet { - who: default_bonded_account(), - free: 300, - reserved: 0 - }] + vec![BEvent::BalanceSet { who: default_bonded_account(), free: 300 }] ); // When @@ -3447,11 +3454,7 @@ mod withdraw_unbonded { ); assert_eq!( balances_events_since_last_call(), - vec![BEvent::BalanceSet { - who: default_bonded_account(), - free: 300, - reserved: 0 - },] + vec![BEvent::BalanceSet { who: default_bonded_account(), free: 300 },] ); CurrentEra::set(StakingMock::bonding_duration()); @@ -5078,18 +5081,15 @@ mod reward_counter_precision { let expected_smallest_reward = inflation(50) / 10u128.pow(18); // tad bit less. cannot be paid out. - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += - expected_smallest_reward - 1)); + deposit_rewards(expected_smallest_reward - 1); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); assert_eq!(pool_events_since_last_call(), vec![]); // revert it. - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free -= - expected_smallest_reward - 1)); + remove_rewards(expected_smallest_reward - 1); // tad bit more. can be claimed. - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += - expected_smallest_reward + 1)); + deposit_rewards(expected_smallest_reward + 1); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); assert_eq!( pool_events_since_last_call(), @@ -5114,9 +5114,7 @@ mod reward_counter_precision { assert_ok!(Pools::join(RuntimeOrigin::signed(20), tiny_bond / 2, 1)); // Suddenly, add a shit ton of rewards. - assert_ok!( - Balances::mutate_account(&default_reward_account(), |a| a.free += inflation(1)) - ); + deposit_rewards(inflation(1)); // now claim. assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -5155,8 +5153,7 @@ mod reward_counter_precision { // is earning all of the inflation per year (which is really unrealistic, but worse // case), that will be: let pool_total_earnings_10_years = inflation(10) - POLKADOT_TOTAL_ISSUANCE_GENESIS; - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += - pool_total_earnings_10_years)); + deposit_rewards(pool_total_earnings_10_years); // some whale now joins with the other half ot the total issuance. This will bloat all // the calculation regarding current reward counter. @@ -5186,7 +5183,7 @@ mod reward_counter_precision { assert_ok!(Pools::join(RuntimeOrigin::signed(30), 10 * DOT, 1)); // and give a reasonably small reward to the pool. - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += DOT)); + deposit_rewards(DOT); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(30))); assert_eq!( @@ -5258,9 +5255,7 @@ mod reward_counter_precision { assert_ok!(Pools::join(RuntimeOrigin::signed(20), 10 * DOT, 1)); // earn some small rewards - assert_ok!( - Balances::mutate_account(&default_reward_account(), |a| a.free += DOT / 1000) - ); + deposit_rewards(DOT / 1000); // no point in claiming for 20 (nonetheless, it should be harmless) assert!(pending_rewards(20).unwrap().is_zero()); @@ -5280,9 +5275,7 @@ mod reward_counter_precision { // earn some small more, still nothing can be claimed for 20, but 10 claims their // share. - assert_ok!( - Balances::mutate_account(&default_reward_account(), |a| a.free += DOT / 1000) - ); + deposit_rewards(DOT / 1000); assert!(pending_rewards(20).unwrap().is_zero()); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); assert_eq!( @@ -5291,9 +5284,7 @@ mod reward_counter_precision { ); // earn some more rewards, this time 20 can also claim. - assert_ok!( - Balances::mutate_account(&default_reward_account(), |a| a.free += DOT / 1000) - ); + deposit_rewards(DOT / 1000); assert_eq!(pending_rewards(20).unwrap(), 1); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(20))); @@ -5332,9 +5323,7 @@ mod reward_counter_precision { assert_ok!(Pools::join(RuntimeOrigin::signed(20), 10 * DOT, 1)); // earn some small rewards - assert_ok!( - Balances::mutate_account(&default_reward_account(), |a| a.free += DOT / 1000) - ); + deposit_rewards(DOT / 1000); // if 20 claims now, their reward counter should stay the same, so that they have a // chance of claiming this if they let it accumulate. Also see @@ -5442,7 +5431,7 @@ mod commission { // Pool earns 80 points and a payout is triggered. // Given: - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 80)); + deposit_rewards(80); assert_eq!( PoolMembers::::get(10).unwrap(), PoolMember:: { pool_id, points: 10, ..Default::default() } @@ -5489,7 +5478,7 @@ mod commission { // is next called, which is not done in this test segment.. // Given: - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 100)); + deposit_rewards(100); // When: assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -5625,7 +5614,7 @@ mod commission { 1, Some((Perbill::from_percent(10), root)), )); - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 40)); + deposit_rewards(40); // When: assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -6377,7 +6366,7 @@ mod commission { ); // The pool earns 10 points - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 10)); + deposit_rewards(10); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); // Then: @@ -6387,7 +6376,7 @@ mod commission { ); // The pool earns 17 points - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 17)); + deposit_rewards(17); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); // Then: @@ -6397,7 +6386,7 @@ mod commission { ); // The pool earns 50 points - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 50)); + deposit_rewards(50); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); // Then: @@ -6407,7 +6396,7 @@ mod commission { ); // The pool earns 10439 points - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 10439)); + deposit_rewards(10439); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); // Then: @@ -6427,7 +6416,7 @@ mod commission { )); // Given: - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 200)); + deposit_rewards(200); assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); // Then: @@ -6469,7 +6458,7 @@ mod commission { // When: // The pool earns 100 points - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 100)); + deposit_rewards(100); // Change commission to 20% assert_ok!(Pools::set_commission( @@ -6486,7 +6475,7 @@ mod commission { ); // The pool earns 100 points - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 100)); + deposit_rewards(100); // Then: @@ -6535,7 +6524,7 @@ mod commission { // When: // The pool earns 100 points - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 100)); + deposit_rewards(100); // Claim payout: assert_ok!(Pools::claim_payout(RuntimeOrigin::signed(10))); @@ -6592,7 +6581,7 @@ mod commission { ); // The pool earns 10 points - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 10)); + deposit_rewards(10); // execute the payout assert_ok!(Pools::do_reward_payout( @@ -6634,7 +6623,7 @@ mod commission { ); // The pool earns 10 points - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 10)); + deposit_rewards(10); // execute the payout assert_ok!(Pools::do_reward_payout( @@ -6677,7 +6666,7 @@ mod commission { ); // Pool earns 80 points, payout is triggered. - assert_ok!(Balances::mutate_account(&default_reward_account(), |a| a.free += 80)); + deposit_rewards(80); assert_eq!( PoolMembers::::get(10).unwrap(), PoolMember:: { pool_id, points: 10, ..Default::default() } diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 0550c8e0ca708..9726f5e6dad27 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -86,6 +86,10 @@ impl pallet_balances::Config for Runtime { type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } pallet_staking_reward_curve::build! { diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 233aa449d391c..058361e9f77e8 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -74,6 +74,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<10>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl pallet_timestamp::Config for Test { diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 23875ccb0ef7a..5054a77a8123f 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -84,6 +84,10 @@ impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } ord_parameter_types! { diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index c49c344aca107..f3771083c4dd4 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -88,6 +88,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl pallet_utility::Config for Test { type RuntimeEvent = RuntimeEvent; @@ -124,7 +128,10 @@ impl InstanceFilter for ProxyType { match self { ProxyType::Any => true, ProxyType::JustTransfer => { - matches!(c, RuntimeCall::Balances(pallet_balances::Call::transfer { .. })) + matches!( + c, + RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. }) + ) }, ProxyType::JustUtility => matches!(c, RuntimeCall::Utility { .. }), } @@ -161,7 +168,7 @@ impl Config for Test { use super::{Call as ProxyCall, Event as ProxyEvent}; use frame_system::Call as SystemCall; -use pallet_balances::{Call as BalancesCall, Error as BalancesError, Event as BalancesEvent}; +use pallet_balances::{Call as BalancesCall, Event as BalancesEvent}; use pallet_utility::{Call as UtilityCall, Event as UtilityEvent}; type SystemError = frame_system::Error; @@ -169,7 +176,7 @@ type SystemError = frame_system::Error; pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); pallet_balances::GenesisConfig:: { - balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 2)], + balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 3)], } .assimilate_storage(&mut t) .unwrap(); @@ -193,7 +200,7 @@ fn expect_events(e: Vec) { } fn call_transfer(dest: u64, value: u64) -> RuntimeCall { - RuntimeCall::Balances(BalancesCall::transfer { dest, value }) + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest, value }) } #[test] @@ -345,7 +352,7 @@ fn proxy_announced_removes_announcement_and_returns_deposit() { #[test] fn filtering_works() { new_test_ext().execute_with(|| { - assert!(Balances::mutate_account(&1, |a| a.free = 1000).is_ok()); + Balances::make_free_balance_be(&1, 1000); assert_ok!(Proxy::add_proxy(RuntimeOrigin::signed(1), 2, ProxyType::Any, 0)); assert_ok!(Proxy::add_proxy(RuntimeOrigin::signed(1), 3, ProxyType::JustTransfer, 0)); assert_ok!(Proxy::add_proxy(RuntimeOrigin::signed(1), 4, ProxyType::JustUtility, 0)); @@ -361,7 +368,7 @@ fn filtering_works() { ); let derivative_id = Utility::derivative_account_id(1, 0); - assert!(Balances::mutate_account(&derivative_id, |a| a.free = 1000).is_ok()); + Balances::make_free_balance_be(&derivative_id, 1000); let inner = Box::new(call_transfer(6, 1)); let call = Box::new(RuntimeCall::Utility(UtilityCall::as_derivative { @@ -516,7 +523,7 @@ fn cannot_add_proxy_without_balance() { assert_eq!(Balances::reserved_balance(5), 2); assert_noop!( Proxy::add_proxy(RuntimeOrigin::signed(5), 4, ProxyType::Any, 0), - BalancesError::::InsufficientBalance + DispatchError::ConsumerRemaining, ); }); } @@ -564,6 +571,7 @@ fn proxying_works() { #[test] fn pure_works() { new_test_ext().execute_with(|| { + Balances::make_free_balance_be(&1, 11); // An extra one for the ED. assert_ok!(Proxy::create_pure(RuntimeOrigin::signed(1), ProxyType::Any, 0, 0)); let anon = Proxy::pure_account(&1, &ProxyType::Any, 0, None); System::assert_last_event( @@ -592,7 +600,7 @@ fn pure_works() { assert_ok!(Proxy::create_pure(RuntimeOrigin::signed(1), ProxyType::Any, 0, 0)); let call = Box::new(call_transfer(6, 1)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(3), anon, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(3), anon, 5)); assert_ok!(Proxy::proxy(RuntimeOrigin::signed(1), anon, None, call)); System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into()); assert_eq!(Balances::free_balance(6), 1); @@ -611,9 +619,9 @@ fn pure_works() { Proxy::kill_pure(RuntimeOrigin::signed(1), 1, ProxyType::Any, 0, 1, 0), Error::::NoPermission ); - assert_eq!(Balances::free_balance(1), 0); + assert_eq!(Balances::free_balance(1), 1); assert_ok!(Proxy::proxy(RuntimeOrigin::signed(1), anon, None, call.clone())); - assert_eq!(Balances::free_balance(1), 2); + assert_eq!(Balances::free_balance(1), 3); assert_noop!( Proxy::proxy(RuntimeOrigin::signed(1), anon, None, call.clone()), Error::::NotProxy diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index 1d21be801c85c..5c190e2a241a5 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -86,6 +86,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { diff --git a/frame/recovery/src/tests.rs b/frame/recovery/src/tests.rs index 9381d6a881ef1..85024d0bc4a9d 100644 --- a/frame/recovery/src/tests.rs +++ b/frame/recovery/src/tests.rs @@ -45,7 +45,10 @@ fn set_recovered_works() { // Root can set a recovered account though assert_ok!(Recovery::set_recovered(RuntimeOrigin::root(), 5, 1)); // Account 1 should now be able to make a call through account 5 - let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 1, value: 100 })); + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer_allow_death { + dest: 1, + value: 100, + })); assert_ok!(Recovery::as_recovered(RuntimeOrigin::signed(1), 5, call)); // Account 1 has successfully drained the funds from account 5 assert_eq!(Balances::free_balance(1), 200); @@ -93,7 +96,10 @@ fn recovery_life_cycle_works() { assert_ok!(Recovery::as_recovered(RuntimeOrigin::signed(1), 5, call)); // Account 1 should now be able to make a call through account 5 to get all of their funds assert_eq!(Balances::free_balance(5), 110); - let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 1, value: 110 })); + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer_allow_death { + dest: 1, + value: 110, + })); assert_ok!(Recovery::as_recovered(RuntimeOrigin::signed(1), 5, call)); // All funds have been fully recovered! assert_eq!(Balances::free_balance(1), 200); diff --git a/frame/referenda/src/migration.rs b/frame/referenda/src/migration.rs index e15eb499b42fc..c27ab452ac637 100644 --- a/frame/referenda/src/migration.rs +++ b/frame/referenda/src/migration.rs @@ -191,7 +191,7 @@ pub mod test { #[test] pub fn referendum_status_v0() { // make sure the bytes of the encoded referendum v0 is decodable. - let ongoing_encoded = sp_core::Bytes::from_str("0x00000000013001012a000000000000000400000100000000000000010000000000000001000000000000000a00000000000000000000000000000000000100").unwrap(); + let ongoing_encoded = sp_core::Bytes::from_str("0x00000000012c01082a0000000000000004000100000000000000010000000000000001000000000000000a00000000000000000000000000000000000100").unwrap(); let ongoing_dec = v0::ReferendumInfoOf::::decode(&mut &*ongoing_encoded).unwrap(); let ongoing = v0::ReferendumInfoOf::::Ongoing(create_status_v0()); assert_eq!(ongoing, ongoing_dec); diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index ade2a09a9f9a4..cdedb79556f35 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -57,7 +57,7 @@ frame_support::construct_runtime!( pub struct BaseFilter; impl Contains for BaseFilter { fn contains(call: &RuntimeCall) -> bool { - !matches!(call, &RuntimeCall::Balances(pallet_balances::Call::set_balance { .. })) + !matches!(call, &RuntimeCall::Balances(pallet_balances::Call::force_set_balance { .. })) } } @@ -120,6 +120,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { pub static AlarmInterval: u64 = 1; @@ -295,19 +299,14 @@ impl VoteTally for Tally { } pub fn set_balance_proposal(value: u64) -> Vec { - RuntimeCall::Balances(pallet_balances::Call::set_balance { - who: 42, - new_free: value, - new_reserved: 0, - }) - .encode() + RuntimeCall::Balances(pallet_balances::Call::force_set_balance { who: 42, new_free: value }) + .encode() } pub fn set_balance_proposal_bounded(value: u64) -> BoundedCallOf { - let c = RuntimeCall::Balances(pallet_balances::Call::set_balance { + let c = RuntimeCall::Balances(pallet_balances::Call::force_set_balance { who: 42, new_free: value, - new_reserved: 0, }); ::bound(c).unwrap() } diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index 0937c43d6e519..828551e4d9c19 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -121,6 +121,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } pallet_staking_reward_curve::build! { diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index a91b1a60f4974..f10a1320ef83c 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -91,6 +91,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 4c4accbbfac8f..b7671255f68fb 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -84,6 +84,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<10>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl pallet_timestamp::Config for Test { diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 73565dedc7cd1..9f72febc2106e 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -93,6 +93,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl Config for Test { diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index e876940cb92d3..c2f559a9780eb 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -157,6 +157,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } sp_runtime::impl_opaque_keys! { diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 966eae8c1da9a..36cafcc1854db 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -30,7 +30,7 @@ use pallet_balances::Error as BalancesError; use sp_runtime::{ assert_eq_error_rate, traits::{BadOrigin, Dispatchable}, - Perbill, Percent, Rounding, + Perbill, Percent, Rounding, TokenError, }; use sp_staking::{ offence::{DisableStrategy, OffenceDetails, OnOffenceHandler}, @@ -98,8 +98,8 @@ fn force_unstake_works() { add_slash(&11); // Cant transfer assert_noop!( - Balances::transfer(RuntimeOrigin::signed(11), 1, 10), - BalancesError::::LiquidityRestrictions + Balances::transfer_allow_death(RuntimeOrigin::signed(11), 1, 10), + TokenError::Frozen, ); // Force unstake requires root. assert_noop!(Staking::force_unstake(RuntimeOrigin::signed(11), 11, 2), BadOrigin); @@ -113,7 +113,7 @@ fn force_unstake_works() { // No longer bonded. assert_eq!(Staking::bonded(&11), None); // Transfer works. - assert_ok!(Balances::transfer(RuntimeOrigin::signed(11), 1, 10)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(11), 1, 10)); }); } @@ -960,14 +960,14 @@ fn cannot_transfer_staked_balance() { assert_eq!(Staking::eras_stakers(active_era(), 11).total, 1000); // Confirm account 11 cannot transfer as a result assert_noop!( - Balances::transfer(RuntimeOrigin::signed(11), 20, 1), - BalancesError::::LiquidityRestrictions + Balances::transfer_allow_death(RuntimeOrigin::signed(11), 20, 1), + TokenError::Frozen, ); // Give account 11 extra free balance let _ = Balances::make_free_balance_be(&11, 10000); // Confirm that account 11 can now transfer some balance - assert_ok!(Balances::transfer(RuntimeOrigin::signed(11), 20, 1)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(11), 20, 1)); }); } @@ -985,10 +985,10 @@ fn cannot_transfer_staked_balance_2() { assert_eq!(Staking::eras_stakers(active_era(), 21).total, 1000); // Confirm account 21 can transfer at most 1000 assert_noop!( - Balances::transfer(RuntimeOrigin::signed(21), 20, 1001), - BalancesError::::LiquidityRestrictions + Balances::transfer_allow_death(RuntimeOrigin::signed(21), 20, 1001), + TokenError::Frozen, ); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(21), 20, 1000)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(21), 20, 1000)); }); } @@ -4187,7 +4187,7 @@ fn payout_creates_controller() { bond_nominator(1234, 1337, 100, vec![11]); // kill controller - assert_ok!(Balances::transfer(RuntimeOrigin::signed(1337), 1234, 100)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1337), 1234, 100)); assert_eq!(Balances::free_balance(1337), 0); mock::start_active_era(1); diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 5385c6b5f4f46..1f6266d999825 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1128,6 +1128,10 @@ mod mock { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } /// Test only Weights for state migration. diff --git a/frame/support/src/traits/stored_map.rs b/frame/support/src/traits/stored_map.rs index a073b268252ad..cbe70f2932349 100644 --- a/frame/support/src/traits/stored_map.rs +++ b/frame/support/src/traits/stored_map.rs @@ -17,7 +17,7 @@ //! Traits and associated datatypes for managing abstract stored values. -use crate::{storage::StorageMap, traits::misc::HandleLifetime}; +use crate::storage::StorageMap; use codec::FullCodec; use sp_runtime::DispatchError; @@ -81,48 +81,29 @@ pub trait StoredMap { /// be the default value), or where the account is being removed or reset back to the default value /// where previously it did exist (though may have been in a default state). This works well with /// system module's `CallOnCreatedAccount` and `CallKillAccount`. -pub struct StorageMapShim(sp_std::marker::PhantomData<(S, L, K, T)>); -impl< - S: StorageMap, - L: HandleLifetime, - K: FullCodec, - T: FullCodec + Default, - > StoredMap for StorageMapShim +pub struct StorageMapShim(sp_std::marker::PhantomData<(S, K, T)>); +impl, K: FullCodec, T: FullCodec + Default> StoredMap + for StorageMapShim { fn get(k: &K) -> T { S::get(k) } fn insert(k: &K, t: T) -> Result<(), DispatchError> { - if !S::contains_key(&k) { - L::created(k)?; - } S::insert(k, t); Ok(()) } fn remove(k: &K) -> Result<(), DispatchError> { if S::contains_key(&k) { - L::killed(k)?; S::remove(k); } Ok(()) } fn mutate(k: &K, f: impl FnOnce(&mut T) -> R) -> Result { - if !S::contains_key(&k) { - L::created(k)?; - } Ok(S::mutate(k, f)) } fn mutate_exists(k: &K, f: impl FnOnce(&mut Option) -> R) -> Result { S::try_mutate_exists(k, |maybe_value| { - let existed = maybe_value.is_some(); let r = f(maybe_value); - let exists = maybe_value.is_some(); - - if !existed && exists { - L::created(k)?; - } else if existed && !exists { - L::killed(k)?; - } Ok(r) }) } @@ -131,15 +112,7 @@ impl< f: impl FnOnce(&mut Option) -> Result, ) -> Result { S::try_mutate_exists(k, |maybe_value| { - let existed = maybe_value.is_some(); let r = f(maybe_value)?; - let exists = maybe_value.is_some(); - - if !existed && exists { - L::created(k).map_err(E::from)?; - } else if existed && !exists { - L::killed(k).map_err(E::from)?; - } Ok(r) }) } diff --git a/frame/support/src/traits/tokens.rs b/frame/support/src/traits/tokens.rs index 2d2bd63ada551..d2753caa6a79d 100644 --- a/frame/support/src/traits/tokens.rs +++ b/frame/support/src/traits/tokens.rs @@ -30,6 +30,7 @@ pub use imbalance::Imbalance; pub mod pay; pub use misc::{ AssetId, Balance, BalanceConversion, BalanceStatus, ConvertRank, DepositConsequence, - ExistenceRequirement, GetSalary, Locker, WithdrawConsequence, WithdrawReasons, + ExistenceRequirement, Fortitude, GetSalary, Locker, Precision, Preservation, Provenance, + Restriction, WithdrawConsequence, WithdrawReasons, }; pub use pay::{Pay, PayFromAccount, PaymentStatus}; diff --git a/frame/support/src/traits/tokens/fungible.rs b/frame/support/src/traits/tokens/fungible.rs deleted file mode 100644 index 12bac29727dd4..0000000000000 --- a/frame/support/src/traits/tokens/fungible.rs +++ /dev/null @@ -1,367 +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. - -//! The traits for dealing with a single fungible token class and any associated types. - -use super::{ - misc::{Balance, DepositConsequence, WithdrawConsequence}, - *, -}; -use crate::{ - dispatch::{DispatchError, DispatchResult}, - traits::misc::Get, -}; -use sp_runtime::traits::Saturating; - -mod balanced; -mod imbalance; -pub use balanced::{Balanced, Unbalanced}; -pub use imbalance::{CreditOf, DebtOf, HandleImbalanceDrop, Imbalance}; - -/// Trait for providing balance-inspection access to a fungible asset. -pub trait Inspect { - /// Scalar type for representing balance of an account. - type Balance: Balance; - - /// The total amount of issuance in the system. - fn total_issuance() -> Self::Balance; - - /// The total amount of issuance in the system excluding those which are controlled by the - /// system. - fn active_issuance() -> Self::Balance { - Self::total_issuance() - } - - /// The minimum balance any single account may have. - fn minimum_balance() -> Self::Balance; - - /// Get the balance of `who`. - fn balance(who: &AccountId) -> Self::Balance; - - /// Get the maximum amount that `who` can withdraw/transfer successfully. - fn reducible_balance(who: &AccountId, keep_alive: bool) -> Self::Balance; - - /// Returns `true` if the balance of `who` may be increased by `amount`. - /// - /// - `who`: The account of which the balance should be increased by `amount`. - /// - `amount`: How much should the balance be increased? - /// - `mint`: Will `amount` be minted to deposit it into `account`? - fn can_deposit(who: &AccountId, amount: Self::Balance, mint: bool) -> DepositConsequence; - - /// Returns `Failed` if the balance of `who` may not be decreased by `amount`, otherwise - /// the consequence. - fn can_withdraw(who: &AccountId, amount: Self::Balance) -> WithdrawConsequence; -} - -/// Trait for providing an ERC-20 style fungible asset. -pub trait Mutate: Inspect { - /// Increase the balance of `who` by exactly `amount`, minting new tokens. If that isn't - /// possible then an `Err` is returned and nothing is changed. - fn mint_into(who: &AccountId, amount: Self::Balance) -> DispatchResult; - - /// Decrease the balance of `who` by at least `amount`, possibly slightly more in the case of - /// minimum_balance requirements, burning the tokens. If that isn't possible then an `Err` is - /// returned and nothing is changed. If successful, the amount of tokens reduced is returned. - fn burn_from(who: &AccountId, amount: Self::Balance) -> Result; - - // TODO: Remove. - /// Attempt to reduce the balance of `who` by as much as possible up to `amount`, and possibly - /// slightly more due to minimum_balance requirements. If no decrease is possible then an `Err` - /// is returned and nothing is changed. If successful, the amount of tokens reduced is returned. - /// - /// The default implementation just uses `withdraw` along with `reducible_balance` to ensure - /// that it doesn't fail. - fn slash(who: &AccountId, amount: Self::Balance) -> Result { - Self::burn_from(who, Self::reducible_balance(who, false).min(amount)) - } - - /// Transfer funds from one account into another. The default implementation uses `mint_into` - /// and `burn_from` and may generate unwanted events. - fn teleport( - source: &AccountId, - dest: &AccountId, - amount: Self::Balance, - ) -> Result { - let extra = Self::can_withdraw(&source, amount).into_result()?; - // As we first burn and then mint, we don't need to check if `mint` fits into the supply. - // If we can withdraw/burn it, we can also mint it again. - Self::can_deposit(dest, amount.saturating_add(extra), false).into_result()?; - let actual = Self::burn_from(source, amount)?; - debug_assert!( - actual == amount.saturating_add(extra), - "can_withdraw must agree with withdraw; qed" - ); - match Self::mint_into(dest, actual) { - Ok(_) => Ok(actual), - Err(err) => { - debug_assert!(false, "can_deposit returned true previously; qed"); - // attempt to return the funds back to source - let revert = Self::mint_into(source, actual); - debug_assert!(revert.is_ok(), "withdrew funds previously; qed"); - Err(err) - }, - } - } -} - -/// Trait for providing a fungible asset which can only be transferred. -pub trait Transfer: Inspect { - /// Transfer funds from one account into another. - fn transfer( - source: &AccountId, - dest: &AccountId, - amount: Self::Balance, - keep_alive: bool, - ) -> Result; - - /// Reduce the active issuance by some amount. - fn deactivate(_: Self::Balance) {} - - /// Increase the active issuance by some amount, up to the outstanding amount reduced. - fn reactivate(_: Self::Balance) {} -} - -/// Trait for inspecting a fungible asset which can be reserved. -pub trait InspectHold: Inspect { - /// Amount of funds held in reserve by `who`. - fn balance_on_hold(who: &AccountId) -> Self::Balance; - - /// Check to see if some `amount` of funds of `who` may be placed on hold. - fn can_hold(who: &AccountId, amount: Self::Balance) -> bool; -} - -// TODO: Introduce `HoldReason`. -/// Trait for mutating a fungible asset which can be reserved. -pub trait MutateHold: InspectHold + Transfer { - /// Hold some funds in an account. - fn hold(who: &AccountId, amount: Self::Balance) -> DispatchResult; - - /// Release up to `amount` held funds in an account. - /// - /// The actual amount released is returned with `Ok`. - /// - /// If `best_effort` is `true`, then the amount actually unreserved and returned as the inner - /// value of `Ok` may be smaller than the `amount` passed. - fn release( - who: &AccountId, - amount: Self::Balance, - best_effort: bool, - ) -> Result; - - // TODO: Introduce repatriate_held - - /// Transfer held funds into a destination account. - /// - /// If `on_hold` is `true`, then the destination account must already exist and the assets - /// transferred will still be on hold in the destination account. If not, then the destination - /// account need not already exist, but must be creatable. - /// - /// If `best_effort` is `true`, then an amount less than `amount` may be transferred without - /// error. - /// - /// The actual amount transferred is returned, or `Err` in the case of error and nothing is - /// changed. - fn transfer_held( - source: &AccountId, - dest: &AccountId, - amount: Self::Balance, - best_effort: bool, - on_held: bool, - ) -> Result; -} - -/// Trait for slashing a fungible asset which can be reserved. -pub trait BalancedHold: Balanced + MutateHold { - /// Reduce the balance of some funds on hold in an account. - /// - /// The resulting imbalance is the first item of the tuple returned. - /// - /// As much funds that are on hold up to `amount` will be deducted as possible. If this is less - /// than `amount`, then a non-zero second item will be returned. - fn slash_held( - who: &AccountId, - amount: Self::Balance, - ) -> (CreditOf, Self::Balance); -} - -impl + MutateHold> BalancedHold for T { - // TODO: This should be implemented properly, and `slash` should be removed. - fn slash_held( - who: &AccountId, - amount: Self::Balance, - ) -> (CreditOf, Self::Balance) { - let actual = match Self::release(who, amount, true) { - Ok(x) => x, - Err(_) => return (Imbalance::default(), amount), - }; - >::slash(who, actual) - } -} - -/// Convert a `fungibles` trait implementation into a `fungible` trait implementation by identifying -/// a single item. -pub struct ItemOf< - F: fungibles::Inspect, - A: Get<>::AssetId>, - AccountId, ->(sp_std::marker::PhantomData<(F, A, AccountId)>); - -impl< - F: fungibles::Inspect, - A: Get<>::AssetId>, - AccountId, - > Inspect for ItemOf -{ - type Balance = >::Balance; - fn total_issuance() -> Self::Balance { - >::total_issuance(A::get()) - } - fn active_issuance() -> Self::Balance { - >::active_issuance(A::get()) - } - fn minimum_balance() -> Self::Balance { - >::minimum_balance(A::get()) - } - fn balance(who: &AccountId) -> Self::Balance { - >::balance(A::get(), who) - } - fn reducible_balance(who: &AccountId, keep_alive: bool) -> Self::Balance { - >::reducible_balance(A::get(), who, keep_alive) - } - fn can_deposit(who: &AccountId, amount: Self::Balance, mint: bool) -> DepositConsequence { - >::can_deposit(A::get(), who, amount, mint) - } - fn can_withdraw(who: &AccountId, amount: Self::Balance) -> WithdrawConsequence { - >::can_withdraw(A::get(), who, amount) - } -} - -impl< - F: fungibles::Mutate, - A: Get<>::AssetId>, - AccountId, - > Mutate for ItemOf -{ - fn mint_into(who: &AccountId, amount: Self::Balance) -> DispatchResult { - >::mint_into(A::get(), who, amount) - } - fn burn_from(who: &AccountId, amount: Self::Balance) -> Result { - >::burn_from(A::get(), who, amount) - } -} - -impl< - F: fungibles::Transfer, - A: Get<>::AssetId>, - AccountId, - > Transfer for ItemOf -{ - fn transfer( - source: &AccountId, - dest: &AccountId, - amount: Self::Balance, - keep_alive: bool, - ) -> Result { - >::transfer(A::get(), source, dest, amount, keep_alive) - } - fn deactivate(amount: Self::Balance) { - >::deactivate(A::get(), amount) - } - fn reactivate(amount: Self::Balance) { - >::reactivate(A::get(), amount) - } -} - -impl< - F: fungibles::InspectHold, - A: Get<>::AssetId>, - AccountId, - > InspectHold for ItemOf -{ - fn balance_on_hold(who: &AccountId) -> Self::Balance { - >::balance_on_hold(A::get(), who) - } - fn can_hold(who: &AccountId, amount: Self::Balance) -> bool { - >::can_hold(A::get(), who, amount) - } -} - -impl< - F: fungibles::MutateHold, - A: Get<>::AssetId>, - AccountId, - > MutateHold for ItemOf -{ - fn hold(who: &AccountId, amount: Self::Balance) -> DispatchResult { - >::hold(A::get(), who, amount) - } - fn release( - who: &AccountId, - amount: Self::Balance, - best_effort: bool, - ) -> Result { - >::release(A::get(), who, amount, best_effort) - } - fn transfer_held( - source: &AccountId, - dest: &AccountId, - amount: Self::Balance, - best_effort: bool, - on_hold: bool, - ) -> Result { - >::transfer_held( - A::get(), - source, - dest, - amount, - best_effort, - on_hold, - ) - } -} - -impl< - F: fungibles::Unbalanced, - A: Get<>::AssetId>, - AccountId, - > Unbalanced for ItemOf -{ - fn set_balance(who: &AccountId, amount: Self::Balance) -> DispatchResult { - >::set_balance(A::get(), who, amount) - } - fn set_total_issuance(amount: Self::Balance) -> () { - >::set_total_issuance(A::get(), amount) - } - fn decrease_balance( - who: &AccountId, - amount: Self::Balance, - ) -> Result { - >::decrease_balance(A::get(), who, amount) - } - fn decrease_balance_at_most(who: &AccountId, amount: Self::Balance) -> Self::Balance { - >::decrease_balance_at_most(A::get(), who, amount) - } - fn increase_balance( - who: &AccountId, - amount: Self::Balance, - ) -> Result { - >::increase_balance(A::get(), who, amount) - } - fn increase_balance_at_most(who: &AccountId, amount: Self::Balance) -> Self::Balance { - >::increase_balance_at_most(A::get(), who, amount) - } -} diff --git a/frame/support/src/traits/tokens/fungible/balanced.rs b/frame/support/src/traits/tokens/fungible/balanced.rs deleted file mode 100644 index 437d2c82defee..0000000000000 --- a/frame/support/src/traits/tokens/fungible/balanced.rs +++ /dev/null @@ -1,354 +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. - -//! The trait and associated types for sets of fungible tokens that manage total issuance without -//! requiring atomic balanced operations. - -use super::{super::Imbalance as ImbalanceT, *}; -use crate::{ - dispatch::{DispatchError, DispatchResult}, - traits::misc::{SameOrOther, TryDrop}, -}; -use sp_runtime::{ - traits::{CheckedAdd, Zero}, - ArithmeticError, TokenError, -}; -use sp_std::marker::PhantomData; - -/// A fungible token class where any creation and deletion of tokens is semi-explicit and where the -/// total supply is maintained automatically. -/// -/// This is auto-implemented when a token class has `Unbalanced` implemented. -pub trait Balanced: Inspect { - /// The type for managing what happens when an instance of `Debt` is dropped without being used. - type OnDropDebt: HandleImbalanceDrop; - /// The type for managing what happens when an instance of `Credit` is dropped without being - /// used. - type OnDropCredit: HandleImbalanceDrop; - - /// Reduce the total issuance by `amount` and return the according imbalance. The imbalance will - /// typically be used to reduce an account by the same amount with e.g. `settle`. - /// - /// This is infallible, but doesn't guarantee that the entire `amount` is burnt, for example - /// in the case of underflow. - fn rescind(amount: Self::Balance) -> DebtOf; - - /// Increase the total issuance by `amount` and return the according imbalance. The imbalance - /// will typically be used to increase an account by the same amount with e.g. - /// `resolve_into_existing` or `resolve_creating`. - /// - /// This is infallible, but doesn't guarantee that the entire `amount` is issued, for example - /// in the case of overflow. - fn issue(amount: Self::Balance) -> CreditOf; - - /// Produce a pair of imbalances that cancel each other out exactly. - /// - /// This is just the same as burning and issuing the same amount and has no effect on the - /// total issuance. - fn pair(amount: Self::Balance) -> (DebtOf, CreditOf) { - (Self::rescind(amount), Self::issue(amount)) - } - - /// Deducts up to `value` from the combined balance of `who`. This function cannot fail. - /// - /// The resulting imbalance is the first item of the tuple returned. - /// - /// As much funds up to `value` will be deducted as possible. If this is less than `value`, - /// then a non-zero second item will be returned. - fn slash(who: &AccountId, amount: Self::Balance) -> (CreditOf, Self::Balance); - - /// Mints exactly `value` into the account of `who`. - /// - /// If `who` doesn't exist, nothing is done and an `Err` returned. This could happen because it - /// the account doesn't yet exist and it isn't possible to create it under the current - /// circumstances and with `value` in it. - fn deposit( - who: &AccountId, - value: Self::Balance, - ) -> Result, DispatchError>; - - /// Removes `value` balance from `who` account if possible. - /// - /// If the removal is not possible, then it returns `Err` and nothing is changed. - /// - /// If the operation is successful, this will return `Ok` with a `NegativeImbalance` whose value - /// is no less than `value`. It may be more in the case that removing it reduced it below - /// `Self::minimum_balance()`. - fn withdraw( - who: &AccountId, - value: Self::Balance, - // TODO: liveness: ExistenceRequirement, - ) -> Result, DispatchError>; - - /// The balance of `who` is increased in order to counter `credit`. If the whole of `credit` - /// cannot be countered, then nothing is changed and the original `credit` is returned in an - /// `Err`. - /// - /// Please note: If `credit.peek()` is less than `Self::minimum_balance()`, then `who` must - /// already exist for this to succeed. - fn resolve( - who: &AccountId, - credit: CreditOf, - ) -> Result<(), CreditOf> { - let v = credit.peek(); - let debt = match Self::deposit(who, v) { - Err(_) => return Err(credit), - Ok(d) => d, - }; - let result = credit.offset(debt).try_drop(); - debug_assert!(result.is_ok(), "ok deposit return must be equal to credit value; qed"); - Ok(()) - } - - /// The balance of `who` is decreased in order to counter `debt`. If the whole of `debt` - /// cannot be countered, then nothing is changed and the original `debt` is returned in an - /// `Err`. - fn settle( - who: &AccountId, - debt: DebtOf, - // TODO: liveness: ExistenceRequirement, - ) -> Result, DebtOf> { - let amount = debt.peek(); - let credit = match Self::withdraw(who, amount) { - Err(_) => return Err(debt), - Ok(d) => d, - }; - match credit.offset(debt) { - SameOrOther::None => Ok(CreditOf::::zero()), - SameOrOther::Same(dust) => Ok(dust), - SameOrOther::Other(rest) => { - debug_assert!(false, "ok withdraw return must be at least debt value; qed"); - Err(rest) - }, - } - } -} - -/// A fungible token class where the balance can be set arbitrarily. -/// -/// **WARNING** -/// Do not use this directly unless you want trouble, since it allows you to alter account balances -/// without keeping the issuance up to date. It has no safeguards against accidentally creating -/// token imbalances in your system leading to accidental imflation or deflation. It's really just -/// for the underlying datatype to implement so the user gets the much safer `Balanced` trait to -/// use. -pub trait Unbalanced: Inspect { - /// Set the balance of `who` to `amount`. If this cannot be done for some reason (e.g. - /// because the account cannot be created or an overflow) then an `Err` is returned. - fn set_balance(who: &AccountId, amount: Self::Balance) -> DispatchResult; - - /// Set the total issuance to `amount`. - fn set_total_issuance(amount: Self::Balance); - - /// Reduce the balance of `who` by `amount`. If it cannot be reduced by that amount for - /// some reason, return `Err` and don't reduce it at all. If Ok, return the imbalance. - /// - /// Minimum balance will be respected and the returned imbalance may be up to - /// `Self::minimum_balance() - 1` greater than `amount`. - fn decrease_balance( - who: &AccountId, - amount: Self::Balance, - ) -> Result { - let old_balance = Self::balance(who); - let (mut new_balance, mut amount) = if Self::reducible_balance(who, false) < amount { - return Err(TokenError::NoFunds.into()) - } else { - (old_balance - amount, amount) - }; - if new_balance < Self::minimum_balance() { - amount = amount.saturating_add(new_balance); - new_balance = Zero::zero(); - } - // Defensive only - this should not fail now. - Self::set_balance(who, new_balance)?; - Ok(amount) - } - - /// Reduce the balance of `who` by the most that is possible, up to `amount`. - /// - /// Minimum balance will be respected and the returned imbalance may be up to - /// `Self::minimum_balance() - 1` greater than `amount`. - /// - /// Return the imbalance by which the account was reduced. - fn decrease_balance_at_most(who: &AccountId, amount: Self::Balance) -> Self::Balance { - let old_balance = Self::balance(who); - let old_free_balance = Self::reducible_balance(who, false); - let (mut new_balance, mut amount) = if old_free_balance < amount { - (old_balance.saturating_sub(old_free_balance), old_free_balance) - } else { - (old_balance - amount, amount) - }; - let minimum_balance = Self::minimum_balance(); - if new_balance < minimum_balance { - amount = amount.saturating_add(new_balance); - new_balance = Zero::zero(); - } - let mut r = Self::set_balance(who, new_balance); - if r.is_err() { - // Some error, probably because we tried to destroy an account which cannot be - // destroyed. - if new_balance.is_zero() && amount >= minimum_balance { - new_balance = minimum_balance; - amount -= minimum_balance; - r = Self::set_balance(who, new_balance); - } - if r.is_err() { - // Still an error. Apparently it's not possible to reduce at all. - amount = Zero::zero(); - } - } - amount - } - - /// Increase the balance of `who` by `amount`. If it cannot be increased by that amount - /// for some reason, return `Err` and don't increase it at all. If Ok, return the imbalance. - /// - /// Minimum balance will be respected and an error will be returned if - /// `amount < Self::minimum_balance()` when the account of `who` is zero. - fn increase_balance( - who: &AccountId, - amount: Self::Balance, - ) -> Result { - let old_balance = Self::balance(who); - let new_balance = old_balance.checked_add(&amount).ok_or(ArithmeticError::Overflow)?; - if new_balance < Self::minimum_balance() { - return Err(TokenError::BelowMinimum.into()) - } - if old_balance != new_balance { - Self::set_balance(who, new_balance)?; - } - Ok(amount) - } - - /// Increase the balance of `who` by the most that is possible, up to `amount`. - /// - /// Minimum balance will be respected and the returned imbalance will be zero in the case that - /// `amount < Self::minimum_balance()`. - /// - /// Return the imbalance by which the account was increased. - fn increase_balance_at_most(who: &AccountId, amount: Self::Balance) -> Self::Balance { - let old_balance = Self::balance(who); - let mut new_balance = old_balance.saturating_add(amount); - let mut amount = new_balance - old_balance; - if new_balance < Self::minimum_balance() { - new_balance = Zero::zero(); - amount = Zero::zero(); - } - if old_balance == new_balance || Self::set_balance(who, new_balance).is_ok() { - amount - } else { - Zero::zero() - } - } -} - -/// Simple handler for an imbalance drop which increases the total issuance of the system by the -/// imbalance amount. Used for leftover debt. -pub struct IncreaseIssuance(PhantomData<(AccountId, U)>); -impl> HandleImbalanceDrop - for IncreaseIssuance -{ - fn handle(amount: U::Balance) { - U::set_total_issuance(U::total_issuance().saturating_add(amount)) - } -} - -/// Simple handler for an imbalance drop which decreases the total issuance of the system by the -/// imbalance amount. Used for leftover credit. -pub struct DecreaseIssuance(PhantomData<(AccountId, U)>); -impl> HandleImbalanceDrop - for DecreaseIssuance -{ - fn handle(amount: U::Balance) { - U::set_total_issuance(U::total_issuance().saturating_sub(amount)) - } -} - -/// An imbalance type which uses `DecreaseIssuance` to deal with anything `Drop`ed. -/// -/// Basically means that funds in someone's account have been removed and not yet placed anywhere -/// else. If it gets dropped, then those funds will be assumed to be "burned" and the total supply -/// will be accordingly decreased to ensure it equals the sum of the balances of all accounts. -type Credit = Imbalance< - >::Balance, - DecreaseIssuance, - IncreaseIssuance, ->; - -/// An imbalance type which uses `IncreaseIssuance` to deal with anything `Drop`ed. -/// -/// Basically means that there are funds in someone's account whose origin is as yet unaccounted -/// for. If it gets dropped, then those funds will be assumed to be "minted" and the total supply -/// will be accordingly increased to ensure it equals the sum of the balances of all accounts. -type Debt = Imbalance< - >::Balance, - IncreaseIssuance, - DecreaseIssuance, ->; - -/// Create some `Credit` item. Only for internal use. -fn credit>(amount: U::Balance) -> Credit { - Imbalance::new(amount) -} - -/// Create some `Debt` item. Only for internal use. -fn debt>(amount: U::Balance) -> Debt { - Imbalance::new(amount) -} - -impl> Balanced for U { - type OnDropCredit = DecreaseIssuance; - type OnDropDebt = IncreaseIssuance; - fn rescind(amount: Self::Balance) -> Debt { - let old = U::total_issuance(); - let new = old.saturating_sub(amount); - U::set_total_issuance(new); - debt(old - new) - } - fn issue(amount: Self::Balance) -> Credit { - let old = U::total_issuance(); - let new = old.saturating_add(amount); - U::set_total_issuance(new); - credit(new - old) - } - fn slash(who: &AccountId, amount: Self::Balance) -> (Credit, Self::Balance) { - let slashed = U::decrease_balance_at_most(who, amount); - // `slashed` could be less than, greater than or equal to `amount`. - // If slashed == amount, it means the account had at least amount in it and it could all be - // removed without a problem. - // If slashed > amount, it means the account had more than amount in it, but not enough more - // to push it over minimum_balance. - // If slashed < amount, it means the account didn't have enough in it to be reduced by - // `amount` without being destroyed. - (credit(slashed), amount.saturating_sub(slashed)) - } - fn deposit( - who: &AccountId, - amount: Self::Balance, - ) -> Result, DispatchError> { - let increase = U::increase_balance(who, amount)?; - Ok(debt(increase)) - } - fn withdraw( - who: &AccountId, - amount: Self::Balance, - // TODO: liveness: ExistenceRequirement, - ) -> Result, DispatchError> { - let decrease = U::decrease_balance(who, amount)?; - Ok(credit(decrease)) - } -} diff --git a/frame/support/src/traits/tokens/fungible/freeze.rs b/frame/support/src/traits/tokens/fungible/freeze.rs new file mode 100644 index 0000000000000..1ec3a5fadf555 --- /dev/null +++ b/frame/support/src/traits/tokens/fungible/freeze.rs @@ -0,0 +1,68 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 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. + +//! The traits for putting freezes within a single fungible token class. + +use scale_info::TypeInfo; +use sp_runtime::DispatchResult; + +/// Trait for inspecting a fungible asset which can be frozen. Freezing is essentially setting a +/// minimum balance bellow which the total balance (inclusive of any funds placed on hold) may not +/// be normally allowed to drop. Generally, freezers will provide an "update" function such that +/// if the total balance does drop below the limit, then the freezer can update their housekeeping +/// accordingly. +pub trait Inspect: super::Inspect { + /// An identifier for a freeze. + type Id: codec::Encode + TypeInfo + 'static; + + /// Amount of funds held in reserve by `who` for the given `id`. + fn balance_frozen(id: &Self::Id, who: &AccountId) -> Self::Balance; + + /// The amount of the balance which can become frozen. Defaults to `total_balance()`. + fn balance_freezable(who: &AccountId) -> Self::Balance { + Self::total_balance(who) + } + + /// Returns `true` if it's possible to introduce a freeze for the given `id` onto the + /// account of `who`. This will be true as long as the implementor supports as many + /// concurrent freeze locks as there are possible values of `id`. + fn can_freeze(id: &Self::Id, who: &AccountId) -> bool; +} + +/// Trait for introducing, altering and removing locks to freeze an account's funds so they never +/// go below a set minimum. +pub trait Mutate: Inspect { + /// Prevent actions which would reduce the balance of the account of `who` below the given + /// `amount` and identify this restriction though the given `id`. Unlike `extend_freeze`, any + /// outstanding freeze in place for `who` under the `id` are dropped. + /// + /// If `amount` is zero, it is equivalent to using `thaw`. + /// + /// Note that `amount` can be greater than the total balance, if desired. + fn set_freeze(id: &Self::Id, who: &AccountId, amount: Self::Balance) -> DispatchResult; + + /// Prevent the balance of the account of `who` from being reduced below the given `amount` and + /// identify this restriction though the given `id`. Unlike `set_freeze`, this does not + /// counteract any pre-existing freezes in place for `who` under the `id`. Also unlike + /// `set_freeze`, in the case that `amount` is zero, this is no-op and never fails. + /// + /// Note that more funds can be locked than the total balance, if desired. + fn extend_freeze(id: &Self::Id, who: &AccountId, amount: Self::Balance) -> DispatchResult; + + /// Remove an existing lock. + fn thaw(id: &Self::Id, who: &AccountId) -> DispatchResult; +} diff --git a/frame/support/src/traits/tokens/fungible/hold.rs b/frame/support/src/traits/tokens/fungible/hold.rs new file mode 100644 index 0000000000000..ddcb8c6ac1da8 --- /dev/null +++ b/frame/support/src/traits/tokens/fungible/hold.rs @@ -0,0 +1,393 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 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. + +//! The traits for putting holds within a single fungible token class. + +use crate::{ + ensure, + traits::tokens::{ + DepositConsequence::Success, + Fortitude::{self, Force}, + Precision::{self, BestEffort, Exact}, + Preservation::{self, Protect}, + Provenance::Extant, + Restriction::{self, Free, OnHold}, + }, +}; +use scale_info::TypeInfo; +use sp_arithmetic::{ + traits::{CheckedAdd, CheckedSub, Zero}, + ArithmeticError, +}; +use sp_runtime::{DispatchError, DispatchResult, Saturating, TokenError}; + +use super::*; + +/// Trait for inspecting a fungible asset whose accounts support partitioning and slashing. +pub trait Inspect: super::Inspect { + /// An identifier for a hold. Used for disambiguating different holds so that + /// they can be individually replaced or removed and funds from one hold don't accidentally + /// become unreserved or slashed for another. + type Reason: codec::Encode + TypeInfo + 'static; + + /// Amount of funds on hold (for all hold reasons) of `who`. + fn total_balance_on_hold(who: &AccountId) -> Self::Balance; + + /// Get the maximum amount that the `total_balance_on_hold` of `who` can be reduced successfully + /// based on whether we are willing to force the reduction and potentially go below user-level + /// restrictions on the minimum amount of the account. Note: This cannot bring the account into + /// an inconsistent state with regards any required existential deposit. + /// + /// Always less than `total_balance_on_hold()`. + fn reducible_total_balance_on_hold(who: &AccountId, force: Fortitude) -> Self::Balance; + + /// Amount of funds on hold (for the given reason) of `who`. + fn balance_on_hold(reason: &Self::Reason, who: &AccountId) -> Self::Balance; + + /// Returns `true` if it's possible to place (additional) funds under a hold of a given + /// `reason`. This may fail if the account has exhausted a limited number of concurrent + /// holds or if it cannot be made to exist (e.g. there is no provider reference). + /// + /// NOTE: This does not take into account changes which could be made to the account of `who` + /// (such as removing a provider reference) after this call is made. Any usage of this should + /// therefore ensure the account is already in the appropriate state prior to calling it. + fn hold_available(reason: &Self::Reason, who: &AccountId) -> bool; + + /// Check to see if some `amount` of funds of `who` may be placed on hold with the given + /// `reason`. Reasons why this may not be true: + /// + /// - The implementor supports only a limited number of concurrent holds on an account which is + /// the possible values of `reason`; + /// - The total balance of the account is less than `amount`; + /// - Removing `amount` from the total balance would kill the account and remove the only + /// provider reference. + /// + /// Note: we pass `true` as the third argument to `reducible_balance` since we assume that if + /// needed the balance can slashed. If we are using a simple non-forcing reserve-transfer, then + /// we really ought to check that we are not reducing the funds below the freeze-limit (if any). + /// + /// NOTE: This does not take into account changes which could be made to the account of `who` + /// (such as removing a provider reference) after this call is made. Any usage of this should + /// therefore ensure the account is already in the appropriate state prior to calling it. + fn ensure_can_hold( + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + ) -> DispatchResult { + ensure!(Self::hold_available(reason, who), TokenError::CannotCreateHold); + ensure!( + amount <= Self::reducible_balance(who, Protect, Force), + TokenError::FundsUnavailable + ); + Ok(()) + } + + /// Check to see if some `amount` of funds of `who` may be placed on hold for the given + /// `reason`. Reasons why this may not be true: + /// + /// - The implementor supports only a limited number of concurrernt holds on an account which is + /// the possible values of `reason`; + /// - The main balance of the account is less than `amount`; + /// - Removing `amount` from the main balance would kill the account and remove the only + /// provider reference. + /// + /// NOTE: This does not take into account changes which could be made to the account of `who` + /// (such as removing a provider reference) after this call is made. Any usage of this should + /// therefore ensure the account is already in the appropriate state prior to calling it. + fn can_hold(reason: &Self::Reason, who: &AccountId, amount: Self::Balance) -> bool { + Self::ensure_can_hold(reason, who, amount).is_ok() + } +} + +/// A fungible, holdable token class where the balance on hold can be set arbitrarily. +/// +/// **WARNING** +/// Do not use this directly unless you want trouble, since it allows you to alter account balances +/// without keeping the issuance up to date. It has no safeguards against accidentally creating +/// token imbalances in your system leading to accidental imflation or deflation. It's really just +/// for the underlying datatype to implement so the user gets the much safer `Balanced` trait to +/// use. +pub trait Unbalanced: Inspect { + /// Forcefully set the balance on hold of `who` to `amount`. This is independent of any other + /// balances on hold or the main ("free") balance. + /// + /// If this call executes successfully, you can `assert_eq!(Self::balance_on_hold(), amount);`. + /// + /// This function does its best to force the balance change through, but will not break system + /// invariants such as any Existential Deposits needed or overflows/underflows. + /// If this cannot be done for some reason (e.g. because the account doesn't exist) then an + /// `Err` is returned. + // Implmentation note: This should increment the consumer refs if it moves total on hold from + // zero to non-zero and decrement in the opposite direction. + // + // Since this was not done in the previous logic, this will need either a migration or a + // state item which tracks whether the account is on the old logic or new. + fn set_balance_on_hold( + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + ) -> DispatchResult; + + /// Reduce the balance on hold of `who` by `amount`. + /// + /// If `precision` is `Exact` and it cannot be reduced by that amount for + /// some reason, return `Err` and don't reduce it at all. If `precision` is `BestEffort`, then + /// reduce the balance of `who` by the most that is possible, up to `amount`. + /// + /// In either case, if `Ok` is returned then the inner is the amount by which is was reduced. + fn decrease_balance_on_hold( + reason: &Self::Reason, + who: &AccountId, + mut amount: Self::Balance, + precision: Precision, + ) -> Result { + let old_balance = Self::balance_on_hold(reason, who); + if let BestEffort = precision { + amount = amount.min(old_balance); + } + let new_balance = old_balance.checked_sub(&amount).ok_or(TokenError::FundsUnavailable)?; + Self::set_balance_on_hold(reason, who, new_balance)?; + Ok(amount) + } + + /// Increase the balance on hold of `who` by `amount`. + /// + /// If it cannot be increased by that amount for some reason, return `Err` and don't increase + /// it at all. If Ok, return the imbalance. + fn increase_balance_on_hold( + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + precision: Precision, + ) -> Result { + let old_balance = Self::balance_on_hold(reason, who); + let new_balance = if let BestEffort = precision { + old_balance.saturating_add(amount) + } else { + old_balance.checked_add(&amount).ok_or(ArithmeticError::Overflow)? + }; + let amount = new_balance.saturating_sub(old_balance); + if !amount.is_zero() { + Self::set_balance_on_hold(reason, who, new_balance)?; + } + Ok(amount) + } +} + +/// Trait for mutating a fungible asset which can be placed on hold. +pub trait Mutate: + Inspect + super::Unbalanced + Unbalanced +{ + /// Hold some funds in an account. If a hold for `reason` is already in place, then this + /// will increase it. + fn hold(reason: &Self::Reason, who: &AccountId, amount: Self::Balance) -> DispatchResult { + // NOTE: This doesn't change the total balance of the account so there's no need to + // check liquidity. + + Self::ensure_can_hold(reason, who, amount)?; + // Should be infallible now, but we proceed softly anyway. + Self::decrease_balance(who, amount, Exact, Protect, Force)?; + Self::increase_balance_on_hold(reason, who, amount, BestEffort)?; + Self::done_hold(reason, who, amount); + Ok(()) + } + + /// Release up to `amount` held funds in an account. + /// + /// The actual amount released is returned with `Ok`. + /// + /// If `precision` is `BestEffort`, then the amount actually unreserved and returned as the + /// inner value of `Ok` may be smaller than the `amount` passed. + /// + /// NOTE! The inner of the `Ok` result variant returns the *actual* amount released. This is the + /// opposite of the `ReservableCurrency::unreserve()` result, which gives the amount not able + /// to be released! + fn release( + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + precision: Precision, + ) -> Result { + // NOTE: This doesn't change the total balance of the account so there's no need to + // check liquidity. + + // We want to make sure we can deposit the amount in advance. If we can't then something is + // very wrong. + ensure!(Self::can_deposit(who, amount, Extant) == Success, TokenError::CannotCreate); + // Get the amount we can actually take from the hold. This might be less than what we want + // if we're only doing a best-effort. + let amount = Self::decrease_balance_on_hold(reason, who, amount, precision)?; + // Increase the main balance by what we took. We always do a best-effort here because we + // already checked that we can deposit before. + let actual = Self::increase_balance(who, amount, BestEffort)?; + Self::done_release(reason, who, actual); + Ok(actual) + } + + /// Attempt to decrease the balance of `who` which is held for the given `reason` by `amount`. + /// + /// If `precision` is `BestEffort`, then as much as possible is reduced, up to `amount`, and the + /// amount of tokens reduced is returned. Otherwise, if the total amount can be reduced, then it + /// is and the amount returned, and if not, then nothing changes and `Err` is returned. + /// + /// If `force` is `Force`, then locks/freezes will be ignored. This should only be used when + /// conducting slashing or other activity which materially disadvantages the account holder + /// since it could provide a means of circumventing freezes. + fn burn_held( + reason: &Self::Reason, + who: &AccountId, + mut amount: Self::Balance, + precision: Precision, + force: Fortitude, + ) -> Result { + // We must check total-balance requirements if `!force`. + let liquid = Self::reducible_total_balance_on_hold(who, force); + if let BestEffort = precision { + amount = amount.min(liquid); + } else { + ensure!(amount <= liquid, TokenError::Frozen); + } + let amount = Self::decrease_balance_on_hold(reason, who, amount, precision)?; + Self::set_total_issuance(Self::total_issuance().saturating_sub(amount)); + Self::done_burn_held(reason, who, amount); + Ok(amount) + } + + /// Transfer held funds into a destination account. + /// + /// If `on_hold` is `true`, then the destination account must already exist and the assets + /// transferred will still be on hold in the destination account. If not, then the destination + /// account need not already exist, but must be creatable. + /// + /// If `precision` is `BestEffort`, then an amount less than `amount` may be transferred without + /// error. + /// + /// If `force` is `Force`, then other fund-locking mechanisms may be disregarded. It should be + /// left as `Polite` in most circumstances, but when you want the same power as a `slash`, it + /// may be `Force`. + /// + /// The actual amount transferred is returned, or `Err` in the case of error and nothing is + /// changed. + fn transfer_on_hold( + reason: &Self::Reason, + source: &AccountId, + dest: &AccountId, + mut amount: Self::Balance, + precision: Precision, + mode: Restriction, + force: Fortitude, + ) -> Result { + // We must check total-balance requirements if `force` is `Fortitude::Polite`. + let have = Self::balance_on_hold(reason, source); + let liquid = Self::reducible_total_balance_on_hold(source, force); + if let BestEffort = precision { + amount = amount.min(liquid).min(have); + } else { + ensure!(amount <= liquid, TokenError::Frozen); + ensure!(amount <= have, TokenError::FundsUnavailable); + } + + // We want to make sure we can deposit the amount in advance. If we can't then something is + // very wrong. + ensure!(Self::can_deposit(dest, amount, Extant) == Success, TokenError::CannotCreate); + ensure!(mode == Free || Self::hold_available(reason, dest), TokenError::CannotCreateHold); + + let amount = Self::decrease_balance_on_hold(reason, source, amount, precision)?; + let actual = if mode == OnHold { + Self::increase_balance_on_hold(reason, dest, amount, precision)? + } else { + Self::increase_balance(dest, amount, precision)? + }; + Self::done_transfer_on_hold(reason, source, dest, actual); + Ok(actual) + } + + /// Transfer some `amount` of free balance from `source` to become owned by `dest` but on hold + /// for `reason`. + /// + /// If `precision` is `BestEffort`, then an amount less than `amount` may be transferred without + /// error. + /// + /// `source` must obey the requirements of `keep_alive`. + /// + /// If `force` is `Force`, then other fund-locking mechanisms may be disregarded. It should be + /// left as `Polite` in most circumstances, but when you want the same power as a `slash`, it + /// may be `Force`. + /// + /// The amount placed on hold is returned or `Err` in the case of error and nothing is changed. + /// + /// WARNING: This may return an error after a partial storage mutation. It should be used only + /// inside a transactional storage context and an `Err` result must imply a storage rollback. + fn transfer_and_hold( + reason: &Self::Reason, + source: &AccountId, + dest: &AccountId, + amount: Self::Balance, + precision: Precision, + expendability: Preservation, + force: Fortitude, + ) -> Result { + ensure!(Self::hold_available(reason, dest), TokenError::CannotCreateHold); + ensure!(Self::can_deposit(dest, amount, Extant) == Success, TokenError::CannotCreate); + let actual = Self::decrease_balance(source, amount, precision, expendability, force)?; + Self::increase_balance_on_hold(reason, dest, actual, precision)?; + Self::done_transfer_on_hold(reason, source, dest, actual); + Ok(actual) + } + + fn done_hold(_reason: &Self::Reason, _who: &AccountId, _amount: Self::Balance) {} + fn done_release(_reason: &Self::Reason, _who: &AccountId, _amount: Self::Balance) {} + fn done_burn_held(_reason: &Self::Reason, _who: &AccountId, _amount: Self::Balance) {} + fn done_transfer_on_hold( + _reason: &Self::Reason, + _source: &AccountId, + _dest: &AccountId, + _amount: Self::Balance, + ) { + } + fn done_transfer_and_hold( + _reason: &Self::Reason, + _source: &AccountId, + _dest: &AccountId, + _transferred: Self::Balance, + ) { + } +} + +/// Trait for slashing a fungible asset which can be place on hold. +pub trait Balanced: super::Balanced + Unbalanced { + /// Reduce the balance of some funds on hold in an account. + /// + /// The resulting imbalance is the first item of the tuple returned. + /// + /// As much funds that are on hold up to `amount` will be deducted as possible. If this is less + /// than `amount`, then a non-zero second item will be returned. + fn slash( + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + ) -> (Credit, Self::Balance) { + let decrease = Self::decrease_balance_on_hold(reason, who, amount, BestEffort) + .unwrap_or(Default::default()); + let credit = + Imbalance::::new(decrease); + Self::done_slash(reason, who, decrease); + (credit, amount.saturating_sub(decrease)) + } + + fn done_slash(_reason: &Self::Reason, _who: &AccountId, _amount: Self::Balance) {} +} diff --git a/frame/support/src/traits/tokens/fungible/imbalance.rs b/frame/support/src/traits/tokens/fungible/imbalance.rs index 1b3d16c62ddf4..de85924a4de7c 100644 --- a/frame/support/src/traits/tokens/fungible/imbalance.rs +++ b/frame/support/src/traits/tokens/fungible/imbalance.rs @@ -18,8 +18,11 @@ //! The imbalance type and its associates, which handles keeps everything adding up properly with //! unbalanced operations. -use super::{super::Imbalance as ImbalanceT, balanced::Balanced, misc::Balance, *}; -use crate::traits::misc::{SameOrOther, TryDrop}; +use super::{super::Imbalance as ImbalanceT, Balanced, *}; +use crate::traits::{ + misc::{SameOrOther, TryDrop}, + tokens::Balance, +}; use sp_runtime::{traits::Zero, RuntimeDebug}; use sp_std::marker::PhantomData; @@ -30,6 +33,10 @@ pub trait HandleImbalanceDrop { fn handle(amount: Balance); } +impl HandleImbalanceDrop for () { + fn handle(_: Balance) {} +} + /// An imbalance in the system, representing a divergence of recorded token supply from the sum of /// the balances of all accounts. This is `must_use` in order to ensure it gets handled (placing /// into an account, settling from an account or altering the supply). @@ -135,7 +142,7 @@ impl, OppositeOnDrop: HandleImbalance } /// Imbalance implying that the total_issuance value is less than the sum of all account balances. -pub type DebtOf = Imbalance< +pub type Debt = Imbalance< >::Balance, // This will generally be implemented by increasing the total_issuance value. >::OnDropDebt, @@ -144,7 +151,7 @@ pub type DebtOf = Imbalance< /// Imbalance implying that the total_issuance value is greater than the sum of all account /// balances. -pub type CreditOf = Imbalance< +pub type Credit = Imbalance< >::Balance, // This will generally be implemented by decreasing the total_issuance value. >::OnDropCredit, diff --git a/frame/support/src/traits/tokens/fungible/item_of.rs b/frame/support/src/traits/tokens/fungible/item_of.rs new file mode 100644 index 0000000000000..cf2d96ef28791 --- /dev/null +++ b/frame/support/src/traits/tokens/fungible/item_of.rs @@ -0,0 +1,451 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 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. + +//! Adapter to use `fungibles::*` implementations as `fungible::*`. + +use sp_core::Get; +use sp_runtime::{DispatchError, DispatchResult}; + +use super::*; +use crate::traits::tokens::{ + fungibles, DepositConsequence, Fortitude, Imbalance as ImbalanceT, Precision, Preservation, + Provenance, Restriction, WithdrawConsequence, +}; + +/// Convert a `fungibles` trait implementation into a `fungible` trait implementation by identifying +/// a single item. +pub struct ItemOf< + F: fungibles::Inspect, + A: Get<>::AssetId>, + AccountId, +>(sp_std::marker::PhantomData<(F, A, AccountId)>); + +impl< + F: fungibles::Inspect, + A: Get<>::AssetId>, + AccountId, + > Inspect for ItemOf +{ + type Balance = >::Balance; + fn total_issuance() -> Self::Balance { + >::total_issuance(A::get()) + } + fn active_issuance() -> Self::Balance { + >::active_issuance(A::get()) + } + fn minimum_balance() -> Self::Balance { + >::minimum_balance(A::get()) + } + fn balance(who: &AccountId) -> Self::Balance { + >::balance(A::get(), who) + } + fn total_balance(who: &AccountId) -> Self::Balance { + >::total_balance(A::get(), who) + } + fn reducible_balance( + who: &AccountId, + preservation: Preservation, + force: Fortitude, + ) -> Self::Balance { + >::reducible_balance(A::get(), who, preservation, force) + } + fn can_deposit( + who: &AccountId, + amount: Self::Balance, + provenance: Provenance, + ) -> DepositConsequence { + >::can_deposit(A::get(), who, amount, provenance) + } + fn can_withdraw(who: &AccountId, amount: Self::Balance) -> WithdrawConsequence { + >::can_withdraw(A::get(), who, amount) + } +} + +impl< + F: fungibles::InspectHold, + A: Get<>::AssetId>, + AccountId, + > InspectHold for ItemOf +{ + type Reason = F::Reason; + + fn reducible_total_balance_on_hold(who: &AccountId, force: Fortitude) -> Self::Balance { + >::reducible_total_balance_on_hold( + A::get(), + who, + force, + ) + } + fn hold_available(reason: &Self::Reason, who: &AccountId) -> bool { + >::hold_available(A::get(), reason, who) + } + fn total_balance_on_hold(who: &AccountId) -> Self::Balance { + >::total_balance_on_hold(A::get(), who) + } + fn balance_on_hold(reason: &Self::Reason, who: &AccountId) -> Self::Balance { + >::balance_on_hold(A::get(), reason, who) + } + fn can_hold(reason: &Self::Reason, who: &AccountId, amount: Self::Balance) -> bool { + >::can_hold(A::get(), reason, who, amount) + } +} + +impl< + F: fungibles::InspectFreeze, + A: Get<>::AssetId>, + AccountId, + > InspectFreeze for ItemOf +{ + type Id = F::Id; + fn balance_frozen(id: &Self::Id, who: &AccountId) -> Self::Balance { + >::balance_frozen(A::get(), id, who) + } + fn balance_freezable(who: &AccountId) -> Self::Balance { + >::balance_freezable(A::get(), who) + } + fn can_freeze(id: &Self::Id, who: &AccountId) -> bool { + >::can_freeze(A::get(), id, who) + } +} + +impl< + F: fungibles::Unbalanced, + A: Get<>::AssetId>, + AccountId, + > Unbalanced for ItemOf +{ + fn handle_dust(dust: regular::Dust) + where + Self: Sized, + { + >::handle_dust(fungibles::Dust(A::get(), dust.0)) + } + fn write_balance( + who: &AccountId, + amount: Self::Balance, + ) -> Result, DispatchError> { + >::write_balance(A::get(), who, amount) + } + fn set_total_issuance(amount: Self::Balance) -> () { + >::set_total_issuance(A::get(), amount) + } + fn decrease_balance( + who: &AccountId, + amount: Self::Balance, + precision: Precision, + preservation: Preservation, + force: Fortitude, + ) -> Result { + >::decrease_balance( + A::get(), + who, + amount, + precision, + preservation, + force, + ) + } + fn increase_balance( + who: &AccountId, + amount: Self::Balance, + precision: Precision, + ) -> Result { + >::increase_balance(A::get(), who, amount, precision) + } +} + +impl< + F: fungibles::UnbalancedHold, + A: Get<>::AssetId>, + AccountId, + > UnbalancedHold for ItemOf +{ + fn set_balance_on_hold( + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + ) -> DispatchResult { + >::set_balance_on_hold( + A::get(), + reason, + who, + amount, + ) + } + fn decrease_balance_on_hold( + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + precision: Precision, + ) -> Result { + >::decrease_balance_on_hold( + A::get(), + reason, + who, + amount, + precision, + ) + } + fn increase_balance_on_hold( + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + precision: Precision, + ) -> Result { + >::increase_balance_on_hold( + A::get(), + reason, + who, + amount, + precision, + ) + } +} + +impl< + F: fungibles::Mutate, + A: Get<>::AssetId>, + AccountId, + > Mutate for ItemOf +{ + fn mint_into(who: &AccountId, amount: Self::Balance) -> Result { + >::mint_into(A::get(), who, amount) + } + fn burn_from( + who: &AccountId, + amount: Self::Balance, + precision: Precision, + force: Fortitude, + ) -> Result { + >::burn_from(A::get(), who, amount, precision, force) + } + fn shelve(who: &AccountId, amount: Self::Balance) -> Result { + >::shelve(A::get(), who, amount) + } + fn restore(who: &AccountId, amount: Self::Balance) -> Result { + >::restore(A::get(), who, amount) + } + fn transfer( + source: &AccountId, + dest: &AccountId, + amount: Self::Balance, + preservation: Preservation, + ) -> Result { + >::transfer(A::get(), source, dest, amount, preservation) + } + + fn set_balance(who: &AccountId, amount: Self::Balance) -> Self::Balance { + >::set_balance(A::get(), who, amount) + } +} + +impl< + F: fungibles::MutateHold, + A: Get<>::AssetId>, + AccountId, + > MutateHold for ItemOf +{ + fn hold(reason: &Self::Reason, who: &AccountId, amount: Self::Balance) -> DispatchResult { + >::hold(A::get(), reason, who, amount) + } + fn release( + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + precision: Precision, + ) -> Result { + >::release(A::get(), reason, who, amount, precision) + } + fn burn_held( + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + precision: Precision, + force: Fortitude, + ) -> Result { + >::burn_held( + A::get(), + reason, + who, + amount, + precision, + force, + ) + } + fn transfer_on_hold( + reason: &Self::Reason, + source: &AccountId, + dest: &AccountId, + amount: Self::Balance, + precision: Precision, + mode: Restriction, + force: Fortitude, + ) -> Result { + >::transfer_on_hold( + A::get(), + reason, + source, + dest, + amount, + precision, + mode, + force, + ) + } + fn transfer_and_hold( + reason: &Self::Reason, + source: &AccountId, + dest: &AccountId, + amount: Self::Balance, + precision: Precision, + preservation: Preservation, + force: Fortitude, + ) -> Result { + >::transfer_and_hold( + A::get(), + reason, + source, + dest, + amount, + precision, + preservation, + force, + ) + } +} + +impl< + F: fungibles::MutateFreeze, + A: Get<>::AssetId>, + AccountId, + > MutateFreeze for ItemOf +{ + fn set_freeze(id: &Self::Id, who: &AccountId, amount: Self::Balance) -> DispatchResult { + >::set_freeze(A::get(), id, who, amount) + } + fn extend_freeze(id: &Self::Id, who: &AccountId, amount: Self::Balance) -> DispatchResult { + >::extend_freeze(A::get(), id, who, amount) + } + fn thaw(id: &Self::Id, who: &AccountId) -> DispatchResult { + >::thaw(A::get(), id, who) + } +} + +pub struct ConvertImbalanceDropHandler( + sp_std::marker::PhantomData<(AccountId, Balance, AssetIdType, AssetId, Handler)>, +); + +impl< + AccountId, + Balance, + AssetIdType, + AssetId: Get, + Handler: crate::traits::tokens::fungibles::HandleImbalanceDrop, + > HandleImbalanceDrop + for ConvertImbalanceDropHandler +{ + fn handle(amount: Balance) { + Handler::handle(AssetId::get(), amount) + } +} + +impl< + F: fungibles::Inspect + + fungibles::Unbalanced + + fungibles::Balanced, + A: Get<>::AssetId>, + AccountId, + > Balanced for ItemOf +{ + type OnDropDebt = + ConvertImbalanceDropHandler; + type OnDropCredit = + ConvertImbalanceDropHandler; + fn deposit( + who: &AccountId, + value: Self::Balance, + precision: Precision, + ) -> Result, DispatchError> { + >::deposit(A::get(), who, value, precision) + .map(|debt| Imbalance::new(debt.peek())) + } + fn issue(amount: Self::Balance) -> Credit { + Imbalance::new(>::issue(A::get(), amount).peek()) + } + fn pair(amount: Self::Balance) -> (Debt, Credit) { + let (a, b) = >::pair(A::get(), amount); + (Imbalance::new(a.peek()), Imbalance::new(b.peek())) + } + fn rescind(amount: Self::Balance) -> Debt { + Imbalance::new(>::rescind(A::get(), amount).peek()) + } + fn resolve( + who: &AccountId, + credit: Credit, + ) -> Result<(), Credit> { + let credit = fungibles::Imbalance::new(A::get(), credit.peek()); + >::resolve(who, credit) + .map_err(|credit| Imbalance::new(credit.peek())) + } + fn settle( + who: &AccountId, + debt: Debt, + preservation: Preservation, + ) -> Result, Debt> { + let debt = fungibles::Imbalance::new(A::get(), debt.peek()); + >::settle(who, debt, preservation) + .map(|credit| Imbalance::new(credit.peek())) + .map_err(|debt| Imbalance::new(debt.peek())) + } + fn withdraw( + who: &AccountId, + value: Self::Balance, + precision: Precision, + preservation: Preservation, + force: Fortitude, + ) -> Result, DispatchError> { + >::withdraw( + A::get(), + who, + value, + precision, + preservation, + force, + ) + .map(|credit| Imbalance::new(credit.peek())) + } +} + +impl< + F: fungibles::BalancedHold, + A: Get<>::AssetId>, + AccountId, + > BalancedHold for ItemOf +{ + fn slash( + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + ) -> (Credit, Self::Balance) { + let (credit, amount) = + >::slash(A::get(), reason, who, amount); + (Imbalance::new(credit.peek()), amount) + } +} + +#[test] +fn test() {} diff --git a/frame/support/src/traits/tokens/fungible/mod.rs b/frame/support/src/traits/tokens/fungible/mod.rs new file mode 100644 index 0000000000000..204b85ac29448 --- /dev/null +++ b/frame/support/src/traits/tokens/fungible/mod.rs @@ -0,0 +1,56 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 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. + +//! The traits for dealing with a single fungible token class and any associated types. +//! +//! ### User-implememted traits +//! - `Inspect`: Regular balance inspector functions. +//! - `Unbalanced`: Low-level balance mutating functions. Does not guarantee proper book-keeping and +//! so should not be called into directly from application code. Other traits depend on this and +//! provide default implementations based on it. +//! - `UnbalancedHold`: Low-level balance mutating functions for balances placed on hold. Does not +//! guarantee proper book-keeping and so should not be called into directly from application code. +//! Other traits depend on this and provide default implementations based on it. +//! - `Mutate`: Regular balance mutator functions. Pre-implemented using `Unbalanced`, though the +//! `done_*` functions should likely be reimplemented in case you want to do something following +//! the operation such as emit events. +//! - `InspectHold`: Inspector functions for balances on hold. +//! - `MutateHold`: Mutator functions for balances on hold. Mostly pre-implemented using +//! `UnbalancedHold`. +//! - `InspectFreeze`: Inspector functions for frozen balance. +//! - `MutateFreeze`: Mutator functions for frozen balance. +//! - `Balanced`: One-sided mutator functions for regular balances, which return imbalance objects +//! which guarantee eventual book-keeping. May be useful for some sophisticated operations where +//! funds must be removed from an account before it is known precisely what should be done with +//! them. + +pub mod freeze; +pub mod hold; +mod imbalance; +mod item_of; +mod regular; + +pub use freeze::{Inspect as InspectFreeze, Mutate as MutateFreeze}; +pub use hold::{ + Balanced as BalancedHold, Inspect as InspectHold, Mutate as MutateHold, + Unbalanced as UnbalancedHold, +}; +pub use imbalance::{Credit, Debt, HandleImbalanceDrop, Imbalance}; +pub use item_of::ItemOf; +pub use regular::{ + Balanced, DecreaseIssuance, Dust, IncreaseIssuance, Inspect, Mutate, Unbalanced, +}; diff --git a/frame/support/src/traits/tokens/fungible/regular.rs b/frame/support/src/traits/tokens/fungible/regular.rs new file mode 100644 index 0000000000000..574392cac8256 --- /dev/null +++ b/frame/support/src/traits/tokens/fungible/regular.rs @@ -0,0 +1,506 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 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. + +//! `Inspect` and `Mutate` traits for working with regular balances. + +use crate::{ + dispatch::DispatchError, + ensure, + traits::{ + tokens::{ + misc::{ + Balance, DepositConsequence, + Fortitude::{self, Force, Polite}, + Precision::{self, BestEffort, Exact}, + Preservation::{self, Expendable}, + Provenance::{self, Extant}, + WithdrawConsequence, + }, + Imbalance as ImbalanceT, + }, + SameOrOther, TryDrop, + }, +}; +use sp_arithmetic::traits::{CheckedAdd, CheckedSub, One}; +use sp_runtime::{traits::Saturating, ArithmeticError, TokenError}; +use sp_std::marker::PhantomData; + +use super::{Credit, Debt, HandleImbalanceDrop, Imbalance}; + +/// Trait for providing balance-inspection access to a fungible asset. +pub trait Inspect: Sized { + /// Scalar type for representing balance of an account. + type Balance: Balance; + + /// The total amount of issuance in the system. + fn total_issuance() -> Self::Balance; + + /// The total amount of issuance in the system excluding those which are controlled by the + /// system. + fn active_issuance() -> Self::Balance { + Self::total_issuance() + } + + /// The minimum balance any single account may have. + fn minimum_balance() -> Self::Balance; + + /// Get the total amount of funds whose ultimate bneficial ownership can be determined as `who`. + /// + /// This may include funds which are wholly inaccessible to `who`, either temporarily or even + /// indefinitely. + /// + /// For the amount of the balance which is currently free to be removed from the account without + /// error, use `reducible_balance`. + /// + /// For the amount of the balance which may eventually be free to be removed from the account, + /// use `balance()`. + fn total_balance(who: &AccountId) -> Self::Balance; + + /// Get the balance of `who` which does not include funds which are exclusively allocated to + /// subsystems of the chain ("on hold" or "reserved"). + /// + /// In general this isn't especially useful outside of tests, and for practical purposes, you'll + /// want to use `reducible_balance()`. + fn balance(who: &AccountId) -> Self::Balance; + + /// Get the maximum amount that `who` can withdraw/transfer successfully based on whether the + /// account should be kept alive (`preservation`) or whether we are willing to force the + /// reduction and potentially go below user-level restrictions on the minimum amount of the + /// account. + /// + /// Always less than or equal to `balance()`. + fn reducible_balance( + who: &AccountId, + preservation: Preservation, + force: Fortitude, + ) -> Self::Balance; + + /// Returns `true` if the balance of `who` may be increased by `amount`. + /// + /// - `who`: The account of which the balance should be increased by `amount`. + /// - `amount`: How much should the balance be increased? + /// - `provenance`: Will `amount` be minted to deposit it into `account` or is it already in the + /// system? + fn can_deposit( + who: &AccountId, + amount: Self::Balance, + provenance: Provenance, + ) -> DepositConsequence; + + /// Returns `Success` if the balance of `who` may be decreased by `amount`, otherwise + /// the consequence. + fn can_withdraw(who: &AccountId, amount: Self::Balance) -> WithdrawConsequence; +} + +/// Special dust type which can be type-safely converted into a `Credit`. +#[must_use] +pub struct Dust>(pub(crate) T::Balance); + +impl> Dust { + /// Convert `Dust` into an instance of `Credit`. + pub fn into_credit(self) -> Credit { + Credit::::new(self.0) + } +} + +/// A fungible token class where the balance can be set arbitrarily. +/// +/// **WARNING** +/// Do not use this directly unless you want trouble, since it allows you to alter account balances +/// without keeping the issuance up to date. It has no safeguards against accidentally creating +/// token imbalances in your system leading to accidental imflation or deflation. It's really just +/// for the underlying datatype to implement so the user gets the much safer `Balanced` trait to +/// use. +pub trait Unbalanced: Inspect { + /// Create some dust and handle it with `Self::handle_dust`. This is an unbalanced operation + /// and it must only be used when an account is modified in a raw fashion, outside of the entire + /// fungibles API. The `amount` is capped at `Self::minimum_balance() - 1`. + /// + /// This should not be reimplemented. + fn handle_raw_dust(amount: Self::Balance) { + Self::handle_dust(Dust(amount.min(Self::minimum_balance().saturating_sub(One::one())))) + } + + /// Do something with the dust which has been destroyed from the system. `Dust` can be converted + /// into a `Credit` with the `Balanced` trait impl. + fn handle_dust(dust: Dust); + + /// Forcefully set the balance of `who` to `amount`. + /// + /// If this call executes successfully, you can `assert_eq!(Self::balance(), amount);`. + /// + /// For implementations which include one or more balances on hold, then these are *not* + /// included in the `amount`. + /// + /// This function does its best to force the balance change through, but will not break system + /// invariants such as any Existential Deposits needed or overflows/underflows. + /// If this cannot be done for some reason (e.g. because the account cannot be created, deleted + /// or would overflow) then an `Err` is returned. + /// + /// If `Ok` is returned then its inner, if `Some` is the amount which was discarded as dust due + /// to existential deposit requirements. The default implementation of `decrease_balance` and + /// `increase_balance` converts this into an `Imbalance` and then passes it into `handle_dust`. + fn write_balance( + who: &AccountId, + amount: Self::Balance, + ) -> Result, DispatchError>; + + /// Set the total issuance to `amount`. + fn set_total_issuance(amount: Self::Balance); + + /// Reduce the balance of `who` by `amount`. + /// + /// If `precision` is `Exact` and it cannot be reduced by that amount for + /// some reason, return `Err` and don't reduce it at all. If `precision` is `BestEffort`, then + /// reduce the balance of `who` by the most that is possible, up to `amount`. + /// + /// In either case, if `Ok` is returned then the inner is the amount by which is was reduced. + /// Minimum balance will be respected and thus the returned amount may be up to + /// `Self::minimum_balance() - 1` greater than `amount` in the case that the reduction caused + /// the account to be deleted. + fn decrease_balance( + who: &AccountId, + mut amount: Self::Balance, + precision: Precision, + preservation: Preservation, + force: Fortitude, + ) -> Result { + let old_balance = Self::balance(who); + let free = Self::reducible_balance(who, preservation, force); + if let BestEffort = precision { + amount = amount.min(free); + } + let new_balance = old_balance.checked_sub(&amount).ok_or(TokenError::FundsUnavailable)?; + if let Some(dust) = Self::write_balance(who, new_balance)? { + Self::handle_dust(Dust(dust)); + } + Ok(old_balance.saturating_sub(new_balance)) + } + + /// Increase the balance of `who` by `amount`. + /// + /// If it cannot be increased by that amount for some reason, return `Err` and don't increase + /// it at all. If Ok, return the imbalance. + /// Minimum balance will be respected and an error will be returned if + /// `amount < Self::minimum_balance()` when the account of `who` is zero. + fn increase_balance( + who: &AccountId, + amount: Self::Balance, + precision: Precision, + ) -> Result { + let old_balance = Self::balance(who); + let new_balance = if let BestEffort = precision { + old_balance.saturating_add(amount) + } else { + old_balance.checked_add(&amount).ok_or(ArithmeticError::Overflow)? + }; + if new_balance < Self::minimum_balance() { + // Attempt to increase from 0 to below minimum -> stays at zero. + if let BestEffort = precision { + Ok(Default::default()) + } else { + Err(TokenError::BelowMinimum.into()) + } + } else { + if new_balance == old_balance { + Ok(Default::default()) + } else { + if let Some(dust) = Self::write_balance(who, new_balance)? { + Self::handle_dust(Dust(dust)); + } + Ok(new_balance.saturating_sub(old_balance)) + } + } + } + + /// Reduce the active issuance by some amount. + fn deactivate(_: Self::Balance) {} + + /// Increase the active issuance by some amount, up to the outstanding amount reduced. + fn reactivate(_: Self::Balance) {} +} + +/// Trait for providing a basic fungible asset. +pub trait Mutate: Inspect + Unbalanced { + /// Increase the balance of `who` by exactly `amount`, minting new tokens. If that isn't + /// possible then an `Err` is returned and nothing is changed. + fn mint_into(who: &AccountId, amount: Self::Balance) -> Result { + Self::total_issuance().checked_add(&amount).ok_or(ArithmeticError::Overflow)?; + let actual = Self::increase_balance(who, amount, Exact)?; + Self::set_total_issuance(Self::total_issuance().saturating_add(actual)); + Self::done_mint_into(who, amount); + Ok(actual) + } + + /// Decrease the balance of `who` by at least `amount`, possibly slightly more in the case of + /// minimum-balance requirements, burning the tokens. If that isn't possible then an `Err` is + /// returned and nothing is changed. If successful, the amount of tokens reduced is returned. + fn burn_from( + who: &AccountId, + amount: Self::Balance, + precision: Precision, + force: Fortitude, + ) -> Result { + let actual = Self::reducible_balance(who, Expendable, force).min(amount); + ensure!(actual == amount || precision == BestEffort, TokenError::FundsUnavailable); + Self::total_issuance().checked_sub(&actual).ok_or(ArithmeticError::Overflow)?; + let actual = Self::decrease_balance(who, actual, BestEffort, Expendable, force)?; + Self::set_total_issuance(Self::total_issuance().saturating_sub(actual)); + Self::done_burn_from(who, actual); + Ok(actual) + } + + /// Attempt to decrease the `asset` balance of `who` by `amount`. + /// + /// Equivalent to `burn_from`, except with an expectation that within the bounds of some + /// universal issuance, the total assets `suspend`ed and `resume`d will be equivalent. The + /// implementation may be configured such that the total assets suspended may never be less than + /// the total assets resumed (which is the invariant for an issuing system), or the reverse + /// (which the invariant in a non-issuing system). + /// + /// Because of this expectation, any metadata associated with the asset is expected to survive + /// the suspect-resume cycle. + fn shelve(who: &AccountId, amount: Self::Balance) -> Result { + let actual = Self::reducible_balance(who, Expendable, Polite).min(amount); + ensure!(actual == amount, TokenError::FundsUnavailable); + Self::total_issuance().checked_sub(&actual).ok_or(ArithmeticError::Overflow)?; + let actual = Self::decrease_balance(who, actual, BestEffort, Expendable, Polite)?; + Self::set_total_issuance(Self::total_issuance().saturating_sub(actual)); + Self::done_shelve(who, actual); + Ok(actual) + } + + /// Attempt to increase the `asset` balance of `who` by `amount`. + /// + /// Equivalent to `mint_into`, except with an expectation that within the bounds of some + /// universal issuance, the total assets `suspend`ed and `resume`d will be equivalent. The + /// implementation may be configured such that the total assets suspended may never be less than + /// the total assets resumed (which is the invariant for an issuing system), or the reverse + /// (which the invariant in a non-issuing system). + /// + /// Because of this expectation, any metadata associated with the asset is expected to survive + /// the suspect-resume cycle. + fn restore(who: &AccountId, amount: Self::Balance) -> Result { + Self::total_issuance().checked_add(&amount).ok_or(ArithmeticError::Overflow)?; + let actual = Self::increase_balance(who, amount, Exact)?; + Self::set_total_issuance(Self::total_issuance().saturating_add(actual)); + Self::done_restore(who, amount); + Ok(actual) + } + + /// Transfer funds from one account into another. + fn transfer( + source: &AccountId, + dest: &AccountId, + amount: Self::Balance, + preservation: Preservation, + ) -> Result { + let _extra = Self::can_withdraw(source, amount).into_result(preservation != Expendable)?; + Self::can_deposit(dest, amount, Extant).into_result()?; + Self::decrease_balance(source, amount, BestEffort, preservation, Polite)?; + // This should never fail as we checked `can_deposit` earlier. But we do a best-effort + // anyway. + let _ = Self::increase_balance(dest, amount, BestEffort); + Self::done_transfer(source, dest, amount); + Ok(amount) + } + + /// Simple infallible function to force an account to have a particular balance, good for use + /// in tests and benchmarks but not recommended for production code owing to the lack of + /// error reporting. + /// + /// Returns the new balance. + fn set_balance(who: &AccountId, amount: Self::Balance) -> Self::Balance { + let b = Self::balance(who); + if b > amount { + Self::burn_from(who, b - amount, BestEffort, Force).map(|d| amount.saturating_sub(d)) + } else { + Self::mint_into(who, amount - b).map(|d| amount.saturating_add(d)) + } + .unwrap_or(b) + } + + fn done_mint_into(_who: &AccountId, _amount: Self::Balance) {} + fn done_burn_from(_who: &AccountId, _amount: Self::Balance) {} + fn done_shelve(_who: &AccountId, _amount: Self::Balance) {} + fn done_restore(_who: &AccountId, _amount: Self::Balance) {} + fn done_transfer(_source: &AccountId, _dest: &AccountId, _amount: Self::Balance) {} +} + +/// Simple handler for an imbalance drop which increases the total issuance of the system by the +/// imbalance amount. Used for leftover debt. +pub struct IncreaseIssuance(PhantomData<(AccountId, U)>); +impl> HandleImbalanceDrop + for IncreaseIssuance +{ + fn handle(amount: U::Balance) { + U::set_total_issuance(U::total_issuance().saturating_add(amount)) + } +} + +/// Simple handler for an imbalance drop which decreases the total issuance of the system by the +/// imbalance amount. Used for leftover credit. +pub struct DecreaseIssuance(PhantomData<(AccountId, U)>); +impl> HandleImbalanceDrop + for DecreaseIssuance +{ + fn handle(amount: U::Balance) { + U::set_total_issuance(U::total_issuance().saturating_sub(amount)) + } +} + +/// A fungible token class where any creation and deletion of tokens is semi-explicit and where the +/// total supply is maintained automatically. +/// +/// This is auto-implemented when a token class has `Unbalanced` implemented. +pub trait Balanced: Inspect + Unbalanced { + /// The type for managing what happens when an instance of `Debt` is dropped without being used. + type OnDropDebt: HandleImbalanceDrop; + /// The type for managing what happens when an instance of `Credit` is dropped without being + /// used. + type OnDropCredit: HandleImbalanceDrop; + + /// Reduce the total issuance by `amount` and return the according imbalance. The imbalance will + /// typically be used to reduce an account by the same amount with e.g. `settle`. + /// + /// This is infallible, but doesn't guarantee that the entire `amount` is burnt, for example + /// in the case of underflow. + fn rescind(amount: Self::Balance) -> Debt { + let old = Self::total_issuance(); + let new = old.saturating_sub(amount); + Self::set_total_issuance(new); + let delta = old - new; + Self::done_rescind(delta); + Imbalance::::new(delta) + } + + /// Increase the total issuance by `amount` and return the according imbalance. The imbalance + /// will typically be used to increase an account by the same amount with e.g. + /// `resolve_into_existing` or `resolve_creating`. + /// + /// This is infallible, but doesn't guarantee that the entire `amount` is issued, for example + /// in the case of overflow. + fn issue(amount: Self::Balance) -> Credit { + let old = Self::total_issuance(); + let new = old.saturating_add(amount); + Self::set_total_issuance(new); + let delta = new - old; + Self::done_issue(delta); + Imbalance::::new(delta) + } + + /// Produce a pair of imbalances that cancel each other out exactly. + /// + /// This is just the same as burning and issuing the same amount and has no effect on the + /// total issuance. + fn pair(amount: Self::Balance) -> (Debt, Credit) { + (Self::rescind(amount), Self::issue(amount)) + } + + /// Mints `value` into the account of `who`, creating it as needed. + /// + /// If `precision` is `BestEffort` and `value` in full could not be minted (e.g. due to + /// overflow), then the maximum is minted, up to `value`. If `precision` is `Exact`, then + /// exactly `value` must be minted into the account of `who` or the operation will fail with an + /// `Err` and nothing will change. + /// + /// If the operation is successful, this will return `Ok` with a `Debt` of the total value + /// added to the account. + fn deposit( + who: &AccountId, + value: Self::Balance, + precision: Precision, + ) -> Result, DispatchError> { + let increase = Self::increase_balance(who, value, precision)?; + Self::done_deposit(who, increase); + Ok(Imbalance::::new(increase)) + } + + /// Removes `value` balance from `who` account if possible. + /// + /// If `precision` is `BestEffort` and `value` in full could not be removed (e.g. due to + /// underflow), then the maximum is removed, up to `value`. If `precision` is `Exact`, then + /// exactly `value` must be removed from the account of `who` or the operation will fail with an + /// `Err` and nothing will change. + /// + /// If the removal is needed but not possible, then it returns `Err` and nothing is changed. + /// If the account needed to be deleted, then slightly more than `value` may be removed from the + /// account owning since up to (but not including) minimum balance may also need to be removed. + /// + /// If the operation is successful, this will return `Ok` with a `Credit` of the total value + /// removed from the account. + fn withdraw( + who: &AccountId, + value: Self::Balance, + precision: Precision, + preservation: Preservation, + force: Fortitude, + ) -> Result, DispatchError> { + let decrease = Self::decrease_balance(who, value, precision, preservation, force)?; + Self::done_withdraw(who, decrease); + Ok(Imbalance::::new(decrease)) + } + + /// The balance of `who` is increased in order to counter `credit`. If the whole of `credit` + /// cannot be countered, then nothing is changed and the original `credit` is returned in an + /// `Err`. + /// + /// Please note: If `credit.peek()` is less than `Self::minimum_balance()`, then `who` must + /// already exist for this to succeed. + fn resolve( + who: &AccountId, + credit: Credit, + ) -> Result<(), Credit> { + let v = credit.peek(); + let debt = match Self::deposit(who, v, Exact) { + Err(_) => return Err(credit), + Ok(d) => d, + }; + let result = credit.offset(debt).try_drop(); + debug_assert!(result.is_ok(), "ok deposit return must be equal to credit value; qed"); + Ok(()) + } + + /// The balance of `who` is decreased in order to counter `debt`. If the whole of `debt` + /// cannot be countered, then nothing is changed and the original `debt` is returned in an + /// `Err`. + fn settle( + who: &AccountId, + debt: Debt, + preservation: Preservation, + ) -> Result, Debt> { + let amount = debt.peek(); + let credit = match Self::withdraw(who, amount, Exact, preservation, Polite) { + Err(_) => return Err(debt), + Ok(d) => d, + }; + + match credit.offset(debt) { + SameOrOther::None => Ok(Credit::::zero()), + SameOrOther::Same(dust) => Ok(dust), + SameOrOther::Other(rest) => { + debug_assert!(false, "ok withdraw return must be at least debt value; qed"); + Err(rest) + }, + } + } + + fn done_rescind(_amount: Self::Balance) {} + fn done_issue(_amount: Self::Balance) {} + fn done_deposit(_who: &AccountId, _amount: Self::Balance) {} + fn done_withdraw(_who: &AccountId, _amount: Self::Balance) {} +} diff --git a/frame/support/src/traits/tokens/fungibles.rs b/frame/support/src/traits/tokens/fungibles.rs deleted file mode 100644 index d146832f3b649..0000000000000 --- a/frame/support/src/traits/tokens/fungibles.rs +++ /dev/null @@ -1,332 +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. - -//! The traits for sets of fungible tokens and any associated types. - -use super::{ - misc::{AssetId, Balance}, - *, -}; -use crate::dispatch::{DispatchError, DispatchResult}; -use sp_runtime::traits::Saturating; -use sp_std::vec::Vec; - -pub mod approvals; -mod balanced; -pub mod enumerable; -pub use enumerable::InspectEnumerable; -pub mod metadata; -pub use balanced::{Balanced, Unbalanced}; -mod imbalance; -pub use imbalance::{CreditOf, DebtOf, HandleImbalanceDrop, Imbalance}; -pub mod roles; - -/// Trait for providing balance-inspection access to a set of named fungible assets. -pub trait Inspect { - /// Means of identifying one asset class from another. - type AssetId: AssetId; - - /// Scalar type for representing balance of an account. - type Balance: Balance; - - /// The total amount of issuance in the system. - fn total_issuance(asset: Self::AssetId) -> Self::Balance; - - /// The total amount of issuance in the system excluding those which are controlled by the - /// system. - fn active_issuance(asset: Self::AssetId) -> Self::Balance { - Self::total_issuance(asset) - } - - /// The minimum balance any single account may have. - fn minimum_balance(asset: Self::AssetId) -> Self::Balance; - - /// Get the `asset` balance of `who`. - fn balance(asset: Self::AssetId, who: &AccountId) -> Self::Balance; - - /// Get the maximum amount of `asset` that `who` can withdraw/transfer successfully. - fn reducible_balance(asset: Self::AssetId, who: &AccountId, keep_alive: bool) -> Self::Balance; - - /// Returns `true` if the `asset` balance of `who` may be increased by `amount`. - /// - /// - `asset`: The asset that should be deposited. - /// - `who`: The account of which the balance should be increased by `amount`. - /// - `amount`: How much should the balance be increased? - /// - `mint`: Will `amount` be minted to deposit it into `account`? - fn can_deposit( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - mint: bool, - ) -> DepositConsequence; - - /// Returns `Failed` if the `asset` balance of `who` may not be decreased by `amount`, otherwise - /// the consequence. - fn can_withdraw( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - ) -> WithdrawConsequence; - - /// Returns `true` if an `asset` exists. - fn asset_exists(asset: Self::AssetId) -> bool; -} - -/// Trait for reading metadata from a fungible asset. -pub trait InspectMetadata: Inspect { - /// Return the name of an asset. - fn name(asset: &Self::AssetId) -> Vec; - - /// Return the symbol of an asset. - fn symbol(asset: &Self::AssetId) -> Vec; - - /// Return the decimals of an asset. - fn decimals(asset: &Self::AssetId) -> u8; -} - -/// Trait for providing a set of named fungible assets which can be created and destroyed. -pub trait Mutate: Inspect { - /// Attempt to increase the `asset` balance of `who` by `amount`. - /// - /// If not possible then don't do anything. Possible reasons for failure include: - /// - Minimum balance not met. - /// - Account cannot be created (e.g. because there is no provider reference and/or the asset - /// isn't considered worth anything). - /// - /// Since this is an operation which should be possible to take alone, if successful it will - /// increase the overall supply of the underlying token. - fn mint_into(asset: Self::AssetId, who: &AccountId, amount: Self::Balance) -> DispatchResult; - - /// Attempt to reduce the `asset` balance of `who` by `amount`. - /// - /// If not possible then don't do anything. Possible reasons for failure include: - /// - Less funds in the account than `amount` - /// - Liquidity requirements (locks, reservations) prevent the funds from being removed - /// - Operation would require destroying the account and it is required to stay alive (e.g. - /// because it's providing a needed provider reference). - /// - /// Since this is an operation which should be possible to take alone, if successful it will - /// reduce the overall supply of the underlying token. - /// - /// Due to minimum balance requirements, it's possible that the amount withdrawn could be up to - /// `Self::minimum_balance() - 1` more than the `amount`. The total amount withdrawn is returned - /// in an `Ok` result. This may be safely ignored if you don't mind the overall supply reducing. - fn burn_from( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - ) -> Result; - - /// Attempt to reduce the `asset` balance of `who` by as much as possible up to `amount`, and - /// possibly slightly more due to minimum_balance requirements. If no decrease is possible then - /// an `Err` is returned and nothing is changed. If successful, the amount of tokens reduced is - /// returned. - /// - /// The default implementation just uses `withdraw` along with `reducible_balance` to ensure - /// that is doesn't fail. - fn slash( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - ) -> Result { - Self::burn_from(asset, who, Self::reducible_balance(asset, who, false).min(amount)) - } - - /// Transfer funds from one account into another. The default implementation uses `mint_into` - /// and `burn_from` and may generate unwanted events. - fn teleport( - asset: Self::AssetId, - source: &AccountId, - dest: &AccountId, - amount: Self::Balance, - ) -> Result { - let extra = Self::can_withdraw(asset, &source, amount).into_result()?; - // As we first burn and then mint, we don't need to check if `mint` fits into the supply. - // If we can withdraw/burn it, we can also mint it again. - Self::can_deposit(asset, dest, amount.saturating_add(extra), false).into_result()?; - let actual = Self::burn_from(asset, source, amount)?; - debug_assert!( - actual == amount.saturating_add(extra), - "can_withdraw must agree with withdraw; qed" - ); - match Self::mint_into(asset, dest, actual) { - Ok(_) => Ok(actual), - Err(err) => { - debug_assert!(false, "can_deposit returned true previously; qed"); - // attempt to return the funds back to source - let revert = Self::mint_into(asset, source, actual); - debug_assert!(revert.is_ok(), "withdrew funds previously; qed"); - Err(err) - }, - } - } -} - -/// Trait for providing a set of named fungible assets which can only be transferred. -pub trait Transfer: Inspect { - /// Transfer funds from one account into another. - fn transfer( - asset: Self::AssetId, - source: &AccountId, - dest: &AccountId, - amount: Self::Balance, - keep_alive: bool, - ) -> Result; - - /// Reduce the active issuance by some amount. - fn deactivate(_: Self::AssetId, _: Self::Balance) {} - - /// Increase the active issuance by some amount, up to the outstanding amount reduced. - fn reactivate(_: Self::AssetId, _: Self::Balance) {} -} - -/// Trait for inspecting a set of named fungible assets which can be placed on hold. -pub trait InspectHold: Inspect { - /// Amount of funds held in hold. - fn balance_on_hold(asset: Self::AssetId, who: &AccountId) -> Self::Balance; - - /// Check to see if some `amount` of `asset` may be held on the account of `who`. - fn can_hold(asset: Self::AssetId, who: &AccountId, amount: Self::Balance) -> bool; -} - -/// Trait for mutating a set of named fungible assets which can be placed on hold. -pub trait MutateHold: InspectHold + Transfer { - /// Hold some funds in an account. - fn hold(asset: Self::AssetId, who: &AccountId, amount: Self::Balance) -> DispatchResult; - - /// Release some funds in an account from being on hold. - /// - /// If `best_effort` is `true`, then the amount actually released and returned as the inner - /// value of `Ok` may be smaller than the `amount` passed. - fn release( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - best_effort: bool, - ) -> Result; - - /// Transfer held funds into a destination account. - /// - /// If `on_hold` is `true`, then the destination account must already exist and the assets - /// transferred will still be on hold in the destination account. If not, then the destination - /// account need not already exist, but must be creatable. - /// - /// If `best_effort` is `true`, then an amount less than `amount` may be transferred without - /// error. - /// - /// The actual amount transferred is returned, or `Err` in the case of error and nothing is - /// changed. - fn transfer_held( - asset: Self::AssetId, - source: &AccountId, - dest: &AccountId, - amount: Self::Balance, - best_effort: bool, - on_hold: bool, - ) -> Result; -} - -/// Trait for mutating one of several types of fungible assets which can be held. -pub trait BalancedHold: Balanced + MutateHold { - /// Release and slash some funds in an account. - /// - /// The resulting imbalance is the first item of the tuple returned. - /// - /// As much funds up to `amount` will be deducted as possible. If this is less than `amount`, - /// then a non-zero second item will be returned. - fn slash_held( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - ) -> (CreditOf, Self::Balance); -} - -impl + MutateHold> BalancedHold for T { - fn slash_held( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - ) -> (CreditOf, Self::Balance) { - let actual = match Self::release(asset, who, amount, true) { - Ok(x) => x, - Err(_) => return (Imbalance::zero(asset), amount), - }; - >::slash(asset, who, actual) - } -} - -/// Trait for providing the ability to create new fungible assets. -pub trait Create: Inspect { - /// Create a new fungible asset. - fn create( - id: Self::AssetId, - admin: AccountId, - is_sufficient: bool, - min_balance: Self::Balance, - ) -> DispatchResult; -} - -/// Trait for providing the ability to destroy existing fungible assets. -pub trait Destroy: Inspect { - /// Start the destruction an existing fungible asset. - /// * `id`: The `AssetId` to be destroyed. successfully. - /// * `maybe_check_owner`: An optional account id that can be used to authorize the destroy - /// command. If not provided, no authorization checks will be performed before destroying - /// asset. - fn start_destroy(id: Self::AssetId, maybe_check_owner: Option) -> DispatchResult; - - /// Destroy all accounts associated with a given asset. - /// `destroy_accounts` should only be called after `start_destroy` has been called, and the - /// asset is in a `Destroying` state - /// - /// * `id`: The identifier of the asset to be destroyed. This must identify an existing asset. - /// * `max_items`: The maximum number of accounts to be destroyed for a given call of the - /// function. This value should be small enough to allow the operation fit into a logical - /// block. - /// - /// Response: - /// * u32: Total number of approvals which were actually destroyed - /// - /// Due to weight restrictions, this function may need to be called multiple - /// times to fully destroy all approvals. It will destroy `max_items` approvals at a - /// time. - fn destroy_accounts(id: Self::AssetId, max_items: u32) -> Result; - /// Destroy all approvals associated with a given asset up to the `max_items` - /// `destroy_approvals` should only be called after `start_destroy` has been called, and the - /// asset is in a `Destroying` state - /// - /// * `id`: The identifier of the asset to be destroyed. This must identify an existing asset. - /// * `max_items`: The maximum number of accounts to be destroyed for a given call of the - /// function. This value should be small enough to allow the operation fit into a logical - /// block. - /// - /// Response: - /// * u32: Total number of approvals which were actually destroyed - /// - /// Due to weight restrictions, this function may need to be called multiple - /// times to fully destroy all approvals. It will destroy `max_items` approvals at a - /// time. - fn destroy_approvals(id: Self::AssetId, max_items: u32) -> Result; - - /// Complete destroying asset and unreserve currency. - /// `finish_destroy` should only be called after `start_destroy` has been called, and the - /// asset is in a `Destroying` state. All accounts or approvals should be destroyed before - /// hand. - /// - /// * `id`: The identifier of the asset to be destroyed. This must identify an existing asset. - fn finish_destroy(id: Self::AssetId) -> DispatchResult; -} diff --git a/frame/support/src/traits/tokens/fungibles/balanced.rs b/frame/support/src/traits/tokens/fungibles/balanced.rs deleted file mode 100644 index 598ba250ee806..0000000000000 --- a/frame/support/src/traits/tokens/fungibles/balanced.rs +++ /dev/null @@ -1,394 +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. - -//! The trait and associated types for sets of fungible tokens that manage total issuance without -//! requiring atomic balanced operations. - -use super::*; -use crate::{ - dispatch::{DispatchError, DispatchResult}, - traits::misc::{SameOrOther, TryDrop}, -}; -use sp_arithmetic::traits::Saturating; -use sp_runtime::{ - traits::{CheckedAdd, Zero}, - ArithmeticError, TokenError, -}; -use sp_std::marker::PhantomData; - -/// A fungible token class where any creation and deletion of tokens is semi-explicit and where the -/// total supply is maintained automatically. -/// -/// This is auto-implemented when a token class has `Unbalanced` implemented. -pub trait Balanced: Inspect { - /// The type for managing what happens when an instance of `Debt` is dropped without being used. - type OnDropDebt: HandleImbalanceDrop; - /// The type for managing what happens when an instance of `Credit` is dropped without being - /// used. - type OnDropCredit: HandleImbalanceDrop; - - /// Reduce the total issuance by `amount` and return the according imbalance. The imbalance will - /// typically be used to reduce an account by the same amount with e.g. `settle`. - /// - /// This is infallible, but doesn't guarantee that the entire `amount` is burnt, for example - /// in the case of underflow. - fn rescind(asset: Self::AssetId, amount: Self::Balance) -> DebtOf; - - /// Increase the total issuance by `amount` and return the according imbalance. The imbalance - /// will typically be used to increase an account by the same amount with e.g. - /// `resolve_into_existing` or `resolve_creating`. - /// - /// This is infallible, but doesn't guarantee that the entire `amount` is issued, for example - /// in the case of overflow. - fn issue(asset: Self::AssetId, amount: Self::Balance) -> CreditOf; - - /// Produce a pair of imbalances that cancel each other out exactly. - /// - /// This is just the same as burning and issuing the same amount and has no effect on the - /// total issuance. - fn pair( - asset: Self::AssetId, - amount: Self::Balance, - ) -> (DebtOf, CreditOf) { - (Self::rescind(asset, amount), Self::issue(asset, amount)) - } - - /// Deducts up to `value` from the combined balance of `who`, preferring to deduct from the - /// free balance. This function cannot fail. - /// - /// The resulting imbalance is the first item of the tuple returned. - /// - /// As much funds up to `value` will be deducted as possible. If this is less than `value`, - /// then a non-zero second item will be returned. - fn slash( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - ) -> (CreditOf, Self::Balance); - - /// Mints exactly `value` into the `asset` account of `who`. - /// - /// If `who` doesn't exist, nothing is done and an `Err` returned. This could happen because it - /// the account doesn't yet exist and it isn't possible to create it under the current - /// circumstances and with `value` in it. - fn deposit( - asset: Self::AssetId, - who: &AccountId, - value: Self::Balance, - ) -> Result, DispatchError>; - - /// Removes `value` free `asset` balance from `who` account if possible. - /// - /// If the removal is not possible, then it returns `Err` and nothing is changed. - /// - /// If the operation is successful, this will return `Ok` with a `NegativeImbalance` whose value - /// is no less than `value`. It may be more in the case that removing it reduced it below - /// `Self::minimum_balance()`. - fn withdraw( - asset: Self::AssetId, - who: &AccountId, - value: Self::Balance, - // TODO: liveness: ExistenceRequirement, - ) -> Result, DispatchError>; - - /// The balance of `who` is increased in order to counter `credit`. If the whole of `credit` - /// cannot be countered, then nothing is changed and the original `credit` is returned in an - /// `Err`. - /// - /// Please note: If `credit.peek()` is less than `Self::minimum_balance()`, then `who` must - /// already exist for this to succeed. - fn resolve( - who: &AccountId, - credit: CreditOf, - ) -> Result<(), CreditOf> { - let v = credit.peek(); - let debt = match Self::deposit(credit.asset(), who, v) { - Err(_) => return Err(credit), - Ok(d) => d, - }; - if let Ok(result) = credit.offset(debt) { - let result = result.try_drop(); - debug_assert!(result.is_ok(), "ok deposit return must be equal to credit value; qed"); - } else { - debug_assert!(false, "debt.asset is credit.asset; qed"); - } - Ok(()) - } - - /// The balance of `who` is decreased in order to counter `debt`. If the whole of `debt` - /// cannot be countered, then nothing is changed and the original `debt` is returned in an - /// `Err`. - fn settle( - who: &AccountId, - debt: DebtOf, - // TODO: liveness: ExistenceRequirement, - ) -> Result, DebtOf> { - let amount = debt.peek(); - let asset = debt.asset(); - let credit = match Self::withdraw(asset, who, amount) { - Err(_) => return Err(debt), - Ok(d) => d, - }; - match credit.offset(debt) { - Ok(SameOrOther::None) => Ok(CreditOf::::zero(asset)), - Ok(SameOrOther::Same(dust)) => Ok(dust), - Ok(SameOrOther::Other(rest)) => { - debug_assert!(false, "ok withdraw return must be at least debt value; qed"); - Err(rest) - }, - Err(_) => { - debug_assert!(false, "debt.asset is credit.asset; qed"); - Ok(CreditOf::::zero(asset)) - }, - } - } -} - -/// A fungible token class where the balance can be set arbitrarily. -/// -/// **WARNING** -/// Do not use this directly unless you want trouble, since it allows you to alter account balances -/// without keeping the issuance up to date. It has no safeguards against accidentally creating -/// token imbalances in your system leading to accidental inflation or deflation. It's really just -/// for the underlying datatype to implement so the user gets the much safer `Balanced` trait to -/// use. -pub trait Unbalanced: Inspect { - /// Set the `asset` balance of `who` to `amount`. If this cannot be done for some reason (e.g. - /// because the account cannot be created or an overflow) then an `Err` is returned. - fn set_balance(asset: Self::AssetId, who: &AccountId, amount: Self::Balance) -> DispatchResult; - - /// Set the total issuance of `asset` to `amount`. - fn set_total_issuance(asset: Self::AssetId, amount: Self::Balance); - - /// Reduce the `asset` balance of `who` by `amount`. If it cannot be reduced by that amount for - /// some reason, return `Err` and don't reduce it at all. If Ok, return the imbalance. - /// - /// Minimum balance will be respected and the returned imbalance may be up to - /// `Self::minimum_balance() - 1` greater than `amount`. - fn decrease_balance( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - ) -> Result { - let old_balance = Self::balance(asset, who); - let (mut new_balance, mut amount) = if Self::reducible_balance(asset, who, false) < amount { - return Err(TokenError::NoFunds.into()) - } else { - (old_balance - amount, amount) - }; - if new_balance < Self::minimum_balance(asset) { - amount = amount.saturating_add(new_balance); - new_balance = Zero::zero(); - } - // Defensive only - this should not fail now. - Self::set_balance(asset, who, new_balance)?; - Ok(amount) - } - - /// Reduce the `asset` balance of `who` by the most that is possible, up to `amount`. - /// - /// Minimum balance will be respected and the returned imbalance may be up to - /// `Self::minimum_balance() - 1` greater than `amount`. - /// - /// Return the imbalance by which the account was reduced. - fn decrease_balance_at_most( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - ) -> Self::Balance { - let old_balance = Self::balance(asset, who); - let old_free_balance = Self::reducible_balance(asset, who, false); - let (mut new_balance, mut amount) = if old_free_balance < amount { - (old_balance.saturating_sub(old_free_balance), old_free_balance) - } else { - (old_balance - amount, amount) - }; - let minimum_balance = Self::minimum_balance(asset); - if new_balance < minimum_balance { - amount = amount.saturating_add(new_balance); - new_balance = Zero::zero(); - } - let mut r = Self::set_balance(asset, who, new_balance); - if r.is_err() { - // Some error, probably because we tried to destroy an account which cannot be - // destroyed. - if new_balance.is_zero() && amount >= minimum_balance { - new_balance = minimum_balance; - amount -= minimum_balance; - r = Self::set_balance(asset, who, new_balance); - } - if r.is_err() { - // Still an error. Apparently it's not possible to reduce at all. - amount = Zero::zero(); - } - } - amount - } - - /// Increase the `asset` balance of `who` by `amount`. If it cannot be increased by that amount - /// for some reason, return `Err` and don't increase it at all. If Ok, return the imbalance. - /// - /// Minimum balance will be respected and an error will be returned if - /// `amount < Self::minimum_balance()` when the account of `who` is zero. - fn increase_balance( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - ) -> Result { - let old_balance = Self::balance(asset, who); - let new_balance = old_balance.checked_add(&amount).ok_or(ArithmeticError::Overflow)?; - if new_balance < Self::minimum_balance(asset) { - return Err(TokenError::BelowMinimum.into()) - } - if old_balance != new_balance { - Self::set_balance(asset, who, new_balance)?; - } - Ok(amount) - } - - /// Increase the `asset` balance of `who` by the most that is possible, up to `amount`. - /// - /// Minimum balance will be respected and the returned imbalance will be zero in the case that - /// `amount < Self::minimum_balance()`. - /// - /// Return the imbalance by which the account was increased. - fn increase_balance_at_most( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - ) -> Self::Balance { - let old_balance = Self::balance(asset, who); - let mut new_balance = old_balance.saturating_add(amount); - let mut amount = new_balance - old_balance; - if new_balance < Self::minimum_balance(asset) { - new_balance = Zero::zero(); - amount = Zero::zero(); - } - if old_balance == new_balance || Self::set_balance(asset, who, new_balance).is_ok() { - amount - } else { - Zero::zero() - } - } -} - -/// Simple handler for an imbalance drop which increases the total issuance of the system by the -/// imbalance amount. Used for leftover debt. -pub struct IncreaseIssuance(PhantomData<(AccountId, U)>); -impl> HandleImbalanceDrop - for IncreaseIssuance -{ - fn handle(asset: U::AssetId, amount: U::Balance) { - U::set_total_issuance(asset, U::total_issuance(asset).saturating_add(amount)) - } -} - -/// Simple handler for an imbalance drop which decreases the total issuance of the system by the -/// imbalance amount. Used for leftover credit. -pub struct DecreaseIssuance(PhantomData<(AccountId, U)>); -impl> HandleImbalanceDrop - for DecreaseIssuance -{ - fn handle(asset: U::AssetId, amount: U::Balance) { - U::set_total_issuance(asset, U::total_issuance(asset).saturating_sub(amount)) - } -} - -/// An imbalance type which uses `DecreaseIssuance` to deal with anything `Drop`ed. -/// -/// Basically means that funds in someone's account have been removed and not yet placed anywhere -/// else. If it gets dropped, then those funds will be assumed to be "burned" and the total supply -/// will be accordingly decreased to ensure it equals the sum of the balances of all accounts. -type Credit = Imbalance< - >::AssetId, - >::Balance, - DecreaseIssuance, - IncreaseIssuance, ->; - -/// An imbalance type which uses `IncreaseIssuance` to deal with anything `Drop`ed. -/// -/// Basically means that there are funds in someone's account whose origin is as yet unaccounted -/// for. If it gets dropped, then those funds will be assumed to be "minted" and the total supply -/// will be accordingly increased to ensure it equals the sum of the balances of all accounts. -type Debt = Imbalance< - >::AssetId, - >::Balance, - IncreaseIssuance, - DecreaseIssuance, ->; - -/// Create some `Credit` item. Only for internal use. -fn credit>( - asset: U::AssetId, - amount: U::Balance, -) -> Credit { - Imbalance::new(asset, amount) -} - -/// Create some `Debt` item. Only for internal use. -fn debt>( - asset: U::AssetId, - amount: U::Balance, -) -> Debt { - Imbalance::new(asset, amount) -} - -impl> Balanced for U { - type OnDropCredit = DecreaseIssuance; - type OnDropDebt = IncreaseIssuance; - fn rescind(asset: Self::AssetId, amount: Self::Balance) -> Debt { - U::set_total_issuance(asset, U::total_issuance(asset).saturating_sub(amount)); - debt(asset, amount) - } - fn issue(asset: Self::AssetId, amount: Self::Balance) -> Credit { - U::set_total_issuance(asset, U::total_issuance(asset).saturating_add(amount)); - credit(asset, amount) - } - fn slash( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - ) -> (Credit, Self::Balance) { - let slashed = U::decrease_balance_at_most(asset, who, amount); - // `slashed` could be less than, greater than or equal to `amount`. - // If slashed == amount, it means the account had at least amount in it and it could all be - // removed without a problem. - // If slashed > amount, it means the account had more than amount in it, but not enough more - // to push it over minimum_balance. - // If slashed < amount, it means the account didn't have enough in it to be reduced by - // `amount` without being destroyed. - (credit(asset, slashed), amount.saturating_sub(slashed)) - } - fn deposit( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - ) -> Result, DispatchError> { - let increase = U::increase_balance(asset, who, amount)?; - Ok(debt(asset, increase)) - } - fn withdraw( - asset: Self::AssetId, - who: &AccountId, - amount: Self::Balance, - // TODO: liveness: ExistenceRequirement, - ) -> Result, DispatchError> { - let decrease = U::decrease_balance(asset, who, amount)?; - Ok(credit(asset, decrease)) - } -} diff --git a/frame/support/src/traits/tokens/fungibles/enumerable.rs b/frame/support/src/traits/tokens/fungibles/enumerable.rs index 5d7266d9f2c16..08bb784a7dbf6 100644 --- a/frame/support/src/traits/tokens/fungibles/enumerable.rs +++ b/frame/support/src/traits/tokens/fungibles/enumerable.rs @@ -15,10 +15,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::traits::fungibles::Inspect; - /// Interface for enumerating assets in existence or owned by a given account. -pub trait InspectEnumerable: Inspect { +pub trait Inspect: super::Inspect { type AssetsIterator; /// Returns an iterator of the collections in existence. diff --git a/frame/support/src/traits/tokens/fungibles/freeze.rs b/frame/support/src/traits/tokens/fungibles/freeze.rs new file mode 100644 index 0000000000000..08549c2d4b744 --- /dev/null +++ b/frame/support/src/traits/tokens/fungibles/freeze.rs @@ -0,0 +1,78 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 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. + +//! The traits for putting freezes within a single fungible token class. + +use scale_info::TypeInfo; +use sp_runtime::DispatchResult; + +/// Trait for inspecting a fungible asset which can be frozen. Freezing is essentially setting a +/// minimum balance below which the total balance (inclusive of any funds placed on hold) may not +/// be normally allowed to drop. Generally, freezers will provide an "update" function such that +/// if the total balance does drop below the limit, then the freezer can update their housekeeping +/// accordingly. +pub trait Inspect: super::Inspect { + /// An identifier for a freeze. + type Id: codec::Encode + TypeInfo + 'static; + + /// Amount of funds held in reserve by `who` for the given `id`. + fn balance_frozen(asset: Self::AssetId, id: &Self::Id, who: &AccountId) -> Self::Balance; + + /// The amount of the balance which can become frozen. Defaults to `total_balance()`. + fn balance_freezable(asset: Self::AssetId, who: &AccountId) -> Self::Balance { + Self::total_balance(asset, who) + } + + /// Returns `true` if it's possible to introduce a freeze for the given `id` onto the + /// account of `who`. This will be true as long as the implementor supports as many + /// concurrent freeze locks as there are possible values of `id`. + fn can_freeze(asset: Self::AssetId, id: &Self::Id, who: &AccountId) -> bool; +} + +/// Trait for introducing, altering and removing locks to freeze an account's funds so they never +/// go below a set minimum. +pub trait Mutate: Inspect { + /// Prevent actions which would reduce the balance of the account of `who` below the given + /// `amount` and identify this restriction though the given `id`. Unlike `extend_freeze`, any + /// outstanding freeze in place for `who` under the `id` are dropped. + /// + /// If `amount` is zero, it is equivalent to using `thaw`. + /// + /// Note that `amount` can be greater than the total balance, if desired. + fn set_freeze( + asset: Self::AssetId, + id: &Self::Id, + who: &AccountId, + amount: Self::Balance, + ) -> DispatchResult; + + /// Prevent the balance of the account of `who` from being reduced below the given `amount` and + /// identify this restriction though the given `id`. Unlike `set_freeze`, this does not + /// counteract any pre-existing freezes in place for `who` under the `id`. Also unlike + /// `set_freeze`, in the case that `amount` is zero, this is no-op and never fails. + /// + /// Note that more funds can be locked than the total balance, if desired. + fn extend_freeze( + asset: Self::AssetId, + id: &Self::Id, + who: &AccountId, + amount: Self::Balance, + ) -> DispatchResult; + + /// Remove an existing lock. + fn thaw(asset: Self::AssetId, id: &Self::Id, who: &AccountId) -> DispatchResult; +} diff --git a/frame/support/src/traits/tokens/fungibles/hold.rs b/frame/support/src/traits/tokens/fungibles/hold.rs new file mode 100644 index 0000000000000..68580ebff4bce --- /dev/null +++ b/frame/support/src/traits/tokens/fungibles/hold.rs @@ -0,0 +1,457 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 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. + +//! The traits for putting holds within a single fungible token class. + +use crate::{ + ensure, + traits::tokens::{ + DepositConsequence::Success, + Fortitude::{self, Force}, + Precision::{self, BestEffort, Exact}, + Preservation::{self, Protect}, + Provenance::Extant, + Restriction::{self, Free, OnHold}, + }, +}; +use scale_info::TypeInfo; +use sp_arithmetic::{ + traits::{CheckedAdd, CheckedSub, Zero}, + ArithmeticError, +}; +use sp_runtime::{DispatchError, DispatchResult, Saturating, TokenError}; + +use super::*; + +/// Trait for inspecting a fungible asset whose accounts support partitioning and slashing. +pub trait Inspect: super::Inspect { + /// An identifier for a hold. Used for disambiguating different holds so that + /// they can be individually replaced or removed and funds from one hold don't accidentally + /// become unreserved or slashed for another. + type Reason: codec::Encode + TypeInfo + 'static; + + /// Amount of funds on hold (for all hold reasons) of `who`. + fn total_balance_on_hold(asset: Self::AssetId, who: &AccountId) -> Self::Balance; + + /// Get the maximum amount that the `total_balance_on_hold` of `who` can be reduced successfully + /// based on whether we are willing to force the reduction and potentially go below user-level + /// restrictions on the minimum amount of the account. Note: This cannot bring the account into + /// an inconsistent state with regards any required existential deposit. + /// + /// Always less than `total_balance_on_hold()`. + fn reducible_total_balance_on_hold( + asset: Self::AssetId, + who: &AccountId, + force: Fortitude, + ) -> Self::Balance; + + /// Amount of funds on hold (for the given reason) of `who`. + fn balance_on_hold( + asset: Self::AssetId, + reason: &Self::Reason, + who: &AccountId, + ) -> Self::Balance; + + /// Returns `true` if it's possible to place (additional) funds under a hold of a given + /// `reason`. This may fail if the account has exhausted a limited number of concurrent + /// holds or if it cannot be made to exist (e.g. there is no provider reference). + /// + /// NOTE: This does not take into account changes which could be made to the account of `who` + /// (such as removing a provider reference) after this call is made. Any usage of this should + /// therefore ensure the account is already in the appropriate state prior to calling it. + fn hold_available(asset: Self::AssetId, reason: &Self::Reason, who: &AccountId) -> bool; + + /// Check to see if some `amount` of funds of `who` may be placed on hold with the given + /// `reason`. Reasons why this may not be true: + /// + /// - The implementor supports only a limited number of concurrent holds on an account which is + /// the possible values of `reason`; + /// - The total balance of the account is less than `amount`; + /// - Removing `amount` from the total balance would kill the account and remove the only + /// provider reference. + /// + /// Note: we pass `Fortitude::Force` as the last argument to `reducible_balance` since we assume + /// that if needed the balance can slashed. If we are using a simple non-forcing + /// reserve-transfer, then we really ought to check that we are not reducing the funds below the + /// freeze-limit (if any). + /// + /// NOTE: This does not take into account changes which could be made to the account of `who` + /// (such as removing a provider reference) after this call is made. Any usage of this should + /// therefore ensure the account is already in the appropriate state prior to calling it. + fn ensure_can_hold( + asset: Self::AssetId, + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + ) -> DispatchResult { + ensure!(Self::hold_available(asset, reason, who), TokenError::CannotCreateHold); + ensure!( + amount <= Self::reducible_balance(asset, who, Protect, Force), + TokenError::FundsUnavailable + ); + Ok(()) + } + + /// Check to see if some `amount` of funds of `who` may be placed on hold for the given + /// `reason`. Reasons why this may not be true: + /// + /// - The implementor supports only a limited number of concurrent holds on an account which is + /// the possible values of `reason`; + /// - The main balance of the account is less than `amount`; + /// - Removing `amount` from the main balance would kill the account and remove the only + /// provider reference. + /// + /// NOTE: This does not take into account changes which could be made to the account of `who` + /// (such as removing a provider reference) after this call is made. Any usage of this should + /// therefore ensure the account is already in the appropriate state prior to calling it. + fn can_hold( + asset: Self::AssetId, + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + ) -> bool { + Self::ensure_can_hold(asset, reason, who, amount).is_ok() + } +} + +/// A fungible, holdable token class where the balance on hold can be set arbitrarily. +/// +/// **WARNING** +/// Do not use this directly unless you want trouble, since it allows you to alter account balances +/// without keeping the issuance up to date. It has no safeguards against accidentally creating +/// token imbalances in your system leading to accidental imflation or deflation. It's really just +/// for the underlying datatype to implement so the user gets the much safer `Balanced` trait to +/// use. +pub trait Unbalanced: Inspect { + /// Forcefully set the balance on hold of `who` to `amount`. This is independent of any other + /// balances on hold or the main ("free") balance. + /// + /// If this call executes successfully, you can `assert_eq!(Self::balance_on_hold(), amount);`. + /// + /// This function does its best to force the balance change through, but will not break system + /// invariants such as any Existential Deposits needed or overflows/underflows. + /// If this cannot be done for some reason (e.g. because the account doesn't exist) then an + /// `Err` is returned. + // Implmentation note: This should increment the consumer refs if it moves total on hold from + // zero to non-zero and decrement in the opposite direction. + // + // Since this was not done in the previous logic, this will need either a migration or a + // state item which tracks whether the account is on the old logic or new. + fn set_balance_on_hold( + asset: Self::AssetId, + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + ) -> DispatchResult; + + /// Reduce the balance on hold of `who` by `amount`. + /// + /// If `precision` is `Precision::Exact` and it cannot be reduced by that amount for + /// some reason, return `Err` and don't reduce it at all. If `precision` is + /// `Precision::BestEffort`, then reduce the balance of `who` by the most that is possible, up + /// to `amount`. + /// + /// In either case, if `Ok` is returned then the inner is the amount by which is was reduced. + fn decrease_balance_on_hold( + asset: Self::AssetId, + reason: &Self::Reason, + who: &AccountId, + mut amount: Self::Balance, + precision: Precision, + ) -> Result { + let old_balance = Self::balance_on_hold(asset, reason, who); + if let BestEffort = precision { + amount = amount.min(old_balance); + } + let new_balance = old_balance.checked_sub(&amount).ok_or(TokenError::FundsUnavailable)?; + Self::set_balance_on_hold(asset, reason, who, new_balance)?; + Ok(amount) + } + + /// Increase the balance on hold of `who` by `amount`. + /// + /// If it cannot be increased by that amount for some reason, return `Err` and don't increase + /// it at all. If Ok, return the imbalance. + fn increase_balance_on_hold( + asset: Self::AssetId, + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + precision: Precision, + ) -> Result { + let old_balance = Self::balance_on_hold(asset, reason, who); + let new_balance = if let BestEffort = precision { + old_balance.saturating_add(amount) + } else { + old_balance.checked_add(&amount).ok_or(ArithmeticError::Overflow)? + }; + let amount = new_balance.saturating_sub(old_balance); + if !amount.is_zero() { + Self::set_balance_on_hold(asset, reason, who, new_balance)?; + } + Ok(amount) + } +} + +/// Trait for slashing a fungible asset which can be place on hold. +pub trait Balanced: super::Balanced + Unbalanced { + /// Reduce the balance of some funds on hold in an account. + /// + /// The resulting imbalance is the first item of the tuple returned. + /// + /// As much funds that are on hold up to `amount` will be deducted as possible. If this is less + /// than `amount`, then a non-zero second item will be returned. + fn slash( + asset: Self::AssetId, + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + ) -> (Credit, Self::Balance) { + let decrease = Self::decrease_balance_on_hold(asset, reason, who, amount, BestEffort) + .unwrap_or(Default::default()); + let credit = + Imbalance::::new( + asset, decrease, + ); + Self::done_slash(asset, reason, who, decrease); + (credit, amount.saturating_sub(decrease)) + } + + fn done_slash( + _asset: Self::AssetId, + _reason: &Self::Reason, + _who: &AccountId, + _amount: Self::Balance, + ) { + } +} + +/// Trait for mutating a fungible asset which can be placed on hold. +pub trait Mutate: + Inspect + super::Unbalanced + Unbalanced +{ + /// Hold some funds in an account. If a hold for `reason` is already in place, then this + /// will increase it. + fn hold( + asset: Self::AssetId, + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + ) -> DispatchResult { + // NOTE: This doesn't change the total balance of the account so there's no need to + // check liquidity. + + Self::ensure_can_hold(asset, reason, who, amount)?; + // Should be infallible now, but we proceed softly anyway. + Self::decrease_balance(asset, who, amount, Exact, Protect, Force)?; + Self::increase_balance_on_hold(asset, reason, who, amount, BestEffort)?; + Self::done_hold(asset, reason, who, amount); + Ok(()) + } + + /// Release up to `amount` held funds in an account. + /// + /// The actual amount released is returned with `Ok`. + /// + /// If `precision` is `BestEffort`, then the amount actually unreserved and returned as the + /// inner value of `Ok` may be smaller than the `amount` passed. + fn release( + asset: Self::AssetId, + reason: &Self::Reason, + who: &AccountId, + amount: Self::Balance, + precision: Precision, + ) -> Result { + // NOTE: This doesn't change the total balance of the account so there's no need to + // check liquidity. + + // We want to make sure we can deposit the amount in advance. If we can't then something is + // very wrong. + ensure!(Self::can_deposit(asset, who, amount, Extant) == Success, TokenError::CannotCreate); + // Get the amount we can actually take from the hold. This might be less than what we want + // if we're only doing a best-effort. + let amount = Self::decrease_balance_on_hold(asset, reason, who, amount, precision)?; + // Increase the main balance by what we took. We always do a best-effort here because we + // already checked that we can deposit before. + let actual = Self::increase_balance(asset, who, amount, BestEffort)?; + Self::done_release(asset, reason, who, actual); + Ok(actual) + } + + /// Attempt to decrease the balance of `who` which is held for the given `reason` by `amount`. + /// + /// If `precision` is true, then as much as possible is reduced, up to `amount`, and the + /// amount of tokens reduced is returned. Otherwise, if the total amount can be reduced, then it + /// is and the amount returned, and if not, then nothing changes and `Err` is returned. + /// + /// If `force` is `Force`, then locks/freezes will be ignored. This should only be used when + /// conducting slashing or other activity which materially disadvantages the account holder + /// since it could provide a means of circumventing freezes. + fn burn_held( + asset: Self::AssetId, + reason: &Self::Reason, + who: &AccountId, + mut amount: Self::Balance, + precision: Precision, + force: Fortitude, + ) -> Result { + // We must check total-balance requirements if `!force`. + let liquid = Self::reducible_total_balance_on_hold(asset, who, force); + if let BestEffort = precision { + amount = amount.min(liquid); + } else { + ensure!(amount <= liquid, TokenError::Frozen); + } + let amount = Self::decrease_balance_on_hold(asset, reason, who, amount, precision)?; + Self::set_total_issuance(asset, Self::total_issuance(asset).saturating_sub(amount)); + Self::done_burn_held(asset, reason, who, amount); + Ok(amount) + } + + /// Transfer held funds into a destination account. + /// + /// If `on_hold` is `true`, then the destination account must already exist and the assets + /// transferred will still be on hold in the destination account. If not, then the destination + /// account need not already exist, but must be creatable. + /// + /// If `precision` is `BestEffort`, then an amount less than `amount` may be transferred without + /// error. + /// + /// If `force` is `Force`, then other fund-locking mechanisms may be disregarded. It should be + /// left as `Regular` in most circumstances, but when you want the same power as a `slash`, it + /// may be `Force`. + /// + /// The actual amount transferred is returned, or `Err` in the case of error and nothing is + /// changed. + fn transfer_on_hold( + asset: Self::AssetId, + reason: &Self::Reason, + source: &AccountId, + dest: &AccountId, + mut amount: Self::Balance, + precision: Precision, + mode: Restriction, + force: Fortitude, + ) -> Result { + // We must check total-balance requirements if `!force`. + let have = Self::balance_on_hold(asset, reason, source); + let liquid = Self::reducible_total_balance_on_hold(asset, source, force); + if let BestEffort = precision { + amount = amount.min(liquid).min(have); + } else { + ensure!(amount <= liquid, TokenError::Frozen); + ensure!(amount <= have, TokenError::FundsUnavailable); + } + + // We want to make sure we can deposit the amount in advance. If we can't then something is + // very wrong. + ensure!( + Self::can_deposit(asset, dest, amount, Extant) == Success, + TokenError::CannotCreate + ); + ensure!( + mode == Free || Self::hold_available(asset, reason, dest), + TokenError::CannotCreateHold + ); + + let amount = Self::decrease_balance_on_hold(asset, reason, source, amount, precision)?; + let actual = if mode == OnHold { + Self::increase_balance_on_hold(asset, reason, dest, amount, precision)? + } else { + Self::increase_balance(asset, dest, amount, precision)? + }; + Self::done_transfer_on_hold(asset, reason, source, dest, actual); + Ok(actual) + } + + /// Transfer some `amount` of free balance from `source` to become owned by `dest` but on hold + /// for `reason`. + /// for `reason`. + /// + /// If `precision` is `BestEffort`, then an amount less than `amount` may be transferred without + /// error. + /// + /// `source` must obey the requirements of `keep_alive`. + /// + /// If `force` is `Force`, then other fund-locking mechanisms may be disregarded. It should be + /// left as `Regular` in most circumstances, but when you want the same power as a `slash`, it + /// may be `Force`. + /// + /// The amount placed on hold is returned or `Err` in the case of error and nothing is changed. + /// + /// WARNING: This may return an error after a partial storage mutation. It should be used only + /// inside a transactional storage context and an `Err` result must imply a storage rollback. + fn transfer_and_hold( + asset: Self::AssetId, + reason: &Self::Reason, + source: &AccountId, + dest: &AccountId, + amount: Self::Balance, + precision: Precision, + expendability: Preservation, + force: Fortitude, + ) -> Result { + ensure!(Self::hold_available(asset, reason, dest), TokenError::CannotCreateHold); + ensure!( + Self::can_deposit(asset, dest, amount, Extant) == Success, + TokenError::CannotCreate + ); + let actual = + Self::decrease_balance(asset, source, amount, precision, expendability, force)?; + Self::increase_balance_on_hold(asset, reason, dest, actual, precision)?; + Self::done_transfer_on_hold(asset, reason, source, dest, actual); + Ok(actual) + } + + fn done_hold( + _asset: Self::AssetId, + _reason: &Self::Reason, + _who: &AccountId, + _amount: Self::Balance, + ) { + } + fn done_release( + _asset: Self::AssetId, + _reason: &Self::Reason, + _who: &AccountId, + _amount: Self::Balance, + ) { + } + fn done_burn_held( + _asset: Self::AssetId, + _reason: &Self::Reason, + _who: &AccountId, + _amount: Self::Balance, + ) { + } + fn done_transfer_on_hold( + _asset: Self::AssetId, + _reason: &Self::Reason, + _source: &AccountId, + _dest: &AccountId, + _amount: Self::Balance, + ) { + } + fn done_transfer_and_hold( + _asset: Self::AssetId, + _reason: &Self::Reason, + _source: &AccountId, + _dest: &AccountId, + _transferred: Self::Balance, + ) { + } +} diff --git a/frame/support/src/traits/tokens/fungibles/imbalance.rs b/frame/support/src/traits/tokens/fungibles/imbalance.rs index 87445859cb5c7..ab18eec3811ff 100644 --- a/frame/support/src/traits/tokens/fungibles/imbalance.rs +++ b/frame/support/src/traits/tokens/fungibles/imbalance.rs @@ -18,12 +18,11 @@ //! The imbalance type and its associates, which handles keeps everything adding up properly with //! unbalanced operations. -use super::{ - balanced::Balanced, - fungibles::{AssetId, Balance}, - *, +use super::*; +use crate::traits::{ + misc::{SameOrOther, TryDrop}, + tokens::{AssetId, Balance}, }; -use crate::traits::misc::{SameOrOther, TryDrop}; use sp_runtime::{traits::Zero, RuntimeDebug}; use sp_std::marker::PhantomData; @@ -160,7 +159,7 @@ impl< } /// Imbalance implying that the total_issuance value is less than the sum of all account balances. -pub type DebtOf = Imbalance< +pub type Debt = Imbalance< >::AssetId, >::Balance, // This will generally be implemented by increasing the total_issuance value. @@ -170,7 +169,7 @@ pub type DebtOf = Imbalance< /// Imbalance implying that the total_issuance value is greater than the sum of all account /// balances. -pub type CreditOf = Imbalance< +pub type Credit = Imbalance< >::AssetId, >::Balance, // This will generally be implemented by decreasing the total_issuance value. diff --git a/frame/support/src/traits/tokens/fungibles/lifetime.rs b/frame/support/src/traits/tokens/fungibles/lifetime.rs new file mode 100644 index 0000000000000..9e2c306f6f38a --- /dev/null +++ b/frame/support/src/traits/tokens/fungibles/lifetime.rs @@ -0,0 +1,84 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 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. + +//! Traits for creating and destroying assets. + +use sp_runtime::{DispatchError, DispatchResult}; + +use super::Inspect; + +/// Trait for providing the ability to create new fungible assets. +pub trait Create: Inspect { + /// Create a new fungible asset. + fn create( + id: Self::AssetId, + admin: AccountId, + is_sufficient: bool, + min_balance: Self::Balance, + ) -> DispatchResult; +} + +/// Trait for providing the ability to destroy existing fungible assets. +pub trait Destroy: Inspect { + /// Start the destruction an existing fungible asset. + /// * `id`: The `AssetId` to be destroyed. successfully. + /// * `maybe_check_owner`: An optional account id that can be used to authorize the destroy + /// command. If not provided, no authorization checks will be performed before destroying + /// asset. + fn start_destroy(id: Self::AssetId, maybe_check_owner: Option) -> DispatchResult; + + /// Destroy all accounts associated with a given asset. + /// `destroy_accounts` should only be called after `start_destroy` has been called, and the + /// asset is in a `Destroying` state + /// + /// * `id`: The identifier of the asset to be destroyed. This must identify an existing asset. + /// * `max_items`: The maximum number of accounts to be destroyed for a given call of the + /// function. This value should be small enough to allow the operation fit into a logical + /// block. + /// + /// Response: + /// * u32: Total number of approvals which were actually destroyed + /// + /// Due to weight restrictions, this function may need to be called multiple + /// times to fully destroy all approvals. It will destroy `max_items` approvals at a + /// time. + fn destroy_accounts(id: Self::AssetId, max_items: u32) -> Result; + /// Destroy all approvals associated with a given asset up to the `max_items` + /// `destroy_approvals` should only be called after `start_destroy` has been called, and the + /// asset is in a `Destroying` state + /// + /// * `id`: The identifier of the asset to be destroyed. This must identify an existing asset. + /// * `max_items`: The maximum number of accounts to be destroyed for a given call of the + /// function. This value should be small enough to allow the operation fit into a logical + /// block. + /// + /// Response: + /// * u32: Total number of approvals which were actually destroyed + /// + /// Due to weight restrictions, this function may need to be called multiple + /// times to fully destroy all approvals. It will destroy `max_items` approvals at a + /// time. + fn destroy_approvals(id: Self::AssetId, max_items: u32) -> Result; + + /// Complete destroying asset and unreserve currency. + /// `finish_destroy` should only be called after `start_destroy` has been called, and the + /// asset is in a `Destroying` state. All accounts or approvals should be destroyed before + /// hand. + /// + /// * `id`: The identifier of the asset to be destroyed. This must identify an existing asset. + fn finish_destroy(id: Self::AssetId) -> DispatchResult; +} diff --git a/frame/support/src/traits/tokens/fungibles/mod.rs b/frame/support/src/traits/tokens/fungibles/mod.rs new file mode 100644 index 0000000000000..697eff39ff748 --- /dev/null +++ b/frame/support/src/traits/tokens/fungibles/mod.rs @@ -0,0 +1,40 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 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. + +//! The traits for sets of fungible tokens and any associated types. + +pub mod approvals; +mod enumerable; +pub mod freeze; +pub mod hold; +mod imbalance; +mod lifetime; +pub mod metadata; +mod regular; +pub mod roles; + +pub use enumerable::Inspect as InspectEnumerable; +pub use freeze::{Inspect as InspectFreeze, Mutate as MutateFreeze}; +pub use hold::{ + Balanced as BalancedHold, Inspect as InspectHold, Mutate as MutateHold, + Unbalanced as UnbalancedHold, +}; +pub use imbalance::{Credit, Debt, HandleImbalanceDrop, Imbalance}; +pub use lifetime::{Create, Destroy}; +pub use regular::{ + Balanced, DecreaseIssuance, Dust, IncreaseIssuance, Inspect, Mutate, Unbalanced, +}; diff --git a/frame/support/src/traits/tokens/fungibles/regular.rs b/frame/support/src/traits/tokens/fungibles/regular.rs new file mode 100644 index 0000000000000..03c14988015ab --- /dev/null +++ b/frame/support/src/traits/tokens/fungibles/regular.rs @@ -0,0 +1,571 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 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. + +//! `Inspect` and `Mutate` traits for working with regular balances. + +use sp_std::marker::PhantomData; + +use crate::{ + dispatch::DispatchError, + ensure, + traits::{ + tokens::{ + misc::{ + Balance, DepositConsequence, + Fortitude::{self, Force, Polite}, + Precision::{self, BestEffort, Exact}, + Preservation::{self, Expendable}, + Provenance::{self, Extant}, + WithdrawConsequence, + }, + AssetId, + }, + SameOrOther, TryDrop, + }, +}; +use sp_arithmetic::traits::{CheckedAdd, CheckedSub, One}; +use sp_runtime::{traits::Saturating, ArithmeticError, TokenError}; + +use super::{Credit, Debt, HandleImbalanceDrop, Imbalance}; + +/// Trait for providing balance-inspection access to a set of named fungible assets. +pub trait Inspect: Sized { + /// Means of identifying one asset class from another. + type AssetId: AssetId; + + /// Scalar type for representing balance of an account. + type Balance: Balance; + + /// The total amount of issuance in the system. + fn total_issuance(asset: Self::AssetId) -> Self::Balance; + + /// The total amount of issuance in the system excluding those which are controlled by the + /// system. + fn active_issuance(asset: Self::AssetId) -> Self::Balance { + Self::total_issuance(asset) + } + + /// The minimum balance any single account may have. + fn minimum_balance(asset: Self::AssetId) -> Self::Balance; + + /// Get the total amount of funds whose ultimate bneficial ownership can be determined as `who`. + /// + /// This may include funds which are wholly inaccessible to `who`, either temporarily or even + /// indefinitely. + /// + /// For the amount of the balance which is currently free to be removed from the account without + /// error, use `reducible_balance`. + /// + /// For the amount of the balance which may eventually be free to be removed from the account, + /// use `balance()`. + fn total_balance(asset: Self::AssetId, who: &AccountId) -> Self::Balance; + + /// Get the balance of `who` which does not include funds which are exclusively allocated to + /// subsystems of the chain ("on hold" or "reserved"). + /// + /// In general this isn't especially useful outside of tests, and for practical purposes, you'll + /// want to use `reducible_balance()`. + fn balance(asset: Self::AssetId, who: &AccountId) -> Self::Balance; + + /// Get the maximum amount that `who` can withdraw/transfer successfully based on whether the + /// account should be kept alive (`preservation`) or whether we are willing to force the + /// transfer and potentially go below user-level restrictions on the minimum amount of the + /// account. + /// + /// Always less than `free_balance()`. + fn reducible_balance( + asset: Self::AssetId, + who: &AccountId, + preservation: Preservation, + force: Fortitude, + ) -> Self::Balance; + + /// Returns `true` if the `asset` balance of `who` may be increased by `amount`. + /// + /// - `asset`: The asset that should be deposited. + /// - `who`: The account of which the balance should be increased by `amount`. + /// - `amount`: How much should the balance be increased? + /// - `mint`: Will `amount` be minted to deposit it into `account`? + fn can_deposit( + asset: Self::AssetId, + who: &AccountId, + amount: Self::Balance, + provenance: Provenance, + ) -> DepositConsequence; + + /// Returns `Failed` if the `asset` balance of `who` may not be decreased by `amount`, otherwise + /// the consequence. + fn can_withdraw( + asset: Self::AssetId, + who: &AccountId, + amount: Self::Balance, + ) -> WithdrawConsequence; + + /// Returns `true` if an `asset` exists. + fn asset_exists(asset: Self::AssetId) -> bool; +} + +/// Special dust type which can be type-safely converted into a `Credit`. +#[must_use] +pub struct Dust>(pub(crate) T::AssetId, pub(crate) T::Balance); + +impl> Dust { + /// Convert `Dust` into an instance of `Credit`. + pub fn into_credit(self) -> Credit { + Credit::::new(self.0, self.1) + } +} + +/// A fungible token class where the balance can be set arbitrarily. +/// +/// **WARNING** +/// Do not use this directly unless you want trouble, since it allows you to alter account balances +/// without keeping the issuance up to date. It has no safeguards against accidentally creating +/// token imbalances in your system leading to accidental imflation or deflation. It's really just +/// for the underlying datatype to implement so the user gets the much safer `Balanced` trait to +/// use. +pub trait Unbalanced: Inspect { + /// Create some dust and handle it with `Self::handle_dust`. This is an unbalanced operation + /// and it must only be used when an account is modified in a raw fashion, outside of the entire + /// fungibles API. The `amount` is capped at `Self::minimum_balance() - 1`. + /// + /// This should not be reimplemented. + fn handle_raw_dust(asset: Self::AssetId, amount: Self::Balance) { + Self::handle_dust(Dust( + asset, + amount.min(Self::minimum_balance(asset).saturating_sub(One::one())), + )) + } + + /// Do something with the dust which has been destroyed from the system. `Dust` can be converted + /// into a `Credit` with the `Balanced` trait impl. + fn handle_dust(dust: Dust); + + /// Forcefully set the balance of `who` to `amount`. + /// + /// If this call executes successfully, you can `assert_eq!(Self::balance(), amount);`. + /// + /// For implementations which include one or more balances on hold, then these are *not* + /// included in the `amount`. + /// + /// This function does its best to force the balance change through, but will not break system + /// invariants such as any Existential Deposits needed or overflows/underflows. + /// If this cannot be done for some reason (e.g. because the account cannot be created, deleted + /// or would overflow) then an `Err` is returned. + fn write_balance( + asset: Self::AssetId, + who: &AccountId, + amount: Self::Balance, + ) -> Result, DispatchError>; + + /// Set the total issuance to `amount`. + fn set_total_issuance(asset: Self::AssetId, amount: Self::Balance); + + /// Reduce the balance of `who` by `amount`. + /// + /// If `precision` is `Exact` and it cannot be reduced by that amount for + /// some reason, return `Err` and don't reduce it at all. If `precision` is `BestEffort`, then + /// reduce the balance of `who` by the most that is possible, up to `amount`. + /// + /// In either case, if `Ok` is returned then the inner is the amount by which is was reduced. + /// Minimum balance will be respected and thus the returned amount may be up to + /// `Self::minimum_balance() - 1` greater than `amount` in the case that the reduction caused + /// the account to be deleted. + fn decrease_balance( + asset: Self::AssetId, + who: &AccountId, + mut amount: Self::Balance, + precision: Precision, + preservation: Preservation, + force: Fortitude, + ) -> Result { + let old_balance = Self::balance(asset, who); + let free = Self::reducible_balance(asset, who, preservation, force); + if let BestEffort = precision { + amount = amount.min(free); + } + let new_balance = old_balance.checked_sub(&amount).ok_or(TokenError::FundsUnavailable)?; + if let Some(dust) = Self::write_balance(asset, who, new_balance)? { + Self::handle_dust(Dust(asset, dust)); + } + Ok(old_balance.saturating_sub(new_balance)) + } + + /// Increase the balance of `who` by `amount`. + /// + /// If it cannot be increased by that amount for some reason, return `Err` and don't increase + /// it at all. If Ok, return the imbalance. + /// Minimum balance will be respected and an error will be returned if + /// `amount < Self::minimum_balance()` when the account of `who` is zero. + fn increase_balance( + asset: Self::AssetId, + who: &AccountId, + amount: Self::Balance, + precision: Precision, + ) -> Result { + let old_balance = Self::balance(asset, who); + let new_balance = if let BestEffort = precision { + old_balance.saturating_add(amount) + } else { + old_balance.checked_add(&amount).ok_or(ArithmeticError::Overflow)? + }; + if new_balance < Self::minimum_balance(asset) { + // Attempt to increase from 0 to below minimum -> stays at zero. + if let BestEffort = precision { + Ok(Self::Balance::default()) + } else { + Err(TokenError::BelowMinimum.into()) + } + } else { + if new_balance == old_balance { + Ok(Self::Balance::default()) + } else { + if let Some(dust) = Self::write_balance(asset, who, new_balance)? { + Self::handle_dust(Dust(asset, dust)); + } + Ok(new_balance.saturating_sub(old_balance)) + } + } + } + + /// Reduce the active issuance by some amount. + fn deactivate(_asset: Self::AssetId, _: Self::Balance) {} + + /// Increase the active issuance by some amount, up to the outstanding amount reduced. + fn reactivate(_asset: Self::AssetId, _: Self::Balance) {} +} + +/// Trait for providing a basic fungible asset. +pub trait Mutate: Inspect + Unbalanced { + /// Increase the balance of `who` by exactly `amount`, minting new tokens. If that isn't + /// possible then an `Err` is returned and nothing is changed. + fn mint_into( + asset: Self::AssetId, + who: &AccountId, + amount: Self::Balance, + ) -> Result { + Self::total_issuance(asset) + .checked_add(&amount) + .ok_or(ArithmeticError::Overflow)?; + let actual = Self::increase_balance(asset, who, amount, Exact)?; + Self::set_total_issuance(asset, Self::total_issuance(asset).saturating_add(actual)); + Self::done_mint_into(asset, who, amount); + Ok(actual) + } + + /// Decrease the balance of `who` by at least `amount`, possibly slightly more in the case of + /// minimum-balance requirements, burning the tokens. If that isn't possible then an `Err` is + /// returned and nothing is changed. If successful, the amount of tokens reduced is returned. + fn burn_from( + asset: Self::AssetId, + who: &AccountId, + amount: Self::Balance, + precision: Precision, + force: Fortitude, + ) -> Result { + let actual = Self::reducible_balance(asset, who, Expendable, force).min(amount); + ensure!(actual == amount || precision == BestEffort, TokenError::FundsUnavailable); + Self::total_issuance(asset) + .checked_sub(&actual) + .ok_or(ArithmeticError::Overflow)?; + let actual = Self::decrease_balance(asset, who, actual, BestEffort, Expendable, force)?; + Self::set_total_issuance(asset, Self::total_issuance(asset).saturating_sub(actual)); + Self::done_burn_from(asset, who, actual); + Ok(actual) + } + + /// Attempt to decrease the `asset` balance of `who` by `amount`. + /// + /// Equivalent to `burn_from`, except with an expectation that within the bounds of some + /// universal issuance, the total assets `suspend`ed and `resume`d will be equivalent. The + /// implementation may be configured such that the total assets suspended may never be less than + /// the total assets resumed (which is the invariant for an issuing system), or the reverse + /// (which the invariant in a non-issuing system). + /// + /// Because of this expectation, any metadata associated with the asset is expected to survive + /// the suspect-resume cycle. + fn shelve( + asset: Self::AssetId, + who: &AccountId, + amount: Self::Balance, + ) -> Result { + let actual = Self::reducible_balance(asset, who, Expendable, Polite).min(amount); + ensure!(actual == amount, TokenError::FundsUnavailable); + Self::total_issuance(asset) + .checked_sub(&actual) + .ok_or(ArithmeticError::Overflow)?; + let actual = Self::decrease_balance(asset, who, actual, BestEffort, Expendable, Polite)?; + Self::set_total_issuance(asset, Self::total_issuance(asset).saturating_sub(actual)); + Self::done_shelve(asset, who, actual); + Ok(actual) + } + + /// Attempt to increase the `asset` balance of `who` by `amount`. + /// + /// Equivalent to `mint_into`, except with an expectation that within the bounds of some + /// universal issuance, the total assets `suspend`ed and `resume`d will be equivalent. The + /// implementation may be configured such that the total assets suspended may never be less than + /// the total assets resumed (which is the invariant for an issuing system), or the reverse + /// (which the invariant in a non-issuing system). + /// + /// Because of this expectation, any metadata associated with the asset is expected to survive + /// the suspect-resume cycle. + fn restore( + asset: Self::AssetId, + who: &AccountId, + amount: Self::Balance, + ) -> Result { + Self::total_issuance(asset) + .checked_add(&amount) + .ok_or(ArithmeticError::Overflow)?; + let actual = Self::increase_balance(asset, who, amount, Exact)?; + Self::set_total_issuance(asset, Self::total_issuance(asset).saturating_add(actual)); + Self::done_restore(asset, who, amount); + Ok(actual) + } + + /// Transfer funds from one account into another. + fn transfer( + asset: Self::AssetId, + source: &AccountId, + dest: &AccountId, + amount: Self::Balance, + preservation: Preservation, + ) -> Result { + let _extra = + Self::can_withdraw(asset, source, amount).into_result(preservation != Expendable)?; + Self::can_deposit(asset, dest, amount, Extant).into_result()?; + Self::decrease_balance(asset, source, amount, BestEffort, preservation, Polite)?; + // This should never fail as we checked `can_deposit` earlier. But we do a best-effort + // anyway. + let _ = Self::increase_balance(asset, dest, amount, BestEffort); + Self::done_transfer(asset, source, dest, amount); + Ok(amount) + } + + /// Simple infallible function to force an account to have a particular balance, good for use + /// in tests and benchmarks but not recommended for production code owing to the lack of + /// error reporting. + /// + /// Returns the new balance. + fn set_balance(asset: Self::AssetId, who: &AccountId, amount: Self::Balance) -> Self::Balance { + let b = Self::balance(asset, who); + if b > amount { + Self::burn_from(asset, who, b - amount, BestEffort, Force) + .map(|d| amount.saturating_sub(d)) + } else { + Self::mint_into(asset, who, amount - b).map(|d| amount.saturating_add(d)) + } + .unwrap_or(b) + } + fn done_mint_into(_asset: Self::AssetId, _who: &AccountId, _amount: Self::Balance) {} + fn done_burn_from(_asset: Self::AssetId, _who: &AccountId, _amount: Self::Balance) {} + fn done_shelve(_asset: Self::AssetId, _who: &AccountId, _amount: Self::Balance) {} + fn done_restore(_asset: Self::AssetId, _who: &AccountId, _amount: Self::Balance) {} + fn done_transfer( + _asset: Self::AssetId, + _source: &AccountId, + _dest: &AccountId, + _amount: Self::Balance, + ) { + } +} + +/// Simple handler for an imbalance drop which increases the total issuance of the system by the +/// imbalance amount. Used for leftover debt. +pub struct IncreaseIssuance(PhantomData<(AccountId, U)>); +impl> HandleImbalanceDrop + for IncreaseIssuance +{ + fn handle(asset: U::AssetId, amount: U::Balance) { + U::set_total_issuance(asset, U::total_issuance(asset).saturating_add(amount)) + } +} + +/// Simple handler for an imbalance drop which decreases the total issuance of the system by the +/// imbalance amount. Used for leftover credit. +pub struct DecreaseIssuance(PhantomData<(AccountId, U)>); +impl> HandleImbalanceDrop + for DecreaseIssuance +{ + fn handle(asset: U::AssetId, amount: U::Balance) { + U::set_total_issuance(asset, U::total_issuance(asset).saturating_sub(amount)) + } +} + +/// A fungible token class where any creation and deletion of tokens is semi-explicit and where the +/// total supply is maintained automatically. +/// +/// This is auto-implemented when a token class has `Unbalanced` implemented. +pub trait Balanced: Inspect + Unbalanced { + /// The type for managing what happens when an instance of `Debt` is dropped without being used. + type OnDropDebt: HandleImbalanceDrop; + /// The type for managing what happens when an instance of `Credit` is dropped without being + /// used. + type OnDropCredit: HandleImbalanceDrop; + + /// Reduce the total issuance by `amount` and return the according imbalance. The imbalance will + /// typically be used to reduce an account by the same amount with e.g. `settle`. + /// + /// This is infallible, but doesn't guarantee that the entire `amount` is burnt, for example + /// in the case of underflow. + fn rescind(asset: Self::AssetId, amount: Self::Balance) -> Debt { + let old = Self::total_issuance(asset); + let new = old.saturating_sub(amount); + Self::set_total_issuance(asset, new); + let delta = old - new; + Self::done_rescind(asset, delta); + Imbalance::::new( + asset, delta, + ) + } + + /// Increase the total issuance by `amount` and return the according imbalance. The imbalance + /// will typically be used to increase an account by the same amount with e.g. + /// `resolve_into_existing` or `resolve_creating`. + /// + /// This is infallible, but doesn't guarantee that the entire `amount` is issued, for example + /// in the case of overflow. + fn issue(asset: Self::AssetId, amount: Self::Balance) -> Credit { + let old = Self::total_issuance(asset); + let new = old.saturating_add(amount); + Self::set_total_issuance(asset, new); + let delta = new - old; + Self::done_issue(asset, delta); + Imbalance::::new( + asset, delta, + ) + } + + /// Produce a pair of imbalances that cancel each other out exactly. + /// + /// This is just the same as burning and issuing the same amount and has no effect on the + /// total issuance. + fn pair( + asset: Self::AssetId, + amount: Self::Balance, + ) -> (Debt, Credit) { + (Self::rescind(asset, amount), Self::issue(asset, amount)) + } + + /// Mints `value` into the account of `who`, creating it as needed. + /// + /// If `precision` is `BestEffort` and `value` in full could not be minted (e.g. due to + /// overflow), then the maximum is minted, up to `value`. If `precision` is `Exact`, then + /// exactly `value` must be minted into the account of `who` or the operation will fail with an + /// `Err` and nothing will change. + /// + /// If the operation is successful, this will return `Ok` with a `Debt` of the total value + /// added to the account. + fn deposit( + asset: Self::AssetId, + who: &AccountId, + value: Self::Balance, + precision: Precision, + ) -> Result, DispatchError> { + let increase = Self::increase_balance(asset, who, value, precision)?; + Self::done_deposit(asset, who, increase); + Ok(Imbalance::::new( + asset, increase, + )) + } + + /// Removes `value` balance from `who` account if possible. + /// + /// If `precision` is `BestEffort` and `value` in full could not be removed (e.g. due to + /// underflow), then the maximum is removed, up to `value`. If `precision` is `Exact`, then + /// exactly `value` must be removed from the account of `who` or the operation will fail with an + /// `Err` and nothing will change. + /// + /// If the removal is needed but not possible, then it returns `Err` and nothing is changed. + /// If the account needed to be deleted, then slightly more than `value` may be removed from the + /// account owning since up to (but not including) minimum balance may also need to be removed. + /// + /// If the operation is successful, this will return `Ok` with a `Credit` of the total value + /// removed from the account. + fn withdraw( + asset: Self::AssetId, + who: &AccountId, + value: Self::Balance, + precision: Precision, + preservation: Preservation, + force: Fortitude, + ) -> Result, DispatchError> { + let decrease = Self::decrease_balance(asset, who, value, precision, preservation, force)?; + Self::done_withdraw(asset, who, decrease); + Ok(Imbalance::::new( + asset, decrease, + )) + } + + /// The balance of `who` is increased in order to counter `credit`. If the whole of `credit` + /// cannot be countered, then nothing is changed and the original `credit` is returned in an + /// `Err`. + /// + /// Please note: If `credit.peek()` is less than `Self::minimum_balance()`, then `who` must + /// already exist for this to succeed. + fn resolve( + who: &AccountId, + credit: Credit, + ) -> Result<(), Credit> { + let v = credit.peek(); + let debt = match Self::deposit(credit.asset(), who, v, Exact) { + Err(_) => return Err(credit), + Ok(d) => d, + }; + if let Ok(result) = credit.offset(debt) { + let result = result.try_drop(); + debug_assert!(result.is_ok(), "ok deposit return must be equal to credit value; qed"); + } else { + debug_assert!(false, "debt.asset is credit.asset; qed"); + } + Ok(()) + } + + /// The balance of `who` is decreased in order to counter `debt`. If the whole of `debt` + /// cannot be countered, then nothing is changed and the original `debt` is returned in an + /// `Err`. + fn settle( + who: &AccountId, + debt: Debt, + preservation: Preservation, + ) -> Result, Debt> { + let amount = debt.peek(); + let asset = debt.asset(); + let credit = match Self::withdraw(asset, who, amount, Exact, preservation, Polite) { + Err(_) => return Err(debt), + Ok(d) => d, + }; + match credit.offset(debt) { + Ok(SameOrOther::None) => Ok(Credit::::zero(asset)), + Ok(SameOrOther::Same(dust)) => Ok(dust), + Ok(SameOrOther::Other(rest)) => { + debug_assert!(false, "ok withdraw return must be at least debt value; qed"); + Err(rest) + }, + Err(_) => { + debug_assert!(false, "debt.asset is credit.asset; qed"); + Ok(Credit::::zero(asset)) + }, + } + } + + fn done_rescind(_asset: Self::AssetId, _amount: Self::Balance) {} + fn done_issue(_asset: Self::AssetId, _amount: Self::Balance) {} + fn done_deposit(_asset: Self::AssetId, _who: &AccountId, _amount: Self::Balance) {} + fn done_withdraw(_asset: Self::AssetId, _who: &AccountId, _amount: Self::Balance) {} +} diff --git a/frame/support/src/traits/tokens/misc.rs b/frame/support/src/traits/tokens/misc.rs index 6113642c83460..8ad3a9535fd0d 100644 --- a/frame/support/src/traits/tokens/misc.rs +++ b/frame/support/src/traits/tokens/misc.rs @@ -23,12 +23,65 @@ use sp_core::RuntimeDebug; use sp_runtime::{traits::Convert, ArithmeticError, DispatchError, TokenError}; use sp_std::fmt::Debug; +/// The origin of funds to be used for a deposit operation. +#[derive(Copy, Clone, RuntimeDebug, Eq, PartialEq)] +pub enum Provenance { + /// The funds will be minted into the system, increasing total issuance (and potentially + /// causing an overflow there). + Minted, + /// The funds already exist in the system, therefore will not affect total issuance. + Extant, +} + +/// The mode under which usage of funds may be restricted. +#[derive(Copy, Clone, RuntimeDebug, Eq, PartialEq)] +pub enum Restriction { + /// Funds are under the normal conditions. + Free, + /// Funds are on hold. + OnHold, +} + +/// The mode by which we describe whether an operation should keep an account alive. +#[derive(Copy, Clone, RuntimeDebug, Eq, PartialEq)] +pub enum Preservation { + /// We don't care if the account gets killed by this operation. + Expendable, + /// The account may not be killed, but we don't care if the balance gets dusted. + Protect, + /// The account may not be killed and our provider reference must remain (in the context of + /// tokens, this means that the account may not be dusted). + Preserve, +} + +/// The privilege with which a withdraw operation is conducted. +#[derive(Copy, Clone, RuntimeDebug, Eq, PartialEq)] +pub enum Fortitude { + /// The operation should execute with regular privilege. + Polite, + /// The operation should be forced to succeed if possible. This is usually employed for system- + /// level security-critical events such as slashing. + Force, +} + +/// The precision required of an operation generally involving some aspect of quantitative fund +/// withdrawal or transfer. +#[derive(Copy, Clone, RuntimeDebug, Eq, PartialEq)] +pub enum Precision { + /// The operation should must either proceed either exactly according to the amounts involved + /// or not at all. + Exact, + /// The operation may be considered successful even if less than the specified amounts are + /// available to be used. In this case a best effort will be made. + BestEffort, +} + /// One of a number of consequences of withdrawing a fungible from an account. #[derive(Copy, Clone, RuntimeDebug, Eq, PartialEq)] pub enum WithdrawConsequence { /// Withdraw could not happen since the amount to be withdrawn is less than the total funds in /// the account. - NoFunds, + BalanceLow, /// The withdraw would mean the account dying when it needs to exist (usually because it is a /// provider and there are consumer references on it). WouldDie, @@ -53,15 +106,16 @@ pub enum WithdrawConsequence { impl WithdrawConsequence { /// Convert the type into a `Result` with `DispatchError` as the error or the additional /// `Balance` by which the account will be reduced. - pub fn into_result(self) -> Result { + pub fn into_result(self, keep_nonzero: bool) -> Result { use WithdrawConsequence::*; match self { - NoFunds => Err(TokenError::NoFunds.into()), - WouldDie => Err(TokenError::WouldDie.into()), + BalanceLow => Err(TokenError::FundsUnavailable.into()), + WouldDie => Err(TokenError::OnlyProvider.into()), UnknownAsset => Err(TokenError::UnknownAsset.into()), Underflow => Err(ArithmeticError::Underflow.into()), Overflow => Err(ArithmeticError::Overflow.into()), Frozen => Err(TokenError::Frozen.into()), + ReducedToZero(_) if keep_nonzero => Err(TokenError::NotExpendable.into()), ReducedToZero(result) => Ok(result), Success => Ok(Zero::zero()), } diff --git a/frame/support/src/traits/tokens/pay.rs b/frame/support/src/traits/tokens/pay.rs index 1c6a147b5f22e..23bd113bfef56 100644 --- a/frame/support/src/traits/tokens/pay.rs +++ b/frame/support/src/traits/tokens/pay.rs @@ -22,7 +22,7 @@ use scale_info::TypeInfo; use sp_core::{RuntimeDebug, TypedGet}; use sp_std::fmt::Debug; -use super::{fungible, Balance}; +use super::{fungible, Balance, Preservation::Expendable}; /// Can be implemented by `PayFromAccount` using a `fungible` impl, but can also be implemented with /// XCM/MultiAsset and made generic over assets. @@ -76,9 +76,7 @@ pub enum PaymentStatus { /// Simple implementation of `Pay` which makes a payment from a "pot" - i.e. a single account. pub struct PayFromAccount(sp_std::marker::PhantomData<(F, A)>); -impl + fungible::Mutate> Pay - for PayFromAccount -{ +impl> Pay for PayFromAccount { type Balance = F::Balance; type Beneficiary = A::Type; type AssetKind = (); @@ -88,7 +86,7 @@ impl + fungible::Mutate> Pa _: Self::AssetKind, amount: Self::Balance, ) -> Result { - >::transfer(&A::get(), who, amount, false).map_err(|_| ())?; + >::transfer(&A::get(), who, amount, Expendable).map_err(|_| ())?; Ok(()) } fn check_payment(_: ()) -> PaymentStatus { diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index faa1ee5d6cf4f..88291c326edba 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -1661,10 +1661,6 @@ impl BlockNumberProvider for Pallet { } } -fn is_providing(d: &T) -> bool { - d != &T::default() -} - /// Implement StoredMap for a simple single-item, provide-when-not-default system. This works fine /// for storing a single item which allows the account to continue existing as long as it's not /// empty/default. @@ -1680,23 +1676,12 @@ impl StoredMap for Pallet { f: impl FnOnce(&mut Option) -> Result, ) -> Result { let account = Account::::get(k); - let was_providing = is_providing(&account.data); - let mut some_data = if was_providing { Some(account.data) } else { None }; + let is_default = account.data == T::AccountData::default(); + let mut some_data = if is_default { None } else { Some(account.data) }; let result = f(&mut some_data)?; - let is_providing = some_data.is_some(); - if !was_providing && is_providing { - Self::inc_providers(k); - } else if was_providing && !is_providing { - match Self::dec_providers(k)? { - DecRefStatus::Reaped => return Ok(result), - DecRefStatus::Exists => { - // Update value as normal... - }, - } - } else if !was_providing && !is_providing { - return Ok(result) + if Self::providers(k) > 0 { + Account::::mutate(k, |a| a.data = some_data.unwrap_or_default()); } - Account::::mutate(k, |a| a.data = some_data.unwrap_or_default()); Ok(result) } } diff --git a/frame/system/src/tests.rs b/frame/system/src/tests.rs index ebb28ca87bbd8..9b60c6915ab1c 100644 --- a/frame/system/src/tests.rs +++ b/frame/system/src/tests.rs @@ -37,6 +37,7 @@ fn origin_works() { #[test] fn stored_map_works() { new_test_ext().execute_with(|| { + assert_eq!(System::inc_providers(&0), IncRefStatus::Created); assert_ok!(System::insert(&0, 42)); assert!(!System::is_provider_required(&0)); @@ -56,6 +57,7 @@ fn stored_map_works() { assert!(Killed::get().is_empty()); assert_ok!(System::remove(&0)); + assert_ok!(System::dec_providers(&0)); assert_eq!(Killed::get(), vec![0u64]); }); } diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index fa4ec15014292..b2d97de18312f 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -97,6 +97,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { static TenToFourteenTestValue: Vec = vec![10,11,12,13,14]; diff --git a/frame/transaction-payment/asset-tx-payment/src/lib.rs b/frame/transaction-payment/asset-tx-payment/src/lib.rs index b9cd6ef995578..4e83d8b489b70 100644 --- a/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -42,7 +42,7 @@ use frame_support::{ dispatch::{DispatchInfo, DispatchResult, PostDispatchInfo}, traits::{ tokens::{ - fungibles::{Balanced, CreditOf, Inspect}, + fungibles::{Balanced, Credit, Inspect}, WithdrawConsequence, }, IsType, @@ -104,7 +104,7 @@ pub enum InitialPayment { /// The initial fee was payed in the native currency. Native(LiquidityInfoOf), /// The initial fee was payed in an asset. - Asset(CreditOf), + Asset(Credit), } pub use pallet::*; @@ -159,7 +159,7 @@ where AssetBalanceOf: Send + Sync + FixedPointOperand, BalanceOf: Send + Sync + FixedPointOperand + IsType>, ChargeAssetIdOf: Send + Sync, - CreditOf: IsType>, + Credit: IsType>, { /// Utility constructor. Used only in client/factory code. pub fn from(tip: BalanceOf, asset_id: Option>) -> Self { @@ -216,7 +216,7 @@ where AssetBalanceOf: Send + Sync + FixedPointOperand, BalanceOf: Send + Sync + From + FixedPointOperand + IsType>, ChargeAssetIdOf: Send + Sync, - CreditOf: IsType>, + Credit: IsType>, { const IDENTIFIER: &'static str = "ChargeAssetTxPayment"; type AccountId = T::AccountId; diff --git a/frame/transaction-payment/asset-tx-payment/src/mock.rs b/frame/transaction-payment/asset-tx-payment/src/mock.rs index cd5147c3acd13..be7baaf2b370e 100644 --- a/frame/transaction-payment/asset-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-tx-payment/src/mock.rs @@ -120,6 +120,10 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl WeightToFeeT for WeightToFee { @@ -193,7 +197,7 @@ impl pallet_authorship::Config for Runtime { pub struct CreditToBlockAuthor; impl HandleCredit for CreditToBlockAuthor { - fn handle_credit(credit: CreditOf) { + fn handle_credit(credit: Credit) { if let Some(author) = pallet_authorship::Pallet::::author() { // What to do in case paying the author fails (e.g. because `fee < min_balance`) // default: drop the result which will trigger the `OnDrop` of the imbalance. diff --git a/frame/transaction-payment/asset-tx-payment/src/payment.rs b/frame/transaction-payment/asset-tx-payment/src/payment.rs index e273ffcfc565c..f8d6888b9905c 100644 --- a/frame/transaction-payment/asset-tx-payment/src/payment.rs +++ b/frame/transaction-payment/asset-tx-payment/src/payment.rs @@ -20,8 +20,10 @@ use crate::Config; use codec::FullCodec; use frame_support::{ traits::{ - fungibles::{Balanced, CreditOf, Inspect}, - tokens::{Balance, BalanceConversion}, + fungibles::{Balanced, Credit, Inspect}, + tokens::{ + Balance, BalanceConversion, Fortitude::Polite, Precision::Exact, Preservation::Protect, + }, }, unsigned::TransactionValidityError, }; @@ -75,13 +77,13 @@ pub trait HandleCredit> { /// Implement to determine what to do with the withdrawn asset fees. /// Default for `CreditOf` from the assets pallet is to burn and /// decrease total issuance. - fn handle_credit(credit: CreditOf); + fn handle_credit(credit: Credit); } /// Default implementation that just drops the credit according to the `OnDrop` in the underlying /// imbalance type. impl> HandleCredit for () { - fn handle_credit(_credit: CreditOf) {} + fn handle_credit(_credit: Credit) {} } /// Implements the asset transaction for a balance to asset converter (implementing @@ -101,7 +103,7 @@ where { type Balance = BalanceOf; type AssetId = AssetIdOf; - type LiquidityInfo = CreditOf; + type LiquidityInfo = Credit; /// Withdraw the predicted fee from the transaction origin. /// @@ -126,8 +128,15 @@ where if !matches!(can_withdraw, WithdrawConsequence::Success) { return Err(InvalidTransaction::Payment.into()) } - >::withdraw(asset_id, who, converted_fee) - .map_err(|_| TransactionValidityError::from(InvalidTransaction::Payment)) + >::withdraw( + asset_id, + who, + converted_fee, + Exact, + Protect, + Polite, + ) + .map_err(|_| TransactionValidityError::from(InvalidTransaction::Payment)) } /// Hand the fee and the tip over to the `[HandleCredit]` implementation. diff --git a/frame/transaction-payment/asset-tx-payment/src/tests.rs b/frame/transaction-payment/asset-tx-payment/src/tests.rs index cd9891825db32..2fee9c849f4b4 100644 --- a/frame/transaction-payment/asset-tx-payment/src/tests.rs +++ b/frame/transaction-payment/asset-tx-payment/src/tests.rs @@ -28,7 +28,7 @@ use pallet_balances::Call as BalancesCall; use sp_runtime::traits::StaticLookup; const CALL: &::RuntimeCall = - &RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); + &RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 2, value: 69 }); pub struct ExtBuilder { balance_factor: u64, diff --git a/frame/transaction-payment/src/mock.rs b/frame/transaction-payment/src/mock.rs index bfb9a194f8cb2..741f094481c38 100644 --- a/frame/transaction-payment/src/mock.rs +++ b/frame/transaction-payment/src/mock.rs @@ -49,7 +49,7 @@ frame_support::construct_runtime!( ); pub(crate) const CALL: &::RuntimeCall = - &RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); + &RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 2, value: 69 }); parameter_types! { pub(crate) static ExtrinsicBaseWeight: Weight = Weight::zero(); @@ -113,6 +113,10 @@ impl pallet_balances::Config for Runtime { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl WeightToFeeT for WeightToFee { diff --git a/frame/transaction-payment/src/tests.rs b/frame/transaction-payment/src/tests.rs index 218f50e1cc95f..d5109609e2975 100644 --- a/frame/transaction-payment/src/tests.rs +++ b/frame/transaction-payment/src/tests.rs @@ -285,7 +285,7 @@ fn signed_ext_length_fee_is_also_updated_per_congestion() { #[test] fn query_info_and_fee_details_works() { - let call = RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); + let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 2, value: 69 }); let origin = 111111; let extra = (); let xt = TestXt::new(call.clone(), Some((origin, extra))); @@ -348,7 +348,7 @@ fn query_info_and_fee_details_works() { #[test] fn query_call_info_and_fee_details_works() { - let call = RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); + let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 2, value: 69 }); let info = call.get_dispatch_info(); let encoded_call = call.encode(); let len = encoded_call.len() as u32; @@ -530,7 +530,11 @@ fn refund_does_not_recreate_account() { assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 100 - 5); // kill the account between pre and post dispatch - assert_ok!(Balances::transfer(Some(2).into(), 3, Balances::free_balance(2))); + assert_ok!(Balances::transfer_allow_death( + Some(2).into(), + 3, + Balances::free_balance(2) + )); assert_eq!(Balances::free_balance(2), 0); assert_ok!(ChargeTransactionPayment::::post_dispatch( diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index f54c134d74a0e..3a87d8eaea707 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -84,6 +84,10 @@ impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); type ReserveIdentifier = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl pallet_transaction_storage::Config for Test { diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 24d2d01f92f8a..67b21ff6252a8 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -90,6 +90,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl pallet_utility::Config for Test { diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index 67d994d7933c2..bad393a489582 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -82,6 +82,10 @@ impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl Config for Test { diff --git a/frame/utility/Cargo.toml b/frame/utility/Cargo.toml index 099526d3dcb9e..c00255e3d33d8 100644 --- a/frame/utility/Cargo.toml +++ b/frame/utility/Cargo.toml @@ -47,5 +47,6 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "pallet-collective/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index d9ac2ebbc15a9..04f2728242874 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -35,6 +35,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, Hash, IdentityLookup}, + TokenError, }; type BlockNumber = u64; @@ -185,6 +186,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl pallet_root_testing::Config for Test {} @@ -226,7 +231,7 @@ impl Contains for TestBaseCallFilter { fn contains(c: &RuntimeCall) -> bool { match *c { // Transfer works. Use `transfer_keep_alive` for a call that doesn't pass the filter. - RuntimeCall::Balances(pallet_balances::Call::transfer { .. }) => true, + RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. }) => true, RuntimeCall::Utility(_) => true, // For benchmarking, this acts as a noop call RuntimeCall::System(frame_system::Call::remark { .. }) => true, @@ -253,7 +258,7 @@ type ExampleCall = example::Call; type UtilityCall = crate::Call; use frame_system::Call as SystemCall; -use pallet_balances::{Call as BalancesCall, Error as BalancesError}; +use pallet_balances::Call as BalancesCall; use pallet_root_testing::Call as RootTestingCall; use pallet_timestamp::Call as TimestampCall; @@ -278,7 +283,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { } fn call_transfer(dest: u64, value: u64) -> RuntimeCall { - RuntimeCall::Balances(BalancesCall::transfer { dest, value }) + RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest, value }) } fn call_foobar(err: bool, start_weight: Weight, end_weight: Option) -> RuntimeCall { @@ -289,10 +294,10 @@ fn call_foobar(err: bool, start_weight: Weight, end_weight: Option) -> R fn as_derivative_works() { new_test_ext().execute_with(|| { let sub_1_0 = Utility::derivative_account_id(1, 0); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), sub_1_0, 5)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1), sub_1_0, 5)); assert_err_ignore_postinfo!( Utility::as_derivative(RuntimeOrigin::signed(1), 1, Box::new(call_transfer(6, 3)),), - BalancesError::::InsufficientBalance + TokenError::FundsUnavailable, ); assert_ok!(Utility::as_derivative( RuntimeOrigin::signed(1), @@ -599,7 +604,7 @@ fn batch_all_revert() { ), pays_fee: Pays::Yes }, - error: pallet_balances::Error::::InsufficientBalance.into() + error: TokenError::FundsUnavailable.into(), } ); assert_eq!(Balances::free_balance(1), 10); diff --git a/frame/vesting/src/benchmarking.rs b/frame/vesting/src/benchmarking.rs index 35a094a9f4f19..15be519842992 100644 --- a/frame/vesting/src/benchmarking.rs +++ b/frame/vesting/src/benchmarking.rs @@ -139,6 +139,7 @@ benchmarks! { let other: T::AccountId = account("other", 0, SEED); let other_lookup = T::Lookup::unlookup(other.clone()); + T::Currency::make_free_balance_be(&other, T::Currency::minimum_balance()); add_locks::(&other, l as u8); let expected_balance = add_vesting_schedules::(other_lookup.clone(), s)?; @@ -168,6 +169,7 @@ benchmarks! { let other: T::AccountId = account("other", 0, SEED); let other_lookup = T::Lookup::unlookup(other.clone()); + T::Currency::make_free_balance_be(&other, T::Currency::minimum_balance()); add_locks::(&other, l as u8); add_vesting_schedules::(other_lookup.clone(), s)?; // At block 21 everything is unlocked. @@ -200,8 +202,10 @@ benchmarks! { let target: T::AccountId = account("target", 0, SEED); let target_lookup = T::Lookup::unlookup(target.clone()); // Give target existing locks + T::Currency::make_free_balance_be(&target, T::Currency::minimum_balance()); add_locks::(&target, l as u8); // Add one vesting schedules. + let orig_balance = T::Currency::free_balance(&target); let mut expected_balance = add_vesting_schedules::(target_lookup.clone(), s)?; let transfer_amount = T::MinVestedTransfer::get(); @@ -216,7 +220,7 @@ benchmarks! { }: _(RawOrigin::Signed(caller), target_lookup, vesting_schedule) verify { assert_eq!( - expected_balance, + orig_balance + expected_balance, T::Currency::free_balance(&target), "Transfer didn't happen", ); @@ -238,8 +242,10 @@ benchmarks! { let target: T::AccountId = account("target", 0, SEED); let target_lookup = T::Lookup::unlookup(target.clone()); // Give target existing locks + T::Currency::make_free_balance_be(&target, T::Currency::minimum_balance()); add_locks::(&target, l as u8); // Add one less than max vesting schedules + let orig_balance = T::Currency::free_balance(&target); let mut expected_balance = add_vesting_schedules::(target_lookup.clone(), s)?; let transfer_amount = T::MinVestedTransfer::get(); @@ -254,7 +260,7 @@ benchmarks! { }: _(RawOrigin::Root, source_lookup, target_lookup, vesting_schedule) verify { assert_eq!( - expected_balance, + orig_balance + expected_balance, T::Currency::free_balance(&target), "Transfer didn't happen", ); @@ -272,6 +278,7 @@ benchmarks! { let caller: T::AccountId = account("caller", 0, SEED); let caller_lookup = T::Lookup::unlookup(caller.clone()); // Give target existing locks. + T::Currency::make_free_balance_be(&caller, T::Currency::minimum_balance()); add_locks::(&caller, l as u8); // Add max vesting schedules. let expected_balance = add_vesting_schedules::(caller_lookup, s)?; @@ -322,6 +329,7 @@ benchmarks! { let caller: T::AccountId = account("caller", 0, SEED); let caller_lookup = T::Lookup::unlookup(caller.clone()); // Give target other locks. + T::Currency::make_free_balance_be(&caller, T::Currency::minimum_balance()); add_locks::(&caller, l as u8); // Add max vesting schedules. let total_transferred = add_vesting_schedules::(caller_lookup, s)?; diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index f2ad6a70025e5..be6afd4a60ec8 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -80,6 +80,10 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } parameter_types! { pub const MinVestedTransfer: u64 = 256 * 2; diff --git a/frame/vesting/src/tests.rs b/frame/vesting/src/tests.rs index efc134cab7279..46afe895f6fcc 100644 --- a/frame/vesting/src/tests.rs +++ b/frame/vesting/src/tests.rs @@ -17,7 +17,10 @@ use frame_support::{assert_noop, assert_ok, assert_storage_noop, dispatch::EncodeLike}; use frame_system::RawOrigin; -use sp_runtime::traits::{BadOrigin, Identity}; +use sp_runtime::{ + traits::{BadOrigin, Identity}, + TokenError, +}; use super::{Vesting as VestingStorage, *}; use crate::mock::{Balances, ExtBuilder, System, Test, Vesting}; @@ -180,10 +183,8 @@ fn unvested_balance_should_not_transfer() { assert_eq!(user1_free_balance, 100); // Account 1 has free balance // Account 1 has only 5 units vested at block 1 (plus 50 unvested) assert_eq!(Vesting::vesting_balance(&1), Some(45)); - assert_noop!( - Balances::transfer(Some(1).into(), 2, 56), - pallet_balances::Error::::LiquidityRestrictions, - ); // Account 1 cannot send more than vested amount + // Account 1 cannot send more than vested amount... + assert_noop!(Balances::transfer_allow_death(Some(1).into(), 2, 56), TokenError::Frozen); }); } @@ -195,7 +196,7 @@ fn vested_balance_should_transfer() { // Account 1 has only 5 units vested at block 1 (plus 50 unvested) assert_eq!(Vesting::vesting_balance(&1), Some(45)); assert_ok!(Vesting::vest(Some(1).into())); - assert_ok!(Balances::transfer(Some(1).into(), 2, 55)); + assert_ok!(Balances::transfer_allow_death(Some(1).into(), 2, 55)); }); } @@ -213,7 +214,7 @@ fn vested_balance_should_transfer_with_multi_sched() { // Account 1 has only 256 units unlocking at block 1 (plus 1280 already fee). assert_eq!(Vesting::vesting_balance(&1), Some(2304)); assert_ok!(Vesting::vest(Some(1).into())); - assert_ok!(Balances::transfer(Some(1).into(), 2, 1536)); + assert_ok!(Balances::transfer_allow_death(Some(1).into(), 2, 1536)); }); } @@ -233,7 +234,7 @@ fn vested_balance_should_transfer_using_vest_other() { // Account 1 has only 5 units vested at block 1 (plus 50 unvested) assert_eq!(Vesting::vesting_balance(&1), Some(45)); assert_ok!(Vesting::vest_other(Some(2).into(), 1)); - assert_ok!(Balances::transfer(Some(1).into(), 2, 55)); + assert_ok!(Balances::transfer_allow_death(Some(1).into(), 2, 55)); }); } @@ -251,7 +252,7 @@ fn vested_balance_should_transfer_using_vest_other_with_multi_sched() { // Account 1 has only 256 units unlocking at block 1 (plus 1280 already free). assert_eq!(Vesting::vesting_balance(&1), Some(2304)); assert_ok!(Vesting::vest_other(Some(2).into(), 1)); - assert_ok!(Balances::transfer(Some(1).into(), 2, 1536)); + assert_ok!(Balances::transfer_allow_death(Some(1).into(), 2, 1536)); }); } @@ -266,8 +267,8 @@ fn non_vested_cannot_vest_other() { #[test] fn extra_balance_should_transfer() { ExtBuilder::default().existential_deposit(10).build().execute_with(|| { - assert_ok!(Balances::transfer(Some(3).into(), 1, 100)); - assert_ok!(Balances::transfer(Some(3).into(), 2, 100)); + assert_ok!(Balances::transfer_allow_death(Some(3).into(), 1, 100)); + assert_ok!(Balances::transfer_allow_death(Some(3).into(), 2, 100)); let user1_free_balance = Balances::free_balance(&1); assert_eq!(user1_free_balance, 200); // Account 1 has 100 more free balance than normal @@ -278,12 +279,13 @@ fn extra_balance_should_transfer() { // Account 1 has only 5 units vested at block 1 (plus 150 unvested) assert_eq!(Vesting::vesting_balance(&1), Some(45)); assert_ok!(Vesting::vest(Some(1).into())); - assert_ok!(Balances::transfer(Some(1).into(), 3, 155)); // Account 1 can send extra units gained + assert_ok!(Balances::transfer_allow_death(Some(1).into(), 3, 155)); // Account 1 can send extra units gained // Account 2 has no units vested at block 1, but gained 100 assert_eq!(Vesting::vesting_balance(&2), Some(200)); assert_ok!(Vesting::vest(Some(2).into())); - assert_ok!(Balances::transfer(Some(2).into(), 3, 100)); // Account 2 can send extra units gained + assert_ok!(Balances::transfer_allow_death(Some(2).into(), 3, 100)); // Account 2 can send extra + // units gained }); } @@ -305,7 +307,7 @@ fn liquid_funds_should_transfer_with_delayed_vesting() { assert_eq!(Vesting::vesting(&12).unwrap(), vec![user12_vesting_schedule]); // Account 12 can still send liquid funds - assert_ok!(Balances::transfer(Some(12).into(), 3, 256 * 5)); + assert_ok!(Balances::transfer_allow_death(Some(12).into(), 3, 256 * 5)); }); } @@ -1144,14 +1146,11 @@ fn vested_transfer_less_than_existential_deposit_fails() { ); // vested_transfer fails. - assert_noop!( - Vesting::vested_transfer(Some(3).into(), 99, sched), - pallet_balances::Error::::ExistentialDeposit, - ); + assert_noop!(Vesting::vested_transfer(Some(3).into(), 99, sched), TokenError::BelowMinimum,); // force_vested_transfer fails. assert_noop!( Vesting::force_vested_transfer(RawOrigin::Root.into(), 3, 99, sched), - pallet_balances::Error::::ExistentialDeposit, + TokenError::BelowMinimum, ); }); } diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index b16286863d71c..d644cd661ec9f 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -86,6 +86,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type MaxHolds = (); } impl pallet_preimage::Config for Test { diff --git a/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index dc03e074f9e89..622eac3d831af 100644 --- a/primitives/runtime/src/lib.rs +++ b/primitives/runtime/src/lib.rs @@ -606,9 +606,10 @@ impl From for DispatchError { #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum TokenError { /// Funds are unavailable. - NoFunds, - /// Account that must exist would die. - WouldDie, + FundsUnavailable, + /// Some part of the balance gives the only provider reference to the account and thus cannot + /// be (re)moved. + OnlyProvider, /// Account cannot exist with the funds that would be given. BelowMinimum, /// Account cannot be created. @@ -619,18 +620,25 @@ pub enum TokenError { Frozen, /// Operation is not supported by the asset. Unsupported, + /// Account cannot be created for a held balance. + CannotCreateHold, + /// Withdrawal would cause unwanted loss of account. + NotExpendable, } impl From for &'static str { fn from(e: TokenError) -> &'static str { match e { - TokenError::NoFunds => "Funds are unavailable", - TokenError::WouldDie => "Account that must exist would die", + TokenError::FundsUnavailable => "Funds are unavailable", + TokenError::OnlyProvider => "Account that must exist would die", TokenError::BelowMinimum => "Account cannot exist with the funds that would be given", TokenError::CannotCreate => "Account cannot be created", TokenError::UnknownAsset => "The asset in question is unknown", TokenError::Frozen => "Funds exist but are frozen", TokenError::Unsupported => "Operation is not supported by the asset", + TokenError::CannotCreateHold => + "Account cannot be created for recording amount on hold", + TokenError::NotExpendable => "Account that is desired to remain would die", } } } @@ -994,8 +1002,8 @@ mod tests { Module(ModuleError { index: 2, error: [1, 0, 0, 0], message: None }), ConsumerRemaining, NoProviders, - Token(TokenError::NoFunds), - Token(TokenError::WouldDie), + Token(TokenError::FundsUnavailable), + Token(TokenError::OnlyProvider), Token(TokenError::BelowMinimum), Token(TokenError::CannotCreate), Token(TokenError::UnknownAsset), From 5f6cc69377b2bca3f123e598597a95f023d1b981 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 12:27:43 +0000 Subject: [PATCH 39/80] Bump hashbrown from 0.12.3 to 0.13.2 (#13570) Bumps [hashbrown](https://github.com/rust-lang/hashbrown) from 0.12.3 to 0.13.2. - [Release notes](https://github.com/rust-lang/hashbrown/releases) - [Changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/hashbrown/compare/v0.12.3...v0.13.2) --- updated-dependencies: - dependency-name: hashbrown 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 | 2 +- primitives/trie/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da100658bef9a..3145d736f8e2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10673,7 +10673,7 @@ dependencies = [ "array-bytes", "criterion", "hash-db", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "lazy_static", "memory-db", "nohash-hasher", diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index 21582296b67f8..0dacb76d9f27a 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -20,7 +20,7 @@ harness = false [dependencies] ahash = { version = "0.8.2", optional = true } codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } -hashbrown = { version = "0.12.3", optional = true } +hashbrown = { version = "0.13.2", optional = true } hash-db = { version = "0.16.0", default-features = false } lazy_static = { version = "1.4.0", optional = true } memory-db = { version = "0.32.0", default-features = false } From 9795fa31435426137d91936a52cab8e50ebe2f50 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 20 Mar 2023 13:34:36 +0100 Subject: [PATCH 40/80] Hotfix NIS benchmark (#13651) * Hotfix NIS rounding error Signed-off-by: Oliver Tale-Yazdi * Also fix communal Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi --- frame/nis/src/benchmarking.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frame/nis/src/benchmarking.rs b/frame/nis/src/benchmarking.rs index 0cc9e7421d0e6..10fee2abe3ba9 100644 --- a/frame/nis/src/benchmarking.rs +++ b/frame/nis/src/benchmarking.rs @@ -164,6 +164,9 @@ benchmarks! { Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), bid, 1)?; Nis::::process_queues(Perquintill::one(), 1, 2, &mut WeightCounter::unlimited()); frame_system::Pallet::::set_block_number(Receipts::::get(0).unwrap().expiry); + // FIXME: Ensure that the pallet has enough funding. This should already be the case, but + // a rounding error can cause it to fail. + T::Currency::set_balance(&Nis::::account_id(), BalanceOf::::max_value() / 10u32.into()); }: _(RawOrigin::Signed(caller.clone()), 0, None) verify { assert!(Receipts::::get(0).is_none()); @@ -182,6 +185,9 @@ benchmarks! { Nis::::process_queues(Perquintill::one(), 1, 2, &mut WeightCounter::unlimited()); frame_system::Pallet::::set_block_number(Receipts::::get(0).unwrap().expiry); Nis::::communify(RawOrigin::Signed(caller.clone()).into(), 0)?; + // FIXME: Ensure that the pallet has enough funding. This should already be the case, but + // a rounding error can cause it to fail. + T::Currency::set_balance(&Nis::::account_id(), BalanceOf::::max_value() / 10u32.into()); }: _(RawOrigin::Signed(caller.clone()), 0) verify { assert!(Receipts::::get(0).is_none()); From 97c68138e2da66bab9aabd072a92a42c9631f912 Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Wed, 15 Mar 2023 22:37:50 +0100 Subject: [PATCH 41/80] Bump ci-linux image for rust 1.68 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6cf06273650f7..f9e74364a0d6c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,7 +48,7 @@ variables: CARGO_INCREMENTAL: 0 DOCKER_OS: "debian:stretch" ARCH: "x86_64" - CI_IMAGE: "paritytech/ci-linux:production" + CI_IMAGE: "paritytech/ci-linux@sha256:7c76c3f9639f919447abbf9db535588178fde4df583d6926444d44cc20c094e6" # staging 2023-03-20 BUILDAH_IMAGE: "quay.io/buildah/stable:v1.27" RUSTY_CACHIER_SINGLE_BRANCH: master RUSTY_CACHIER_DONT_OPERATE_ON_MAIN_BRANCH: "true" From 46c06438bd457c42890be3102d5413c80c91a92f Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Wed, 15 Mar 2023 22:55:40 +0100 Subject: [PATCH 42/80] Update ui tests for rust 1.68 --- .../both_use_and_excluded_parts.stderr | 9 +++-- .../exclude_undefined_part.stderr | 9 +++-- .../no_std_genesis_config.stderr | 15 -------- .../old_unsupported_pallet_decl.stderr | 4 +-- .../undefined_genesis_config_part.stderr | 15 -------- .../undefined_inherent_part.stderr | 20 +++++------ .../undefined_origin_part.stderr | 18 ---------- .../undefined_validate_unsigned_part.stderr | 8 ++--- .../use_undefined_part.stderr | 9 +++-- .../test/tests/derive_no_bound_ui/eq.stderr | 20 +++++------ .../call_argument_invalid_bound_2.stderr | 14 +++----- .../genesis_default_not_satisfied.stderr | 18 +++++----- .../tests/pallet_ui/hooks_invalid_item.stderr | 20 +++++------ ...orage_result_query_missing_generics.stderr | 2 +- .../type_value_forgotten_where_clause.stderr | 18 +++++----- .../weight_argument_has_suffix.stderr | 34 ------------------- .../ui/impl_incorrect_method_signature.stderr | 8 ++--- ...reference_in_impl_runtime_apis_call.stderr | 4 +-- 18 files changed, 83 insertions(+), 162 deletions(-) diff --git a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr index 5f1fccd43c549..b1c1879aa56ad 100644 --- a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr +++ b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr @@ -8,9 +8,12 @@ error[E0412]: cannot find type `RuntimeCall` in this scope --> tests/construct_runtime_ui/both_use_and_excluded_parts.rs:18:64 | 18 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; - | - ^^^^^^^^^^^ not found in this scope - | | - | help: you might be missing a type parameter: `` + | ^^^^^^^^^^^ not found in this scope + | +help: you might be missing a type parameter + | +18 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; + | +++++++++++++ error[E0412]: cannot find type `Runtime` in this scope --> tests/construct_runtime_ui/both_use_and_excluded_parts.rs:20:25 diff --git a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr index c623ecfbf4cdf..66098898bb877 100644 --- a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr @@ -8,9 +8,12 @@ error[E0412]: cannot find type `RuntimeCall` in this scope --> tests/construct_runtime_ui/exclude_undefined_part.rs:23:64 | 23 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; - | - ^^^^^^^^^^^ not found in this scope - | | - | help: you might be missing a type parameter: `` + | ^^^^^^^^^^^ not found in this scope + | +help: you might be missing a type parameter + | +23 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; + | +++++++++++++ error[E0412]: cannot find type `Runtime` in this scope --> tests/construct_runtime_ui/exclude_undefined_part.rs:25:25 diff --git a/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.stderr b/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.stderr index 2cf451aa65135..cfc8c9264eec6 100644 --- a/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.stderr +++ b/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.stderr @@ -29,18 +29,3 @@ help: consider importing this struct | 1 | use frame_system::GenesisConfig; | - -error[E0283]: type annotations needed - --> tests/construct_runtime_ui/no_std_genesis_config.rs:40:1 - | -40 | / construct_runtime! { -41 | | pub struct Runtime where -42 | | Block = Block, -43 | | NodeBlock = Block, -... | -48 | | } -49 | | } - | |_^ cannot infer type - | - = note: cannot satisfy `_: std::default::Default` - = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) 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 index 6029e7e6f48bb..b1338e8920f41 100644 --- 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 @@ -18,7 +18,7 @@ error: cannot find macro `decl_storage` in this scope 6 | decl_storage! { | ^^^^^^^^^^^^ | - = note: consider importing this macro: + = help: consider importing this macro: frame_support::decl_storage error: cannot find macro `decl_module` in this scope @@ -27,5 +27,5 @@ error: cannot find macro `decl_module` in this scope 10 | decl_module! { | ^^^^^^^^^^^ | - = note: consider importing this macro: + = help: consider importing this macro: frame_support::decl_module diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr index 72099c1b94c0d..f56780c0b0c0d 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr @@ -32,18 +32,3 @@ help: consider importing this struct | 1 | use frame_system::GenesisConfig; | - -error[E0283]: type annotations needed - --> tests/construct_runtime_ui/undefined_genesis_config_part.rs:49:1 - | -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } - | |_^ cannot infer type - | - = note: cannot satisfy `_: std::default::Default` - = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr index dab6514261420..1801379130913 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr @@ -15,7 +15,7 @@ error: `Pallet` does not have #[pallet::inherent] defined, perhaps you should re | = note: this error originates in the macro `pallet::__substrate_inherent_check::is_inherent_part_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0599]: no function or associated item named `create_inherent` found for struct `pallet::Pallet` in the current scope +error[E0599]: no function or associated item named `create_inherent` found for struct `Pallet` in the current scope --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 | 11 | pub struct Pallet(_); @@ -28,14 +28,14 @@ error[E0599]: no function or associated item named `create_inherent` found for s ... | 57 | | } 58 | | } - | |_^ function or associated item not found in `pallet::Pallet` + | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `create_inherent`, perhaps you need to implement it: candidate #1: `ProvideInherent` = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0599]: no function or associated item named `is_inherent` found for struct `pallet::Pallet` in the current scope +error[E0599]: no function or associated item named `is_inherent` found for struct `Pallet` in the current scope --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 | 11 | pub struct Pallet(_); @@ -48,14 +48,14 @@ error[E0599]: no function or associated item named `is_inherent` found for struc ... | 57 | | } 58 | | } - | |_^ function or associated item not found in `pallet::Pallet` + | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `is_inherent`, perhaps you need to implement it: candidate #1: `ProvideInherent` = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0599]: no function or associated item named `check_inherent` found for struct `pallet::Pallet` in the current scope +error[E0599]: no function or associated item named `check_inherent` found for struct `Pallet` in the current scope --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 | 11 | pub struct Pallet(_); @@ -68,14 +68,14 @@ error[E0599]: no function or associated item named `check_inherent` found for st ... | 57 | | } 58 | | } - | |_^ function or associated item not found in `pallet::Pallet` + | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `check_inherent`, perhaps you need to implement it: candidate #1: `ProvideInherent` = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0599]: no associated item named `INHERENT_IDENTIFIER` found for struct `pallet::Pallet` in the current scope +error[E0599]: no associated item named `INHERENT_IDENTIFIER` found for struct `Pallet` in the current scope --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 | 11 | pub struct Pallet(_); @@ -88,14 +88,14 @@ error[E0599]: no associated item named `INHERENT_IDENTIFIER` found for struct `p ... | 57 | | } 58 | | } - | |_^ associated item not found in `pallet::Pallet` + | |_^ associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `INHERENT_IDENTIFIER`, perhaps you need to implement it: candidate #1: `ProvideInherent` = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0599]: no function or associated item named `is_inherent_required` found for struct `pallet::Pallet` in the current scope +error[E0599]: no function or associated item named `is_inherent_required` found for struct `Pallet` in the current scope --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 | 11 | pub struct Pallet(_); @@ -108,7 +108,7 @@ error[E0599]: no function or associated item named `is_inherent_required` found ... | 57 | | } 58 | | } - | |_^ function or associated item not found in `pallet::Pallet` + | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `is_inherent_required`, perhaps you need to implement it: 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 dd1bdf76106e6..dbade9fed2cff 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 @@ -32,21 +32,3 @@ help: consider importing this type alias | 1 | use frame_system::Origin; | - -error[E0282]: type annotations needed - --> tests/construct_runtime_ui/undefined_origin_part.rs:49:1 - | -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } - | |_^ cannot infer type of the type parameter `AccountId` declared on the enum `RawOrigin` - | - = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider specifying the generic argument - | -58 | }:: - | +++++++++++++ diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr index 14106ddd09c17..fa52ce2276635 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr @@ -29,7 +29,7 @@ error[E0599]: no variant or associated item named `Pallet` found for enum `Runti 58 | | } | |_- variant or associated item `Pallet` not found for this enum -error[E0599]: no function or associated item named `pre_dispatch` found for struct `pallet::Pallet` in the current scope +error[E0599]: no function or associated item named `pre_dispatch` found for struct `Pallet` in the current scope --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:49:1 | 11 | pub struct Pallet(_); @@ -42,7 +42,7 @@ error[E0599]: no function or associated item named `pre_dispatch` found for stru ... | 57 | | } 58 | | } - | |_^ function or associated item not found in `pallet::Pallet` + | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `pre_dispatch`, perhaps you need to implement one of them: @@ -50,7 +50,7 @@ error[E0599]: no function or associated item named `pre_dispatch` found for stru candidate #2: `ValidateUnsigned` = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0599]: no function or associated item named `validate_unsigned` found for struct `pallet::Pallet` in the current scope +error[E0599]: no function or associated item named `validate_unsigned` found for struct `Pallet` in the current scope --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:49:1 | 11 | pub struct Pallet(_); @@ -63,7 +63,7 @@ error[E0599]: no function or associated item named `validate_unsigned` found for ... | 57 | | } 58 | | } - | |_^ function or associated item not found in `pallet::Pallet` + | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `validate_unsigned`, perhaps you need to implement one of them: diff --git a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr index e289c75fb008a..cb6b6a44d61da 100644 --- a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr @@ -8,9 +8,12 @@ error[E0412]: cannot find type `RuntimeCall` in this scope --> tests/construct_runtime_ui/use_undefined_part.rs:23:64 | 23 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; - | - ^^^^^^^^^^^ not found in this scope - | | - | help: you might be missing a type parameter: `` + | ^^^^^^^^^^^ not found in this scope + | +help: you might be missing a type parameter + | +23 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; + | +++++++++++++ error[E0412]: cannot find type `Runtime` in this scope --> tests/construct_runtime_ui/use_undefined_part.rs:25:25 diff --git a/frame/support/test/tests/derive_no_bound_ui/eq.stderr b/frame/support/test/tests/derive_no_bound_ui/eq.stderr index 97ac29f96902d..eb3345eede508 100644 --- a/frame/support/test/tests/derive_no_bound_ui/eq.stderr +++ b/frame/support/test/tests/derive_no_bound_ui/eq.stderr @@ -1,12 +1,12 @@ error[E0277]: can't compare `Foo` with `Foo` - --> tests/derive_no_bound_ui/eq.rs:6:8 - | -6 | struct Foo { - | ^^^ no implementation for `Foo == Foo` - | - = help: the trait `PartialEq` is not implemented for `Foo` + --> tests/derive_no_bound_ui/eq.rs:6:8 + | +6 | struct Foo { + | ^^^^^^^^^^^^^^ no implementation for `Foo == Foo` + | + = help: the trait `PartialEq` is not implemented for `Foo` note: required by a bound in `std::cmp::Eq` - --> $RUST/core/src/cmp.rs - | - | pub trait Eq: PartialEq { - | ^^^^^^^^^^^^^^^ required by this bound in `std::cmp::Eq` + --> $RUST/core/src/cmp.rs + | + | pub trait Eq: PartialEq { + | ^^^^^^^^^^^^^^^ required by this bound in `Eq` diff --git a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.stderr b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.stderr index 3e2e70432a9c9..476258c03becd 100644 --- a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.stderr +++ b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.stderr @@ -23,17 +23,11 @@ error[E0369]: binary operation `==` cannot be applied to type `&::Bar: WrapperTypeEncode` is not satisfied --> tests/pallet_ui/call_argument_invalid_bound_2.rs:21:36 | -1 | / #[frame_support::pallet] -2 | | mod pallet { -3 | | use frame_support::pallet_prelude::{Hooks, DispatchResultWithPostInfo}; -4 | | use frame_system::pallet_prelude::{BlockNumberFor, OriginFor}; -... | -16 | | -17 | | #[pallet::call] - | |__________________- required by a bound introduced by this call +1 | #[frame_support::pallet] + | ------------------------ required by a bound introduced by this call ... -21 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { - | ^^^^ the trait `WrapperTypeEncode` is not implemented for `::Bar` +21 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { + | ^^^^ the trait `WrapperTypeEncode` is not implemented for `::Bar` | = note: required for `::Bar` to implement `Encode` diff --git a/frame/support/test/tests/pallet_ui/genesis_default_not_satisfied.stderr b/frame/support/test/tests/pallet_ui/genesis_default_not_satisfied.stderr index 80903928585b4..22b5ce9412ce7 100644 --- a/frame/support/test/tests/pallet_ui/genesis_default_not_satisfied.stderr +++ b/frame/support/test/tests/pallet_ui/genesis_default_not_satisfied.stderr @@ -1,14 +1,14 @@ error[E0277]: the trait bound `pallet::GenesisConfig: std::default::Default` is not satisfied - --> tests/pallet_ui/genesis_default_not_satisfied.rs:22:18 - | -22 | impl GenesisBuild for GenesisConfig {} - | ^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `pallet::GenesisConfig` - | + --> tests/pallet_ui/genesis_default_not_satisfied.rs:22:38 + | +22 | impl GenesisBuild for GenesisConfig {} + | ^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `pallet::GenesisConfig` + | note: required by a bound in `GenesisBuild` - --> $WORKSPACE/frame/support/src/traits/hooks.rs - | - | pub trait GenesisBuild: Default + sp_runtime::traits::MaybeSerializeDeserialize { - | ^^^^^^^ required by this bound in `GenesisBuild` + --> $WORKSPACE/frame/support/src/traits/hooks.rs + | + | pub trait GenesisBuild: Default + sp_runtime::traits::MaybeSerializeDeserialize { + | ^^^^^^^ required by this bound in `GenesisBuild` help: consider annotating `pallet::GenesisConfig` with `#[derive(Default)]` | 19 | #[derive(Default)] diff --git a/frame/support/test/tests/pallet_ui/hooks_invalid_item.stderr b/frame/support/test/tests/pallet_ui/hooks_invalid_item.stderr index ff52a094d6f8d..9c30179bc11ef 100644 --- a/frame/support/test/tests/pallet_ui/hooks_invalid_item.stderr +++ b/frame/support/test/tests/pallet_ui/hooks_invalid_item.stderr @@ -1,15 +1,15 @@ error[E0107]: missing generics for trait `Hooks` - --> tests/pallet_ui/hooks_invalid_item.rs:12:18 - | -12 | impl Hooks for Pallet {} - | ^^^^^ expected 1 generic argument - | + --> tests/pallet_ui/hooks_invalid_item.rs:12:18 + | +12 | impl Hooks for Pallet {} + | ^^^^^ expected 1 generic argument + | note: trait defined here, with 1 generic parameter: `BlockNumber` - --> $WORKSPACE/frame/support/src/traits/hooks.rs - | - | pub trait Hooks { - | ^^^^^ ----------- + --> $WORKSPACE/frame/support/src/traits/hooks.rs + | + | pub trait Hooks { + | ^^^^^ ----------- help: add missing generic argument | 12 | impl Hooks for Pallet {} - | ~~~~~~~~~~~~~~~~~~ + | +++++++++++++ diff --git a/frame/support/test/tests/pallet_ui/storage_result_query_missing_generics.stderr b/frame/support/test/tests/pallet_ui/storage_result_query_missing_generics.stderr index 98265462bbdfb..9e63fd03db52b 100644 --- a/frame/support/test/tests/pallet_ui/storage_result_query_missing_generics.stderr +++ b/frame/support/test/tests/pallet_ui/storage_result_query_missing_generics.stderr @@ -12,4 +12,4 @@ note: enum defined here, with 1 generic parameter: `T` help: add missing generic argument | 17 | type Foo = StorageValue<_, u8, ResultQuery::NonExistentValue>>; - | ~~~~~~~~ + | +++ diff --git a/frame/support/test/tests/pallet_ui/type_value_forgotten_where_clause.stderr b/frame/support/test/tests/pallet_ui/type_value_forgotten_where_clause.stderr index 6288dcd534b60..4b4c78b148455 100644 --- a/frame/support/test/tests/pallet_ui/type_value_forgotten_where_clause.stderr +++ b/frame/support/test/tests/pallet_ui/type_value_forgotten_where_clause.stderr @@ -1,52 +1,52 @@ error[E0277]: the trait bound `::AccountId: From` is not satisfied - --> $DIR/type_value_forgotten_where_clause.rs:24:34 + --> tests/pallet_ui/type_value_forgotten_where_clause.rs:24:34 | 24 | #[pallet::type_value] fn Foo() -> u32 { 3u32 } | ^^^^^^ the trait `From` is not implemented for `::AccountId` | note: required by a bound in `pallet::Config` - --> $DIR/type_value_forgotten_where_clause.rs:8:51 + --> tests/pallet_ui/type_value_forgotten_where_clause.rs:8:51 | 7 | pub trait Config: frame_system::Config | ------ required by a bound in this 8 | where ::AccountId: From - | ^^^^^^^^^ required by this bound in `pallet::Config` + | ^^^^^^^^^ required by this bound in `Config` help: consider further restricting the associated type | 24 | #[pallet::type_value] fn Foo() -> u32 where ::AccountId: From { 3u32 } | +++++++++++++++++++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `::AccountId: From` is not satisfied - --> $DIR/type_value_forgotten_where_clause.rs:24:12 + --> tests/pallet_ui/type_value_forgotten_where_clause.rs:24:12 | 24 | #[pallet::type_value] fn Foo() -> u32 { 3u32 } | ^^^^^^^^^^ the trait `From` is not implemented for `::AccountId` | note: required by a bound in `pallet::Config` - --> $DIR/type_value_forgotten_where_clause.rs:8:51 + --> tests/pallet_ui/type_value_forgotten_where_clause.rs:8:51 | 7 | pub trait Config: frame_system::Config | ------ required by a bound in this 8 | where ::AccountId: From - | ^^^^^^^^^ required by this bound in `pallet::Config` + | ^^^^^^^^^ required by this bound in `Config` help: consider further restricting the associated type | 24 | #[pallet::type_value where ::AccountId: From] fn Foo() -> u32 { 3u32 } | +++++++++++++++++++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `::AccountId: From` is not satisfied - --> $DIR/type_value_forgotten_where_clause.rs:24:12 + --> tests/pallet_ui/type_value_forgotten_where_clause.rs:24:12 | 24 | #[pallet::type_value] fn Foo() -> u32 { 3u32 } | ^^^^^^^^^^ the trait `From` is not implemented for `::AccountId` | note: required by a bound in `pallet::Config` - --> $DIR/type_value_forgotten_where_clause.rs:8:51 + --> tests/pallet_ui/type_value_forgotten_where_clause.rs:8:51 | 7 | pub trait Config: frame_system::Config | ------ required by a bound in this 8 | where ::AccountId: From - | ^^^^^^^^^ required by this bound in `pallet::Config` + | ^^^^^^^^^ required by this bound in `Config` help: consider further restricting the associated type | 24 | #[pallet::type_value] fn Foo() -> u32 where ::AccountId: From { 3u32 } diff --git a/frame/support/test/tests/pallet_ui/weight_argument_has_suffix.stderr b/frame/support/test/tests/pallet_ui/weight_argument_has_suffix.stderr index c9b2010f88bb3..df9b0798ab93d 100644 --- a/frame/support/test/tests/pallet_ui/weight_argument_has_suffix.stderr +++ b/frame/support/test/tests/pallet_ui/weight_argument_has_suffix.stderr @@ -5,37 +5,3 @@ error: invalid suffix `something` for number literal | ^^^^^^^^^^^^^^^ invalid suffix `something` | = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) - -error[E0308]: mismatched types - --> tests/pallet_ui/weight_argument_has_suffix.rs:12:12 - | -12 | #[pallet::call] - | ^^^^ - | | - | expected trait `frame_support::dispatch::ClassifyDispatch`, found trait `frame_support::dispatch::WeighData` - | arguments to this function are incorrect - | - = note: expected reference `&dyn frame_support::dispatch::ClassifyDispatch<()>` - found reference `&dyn frame_support::dispatch::WeighData<()>` -note: associated function defined here - --> $WORKSPACE/frame/support/src/dispatch.rs - | - | fn classify_dispatch(&self, target: T) -> DispatchClass; - | ^^^^^^^^^^^^^^^^^ - -error[E0308]: mismatched types - --> tests/pallet_ui/weight_argument_has_suffix.rs:12:12 - | -12 | #[pallet::call] - | ^^^^ - | | - | expected trait `frame_support::dispatch::PaysFee`, found trait `frame_support::dispatch::WeighData` - | arguments to this function are incorrect - | - = note: expected reference `&dyn frame_support::dispatch::PaysFee<()>` - found reference `&dyn frame_support::dispatch::WeighData<()>` -note: associated function defined here - --> $WORKSPACE/frame/support/src/dispatch.rs - | - | fn pays_fee(&self, _target: T) -> Pays; - | ^^^^^^^^ diff --git a/primitives/api/test/tests/ui/impl_incorrect_method_signature.stderr b/primitives/api/test/tests/ui/impl_incorrect_method_signature.stderr index f5b6ac1da4576..5b36248228bff 100644 --- a/primitives/api/test/tests/ui/impl_incorrect_method_signature.stderr +++ b/primitives/api/test/tests/ui/impl_incorrect_method_signature.stderr @@ -4,7 +4,7 @@ error[E0053]: method `test` has an incompatible type for trait 19 | fn test(data: String) {} | ^^^^^^ | | - | expected `u64`, found struct `std::string::String` + | expected `u64`, found struct `String` | help: change the parameter type to match the trait: `u64` | note: type in trait @@ -12,8 +12,8 @@ note: type in trait | 13 | fn test(data: u64); | ^^^ - = note: expected fn pointer `fn(u64)` - found fn pointer `fn(std::string::String)` + = note: expected signature `fn(u64)` + found signature `fn(std::string::String)` error[E0308]: mismatched types --> tests/ui/impl_incorrect_method_signature.rs:19:11 @@ -21,7 +21,7 @@ error[E0308]: mismatched types 17 | / sp_api::impl_runtime_apis! { 18 | | impl self::Api for Runtime { 19 | | fn test(data: String) {} - | | ^^^^ expected `u64`, found struct `std::string::String` + | | ^^^^ expected `u64`, found struct `String` 20 | | } ... | 32 | | } diff --git a/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr b/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr index 06f8226ec88bf..1515bd3a1208f 100644 --- a/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr +++ b/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr @@ -12,8 +12,8 @@ note: type in trait | 13 | fn test(data: u64); | ^^^ - = note: expected fn pointer `fn(u64)` - found fn pointer `fn(&u64)` + = note: expected signature `fn(u64)` + found signature `fn(&u64)` error[E0308]: mismatched types --> tests/ui/type_reference_in_impl_runtime_apis_call.rs:19:11 From ba9582568d5550c50adc9f5e3626f06eb8a5133b Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Thu, 16 Mar 2023 15:38:06 +0100 Subject: [PATCH 43/80] address clippy & rustdoc warnings The comment was out of date anyway, State::Live no longer takes a snapshot_path argument. --- client/state-db/src/lib.rs | 2 +- primitives/runtime/src/offchain/http.rs | 2 +- primitives/trie/src/lib.rs | 7 ++----- utils/frame/try-runtime/cli/src/lib.rs | 2 -- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/client/state-db/src/lib.rs b/client/state-db/src/lib.rs index 5ebfbaad6d8f6..b41240d629b91 100644 --- a/client/state-db/src/lib.rs +++ b/client/state-db/src/lib.rs @@ -406,7 +406,7 @@ impl StateDbSync { } fn prune(&mut self, commit: &mut CommitSet) -> Result<(), Error> { - if let (&mut Some(ref mut pruning), &PruningMode::Constrained(ref constraints)) = + if let (&mut Some(ref mut pruning), PruningMode::Constrained(constraints)) = (&mut self.pruning, &self.mode) { loop { diff --git a/primitives/runtime/src/offchain/http.rs b/primitives/runtime/src/offchain/http.rs index 0229203c1de5f..25e5c1007d5da 100644 --- a/primitives/runtime/src/offchain/http.rs +++ b/primitives/runtime/src/offchain/http.rs @@ -450,7 +450,7 @@ impl Headers { /// and collect them on your own. pub fn find(&self, name: &str) -> Option<&str> { let raw = name.as_bytes(); - for &(ref key, ref val) in &self.raw { + for (key, val) in &self.raw { if &**key == raw { return str::from_utf8(val).ok() } diff --git a/primitives/trie/src/lib.rs b/primitives/trie/src/lib.rs index 175fb32d4e851..94155458569bf 100644 --- a/primitives/trie/src/lib.rs +++ b/primitives/trie/src/lib.rs @@ -647,7 +647,7 @@ mod tests { count: 1000, }; let mut d = st.make(); - d.sort_by(|&(ref a, _), &(ref b, _)| a.cmp(b)); + d.sort_by(|(a, _), (b, _)| a.cmp(b)); let dr = d.iter().map(|v| (&v.0[..], &v.1[..])).collect(); check_input(&dr); } @@ -716,10 +716,7 @@ mod tests { t } - fn unpopulate_trie<'db, T: TrieConfiguration>( - t: &mut TrieDBMut<'db, T>, - v: &[(Vec, Vec)], - ) { + fn unpopulate_trie(t: &mut TrieDBMut<'_, T>, v: &[(Vec, Vec)]) { for i in v { let key: &[u8] = &i.0; t.remove(key).unwrap(); diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index e1d75064ac87f..bd914d3a2e017 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -599,8 +599,6 @@ pub struct LiveState { #[derive(Debug, Clone, clap::Subcommand)] pub enum State { /// Use a state snapshot as the source of runtime state. - /// - /// This can be crated by passing a value to [`State::Live::snapshot_path`]. Snap { #[arg(short, long)] snapshot_path: PathBuf, From 9d2d020c5134d8c7870396cb04bca63a674abfd5 Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Mon, 20 Mar 2023 19:21:26 +0100 Subject: [PATCH 44/80] Keystore overhaul (iter 2) (#13634) * Remove bloat about remote keystore * Update docs and remove unused 'KeystoreRef' trait * Use wherever possible, MemoryKeystore for testing * Remove unrequired fully qualified method syntax for Keystore --- Cargo.lock | 1 - bin/node-template/node/src/service.rs | 24 +----- bin/node/cli/benches/block_production.rs | 1 - bin/node/cli/benches/transaction_pool.rs | 1 - bin/node/cli/src/service.rs | 35 +++++---- bin/node/executor/tests/submit_transaction.rs | 63 ++++++--------- bin/utils/chain-spec-builder/src/main.rs | 12 +-- .../authority-discovery/src/worker/tests.rs | 4 +- client/cli/src/commands/insert_key.rs | 11 +-- client/cli/src/config.rs | 7 +- client/cli/src/params/keystore_params.rs | 6 +- client/cli/src/runner.rs | 1 - client/consensus/aura/src/lib.rs | 49 ++++++------ client/consensus/babe/rpc/Cargo.toml | 1 - client/consensus/babe/rpc/src/lib.rs | 29 +++---- client/consensus/babe/src/authorship.rs | 32 +++----- client/consensus/babe/src/lib.rs | 25 +++--- client/consensus/babe/src/tests.rs | 19 +++-- .../beefy/src/communication/gossip.rs | 16 ++-- client/consensus/beefy/src/keystore.rs | 61 +++++++-------- client/consensus/beefy/src/tests.rs | 7 +- client/consensus/grandpa/src/lib.rs | 4 +- client/consensus/grandpa/src/tests.rs | 7 +- client/keystore/src/local.rs | 43 ++++++----- client/rpc/src/author/mod.rs | 9 ++- client/rpc/src/author/tests.rs | 8 +- client/service/src/builder.rs | 60 +++------------ client/service/src/config.rs | 2 - client/service/test/src/lib.rs | 1 - frame/benchmarking/src/baseline.rs | 5 +- frame/contracts/src/tests.rs | 4 +- frame/examples/offchain-worker/src/tests.rs | 44 ++++------- frame/nfts/src/mock.rs | 4 +- .../application-crypto/test/src/ecdsa.rs | 2 +- .../application-crypto/test/src/ed25519.rs | 2 +- .../application-crypto/test/src/sr25519.rs | 2 +- primitives/consensus/beefy/src/commitment.rs | 12 +-- primitives/consensus/beefy/src/witness.rs | 13 +--- primitives/consensus/grandpa/src/lib.rs | 18 ++--- primitives/io/src/lib.rs | 77 +++++++++---------- primitives/keystore/src/lib.rs | 9 ++- primitives/keystore/src/testing.rs | 28 +++---- .../benchmarking-cli/src/pallet/command.rs | 7 +- utils/frame/try-runtime/cli/src/lib.rs | 3 +- 44 files changed, 312 insertions(+), 457 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3145d736f8e2f..4928873566627 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8438,7 +8438,6 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-test-runtime-client", - "tempfile", "thiserror", "tokio", ] diff --git a/bin/node-template/node/src/service.rs b/bin/node-template/node/src/service.rs index 40ad80c7b3b79..dfbb5e96354e4 100644 --- a/bin/node-template/node/src/service.rs +++ b/bin/node-template/node/src/service.rs @@ -5,7 +5,6 @@ use sc_client_api::BlockBackend; use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams}; use sc_consensus_grandpa::SharedVoterState; pub use sc_executor::NativeElseWasmExecutor; -use sc_keystore::LocalKeystore; use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams}; use sc_telemetry::{Telemetry, TelemetryWorker}; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; @@ -58,10 +57,6 @@ pub fn new_partial( >, ServiceError, > { - if config.keystore_remote.is_some() { - return Err(ServiceError::Other("Remote Keystores are not supported.".into())) - } - let telemetry = config .telemetry_endpoints .clone() @@ -147,13 +142,6 @@ pub fn new_partial( }) } -fn remote_keystore(_url: &String) -> Result, &'static str> { - // FIXME: here would the concrete keystore be built, - // must return a concrete type (NOT `LocalKeystore`) that - // implements `Keystore` - Err("Remote Keystore not supported.") -} - /// Builds a new service for a full client. pub fn new_full(mut config: Configuration) -> Result { let sc_service::PartialComponents { @@ -161,22 +149,12 @@ pub fn new_full(mut config: Configuration) -> Result backend, mut task_manager, import_queue, - mut keystore_container, + keystore_container, select_chain, transaction_pool, other: (block_import, grandpa_link, mut telemetry), } = new_partial(&config)?; - if let Some(url) = &config.keystore_remote { - match remote_keystore(url) { - Ok(k) => keystore_container.set_remote_keystore(k), - Err(e) => - return Err(ServiceError::Other(format!( - "Error hooking up remote keystore for {}: {}", - url, e - ))), - }; - } let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name( &client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"), &config.chain_spec, diff --git a/bin/node/cli/benches/block_production.rs b/bin/node/cli/benches/block_production.rs index f1c65955eaef8..c7f0cd20efd5b 100644 --- a/bin/node/cli/benches/block_production.rs +++ b/bin/node/cli/benches/block_production.rs @@ -69,7 +69,6 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase { transaction_pool: Default::default(), network: network_config, keystore: KeystoreConfig::InMemory, - keystore_remote: Default::default(), database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 }, trie_cache_maximum_size: Some(64 * 1024 * 1024), state_pruning: Some(PruningMode::ArchiveAll), diff --git a/bin/node/cli/benches/transaction_pool.rs b/bin/node/cli/benches/transaction_pool.rs index 72c1c81608e13..7488ec03363e7 100644 --- a/bin/node/cli/benches/transaction_pool.rs +++ b/bin/node/cli/benches/transaction_pool.rs @@ -64,7 +64,6 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase { }, network: network_config, keystore: KeystoreConfig::InMemory, - keystore_remote: Default::default(), database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 }, trie_cache_maximum_size: Some(64 * 1024 * 1024), state_pruning: Some(PruningMode::ArchiveAll), diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index d32223339dc4a..be8553b7b3a98 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -595,7 +595,7 @@ mod tests { use sp_core::{crypto::Pair as CryptoPair, Public}; use sp_inherents::InherentDataProvider; use sp_keyring::AccountKeyring; - use sp_keystore::{Keystore, KeystorePtr}; + use sp_keystore::KeystorePtr; use sp_runtime::{ generic::{Digest, Era, SignedPayload}, key_types::BABE, @@ -615,12 +615,13 @@ mod tests { sp_tracing::try_init_simple(); let keystore_path = tempfile::tempdir().expect("Creates keystore path"); - let keystore: KeystorePtr = - Arc::new(LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore")); - let alice: sp_consensus_babe::AuthorityId = - Keystore::sr25519_generate_new(&*keystore, BABE, Some("//Alice")) - .expect("Creates authority pair") - .into(); + let keystore: KeystorePtr = LocalKeystore::open(keystore_path.path(), None) + .expect("Creates keystore") + .into(); + let alice: sp_consensus_babe::AuthorityId = keystore + .sr25519_generate_new(BABE, Some("//Alice")) + .expect("Creates authority pair") + .into(); let chain_spec = crate::chain_spec::tests::integration_test_config_with_single_authority(); @@ -735,16 +736,16 @@ mod tests { // sign the pre-sealed hash of the block and then // add it to a digest item. let to_sign = pre_hash.encode(); - let signature = Keystore::sign_with( - &*keystore, - sp_consensus_babe::AuthorityId::ID, - &alice.to_public_crypto_pair(), - &to_sign, - ) - .unwrap() - .unwrap() - .try_into() - .unwrap(); + let signature = keystore + .sign_with( + sp_consensus_babe::AuthorityId::ID, + &alice.to_public_crypto_pair(), + &to_sign, + ) + .unwrap() + .unwrap() + .try_into() + .unwrap(); let item = ::babe_seal(signature); slot += 1; diff --git a/bin/node/executor/tests/submit_transaction.rs b/bin/node/executor/tests/submit_transaction.rs index a3d6681fb6928..9bff415d27e45 100644 --- a/bin/node/executor/tests/submit_transaction.rs +++ b/bin/node/executor/tests/submit_transaction.rs @@ -22,7 +22,6 @@ use sp_application_crypto::AppKey; use sp_core::offchain::{testing::TestTransactionPoolExt, TransactionPoolExt}; use sp_keyring::sr25519::Keyring::Alice; use sp_keystore::{testing::MemoryKeystore, Keystore, KeystoreExt}; -use std::sync::Arc; pub mod common; use self::common::*; @@ -63,25 +62,16 @@ fn should_submit_signed_transaction() { t.register_extension(TransactionPoolExt::new(pool)); let keystore = MemoryKeystore::new(); - Keystore::sr25519_generate_new( - &keystore, - sr25519::AuthorityId::ID, - Some(&format!("{}/hunter1", PHRASE)), - ) - .unwrap(); - Keystore::sr25519_generate_new( - &keystore, - sr25519::AuthorityId::ID, - Some(&format!("{}/hunter2", PHRASE)), - ) - .unwrap(); - Keystore::sr25519_generate_new( - &keystore, - sr25519::AuthorityId::ID, - Some(&format!("{}/hunter3", PHRASE)), - ) - .unwrap(); - t.register_extension(KeystoreExt(Arc::new(keystore))); + keystore + .sr25519_generate_new(sr25519::AuthorityId::ID, Some(&format!("{}/hunter1", PHRASE))) + .unwrap(); + keystore + .sr25519_generate_new(sr25519::AuthorityId::ID, Some(&format!("{}/hunter2", PHRASE))) + .unwrap(); + keystore + .sr25519_generate_new(sr25519::AuthorityId::ID, Some(&format!("{}/hunter3", PHRASE))) + .unwrap(); + t.register_extension(KeystoreExt::new(keystore)); t.execute_with(|| { let results = @@ -106,19 +96,13 @@ fn should_submit_signed_twice_from_the_same_account() { t.register_extension(TransactionPoolExt::new(pool)); let keystore = MemoryKeystore::new(); - Keystore::sr25519_generate_new( - &keystore, - sr25519::AuthorityId::ID, - Some(&format!("{}/hunter1", PHRASE)), - ) - .unwrap(); - Keystore::sr25519_generate_new( - &keystore, - sr25519::AuthorityId::ID, - Some(&format!("{}/hunter2", PHRASE)), - ) - .unwrap(); - t.register_extension(KeystoreExt(Arc::new(keystore))); + keystore + .sr25519_generate_new(sr25519::AuthorityId::ID, Some(&format!("{}/hunter1", PHRASE))) + .unwrap(); + keystore + .sr25519_generate_new(sr25519::AuthorityId::ID, Some(&format!("{}/hunter2", PHRASE))) + .unwrap(); + t.register_extension(KeystoreExt::new(keystore)); t.execute_with(|| { let result = @@ -169,7 +153,7 @@ fn should_submit_signed_twice_from_all_accounts() { keystore .sr25519_generate_new(sr25519::AuthorityId::ID, Some(&format!("{}/hunter2", PHRASE))) .unwrap(); - t.register_extension(KeystoreExt(Arc::new(keystore))); + t.register_extension(KeystoreExt::new(keystore)); t.execute_with(|| { let results = Signer::::all_accounts() @@ -227,13 +211,10 @@ fn submitted_transaction_should_be_valid() { t.register_extension(TransactionPoolExt::new(pool)); let keystore = MemoryKeystore::new(); - Keystore::sr25519_generate_new( - &keystore, - sr25519::AuthorityId::ID, - Some(&format!("{}/hunter1", PHRASE)), - ) - .unwrap(); - t.register_extension(KeystoreExt(Arc::new(keystore))); + keystore + .sr25519_generate_new(sr25519::AuthorityId::ID, Some(&format!("{}/hunter1", PHRASE))) + .unwrap(); + t.register_extension(KeystoreExt::new(keystore)); t.execute_with(|| { let results = diff --git a/bin/utils/chain-spec-builder/src/main.rs b/bin/utils/chain-spec-builder/src/main.rs index f7b7d94c57d1c..f94fca1c1638d 100644 --- a/bin/utils/chain-spec-builder/src/main.rs +++ b/bin/utils/chain-spec-builder/src/main.rs @@ -19,7 +19,6 @@ use std::{ fs, path::{Path, PathBuf}, - sync::Arc, }; use ansi_term::Style; @@ -32,7 +31,7 @@ use sp_core::{ crypto::{ByteArray, Ss58Codec}, sr25519, }; -use sp_keystore::{Keystore, KeystorePtr}; +use sp_keystore::KeystorePtr; /// A utility to easily create a testnet chain spec definition with a given set /// of authorities and endowed accounts and/or generate random accounts. @@ -164,16 +163,17 @@ fn generate_chain_spec( fn generate_authority_keys_and_store(seeds: &[String], keystore_path: &Path) -> Result<(), String> { for (n, seed) in seeds.iter().enumerate() { - let keystore: KeystorePtr = Arc::new( + let keystore: KeystorePtr = LocalKeystore::open(keystore_path.join(format!("auth-{}", n)), None) - .map_err(|err| err.to_string())?, - ); + .map_err(|err| err.to_string())? + .into(); let (_, _, grandpa, babe, im_online, authority_discovery) = chain_spec::authority_keys_from_seed(seed); let insert_key = |key_type, public| { - Keystore::insert(&*keystore, key_type, &format!("//{}", seed), public) + keystore + .insert(key_type, &format!("//{}", seed), public) .map_err(|_| format!("Failed to insert key: {}", grandpa)) }; diff --git a/client/authority-discovery/src/worker/tests.rs b/client/authority-discovery/src/worker/tests.rs index c918d79932624..49055fec51611 100644 --- a/client/authority-discovery/src/worker/tests.rs +++ b/client/authority-discovery/src/worker/tests.rs @@ -697,7 +697,7 @@ fn addresses_to_publish_adds_p2p() { Arc::new(TestApi { authorities: vec![] }), network.clone(), Box::pin(dht_event_rx), - Role::PublishAndDiscover(Arc::new(MemoryKeystore::new())), + Role::PublishAndDiscover(MemoryKeystore::new().into()), Some(prometheus_endpoint::Registry::new()), Default::default(), ); @@ -731,7 +731,7 @@ fn addresses_to_publish_respects_existing_p2p_protocol() { Arc::new(TestApi { authorities: vec![] }), network.clone(), Box::pin(dht_event_rx), - Role::PublishAndDiscover(Arc::new(MemoryKeystore::new())), + Role::PublishAndDiscover(MemoryKeystore::new().into()), Some(prometheus_endpoint::Registry::new()), Default::default(), ); diff --git a/client/cli/src/commands/insert_key.rs b/client/cli/src/commands/insert_key.rs index b02c0181d43a2..e80058d44a5af 100644 --- a/client/cli/src/commands/insert_key.rs +++ b/client/cli/src/commands/insert_key.rs @@ -24,8 +24,7 @@ use clap::Parser; use sc_keystore::LocalKeystore; use sc_service::config::{BasePath, KeystoreConfig}; use sp_core::crypto::{KeyTypeId, SecretString}; -use sp_keystore::{Keystore, KeystorePtr}; -use std::sync::Arc; +use sp_keystore::KeystorePtr; /// The `insert` command #[derive(Debug, Clone, Parser)] @@ -67,9 +66,9 @@ impl InsertKeyCmd { let config_dir = base_path.config_dir(chain_spec.id()); let (keystore, public) = match self.keystore_params.keystore_config(&config_dir)? { - (_, KeystoreConfig::Path { path, password }) => { + KeystoreConfig::Path { path, password } => { let public = with_crypto_scheme!(self.scheme, to_vec(&suri, password.clone()))?; - let keystore: KeystorePtr = Arc::new(LocalKeystore::open(path, password)?); + let keystore: KeystorePtr = LocalKeystore::open(path, password)?.into(); (keystore, public) }, _ => unreachable!("keystore_config always returns path and password; qed"), @@ -78,7 +77,8 @@ impl InsertKeyCmd { let key_type = KeyTypeId::try_from(self.key_type.as_str()).map_err(|_| Error::KeyTypeInvalid)?; - Keystore::insert(&*keystore, key_type, &suri, &public[..]) + keystore + .insert(key_type, &suri, &public[..]) .map_err(|_| Error::KeystoreOperation)?; Ok(()) @@ -95,6 +95,7 @@ mod tests { use super::*; use sc_service::{ChainSpec, ChainType, GenericChainSpec, NoExtension}; use sp_core::{sr25519::Pair, ByteArray, Pair as _}; + use sp_keystore::Keystore; use tempfile::TempDir; struct Cli; diff --git a/client/cli/src/config.rs b/client/cli/src/config.rs index 5fedcf99a12ef..063b2c39839f4 100644 --- a/client/cli/src/config.rs +++ b/client/cli/src/config.rs @@ -185,10 +185,10 @@ pub trait CliConfiguration: Sized { /// /// By default this is retrieved from `KeystoreParams` if it is available. Otherwise it uses /// `KeystoreConfig::InMemory`. - fn keystore_config(&self, config_dir: &PathBuf) -> Result<(Option, KeystoreConfig)> { + fn keystore_config(&self, config_dir: &PathBuf) -> Result { self.keystore_params() .map(|x| x.keystore_config(config_dir)) - .unwrap_or_else(|| Ok((None, KeystoreConfig::InMemory))) + .unwrap_or_else(|| Ok(KeystoreConfig::InMemory)) } /// Get the database cache size. @@ -505,7 +505,7 @@ pub trait CliConfiguration: Sized { let role = self.role(is_dev)?; let max_runtime_instances = self.max_runtime_instances()?.unwrap_or(8); let is_validator = role.is_authority(); - let (keystore_remote, keystore) = self.keystore_config(&config_dir)?; + let keystore = self.keystore_config(&config_dir)?; let telemetry_endpoints = self.telemetry_endpoints(&chain_spec)?; let runtime_cache_size = self.runtime_cache_size()?; @@ -524,7 +524,6 @@ pub trait CliConfiguration: Sized { node_key, DCV::p2p_listen_port(), )?, - keystore_remote, keystore, database: self.database_config(&config_dir, database_cache_size, database)?, trie_cache_maximum_size: self.trie_cache_maximum_size()?, diff --git a/client/cli/src/params/keystore_params.rs b/client/cli/src/params/keystore_params.rs index e6e6fd9eb47ed..8933110c400b7 100644 --- a/client/cli/src/params/keystore_params.rs +++ b/client/cli/src/params/keystore_params.rs @@ -68,9 +68,7 @@ pub fn secret_string_from_str(s: &str) -> std::result::Result Result<(Option, KeystoreConfig)> { + pub fn keystore_config(&self, config_dir: &Path) -> Result { let password = if self.password_interactive { Some(SecretString::new(input_keystore_password()?)) } else if let Some(ref file) = self.password_filename { @@ -85,7 +83,7 @@ impl KeystoreParams { .clone() .unwrap_or_else(|| config_dir.join(DEFAULT_KEYSTORE_CONFIG_PATH)); - Ok((self.keystore_uri.clone(), KeystoreConfig::Path { path, password })) + Ok(KeystoreConfig::Path { path, password }) } /// helper method to fetch password from `KeyParams` or read from stdin diff --git a/client/cli/src/runner.rs b/client/cli/src/runner.rs index 47adfcf89fe99..3d216aef4a75c 100644 --- a/client/cli/src/runner.rs +++ b/client/cli/src/runner.rs @@ -345,7 +345,6 @@ mod tests { transaction_pool: Default::default(), network: NetworkConfiguration::new_memory(), keystore: sc_service::config::KeystoreConfig::InMemory, - keystore_remote: None, database: sc_client_db::DatabaseSource::ParityDb { path: PathBuf::from("db") }, trie_cache_maximum_size: None, state_pruning: None, diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index 8cdad148d6ef4..d06a6016a2297 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -51,7 +51,7 @@ use sp_consensus::{BlockOrigin, Environment, Error as ConsensusError, Proposer, use sp_consensus_slots::Slot; use sp_core::crypto::{ByteArray, Pair, Public}; use sp_inherents::CreateInherentDataProviders; -use sp_keystore::{Keystore, KeystorePtr}; +use sp_keystore::KeystorePtr; use sp_runtime::{ traits::{Block as BlockT, Header, Member, NumberFor, Zero}, DigestItem, @@ -418,10 +418,10 @@ where ) -> Option { let expected_author = slot_author::

(slot, epoch_data); expected_author.and_then(|p| { - if Keystore::has_keys( - &*self.keystore, - &[(p.to_raw_vec(), sp_application_crypto::key_types::AURA)], - ) { + if self + .keystore + .has_keys(&[(p.to_raw_vec(), sp_application_crypto::key_types::AURA)]) + { Some(p.clone()) } else { None @@ -449,19 +449,16 @@ where // add it to a digest item. let public_type_pair = public.to_public_crypto_pair(); let public = public.to_raw_vec(); - let signature = Keystore::sign_with( - &*self.keystore, - as AppKey>::ID, - &public_type_pair, - header_hash.as_ref(), - ) - .map_err(|e| sp_consensus::Error::CannotSign(public.clone(), e.to_string()))? - .ok_or_else(|| { - sp_consensus::Error::CannotSign( - public.clone(), - "Could not find key in keystore.".into(), - ) - })?; + let signature = self + .keystore + .sign_with( as AppKey>::ID, &public_type_pair, header_hash.as_ref()) + .map_err(|e| sp_consensus::Error::CannotSign(public.clone(), e.to_string()))? + .ok_or_else(|| { + sp_consensus::Error::CannotSign( + public.clone(), + "Could not find key in keystore.".into(), + ) + })?; let signature = signature .clone() .try_into() @@ -648,6 +645,7 @@ mod tests { use sp_consensus_aura::sr25519::AuthorityPair; use sp_inherents::InherentData; use sp_keyring::sr25519::Keyring; + use sp_keystore::Keystore; use sp_runtime::{ traits::{Block as BlockT, Header as _}, Digest, @@ -798,7 +796,8 @@ mod tests { LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore."), ); - Keystore::sr25519_generate_new(&*keystore, AURA, Some(&key.to_seed())) + keystore + .sr25519_generate_new(AURA, Some(&key.to_seed())) .expect("Creates authority key"); keystore_paths.push(keystore_path); @@ -883,7 +882,8 @@ mod tests { let keystore_path = tempfile::tempdir().expect("Creates keystore path"); let keystore = LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore."); - let public = Keystore::sr25519_generate_new(&keystore, AuthorityPair::ID, None) + let public = keystore + .sr25519_generate_new(AuthorityPair::ID, None) .expect("Key should be created"); authorities.push(public.into()); @@ -933,12 +933,9 @@ mod tests { let keystore_path = tempfile::tempdir().expect("Creates keystore path"); let keystore = LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore."); - Keystore::sr25519_generate_new( - &keystore, - AuthorityPair::ID, - Some(&Keyring::Alice.to_seed()), - ) - .expect("Key should be created"); + keystore + .sr25519_generate_new(AuthorityPair::ID, Some(&Keyring::Alice.to_seed())) + .expect("Key should be created"); let net = Arc::new(Mutex::new(net)); diff --git a/client/consensus/babe/rpc/Cargo.toml b/client/consensus/babe/rpc/Cargo.toml index 4f5aaf85494b9..f81a14a97c758 100644 --- a/client/consensus/babe/rpc/Cargo.toml +++ b/client/consensus/babe/rpc/Cargo.toml @@ -31,7 +31,6 @@ sp-runtime = { version = "7.0.0", path = "../../../../primitives/runtime" } [dev-dependencies] serde_json = "1.0.85" -tempfile = "3.1.0" tokio = "1.22.0" sc-consensus = { version = "0.10.0-dev", path = "../../../consensus/common" } sc-keystore = { version = "4.0.0-dev", path = "../../../keystore" } diff --git a/client/consensus/babe/rpc/src/lib.rs b/client/consensus/babe/rpc/src/lib.rs index bc4d1c17eb3f1..005d84938e28e 100644 --- a/client/consensus/babe/rpc/src/lib.rs +++ b/client/consensus/babe/rpc/src/lib.rs @@ -37,7 +37,7 @@ use sp_consensus_babe::{ digests::PreDigest, AuthorityId, BabeApi as BabeRuntimeApi, BabeConfiguration, }; use sp_core::crypto::ByteArray; -use sp_keystore::{Keystore, KeystorePtr}; +use sp_keystore::KeystorePtr; use sp_runtime::traits::{Block as BlockT, Header as _}; use std::{collections::HashMap, sync::Arc}; @@ -117,7 +117,7 @@ where .iter() .enumerate() .filter_map(|(i, a)| { - if Keystore::has_keys(&*self.keystore, &[(a.0.to_raw_vec(), AuthorityId::ID)]) { + if self.keystore.has_keys(&[(a.0.to_raw_vec(), AuthorityId::ID)]) { Some((a.0.clone(), i)) } else { None @@ -210,30 +210,21 @@ where #[cfg(test)] mod tests { use super::*; - use sc_keystore::LocalKeystore; - use sp_application_crypto::AppPair; + use sc_consensus_babe::block_import; use sp_core::crypto::key_types::BABE; use sp_keyring::Sr25519Keyring; - use sp_keystore::{Keystore, KeystorePtr}; + use sp_keystore::{testing::MemoryKeystore, Keystore}; use substrate_test_runtime_client::{ runtime::Block, Backend, DefaultTestClientBuilderExt, TestClient, TestClientBuilder, TestClientBuilderExt, }; - use sc_consensus_babe::{block_import, AuthorityPair}; - use std::sync::Arc; - - /// creates keystore backed by a temp file - fn create_temp_keystore( - authority: Sr25519Keyring, - ) -> (KeystorePtr, tempfile::TempDir) { - let keystore_path = tempfile::tempdir().expect("Creates keystore path"); - let keystore = - Arc::new(LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore")); - Keystore::sr25519_generate_new(&*keystore, BABE, Some(&authority.to_seed())) + fn create_keystore(authority: Sr25519Keyring) -> KeystorePtr { + let keystore = MemoryKeystore::new(); + keystore + .sr25519_generate_new(BABE, Some(&authority.to_seed())) .expect("Creates authority key"); - - (keystore, keystore_path) + keystore.into() } fn test_babe_rpc_module( @@ -247,7 +238,7 @@ mod tests { .expect("can initialize block-import"); let epoch_changes = link.epoch_changes().clone(); - let keystore = create_temp_keystore::(Sr25519Keyring::Alice).0; + let keystore = create_keystore(Sr25519Keyring::Alice); Babe::new(client.clone(), epoch_changes, keystore, config, longest_chain, deny_unsafe) } diff --git a/client/consensus/babe/src/authorship.rs b/client/consensus/babe/src/authorship.rs index 956e886d1254c..c4b43b0d074b9 100644 --- a/client/consensus/babe/src/authorship.rs +++ b/client/consensus/babe/src/authorship.rs @@ -29,7 +29,7 @@ use sp_consensus_babe::{ }; use sp_consensus_vrf::schnorrkel::{VRFOutput, VRFProof}; use sp_core::{blake2_256, crypto::ByteArray, U256}; -use sp_keystore::{Keystore, KeystorePtr}; +use sp_keystore::KeystorePtr; /// Calculates the primary selection threshold for a given authority, taking /// into account `c` (`1 - c` represents the probability of a slot being empty). @@ -153,8 +153,7 @@ fn claim_secondary_slot( if authority_id == expected_author { let pre_digest = if author_secondary_vrf { let transcript_data = make_transcript_data(randomness, slot, epoch_index); - let result = Keystore::sr25519_vrf_sign( - &**keystore, + let result = keystore.sr25519_vrf_sign( AuthorityId::ID, authority_id.as_ref(), transcript_data, @@ -169,10 +168,7 @@ fn claim_secondary_slot( } else { None } - } else if Keystore::has_keys( - &**keystore, - &[(authority_id.to_raw_vec(), AuthorityId::ID)], - ) { + } else if keystore.has_keys(&[(authority_id.to_raw_vec(), AuthorityId::ID)]) { Some(PreDigest::SecondaryPlain(SecondaryPlainPreDigest { slot, authority_index: *authority_index as u32, @@ -254,12 +250,8 @@ fn claim_primary_slot( for (authority_id, authority_index) in keys { let transcript = make_transcript(randomness, slot, epoch_index); let transcript_data = make_transcript_data(randomness, slot, epoch_index); - let result = Keystore::sr25519_vrf_sign( - &**keystore, - AuthorityId::ID, - authority_id.as_ref(), - transcript_data, - ); + let result = + keystore.sr25519_vrf_sign(AuthorityId::ID, authority_id.as_ref(), transcript_data); if let Ok(Some(signature)) = result { let public = PublicKey::from_bytes(&authority_id.to_raw_vec()).ok()?; let inout = match signature.output.attach_input_hash(&public, transcript) { @@ -287,20 +279,16 @@ fn claim_primary_slot( #[cfg(test)] mod tests { use super::*; - use sc_keystore::LocalKeystore; use sp_consensus_babe::{AllowedSlots, AuthorityId, BabeEpochConfiguration}; use sp_core::{crypto::Pair as _, sr25519::Pair}; - use std::sync::Arc; + use sp_keystore::testing::MemoryKeystore; #[test] fn claim_secondary_plain_slot_works() { - let keystore: KeystorePtr = Arc::new(LocalKeystore::in_memory()); - let valid_public_key = Keystore::sr25519_generate_new( - &*keystore, - AuthorityId::ID, - Some(sp_core::crypto::DEV_PHRASE), - ) - .unwrap(); + let keystore: KeystorePtr = MemoryKeystore::new().into(); + let valid_public_key = keystore + .sr25519_generate_new(AuthorityId::ID, Some(sp_core::crypto::DEV_PHRASE)) + .unwrap(); let authorities = vec![ (AuthorityId::from(Pair::generate().0.public()), 5), diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 621aac391630b..e2c2793b11c9d 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -119,7 +119,7 @@ use sp_consensus_babe::inherents::BabeInherentData; use sp_consensus_slots::Slot; use sp_core::{crypto::ByteArray, ExecutionContext}; use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider}; -use sp_keystore::{Keystore, KeystorePtr}; +use sp_keystore::KeystorePtr; use sp_runtime::{ generic::OpaqueDigestItemId, traits::{Block as BlockT, Header, NumberFor, SaturatedConversion, Zero}, @@ -834,19 +834,16 @@ where // add it to a digest item. let public_type_pair = public.clone().into(); let public = public.to_raw_vec(); - let signature = Keystore::sign_with( - &*self.keystore, - ::ID, - &public_type_pair, - header_hash.as_ref(), - ) - .map_err(|e| sp_consensus::Error::CannotSign(public.clone(), e.to_string()))? - .ok_or_else(|| { - sp_consensus::Error::CannotSign( - public.clone(), - "Could not find key in keystore.".into(), - ) - })?; + let signature = self + .keystore + .sign_with(::ID, &public_type_pair, header_hash.as_ref()) + .map_err(|e| sp_consensus::Error::CannotSign(public.clone(), e.to_string()))? + .ok_or_else(|| { + sp_consensus::Error::CannotSign( + public.clone(), + "Could not find key in keystore.".into(), + ) + })?; let signature: AuthoritySignature = signature .clone() .try_into() diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 4ac15bf2634d7..7f8448d91991c 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -369,10 +369,11 @@ async fn rejects_empty_block() { } fn create_keystore(authority: Sr25519Keyring) -> KeystorePtr { - let keystore = Arc::new(MemoryKeystore::new()); - Keystore::sr25519_generate_new(&*keystore, BABE, Some(&authority.to_seed())) - .expect("Generates authority key"); + let keystore = MemoryKeystore::new(); keystore + .sr25519_generate_new(BABE, Some(&authority.to_seed())) + .expect("Generates authority key"); + keystore.into() } async fn run_one_test(mutator: impl Fn(&mut TestHeader, Stage) + Send + Sync + 'static) { @@ -637,7 +638,8 @@ fn claim_vrf_check() { v => panic!("Unexpected pre-digest variant {:?}", v), }; let transcript = make_transcript_data(&epoch.randomness.clone(), 0.into(), epoch.epoch_index); - let sign = Keystore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) + let sign = keystore + .sr25519_vrf_sign(AuthorityId::ID, &public, transcript) .unwrap() .unwrap(); assert_eq!(pre_digest.vrf_output, VRFOutput(sign.output)); @@ -648,7 +650,8 @@ fn claim_vrf_check() { v => panic!("Unexpected pre-digest variant {:?}", v), }; let transcript = make_transcript_data(&epoch.randomness.clone(), 1.into(), epoch.epoch_index); - let sign = Keystore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) + let sign = keystore + .sr25519_vrf_sign(AuthorityId::ID, &public, transcript) .unwrap() .unwrap(); assert_eq!(pre_digest.vrf_output, VRFOutput(sign.output)); @@ -661,7 +664,8 @@ fn claim_vrf_check() { }; let fixed_epoch = epoch.clone_for_slot(slot); let transcript = make_transcript_data(&epoch.randomness.clone(), slot, fixed_epoch.epoch_index); - let sign = Keystore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) + let sign = keystore + .sr25519_vrf_sign(AuthorityId::ID, &public, transcript) .unwrap() .unwrap(); assert_eq!(fixed_epoch.epoch_index, 11); @@ -675,7 +679,8 @@ fn claim_vrf_check() { }; let fixed_epoch = epoch.clone_for_slot(slot); let transcript = make_transcript_data(&epoch.randomness.clone(), slot, fixed_epoch.epoch_index); - let sign = Keystore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) + let sign = keystore + .sr25519_vrf_sign(AuthorityId::ID, &public, transcript) .unwrap() .unwrap(); assert_eq!(fixed_epoch.epoch_index, 11); diff --git a/client/consensus/beefy/src/communication/gossip.rs b/client/consensus/beefy/src/communication/gossip.rs index 4bbd7a7f68d5c..2b5e772c0578f 100644 --- a/client/consensus/beefy/src/communication/gossip.rs +++ b/client/consensus/beefy/src/communication/gossip.rs @@ -243,17 +243,14 @@ where #[cfg(test)] mod tests { - use sc_keystore::LocalKeystore; - use sc_network_test::Block; - use sp_keystore::{Keystore, KeystorePtr}; - + use super::*; use crate::keystore::BeefyKeystore; + use sc_network_test::Block; use sp_consensus_beefy::{ crypto::Signature, known_payloads, Commitment, Keyring, MmrRootHash, Payload, VoteMessage, KEY_TYPE, }; - - use super::*; + use sp_keystore::{testing::MemoryKeystore, Keystore}; #[test] fn known_votes_insert_remove() { @@ -306,10 +303,9 @@ mod tests { } fn sign_commitment(who: &Keyring, commitment: &Commitment) -> Signature { - let store: KeystorePtr = std::sync::Arc::new(LocalKeystore::in_memory()); - Keystore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&who.to_seed())).unwrap(); - let beefy_keystore: BeefyKeystore = Some(store).into(); - + let store = MemoryKeystore::new(); + store.ecdsa_generate_new(KEY_TYPE, Some(&who.to_seed())).unwrap(); + let beefy_keystore: BeefyKeystore = Some(store.into()).into(); beefy_keystore.sign(&who.public(), &commitment.encode()).unwrap() } diff --git a/client/consensus/beefy/src/keystore.rs b/client/consensus/beefy/src/keystore.rs index 596e8f2eb9c6d..795d4cc8ade10 100644 --- a/client/consensus/beefy/src/keystore.rs +++ b/client/consensus/beefy/src/keystore.rs @@ -18,7 +18,7 @@ use sp_application_crypto::RuntimeAppPublic; use sp_core::keccak_256; -use sp_keystore::{Keystore, KeystorePtr}; +use sp_keystore::KeystorePtr; use log::warn; @@ -50,7 +50,7 @@ impl BeefyKeystore { // we do check for multiple private keys as a key store sanity check. let public: Vec = keys .iter() - .filter(|k| Keystore::has_keys(&*store, &[(k.to_raw_vec(), KEY_TYPE)])) + .filter(|k| store.has_keys(&[(k.to_raw_vec(), KEY_TYPE)])) .cloned() .collect(); @@ -77,7 +77,8 @@ impl BeefyKeystore { let msg = keccak_256(message); let public = public.as_ref(); - let sig = Keystore::ecdsa_sign_prehashed(&*store, KEY_TYPE, public, &msg) + let sig = store + .ecdsa_sign_prehashed(KEY_TYPE, public, &msg) .map_err(|e| error::Error::Keystore(e.to_string()))? .ok_or_else(|| error::Error::Signature("ecdsa_sign_prehashed() failed".to_string()))?; @@ -94,10 +95,8 @@ impl BeefyKeystore { pub fn public_keys(&self) -> Result, error::Error> { let store = self.0.clone().ok_or_else(|| error::Error::Keystore("no Keystore".into()))?; - let pk: Vec = Keystore::ecdsa_public_keys(&*store, KEY_TYPE) - .drain(..) - .map(Public::from) - .collect(); + let pk: Vec = + store.ecdsa_public_keys(KEY_TYPE).drain(..).map(Public::from).collect(); Ok(pk) } @@ -118,18 +117,15 @@ impl From> for BeefyKeystore { #[cfg(test)] pub mod tests { - use std::sync::Arc; - - use sc_keystore::LocalKeystore; - use sp_core::{ecdsa, Pair}; - use sp_consensus_beefy::{crypto, Keyring}; + use sp_core::{ecdsa, Pair}; + use sp_keystore::testing::MemoryKeystore; use super::*; use crate::error::Error; fn keystore() -> KeystorePtr { - Arc::new(LocalKeystore::in_memory()) + MemoryKeystore::new().into() } #[test] @@ -197,11 +193,11 @@ pub mod tests { fn authority_id_works() { let store = keystore(); - let alice: crypto::Public = - Keystore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&Keyring::Alice.to_seed())) - .ok() - .unwrap() - .into(); + let alice: crypto::Public = store + .ecdsa_generate_new(KEY_TYPE, Some(&Keyring::Alice.to_seed())) + .ok() + .unwrap() + .into(); let bob = Keyring::Bob.public(); let charlie = Keyring::Charlie.public(); @@ -223,11 +219,11 @@ pub mod tests { fn sign_works() { let store = keystore(); - let alice: crypto::Public = - Keystore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&Keyring::Alice.to_seed())) - .ok() - .unwrap() - .into(); + let alice: crypto::Public = store + .ecdsa_generate_new(KEY_TYPE, Some(&Keyring::Alice.to_seed())) + .ok() + .unwrap() + .into(); let store: BeefyKeystore = Some(store).into(); @@ -243,9 +239,7 @@ pub mod tests { fn sign_error() { let store = keystore(); - let _ = Keystore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&Keyring::Bob.to_seed())) - .ok() - .unwrap(); + store.ecdsa_generate_new(KEY_TYPE, Some(&Keyring::Bob.to_seed())).ok().unwrap(); let store: BeefyKeystore = Some(store).into(); @@ -274,11 +268,11 @@ pub mod tests { fn verify_works() { let store = keystore(); - let alice: crypto::Public = - Keystore::ecdsa_generate_new(&*store, KEY_TYPE, Some(&Keyring::Alice.to_seed())) - .ok() - .unwrap() - .into(); + let alice: crypto::Public = store + .ecdsa_generate_new(KEY_TYPE, Some(&Keyring::Alice.to_seed())) + .ok() + .unwrap() + .into(); let store: BeefyKeystore = Some(store).into(); @@ -300,9 +294,8 @@ pub mod tests { let store = keystore(); - let add_key = |key_type, seed: Option<&str>| { - Keystore::ecdsa_generate_new(&*store, key_type, seed).unwrap() - }; + let add_key = + |key_type, seed: Option<&str>| store.ecdsa_generate_new(key_type, seed).unwrap(); // test keys let _ = add_key(TEST_TYPE, Some(Keyring::Alice.to_seed().as_str())); diff --git a/client/consensus/beefy/src/tests.rs b/client/consensus/beefy/src/tests.rs index 9a3653f7cc549..0ad5f10886093 100644 --- a/client/consensus/beefy/src/tests.rs +++ b/client/consensus/beefy/src/tests.rs @@ -340,10 +340,11 @@ pub(crate) fn make_beefy_ids(keys: &[BeefyKeyring]) -> Vec { } pub(crate) fn create_beefy_keystore(authority: BeefyKeyring) -> KeystorePtr { - let keystore = Arc::new(MemoryKeystore::new()); - Keystore::ecdsa_generate_new(&*keystore, BeefyKeyType, Some(&authority.to_seed())) - .expect("Creates authority key"); + let keystore = MemoryKeystore::new(); keystore + .ecdsa_generate_new(BeefyKeyType, Some(&authority.to_seed())) + .expect("Creates authority key"); + keystore.into() } async fn voter_init_setup( diff --git a/client/consensus/grandpa/src/lib.rs b/client/consensus/grandpa/src/lib.rs index 6b3730fc7f476..cf98e17920d5d 100644 --- a/client/consensus/grandpa/src/lib.rs +++ b/client/consensus/grandpa/src/lib.rs @@ -79,7 +79,7 @@ use sp_consensus_grandpa::{ AuthorityList, AuthoritySignature, SetId, CLIENT_LOG_TARGET as LOG_TARGET, }; use sp_core::{crypto::ByteArray, traits::CallContext}; -use sp_keystore::{Keystore, KeystorePtr}; +use sp_keystore::KeystorePtr; use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, NumberFor, Zero}, @@ -1141,7 +1141,7 @@ fn local_authority_id( keystore.and_then(|keystore| { voters .iter() - .find(|(p, _)| Keystore::has_keys(&**keystore, &[(p.to_raw_vec(), AuthorityId::ID)])) + .find(|(p, _)| keystore.has_keys(&[(p.to_raw_vec(), AuthorityId::ID)])) .map(|(p, _)| p.clone()) }) } diff --git a/client/consensus/grandpa/src/tests.rs b/client/consensus/grandpa/src/tests.rs index 6f19ca7391e65..7a3f862d3602b 100644 --- a/client/consensus/grandpa/src/tests.rs +++ b/client/consensus/grandpa/src/tests.rs @@ -281,10 +281,11 @@ fn make_ids(keys: &[Ed25519Keyring]) -> AuthorityList { } fn create_keystore(authority: Ed25519Keyring) -> KeystorePtr { - let keystore = Arc::new(MemoryKeystore::new()); - Keystore::ed25519_generate_new(&*keystore, GRANDPA, Some(&authority.to_seed())) - .expect("Creates authority key"); + let keystore = MemoryKeystore::new(); keystore + .ed25519_generate_new(GRANDPA, Some(&authority.to_seed())) + .expect("Creates authority key"); + keystore.into() } async fn run_until_complete(future: impl Future + Unpin, net: &Arc>) { diff --git a/client/keystore/src/local.rs b/client/keystore/src/local.rs index 18ee58b8719b9..a4af7811721ce 100644 --- a/client/keystore/src/local.rs +++ b/client/keystore/src/local.rs @@ -135,6 +135,9 @@ impl Keystore for LocalKeystore { .unwrap_or_default() } + /// 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. fn sr25519_generate_new( &self, id: KeyTypeId, @@ -162,6 +165,9 @@ impl Keystore for LocalKeystore { .unwrap_or_default() } + /// 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. fn ed25519_generate_new( &self, id: KeyTypeId, @@ -189,6 +195,9 @@ impl Keystore for LocalKeystore { .unwrap_or_default() } + /// 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. fn ecdsa_generate_new( &self, id: KeyTypeId, @@ -504,17 +513,14 @@ mod tests { let key: ed25519::AppPair = store.0.write().generate().unwrap(); let key2 = ed25519::Pair::generate().0; - assert!(!Keystore::has_keys(&store, &[(key2.public().to_vec(), ed25519::AppPublic::ID)])); + assert!(!store.has_keys(&[(key2.public().to_vec(), ed25519::AppPublic::ID)])); - assert!(!Keystore::has_keys( - &store, - &[ - (key2.public().to_vec(), ed25519::AppPublic::ID), - (key.public().to_raw_vec(), ed25519::AppPublic::ID), - ], - )); + assert!(!store.has_keys(&[ + (key2.public().to_vec(), ed25519::AppPublic::ID), + (key.public().to_raw_vec(), ed25519::AppPublic::ID), + ],)); - assert!(Keystore::has_keys(&store, &[(key.public().to_raw_vec(), ed25519::AppPublic::ID)])); + assert!(store.has_keys(&[(key.public().to_raw_vec(), ed25519::AppPublic::ID)])); } #[test] @@ -626,31 +632,30 @@ mod tests { let file_name = temp_dir.path().join(array_bytes::bytes2hex("", &SR25519.0[..2])); fs::write(file_name, "test").expect("Invalid file is written"); - assert!(Keystore::sr25519_public_keys(&store, SR25519).is_empty()); + assert!(store.sr25519_public_keys(SR25519).is_empty()); } #[test] fn generate_with_seed_is_not_stored() { let temp_dir = TempDir::new().unwrap(); let store = LocalKeystore::open(temp_dir.path(), None).unwrap(); - let _alice_tmp_key = - Keystore::sr25519_generate_new(&store, TEST_KEY_TYPE, Some("//Alice")).unwrap(); + let _alice_tmp_key = store.sr25519_generate_new(TEST_KEY_TYPE, Some("//Alice")).unwrap(); - assert_eq!(Keystore::sr25519_public_keys(&store, TEST_KEY_TYPE).len(), 1); + assert_eq!(store.sr25519_public_keys(TEST_KEY_TYPE).len(), 1); drop(store); let store = LocalKeystore::open(temp_dir.path(), None).unwrap(); - assert_eq!(Keystore::sr25519_public_keys(&store, TEST_KEY_TYPE).len(), 0); + assert_eq!(store.sr25519_public_keys(TEST_KEY_TYPE).len(), 0); } #[test] fn generate_can_be_fetched_in_memory() { let store = LocalKeystore::in_memory(); - Keystore::sr25519_generate_new(&store, TEST_KEY_TYPE, Some("//Alice")).unwrap(); + store.sr25519_generate_new(TEST_KEY_TYPE, Some("//Alice")).unwrap(); - assert_eq!(Keystore::sr25519_public_keys(&store, TEST_KEY_TYPE).len(), 1); - Keystore::sr25519_generate_new(&store, TEST_KEY_TYPE, None).unwrap(); - assert_eq!(Keystore::sr25519_public_keys(&store, TEST_KEY_TYPE).len(), 2); + assert_eq!(store.sr25519_public_keys(TEST_KEY_TYPE).len(), 1); + store.sr25519_generate_new(TEST_KEY_TYPE, None).unwrap(); + assert_eq!(store.sr25519_public_keys(TEST_KEY_TYPE).len(), 2); } #[test] @@ -661,7 +666,7 @@ mod tests { let temp_dir = TempDir::new().unwrap(); let store = LocalKeystore::open(temp_dir.path(), None).unwrap(); - let public = Keystore::sr25519_generate_new(&store, TEST_KEY_TYPE, None).unwrap(); + let public = store.sr25519_generate_new(TEST_KEY_TYPE, None).unwrap(); let path = store.0.read().key_file_path(public.as_ref(), TEST_KEY_TYPE).unwrap(); let permissions = File::open(path).unwrap().metadata().unwrap().permissions(); diff --git a/client/rpc/src/author/mod.rs b/client/rpc/src/author/mod.rs index 9752a32b17c67..00a126500e26d 100644 --- a/client/rpc/src/author/mod.rs +++ b/client/rpc/src/author/mod.rs @@ -40,7 +40,7 @@ use sc_transaction_pool_api::{ use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_core::Bytes; -use sp_keystore::{Keystore, KeystorePtr}; +use sp_keystore::KeystorePtr; use sp_runtime::{generic, traits::Block as BlockT}; use sp_session::SessionKeys; @@ -112,7 +112,8 @@ where self.deny_unsafe.check_if_safe()?; let key_type = key_type.as_str().try_into().map_err(|_| Error::BadKeyType)?; - Keystore::insert(&*self.keystore, key_type, &suri, &public[..]) + self.keystore + .insert(key_type, &suri, &public[..]) .map_err(|_| Error::KeystoreUnavailable)?; Ok(()) } @@ -139,14 +140,14 @@ where .map_err(|e| Error::Client(Box::new(e)))? .ok_or(Error::InvalidSessionKeys)?; - Ok(Keystore::has_keys(&*self.keystore, &keys)) + Ok(self.keystore.has_keys(&keys)) } fn has_key(&self, public_key: Bytes, key_type: String) -> RpcResult { self.deny_unsafe.check_if_safe()?; let key_type = key_type.as_str().try_into().map_err(|_| Error::BadKeyType)?; - Ok(Keystore::has_keys(&*self.keystore, &[(public_key.to_vec(), key_type)])) + Ok(self.keystore.has_keys(&[(public_key.to_vec(), key_type)])) } fn pending_extrinsics(&self) -> RpcResult> { diff --git a/client/rpc/src/author/tests.rs b/client/rpc/src/author/tests.rs index 209673fce2602..75b6390c83cc7 100644 --- a/client/rpc/src/author/tests.rs +++ b/client/rpc/src/author/tests.rs @@ -36,7 +36,7 @@ use sp_core::{ testing::{ED25519, SR25519}, H256, }; -use sp_keystore::testing::MemoryKeystore; +use sp_keystore::{testing::MemoryKeystore, Keystore}; use std::sync::Arc; use substrate_test_runtime_client::{ self, @@ -225,7 +225,7 @@ async fn author_should_insert_key() { keypair.public().0.to_vec().into(), ); api.call::<_, ()>("author_insertKey", params).await.unwrap(); - let pubkeys = Keystore::keys(&*setup.keystore, ED25519).unwrap(); + let pubkeys = setup.keystore.keys(ED25519).unwrap(); assert!( pubkeys.contains(&CryptoTypePublicPair(ed25519::CRYPTO_ID, keypair.public().to_raw_vec())) @@ -240,8 +240,8 @@ async fn author_should_rotate_keys() { let new_pubkeys: Bytes = api.call("author_rotateKeys", EmptyParams::new()).await.unwrap(); let session_keys = SessionKeys::decode(&mut &new_pubkeys[..]).expect("SessionKeys decode successfully"); - let ed25519_pubkeys = Keystore::keys(&*setup.keystore, ED25519).unwrap(); - let sr25519_pubkeys = Keystore::keys(&*setup.keystore, SR25519).unwrap(); + let ed25519_pubkeys = setup.keystore.keys(ED25519).unwrap(); + let sr25519_pubkeys = setup.keystore.keys(SR25519).unwrap(); assert!(ed25519_pubkeys .contains(&CryptoTypePublicPair(ed25519::CRYPTO_ID, session_keys.ed25519.to_raw_vec()))); assert!(sr25519_pubkeys diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 034d056d6f66f..bee40e9a3da0c 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -67,7 +67,7 @@ use sp_consensus::block_validation::{ BlockAnnounceValidator, Chain, DefaultBlockAnnounceValidator, }; use sp_core::traits::{CodeExecutor, SpawnNamed}; -use sp_keystore::{Keystore, KeystorePtr}; +use sp_keystore::KeystorePtr; use sp_runtime::traits::{Block as BlockT, BlockIdTo, NumberFor, Zero}; use std::{str::FromStr, sync::Arc, time::SystemTime}; @@ -85,24 +85,8 @@ pub type TFullCallExecutor = type TFullParts = (TFullClient, Arc>, KeystoreContainer, TaskManager); -trait AsKeystoreRef { - fn keystore_ref(&self) -> Arc; -} - -impl AsKeystoreRef for Arc -where - T: Keystore + 'static, -{ - fn keystore_ref(&self) -> Arc { - self.clone() - } -} - -/// Construct and hold different layers of Keystore wrappers -pub struct KeystoreContainer { - remote: Option>, - local: Arc, -} +/// Construct a local keystore shareable container +pub struct KeystoreContainer(Arc); impl KeystoreContainer { /// Construct KeystoreContainer @@ -113,41 +97,17 @@ impl KeystoreContainer { KeystoreConfig::InMemory => LocalKeystore::in_memory(), }); - Ok(Self { remote: Default::default(), local: keystore }) + Ok(Self(keystore)) } - /// Set the remote keystore. - /// Should be called right away at startup and not at runtime: - /// even though this overrides any previously set remote store, it - /// does not reset any references previously handed out - they will - /// stick around. - pub fn set_remote_keystore(&mut self, remote: Arc) - where - T: Keystore + 'static, - { - self.remote = Some(Box::new(remote)) + /// Returns a shared reference to a dynamic `Keystore` trait implementation. + pub fn keystore(&self) -> KeystorePtr { + self.0.clone() } - /// Returns an adapter to a `Keystore` implementation. - pub fn keystore(&self) -> Arc { - if let Some(c) = self.remote.as_ref() { - c.keystore_ref() - } else { - self.local.clone() - } - } - - /// Returns the local keystore if available - /// - /// The function will return None if the available keystore is not a local keystore. - /// - /// # Note - /// - /// Using the [`LocalKeystore`] will result in loosing the ability to use any other keystore - /// implementation, like a remote keystore for example. Only use this if you a certain that you - /// require it! - pub fn local_keystore(&self) -> Option> { - Some(self.local.clone()) + /// Returns a shared reference to the local keystore . + pub fn local_keystore(&self) -> Arc { + self.0.clone() } } diff --git a/client/service/src/config.rs b/client/service/src/config.rs index c7d98a4533436..6550fcdd8ef4f 100644 --- a/client/service/src/config.rs +++ b/client/service/src/config.rs @@ -61,8 +61,6 @@ pub struct Configuration { pub network: NetworkConfiguration, /// Configuration for the keystore. pub keystore: KeystoreConfig, - /// Remote URI to connect to for async keystore support - pub keystore_remote: Option, /// Configuration for the database. pub database: DatabaseSource, /// Maximum size of internal trie cache in bytes. diff --git a/client/service/test/src/lib.rs b/client/service/test/src/lib.rs index f80446a4d43eb..8a2e5050bd5d3 100644 --- a/client/service/test/src/lib.rs +++ b/client/service/test/src/lib.rs @@ -242,7 +242,6 @@ fn node_config< tokio_handle, transaction_pool: Default::default(), network: network_config, - keystore_remote: Default::default(), keystore: KeystoreConfig::Path { path: root.join("key"), password: None }, database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 }, trie_cache_maximum_size: Some(16 * 1024 * 1024), diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 1f6e9c5a68892..25336b6974d9f 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -160,12 +160,11 @@ pub mod mock { impl super::Config for Test {} pub fn new_test_ext() -> sp_io::TestExternalities { - use sp_keystore::{testing::MemoryKeystore, KeystoreExt, KeystorePtr}; - use sp_std::sync::Arc; + use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); let mut ext = sp_io::TestExternalities::new(t); - ext.register_extension(KeystoreExt(Arc::new(MemoryKeystore::new()) as KeystorePtr)); + ext.register_extension(KeystoreExt::new(MemoryKeystore::new())); ext } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 185945b71e5be..915a56a3f056c 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -50,7 +50,7 @@ use sp_runtime::{ traits::{BlakeTwo256, Convert, Hash, IdentityLookup}, AccountId32, TokenError, }; -use std::{ops::Deref, sync::Arc}; +use std::ops::Deref; use crate as pallet_contracts; @@ -444,7 +444,7 @@ impl ExtBuilder { .assimilate_storage(&mut t) .unwrap(); let mut ext = sp_io::TestExternalities::new(t); - ext.register_extension(KeystoreExt(Arc::new(MemoryKeystore::new()))); + ext.register_extension(KeystoreExt::new(MemoryKeystore::new())); ext.execute_with(|| System::set_block_number(1)); ext } diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index c513590435252..3df7f4a8d5439 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -27,7 +27,6 @@ use sp_core::{ sr25519::Signature, H256, }; -use std::sync::Arc; use sp_keystore::{testing::MemoryKeystore, Keystore, KeystoreExt}; use sp_runtime::{ @@ -206,17 +205,14 @@ fn should_submit_signed_transaction_on_chain() { let (offchain, offchain_state) = testing::TestOffchainExt::new(); let (pool, pool_state) = testing::TestTransactionPoolExt::new(); let keystore = MemoryKeystore::new(); - Keystore::sr25519_generate_new( - &keystore, - crate::crypto::Public::ID, - Some(&format!("{}/hunter1", PHRASE)), - ) - .unwrap(); + keystore + .sr25519_generate_new(crate::crypto::Public::ID, Some(&format!("{}/hunter1", PHRASE))) + .unwrap(); let mut t = sp_io::TestExternalities::default(); t.register_extension(OffchainWorkerExt::new(offchain)); t.register_extension(TransactionPoolExt::new(pool)); - t.register_extension(KeystoreExt(Arc::new(keystore))); + t.register_extension(KeystoreExt::new(keystore)); price_oracle_response(&mut offchain_state.write()); @@ -241,21 +237,16 @@ fn should_submit_unsigned_transaction_on_chain_for_any_account() { let keystore = MemoryKeystore::new(); - Keystore::sr25519_generate_new( - &keystore, - crate::crypto::Public::ID, - Some(&format!("{}/hunter1", PHRASE)), - ) - .unwrap(); - - let public_key = *Keystore::sr25519_public_keys(&keystore, crate::crypto::Public::ID) - .get(0) + keystore + .sr25519_generate_new(crate::crypto::Public::ID, Some(&format!("{}/hunter1", PHRASE))) .unwrap(); + let public_key = *keystore.sr25519_public_keys(crate::crypto::Public::ID).get(0).unwrap(); + let mut t = sp_io::TestExternalities::default(); t.register_extension(OffchainWorkerExt::new(offchain)); t.register_extension(TransactionPoolExt::new(pool)); - t.register_extension(KeystoreExt(Arc::new(keystore))); + t.register_extension(KeystoreExt::new(keystore)); price_oracle_response(&mut offchain_state.write()); @@ -300,21 +291,16 @@ fn should_submit_unsigned_transaction_on_chain_for_all_accounts() { let keystore = MemoryKeystore::new(); - Keystore::sr25519_generate_new( - &keystore, - crate::crypto::Public::ID, - Some(&format!("{}/hunter1", PHRASE)), - ) - .unwrap(); - - let public_key = *Keystore::sr25519_public_keys(&keystore, crate::crypto::Public::ID) - .get(0) + keystore + .sr25519_generate_new(crate::crypto::Public::ID, Some(&format!("{}/hunter1", PHRASE))) .unwrap(); + let public_key = *keystore.sr25519_public_keys(crate::crypto::Public::ID).get(0).unwrap(); + let mut t = sp_io::TestExternalities::default(); t.register_extension(OffchainWorkerExt::new(offchain)); t.register_extension(TransactionPoolExt::new(pool)); - t.register_extension(KeystoreExt(Arc::new(keystore))); + t.register_extension(KeystoreExt::new(keystore)); price_oracle_response(&mut offchain_state.write()); @@ -360,7 +346,7 @@ fn should_submit_raw_unsigned_transaction_on_chain() { let mut t = sp_io::TestExternalities::default(); t.register_extension(OffchainWorkerExt::new(offchain)); t.register_extension(TransactionPoolExt::new(pool)); - t.register_extension(KeystoreExt(Arc::new(keystore))); + t.register_extension(KeystoreExt::new(keystore)); price_oracle_response(&mut offchain_state.write()); diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index 91ac5d6a72203..e2856a07b994c 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -31,7 +31,6 @@ use sp_runtime::{ traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, MultiSignature, }; -use std::sync::Arc; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -134,9 +133,8 @@ impl Config for Test { pub(crate) fn new_test_ext() -> sp_io::TestExternalities { let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - let keystore = MemoryKeystore::new(); let mut ext = sp_io::TestExternalities::new(t); - ext.register_extension(KeystoreExt(Arc::new(keystore))); + ext.register_extension(KeystoreExt::new(MemoryKeystore::new())); ext.execute_with(|| System::set_block_number(1)); ext } diff --git a/primitives/application-crypto/test/src/ecdsa.rs b/primitives/application-crypto/test/src/ecdsa.rs index 7b96b42d5556b..fe9e17a65b1a7 100644 --- a/primitives/application-crypto/test/src/ecdsa.rs +++ b/primitives/application-crypto/test/src/ecdsa.rs @@ -34,7 +34,7 @@ fn ecdsa_works_in_runtime() { .test_ecdsa_crypto(test_client.chain_info().genesis_hash) .expect("Tests `ecdsa` crypto."); - let supported_keys = Keystore::keys(&*keystore, ECDSA).unwrap(); + let supported_keys = keystore.keys(ECDSA).unwrap(); assert!(supported_keys.contains(&public.clone().into())); assert!(AppPair::verify(&signature, "ecdsa", &AppPublic::from(public))); } diff --git a/primitives/application-crypto/test/src/ed25519.rs b/primitives/application-crypto/test/src/ed25519.rs index 1cf2b574b6bfb..5687bd013970a 100644 --- a/primitives/application-crypto/test/src/ed25519.rs +++ b/primitives/application-crypto/test/src/ed25519.rs @@ -35,7 +35,7 @@ fn ed25519_works_in_runtime() { .test_ed25519_crypto(test_client.chain_info().genesis_hash) .expect("Tests `ed25519` crypto."); - let supported_keys = Keystore::keys(&*keystore, ED25519).unwrap(); + let supported_keys = keystore.keys(ED25519).unwrap(); assert!(supported_keys.contains(&public.clone().into())); assert!(AppPair::verify(&signature, "ed25519", &AppPublic::from(public))); } diff --git a/primitives/application-crypto/test/src/sr25519.rs b/primitives/application-crypto/test/src/sr25519.rs index aa8f75c0dc27a..92886b80cbfb3 100644 --- a/primitives/application-crypto/test/src/sr25519.rs +++ b/primitives/application-crypto/test/src/sr25519.rs @@ -35,7 +35,7 @@ fn sr25519_works_in_runtime() { .test_sr25519_crypto(test_client.chain_info().genesis_hash) .expect("Tests `sr25519` crypto."); - let supported_keys = Keystore::keys(&*keystore, SR25519).unwrap(); + let supported_keys = keystore.keys(SR25519).unwrap(); assert!(supported_keys.contains(&public.clone().into())); assert!(AppPair::verify(&signature, "sr25519", &AppPublic::from(public))); } diff --git a/primitives/consensus/beefy/src/commitment.rs b/primitives/consensus/beefy/src/commitment.rs index 6ae17b06d96a4..8ad3cc3721a00 100644 --- a/primitives/consensus/beefy/src/commitment.rs +++ b/primitives/consensus/beefy/src/commitment.rs @@ -253,7 +253,7 @@ mod tests { use crate::{crypto, known_payloads, KEY_TYPE}; use codec::Decode; use sp_core::{keccak_256, Pair}; - use sp_keystore::{testing::MemoryKeystore, Keystore, KeystorePtr}; + use sp_keystore::{testing::MemoryKeystore, KeystorePtr}; type TestCommitment = Commitment; type TestSignedCommitment = SignedCommitment; @@ -266,17 +266,13 @@ mod tests { let store: KeystorePtr = MemoryKeystore::new().into(); let alice = sp_core::ecdsa::Pair::from_string("//Alice", None).unwrap(); - let _ = Keystore::insert(&*store, KEY_TYPE, "//Alice", alice.public().as_ref()).unwrap(); + store.insert(KEY_TYPE, "//Alice", alice.public().as_ref()).unwrap(); let msg = keccak_256(b"This is the first message"); - let sig1 = Keystore::ecdsa_sign_prehashed(&*store, KEY_TYPE, &alice.public(), &msg) - .unwrap() - .unwrap(); + let sig1 = store.ecdsa_sign_prehashed(KEY_TYPE, &alice.public(), &msg).unwrap().unwrap(); let msg = keccak_256(b"This is the second message"); - let sig2 = Keystore::ecdsa_sign_prehashed(&*store, KEY_TYPE, &alice.public(), &msg) - .unwrap() - .unwrap(); + let sig2 = store.ecdsa_sign_prehashed(KEY_TYPE, &alice.public(), &msg).unwrap().unwrap(); (sig1.into(), sig2.into()) } diff --git a/primitives/consensus/beefy/src/witness.rs b/primitives/consensus/beefy/src/witness.rs index 70b924c0a42fe..ff9a0401dc632 100644 --- a/primitives/consensus/beefy/src/witness.rs +++ b/primitives/consensus/beefy/src/witness.rs @@ -74,9 +74,8 @@ impl SignedCommitmentWitness Vec { - let keystore = &***self - .extension::() - .expect("No `keystore` associated for the current context!"); - Keystore::ed25519_public_keys(keystore, id) + self.extension::() + .expect("No `keystore` associated for the current context!") + .ed25519_public_keys(id) } /// Generate an `ed22519` key for the given key type using an optional `seed` and @@ -745,10 +744,10 @@ pub trait Crypto { /// Returns the public key. fn ed25519_generate(&mut self, id: KeyTypeId, seed: Option>) -> ed25519::Public { let seed = seed.as_ref().map(|s| std::str::from_utf8(s).expect("Seed is valid utf8!")); - let keystore = &***self - .extension::() - .expect("No `keystore` associated for the current context!"); - Keystore::ed25519_generate_new(keystore, id, seed).expect("`ed25519_generate` failed") + self.extension::() + .expect("No `keystore` associated for the current context!") + .ed25519_generate_new(id, seed) + .expect("`ed25519_generate` failed") } /// Sign the given `msg` with the `ed25519` key that corresponds to the given public key and @@ -761,10 +760,9 @@ pub trait Crypto { pub_key: &ed25519::Public, msg: &[u8], ) -> Option { - let keystore = &***self - .extension::() - .expect("No `keystore` associated for the current context!"); - Keystore::sign_with(keystore, id, &pub_key.into(), msg) + self.extension::() + .expect("No `keystore` associated for the current context!") + .sign_with(id, &pub_key.into(), msg) .ok() .flatten() .and_then(|sig| ed25519::Signature::from_slice(&sig)) @@ -873,10 +871,9 @@ pub trait Crypto { /// Returns all `sr25519` public keys for the given key id from the keystore. fn sr25519_public_keys(&mut self, id: KeyTypeId) -> Vec { - let keystore = &***self - .extension::() - .expect("No `keystore` associated for the current context!"); - Keystore::sr25519_public_keys(keystore, id) + self.extension::() + .expect("No `keystore` associated for the current context!") + .sr25519_public_keys(id) } /// Generate an `sr22519` key for the given key type using an optional seed and @@ -887,10 +884,10 @@ pub trait Crypto { /// Returns the public key. fn sr25519_generate(&mut self, id: KeyTypeId, seed: Option>) -> sr25519::Public { let seed = seed.as_ref().map(|s| std::str::from_utf8(s).expect("Seed is valid utf8!")); - let keystore = &***self - .extension::() - .expect("No `keystore` associated for the current context!"); - Keystore::sr25519_generate_new(keystore, id, seed).expect("`sr25519_generate` failed") + self.extension::() + .expect("No `keystore` associated for the current context!") + .sr25519_generate_new(id, seed) + .expect("`sr25519_generate` failed") } /// Sign the given `msg` with the `sr25519` key that corresponds to the given public key and @@ -903,10 +900,9 @@ pub trait Crypto { pub_key: &sr25519::Public, msg: &[u8], ) -> Option { - let keystore = &***self - .extension::() - .expect("No `keystore` associated for the current context!"); - Keystore::sign_with(keystore, id, &pub_key.into(), msg) + self.extension::() + .expect("No `keystore` associated for the current context!") + .sign_with(id, &pub_key.into(), msg) .ok() .flatten() .and_then(|sig| sr25519::Signature::from_slice(&sig)) @@ -922,10 +918,9 @@ pub trait Crypto { /// Returns all `ecdsa` public keys for the given key id from the keystore. fn ecdsa_public_keys(&mut self, id: KeyTypeId) -> Vec { - let keystore = &***self - .extension::() - .expect("No `keystore` associated for the current context!"); - Keystore::ecdsa_public_keys(keystore, id) + self.extension::() + .expect("No `keystore` associated for the current context!") + .ecdsa_public_keys(id) } /// Generate an `ecdsa` key for the given key type using an optional `seed` and @@ -936,10 +931,10 @@ pub trait Crypto { /// Returns the public key. fn ecdsa_generate(&mut self, id: KeyTypeId, seed: Option>) -> ecdsa::Public { let seed = seed.as_ref().map(|s| std::str::from_utf8(s).expect("Seed is valid utf8!")); - let keystore = &***self - .extension::() - .expect("No `keystore` associated for the current context!"); - Keystore::ecdsa_generate_new(keystore, id, seed).expect("`ecdsa_generate` failed") + self.extension::() + .expect("No `keystore` associated for the current context!") + .ecdsa_generate_new(id, seed) + .expect("`ecdsa_generate` failed") } /// Sign the given `msg` with the `ecdsa` key that corresponds to the given public key and @@ -952,10 +947,9 @@ pub trait Crypto { pub_key: &ecdsa::Public, msg: &[u8], ) -> Option { - let keystore = &***self - .extension::() - .expect("No `keystore` associated for the current context!"); - Keystore::sign_with(keystore, id, &pub_key.into(), msg) + self.extension::() + .expect("No `keystore` associated for the current context!") + .sign_with(id, &pub_key.into(), msg) .ok() .flatten() .and_then(|sig| ecdsa::Signature::from_slice(&sig)) @@ -971,10 +965,11 @@ pub trait Crypto { pub_key: &ecdsa::Public, msg: &[u8; 32], ) -> Option { - let keystore = &***self - .extension::() - .expect("No `keystore` associated for the current context!"); - Keystore::ecdsa_sign_prehashed(keystore, id, pub_key, msg).ok().flatten() + self.extension::() + .expect("No `keystore` associated for the current context!") + .ecdsa_sign_prehashed(id, pub_key, msg) + .ok() + .flatten() } /// Verify `ecdsa` signature. diff --git a/primitives/keystore/src/lib.rs b/primitives/keystore/src/lib.rs index e0c00967b6b5e..d1cbe227ed551 100644 --- a/primitives/keystore/src/lib.rs +++ b/primitives/keystore/src/lib.rs @@ -150,10 +150,17 @@ pub trait Keystore: Send + Sync { ) -> Result, Error>; } -/// A pointer to a keystore. +/// A shared pointer to a keystore implementation. pub type KeystorePtr = Arc; sp_externalities::decl_extension! { /// The keystore extension to register/retrieve from the externalities. pub struct KeystoreExt(KeystorePtr); } + +impl KeystoreExt { + /// Create a new instance of `KeystoreExt` + pub fn new(keystore: T) -> Self { + Self(Arc::new(keystore)) + } +} diff --git a/primitives/keystore/src/testing.rs b/primitives/keystore/src/testing.rs index fecc11342c464..73b560d563a17 100644 --- a/primitives/keystore/src/testing.rs +++ b/primitives/keystore/src/testing.rs @@ -304,9 +304,9 @@ mod tests { fn store_key_and_extract() { let store = MemoryKeystore::new(); - let public = Keystore::ed25519_generate_new(&store, ED25519, None).expect("Generates key"); + let public = store.ed25519_generate_new(ED25519, None).expect("Generates key"); - let public_keys = Keystore::keys(&store, ED25519).unwrap(); + let public_keys = store.keys(ED25519).unwrap(); assert!(public_keys.contains(&public.into())); } @@ -318,10 +318,11 @@ mod tests { let secret_uri = "//Alice"; let key_pair = sr25519::Pair::from_string(secret_uri, None).expect("Generates key pair"); - Keystore::insert(&store, SR25519, secret_uri, key_pair.public().as_ref()) + store + .insert(SR25519, secret_uri, key_pair.public().as_ref()) .expect("Inserts unknown key"); - let public_keys = Keystore::keys(&store, SR25519).unwrap(); + let public_keys = store.keys(SR25519).unwrap(); assert!(public_keys.contains(&key_pair.public().into())); } @@ -342,19 +343,14 @@ mod tests { ], }; - let result = Keystore::sr25519_vrf_sign( - &store, - SR25519, - &key_pair.public(), - transcript_data.clone(), - ); + let result = store.sr25519_vrf_sign(SR25519, &key_pair.public(), transcript_data.clone()); assert!(result.unwrap().is_none()); - Keystore::insert(&store, SR25519, secret_uri, key_pair.public().as_ref()) + store + .insert(SR25519, secret_uri, key_pair.public().as_ref()) .expect("Inserts unknown key"); - let result = - Keystore::sr25519_vrf_sign(&store, SR25519, &key_pair.public(), transcript_data); + let result = store.sr25519_vrf_sign(SR25519, &key_pair.public(), transcript_data); assert!(result.unwrap().is_some()); } @@ -369,13 +365,13 @@ mod tests { let msg = sp_core::keccak_256(b"this should be a hashed message"); // no key in key store - let res = Keystore::ecdsa_sign_prehashed(&store, ECDSA, &pair.public(), &msg).unwrap(); + let res = store.ecdsa_sign_prehashed(ECDSA, &pair.public(), &msg).unwrap(); assert!(res.is_none()); // insert key, sign again - Keystore::insert(&store, ECDSA, suri, pair.public().as_ref()).unwrap(); + store.insert(ECDSA, suri, pair.public().as_ref()).unwrap(); - let res = Keystore::ecdsa_sign_prehashed(&store, ECDSA, &pair.public(), &msg).unwrap(); + let res = store.ecdsa_sign_prehashed(ECDSA, &pair.public(), &msg).unwrap(); assert!(res.is_some()); } } diff --git a/utils/frame/benchmarking-cli/src/pallet/command.rs b/utils/frame/benchmarking-cli/src/pallet/command.rs index f11e6bd920abf..15ebc668ff4fb 100644 --- a/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -38,10 +38,10 @@ use sp_core::{ traits::CallContext, }; use sp_externalities::Extensions; -use sp_keystore::{testing::MemoryKeystore, KeystoreExt, KeystorePtr}; +use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; use sp_state_machine::StateMachine; -use std::{collections::HashMap, fmt::Debug, fs, str::FromStr, sync::Arc, time}; +use std::{collections::HashMap, fmt::Debug, fs, str::FromStr, time}; /// Logging target const LOG_TARGET: &'static str = "frame::benchmark::pallet"; @@ -218,9 +218,10 @@ impl PalletCmd { let extensions = || -> Extensions { let mut extensions = Extensions::default(); - extensions.register(KeystoreExt(Arc::new(MemoryKeystore::new()) as KeystorePtr)); let (offchain, _) = TestOffchainExt::new(); let (pool, _) = TestTransactionPoolExt::new(); + let keystore = MemoryKeystore::new(); + extensions.register(KeystoreExt::new(keystore)); extensions.register(OffchainWorkerExt::new(offchain.clone())); extensions.register(OffchainDbExt::new(offchain)); extensions.register(TransactionPoolExt::new(pool)); diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index bd914d3a2e017..34966fc2a1197 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -816,9 +816,10 @@ pub(crate) fn full_extensions() -> Extensions { extensions.register(TaskExecutorExt::new(TaskExecutor::new())); let (offchain, _offchain_state) = TestOffchainExt::new(); let (pool, _pool_state) = TestTransactionPoolExt::new(); + let keystore = MemoryKeystore::new(); extensions.register(OffchainDbExt::new(offchain.clone())); extensions.register(OffchainWorkerExt::new(offchain)); - extensions.register(KeystoreExt(std::sync::Arc::new(MemoryKeystore::new()))); + extensions.register(KeystoreExt::new(keystore)); extensions.register(TransactionPoolExt::new(pool)); extensions From b8b8cce3400c4c157579404e17d4c623a83c3617 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Mon, 20 Mar 2023 21:58:21 +0100 Subject: [PATCH 45/80] frame::executive: LOG_TARGET const added (#13650) part of: #12873 Co-authored-by: parity-processbot <> --- frame/executive/src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 10cf6e06b3431..5003920eadcb5 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -137,6 +137,9 @@ use sp_runtime::{ }; use sp_std::{marker::PhantomData, prelude::*}; +#[allow(dead_code)] +const LOG_TARGET: &str = "runtime::executive"; + pub type CheckedOf = >::Checked; pub type CallOf = as Applyable>::Call; pub type OriginOf = as Dispatchable>::RuntimeOrigin; @@ -240,7 +243,7 @@ where select: frame_try_runtime::TryStateSelect, ) -> Result { frame_support::log::info!( - target: "frame::executive", + target: LOG_TARGET, "try-runtime: executing block #{:?} / state root check: {:?} / signature check: {:?} / try-state-select: {:?}", block.header().number(), state_root_check, @@ -277,7 +280,7 @@ where for e in extrinsics { if let Err(err) = try_apply_extrinsic(e.clone()) { frame_support::log::error!( - target: "runtime::executive", "executing transaction {:?} failed due to {:?}. Aborting the rest of the block execution.", + target: LOG_TARGET, "executing transaction {:?} failed due to {:?}. Aborting the rest of the block execution.", e, err, ); @@ -296,7 +299,7 @@ where select, ) .map_err(|e| { - frame_support::log::error!(target: "runtime::executive", "failure: {:?}", e); + frame_support::log::error!(target: LOG_TARGET, "failure: {:?}", e); e })?; drop(_guard); From 8f0b0f69e79c0dcf1487b9858792439c35a1d4cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 21 Mar 2023 00:09:22 +0100 Subject: [PATCH 46/80] contracts: Upgrade to wasmi 0.28 (#13312) * Upgrade to wasmi 0.28 * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * Update stale comment * Renamed variants of `Determinism` * Compile fix --------- Co-authored-by: command-bot <> --- Cargo.lock | 21 +- bin/node/runtime/src/lib.rs | 2 +- frame/contracts/Cargo.toml | 4 +- frame/contracts/proc-macro/src/lib.rs | 4 +- frame/contracts/src/benchmarking/code.rs | 2 +- frame/contracts/src/benchmarking/mod.rs | 12 +- frame/contracts/src/exec.rs | 74 +- frame/contracts/src/lib.rs | 12 +- frame/contracts/src/migration.rs | 4 +- frame/contracts/src/schedule.rs | 7 +- frame/contracts/src/tests.rs | 129 +- frame/contracts/src/wasm/mod.rs | 22 +- frame/contracts/src/wasm/prepare.rs | 70 +- frame/contracts/src/wasm/runtime.rs | 6 +- frame/contracts/src/weights.rs | 2362 +++++++++++----------- 15 files changed, 1338 insertions(+), 1393 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4928873566627..5306d2015b17b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5751,7 +5751,7 @@ dependencies = [ "sp-runtime", "sp-std", "wasm-instrument 0.4.0", - "wasmi 0.20.0", + "wasmi 0.28.0", "wasmparser-nostd", "wat", ] @@ -12188,13 +12188,13 @@ dependencies = [ [[package]] name = "wasmi" -version = "0.20.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01bf50edb2ea9d922aa75a7bf3c15e26a6c9e2d18c56e862b49737a582901729" +checksum = "8e61a7006b0fdf24f6bbe8dcfdad5ca1b350de80061fb2827f31c82fbbb9565a" dependencies = [ "spin 0.9.5", "wasmi_arena", - "wasmi_core 0.5.0", + "wasmi_core 0.12.0", "wasmparser-nostd", ] @@ -12209,9 +12209,9 @@ dependencies = [ [[package]] name = "wasmi_arena" -version = "0.1.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ea379cbb0b41f3a9f0bf7b47036d036aae7f43383d8cc487d4deccf40dee0a" +checksum = "401c1f35e413fac1846d4843745589d9ec678977ab35a384db8ae7830525d468" [[package]] name = "wasmi_core" @@ -12229,13 +12229,14 @@ dependencies = [ [[package]] name = "wasmi_core" -version = "0.5.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5bf998ab792be85e20e771fe14182b4295571ad1d4f89d3da521c1bef5f597a" +checksum = "624e6333e861ef49095d2d678b76ebf30b06bf37effca845be7e5b87c90071b7" dependencies = [ "downcast-rs", "libm 0.2.6", "num-traits", + "paste", ] [[package]] @@ -12250,9 +12251,9 @@ dependencies = [ [[package]] name = "wasmparser-nostd" -version = "0.91.0" +version = "0.100.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c37f310b5a62bfd5ae7c0f1d8e6f98af16a5d6d84ba764e9c36439ec14e318b" +checksum = "9157cab83003221bfd385833ab587a039f5d6fa7304854042ba358a3b09e0724" dependencies = [ "indexmap-nostd", ] diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 3f0ea07122884..48bea5ddc101f 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -2147,7 +2147,7 @@ impl_runtime_apis! { storage_deposit_limit, input_data, true, - pallet_contracts::Determinism::Deterministic, + pallet_contracts::Determinism::Enforced, ) } diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index e19326b785b2b..f357a21b9cf5e 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -26,8 +26,8 @@ serde = { version = "1", optional = true, features = ["derive"] } smallvec = { version = "1", default-features = false, features = [ "const_generics", ] } -wasmi = { version = "0.20", default-features = false } -wasmparser = { package = "wasmparser-nostd", version = "0.91", default-features = false } +wasmi = { version = "0.28", default-features = false } +wasmparser = { package = "wasmparser-nostd", version = "0.100", default-features = false } impl-trait-for-tuples = "0.2" # Only used in benchmarking to generate random contract code diff --git a/frame/contracts/proc-macro/src/lib.rs b/frame/contracts/proc-macro/src/lib.rs index c3e61dae5f000..32241068fe23f 100644 --- a/frame/contracts/proc-macro/src/lib.rs +++ b/frame/contracts/proc-macro/src/lib.rs @@ -613,7 +613,7 @@ fn expand_functions(def: &EnvDef, expand_blocks: bool, host_state: TokenStream2) let inner = if expand_blocks { quote! { || #output { let (memory, ctx) = __caller__ - .host_data() + .data() .memory() .expect("Memory must be set when setting up host data; qed") .data_and_store_mut(&mut __caller__); @@ -630,7 +630,7 @@ fn expand_functions(def: &EnvDef, expand_blocks: bool, host_state: TokenStream2) let map_err = if expand_blocks { quote! { |reason| { - ::wasmi::core::Trap::host(reason) + ::wasmi::core::Trap::from(reason) } } } else { diff --git a/frame/contracts/src/benchmarking/code.rs b/frame/contracts/src/benchmarking/code.rs index c2d623ae4e834..07f24f385b035 100644 --- a/frame/contracts/src/benchmarking/code.rs +++ b/frame/contracts/src/benchmarking/code.rs @@ -512,7 +512,7 @@ pub fn max_pages() -> u32 { fn inject_gas_metering(module: Module) -> Module { let schedule = T::Schedule::get(); - let gas_rules = schedule.rules(Determinism::Deterministic); + let gas_rules = schedule.rules(Determinism::Enforced); let backend = gas_metering::host_function::Injector::new("seal0", "gas"); gas_metering::inject(module, backend, &gas_rules).unwrap() } diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index fb8e4ac4b3634..9b75b140f03d8 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -381,7 +381,7 @@ benchmarks! { T::Currency::make_free_balance_be(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::sized(c, Location::Call); let origin = RawOrigin::Signed(caller.clone()); - }: _(origin, code, None, Determinism::Deterministic) + }: _(origin, code, None, Determinism::Enforced) verify { // uploading the code reserves some balance in the callers account assert!(T::Currency::reserved_balance(&caller) > 0u32.into()); @@ -397,7 +397,7 @@ benchmarks! { T::Currency::make_free_balance_be(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::dummy(); let origin = RawOrigin::Signed(caller.clone()); - let uploaded = >::bare_upload_code(caller.clone(), code, None, Determinism::Deterministic)?; + let uploaded = >::bare_upload_code(caller.clone(), code, None, Determinism::Enforced)?; assert_eq!(uploaded.code_hash, hash); assert_eq!(uploaded.deposit, T::Currency::reserved_balance(&caller)); assert!(>::code_exists(&hash)); @@ -941,7 +941,7 @@ benchmarks! { None, vec![], true, - Determinism::Deterministic, + Determinism::Enforced, ) .result?; } @@ -990,7 +990,7 @@ benchmarks! { None, vec![], true, - Determinism::Deterministic, + Determinism::Enforced, ) .result?; } @@ -3063,7 +3063,7 @@ benchmarks! { None, data, false, - Determinism::Deterministic, + Determinism::Enforced, ) .result?; } @@ -3112,7 +3112,7 @@ benchmarks! { None, data, false, - Determinism::Deterministic, + Determinism::Enforced, ) .result?; } diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 6a053712e66e7..51ea234f27376 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -665,7 +665,7 @@ where schedule, value, debug_message, - Determinism::Deterministic, + Determinism::Enforced, )?; let account_id = stack.top_frame().account_id.clone(); stack.run(executable, input_data).map(|ret| (account_id, ret)) @@ -759,10 +759,10 @@ where }, }; - // `AllowIndeterminism` will only be ever set in case of off-chain execution. + // `Relaxed` will only be ever set in case of off-chain execution. // Instantiations are never allowed even when executing off-chain. if !(executable.is_deterministic() || - (matches!(determinism, Determinism::AllowIndeterminism) && + (matches!(determinism, Determinism::Relaxed) && matches!(entry_point, ExportedFunction::Call))) { return Err(Error::::Indeterministic.into()) @@ -1607,7 +1607,7 @@ mod tests { value, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ), Ok(_) ); @@ -1661,7 +1661,7 @@ mod tests { value, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ) .unwrap(); @@ -1703,7 +1703,7 @@ mod tests { value, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ) .unwrap(); @@ -1739,7 +1739,7 @@ mod tests { 55, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ) .unwrap(); @@ -1791,7 +1791,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ); let output = result.unwrap(); @@ -1824,7 +1824,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ); let output = result.unwrap(); @@ -1855,7 +1855,7 @@ mod tests { 0, vec![1, 2, 3, 4], None, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result, Ok(_)); }); @@ -1935,7 +1935,7 @@ mod tests { value, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result, Ok(_)); @@ -1981,7 +1981,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result, Ok(_)); @@ -2015,7 +2015,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result, Ok(_)); }); @@ -2045,7 +2045,7 @@ mod tests { 0, vec![0], None, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result, Ok(_)); }); @@ -2073,7 +2073,7 @@ mod tests { 0, vec![0], None, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result, Ok(_)); }); @@ -2109,7 +2109,7 @@ mod tests { 0, vec![0], None, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result, Ok(_)); }); @@ -2145,7 +2145,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result, Ok(_)); @@ -2304,7 +2304,7 @@ mod tests { min_balance * 10, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ), Ok(_) ); @@ -2369,7 +2369,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ), Ok(_) ); @@ -2455,7 +2455,7 @@ mod tests { 0, vec![0], None, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result, Ok(_)); }); @@ -2521,7 +2521,7 @@ mod tests { 0, vec![], Some(&mut debug_buffer), - Determinism::Deterministic, + Determinism::Enforced, ) .unwrap(); }); @@ -2555,7 +2555,7 @@ mod tests { 0, vec![], Some(&mut debug_buffer), - Determinism::Deterministic, + Determinism::Enforced, ); assert!(result.is_err()); }); @@ -2592,7 +2592,7 @@ mod tests { 0, vec![], Some(&mut debug_buf_after), - Determinism::Deterministic, + Determinism::Enforced, ) .unwrap(); assert_eq!(debug_buf_before, debug_buf_after); @@ -2625,7 +2625,7 @@ mod tests { 0, CHARLIE.encode(), None, - Determinism::Deterministic + Determinism::Enforced )); // Calling into oneself fails @@ -2639,7 +2639,7 @@ mod tests { 0, BOB.encode(), None, - Determinism::Deterministic + Determinism::Enforced ) .map_err(|e| e.error), >::ReentranceDenied, @@ -2678,7 +2678,7 @@ mod tests { 0, vec![0], None, - Determinism::Deterministic + Determinism::Enforced ) .map_err(|e| e.error), >::ReentranceDenied, @@ -2713,7 +2713,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ) .unwrap(); @@ -2798,7 +2798,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ) .unwrap(); @@ -3007,7 +3007,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic + Determinism::Enforced )); }); } @@ -3134,7 +3134,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic + Determinism::Enforced )); }); } @@ -3173,7 +3173,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic + Determinism::Enforced )); }); } @@ -3212,7 +3212,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic + Determinism::Enforced )); }); } @@ -3268,7 +3268,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic + Determinism::Enforced )); }); } @@ -3324,7 +3324,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic + Determinism::Enforced )); }); } @@ -3356,7 +3356,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result, Ok(_)); }); @@ -3402,7 +3402,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic + Determinism::Enforced )); }); } @@ -3432,7 +3432,7 @@ mod tests { 0, vec![], None, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result, Ok(_)); }); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index d3369b6c290bf..cd4b7daa6da0f 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -509,9 +509,9 @@ pub mod pallet { /// the in storage version to the current /// [`InstructionWeights::version`](InstructionWeights). /// - /// - `determinism`: If this is set to any other value but [`Determinism::Deterministic`] - /// then the only way to use this code is to delegate call into it from an offchain - /// execution. Set to [`Determinism::Deterministic`] if in doubt. + /// - `determinism`: If this is set to any other value but [`Determinism::Enforced`] then + /// the only way to use this code is to delegate call into it from an offchain execution. + /// Set to [`Determinism::Enforced`] if in doubt. /// /// # Note /// @@ -625,8 +625,8 @@ pub mod pallet { storage_deposit_limit: storage_deposit_limit.map(Into::into), debug_message: None, }; - let mut output = CallInput:: { dest, determinism: Determinism::Deterministic } - .run_guarded(common); + let mut output = + CallInput:: { dest, determinism: Determinism::Enforced }.run_guarded(common); if let Ok(retval) = &output.result { if retval.did_revert() { output.result = Err(>::ContractReverted.into()); @@ -1096,7 +1096,7 @@ impl Invokable for InstantiateInput { binary.clone(), &schedule, common.origin.clone(), - Determinism::Deterministic, + Determinism::Enforced, TryInstantiate::Skip, ) .map_err(|(err, msg)| { diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index cd8f1dd1c9cd4..96a4c3203474c 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -394,7 +394,7 @@ mod v9 { initial: old.initial, maximum: old.maximum, code: old.code, - determinism: Determinism::Deterministic, + determinism: Determinism::Enforced, }) }); } @@ -464,7 +464,7 @@ mod post_checks { fn v9() -> Result<(), &'static str> { for value in CodeStorage::::iter_values() { ensure!( - value.determinism == Determinism::Deterministic, + value.determinism == Determinism::Enforced, "All pre-existing codes need to be deterministic." ); } diff --git a/frame/contracts/src/schedule.rs b/frame/contracts/src/schedule.rs index 796a7f6d3718d..ccf1e98bd2382 100644 --- a/frame/contracts/src/schedule.rs +++ b/frame/contracts/src/schedule.rs @@ -175,9 +175,9 @@ pub struct InstructionWeights { pub version: u32, /// Weight to be used for instructions which don't have benchmarks assigned. /// - /// This weight is used whenever a code is uploaded with [`Determinism::AllowIndeterminism`] + /// This weight is used whenever a code is uploaded with [`Determinism::Relaxed`] /// and an instruction (usually a float instruction) is encountered. This weight is **not** - /// used if a contract is uploaded with [`Determinism::Deterministic`]. If this field is set to + /// used if a contract is uploaded with [`Determinism::Enforced`]. If this field is set to /// `0` (the default) only deterministic codes are allowed to be uploaded. pub fallback: u32, pub i64const: u32, @@ -715,8 +715,7 @@ impl<'a, T: Config> gas_metering::Rules for ScheduleRules<'a, T> { // Returning None makes the gas instrumentation fail which we intend for // unsupported or unknown instructions. Offchain we might allow indeterminism and hence // use the fallback weight for those instructions. - _ if matches!(self.determinism, Determinism::AllowIndeterminism) && w.fallback > 0 => - w.fallback, + _ if matches!(self.determinism, Determinism::Relaxed) && w.fallback > 0 => w.fallback, _ => return None, }; Some(weight) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 915a56a3f056c..146e5fd24ad07 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -529,7 +529,7 @@ fn instantiate_and_call_and_deposit_event() { RuntimeOrigin::signed(ALICE), wasm, None, - Determinism::Deterministic + Determinism::Enforced )); // Drop previous events @@ -726,13 +726,8 @@ fn instantiate_unique_trie_id() { ExtBuilder::default().existential_deposit(500).build().execute_with(|| { let _ = Balances::deposit_creating(&ALICE, 1_000_000); - Contracts::upload_code( - RuntimeOrigin::signed(ALICE), - wasm, - None, - Determinism::Deterministic, - ) - .unwrap(); + Contracts::upload_code(RuntimeOrigin::signed(ALICE), wasm, None, Determinism::Enforced) + .unwrap(); // Instantiate the contract and store its trie id for later comparison. let addr = Contracts::bare_instantiate( @@ -860,7 +855,7 @@ fn deploy_and_call_other_contract() { .result .unwrap() .account_id; - Contracts::bare_upload_code(ALICE, callee_wasm, None, Determinism::Deterministic).unwrap(); + Contracts::bare_upload_code(ALICE, callee_wasm, None, Determinism::Enforced).unwrap(); let callee_addr = Contracts::contract_address( &caller_addr, @@ -1011,7 +1006,7 @@ fn delegate_call() { RuntimeOrigin::signed(ALICE), callee_wasm, Some(codec::Compact(100_000)), - Determinism::Deterministic, + Determinism::Enforced, )); assert_ok!(Contracts::call( @@ -1321,7 +1316,7 @@ fn destroy_contract_and_transfer_funds() { ExtBuilder::default().existential_deposit(50).build().execute_with(|| { // Create code hash for bob to instantiate let _ = Balances::deposit_creating(&ALICE, 1_000_000); - Contracts::bare_upload_code(ALICE, callee_wasm, None, Determinism::Deterministic).unwrap(); + Contracts::bare_upload_code(ALICE, callee_wasm, None, Determinism::Enforced).unwrap(); // This deploys the BOB contract, which in turn deploys the CHARLIE contract during // construction. @@ -1431,7 +1426,7 @@ fn crypto_hashes() { None, params, false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1473,7 +1468,7 @@ fn transfer_return_code() { None, vec![], false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1514,7 +1509,7 @@ fn call_return_code() { None, AsRef::<[u8]>::as_ref(&DJANGO).to_vec(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1548,7 +1543,7 @@ fn call_return_code() { .cloned() .collect(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1568,7 +1563,7 @@ fn call_return_code() { .cloned() .collect(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1587,7 +1582,7 @@ fn call_return_code() { .cloned() .collect(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1639,7 +1634,7 @@ fn instantiate_return_code() { None, callee_hash.clone(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1655,7 +1650,7 @@ fn instantiate_return_code() { None, vec![0; 33], false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1670,7 +1665,7 @@ fn instantiate_return_code() { None, callee_hash.iter().chain(&1u32.to_le_bytes()).cloned().collect(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1685,7 +1680,7 @@ fn instantiate_return_code() { None, callee_hash.iter().chain(&2u32.to_le_bytes()).cloned().collect(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1772,7 +1767,7 @@ fn chain_extension_works() { None, input.clone(), false, - Determinism::Deterministic, + Determinism::Enforced, ); assert_eq!(TestExtension::last_seen_buffer(), input); assert_eq!(result.result.unwrap().data, input); @@ -1786,7 +1781,7 @@ fn chain_extension_works() { None, ExtensionInput { extension_id: 0, func_id: 1, extra: &[] }.into(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1802,7 +1797,7 @@ fn chain_extension_works() { None, ExtensionInput { extension_id: 0, func_id: 2, extra: &[0] }.into(), false, - Determinism::Deterministic, + Determinism::Enforced, ); assert_ok!(result.result); let gas_consumed = result.gas_consumed; @@ -1814,7 +1809,7 @@ fn chain_extension_works() { None, ExtensionInput { extension_id: 0, func_id: 2, extra: &[42] }.into(), false, - Determinism::Deterministic, + Determinism::Enforced, ); assert_ok!(result.result); assert_eq!(result.gas_consumed.ref_time(), gas_consumed.ref_time() + 42); @@ -1826,7 +1821,7 @@ fn chain_extension_works() { None, ExtensionInput { extension_id: 0, func_id: 2, extra: &[95] }.into(), false, - Determinism::Deterministic, + Determinism::Enforced, ); assert_ok!(result.result); assert_eq!(result.gas_consumed.ref_time(), gas_consumed.ref_time() + 95); @@ -1840,7 +1835,7 @@ fn chain_extension_works() { None, ExtensionInput { extension_id: 0, func_id: 3, extra: &[] }.into(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1858,7 +1853,7 @@ fn chain_extension_works() { None, ExtensionInput { extension_id: 1, func_id: 0, extra: &[] }.into(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -1919,7 +1914,7 @@ fn chain_extension_temp_storage_works() { None, input.clone(), false, - Determinism::Deterministic + Determinism::Enforced ) .result ); @@ -2480,7 +2475,7 @@ fn reinstrument_does_charge() { None, zero.clone(), false, - Determinism::Deterministic, + Determinism::Enforced, ); assert!(!result0.result.unwrap().did_revert()); @@ -2492,7 +2487,7 @@ fn reinstrument_does_charge() { None, zero.clone(), false, - Determinism::Deterministic, + Determinism::Enforced, ); assert!(!result1.result.unwrap().did_revert()); @@ -2514,7 +2509,7 @@ fn reinstrument_does_charge() { None, zero.clone(), false, - Determinism::Deterministic, + Determinism::Enforced, ); assert!(!result2.result.unwrap().did_revert()); assert!(result2.gas_consumed.ref_time() > result1.gas_consumed.ref_time()); @@ -2553,7 +2548,7 @@ fn debug_message_works() { None, vec![], true, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result.result, Ok(_)); @@ -2589,7 +2584,7 @@ fn debug_message_logging_disabled() { None, vec![], false, - Determinism::Deterministic, + Determinism::Enforced, ); assert_matches!(result.result, Ok(_)); // the dispatchables always run without debugging @@ -2625,7 +2620,7 @@ fn debug_message_invalid_utf8() { None, vec![], true, - Determinism::Deterministic, + Determinism::Enforced, ); assert_ok!(result.result); assert!(result.debug_message.is_empty()); @@ -2684,7 +2679,7 @@ fn gas_estimation_nested_call_fixed_limit() { None, input.clone(), false, - Determinism::Deterministic, + Determinism::Enforced, ); assert_ok!(&result.result); @@ -2701,7 +2696,7 @@ fn gas_estimation_nested_call_fixed_limit() { Some(result.storage_deposit.charge_or_zero()), input, false, - Determinism::Deterministic, + Determinism::Enforced, ) .result ); @@ -2760,7 +2755,7 @@ fn gas_estimation_call_runtime() { None, call.encode(), false, - Determinism::Deterministic, + Determinism::Enforced, ); // contract encodes the result of the dispatch runtime let outcome = u32::decode(&mut result.result.unwrap().data.as_ref()).unwrap(); @@ -2777,7 +2772,7 @@ fn gas_estimation_call_runtime() { None, call.encode(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result ); @@ -2840,7 +2835,7 @@ fn gas_call_runtime_reentrancy_guarded() { None, call.encode(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -2902,7 +2897,7 @@ fn ecdsa_recover() { None, params, false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -2926,7 +2921,7 @@ fn upload_code_works() { RuntimeOrigin::signed(ALICE), wasm, Some(codec::Compact(1_000)), - Determinism::Deterministic, + Determinism::Enforced, )); assert!(>::contains_key(code_hash)); @@ -2966,7 +2961,7 @@ fn upload_code_limit_too_low() { RuntimeOrigin::signed(ALICE), wasm, Some(codec::Compact(100)), - Determinism::Deterministic + Determinism::Enforced ), >::StorageDepositLimitExhausted, ); @@ -2990,7 +2985,7 @@ fn upload_code_not_enough_balance() { RuntimeOrigin::signed(ALICE), wasm, Some(codec::Compact(1_000)), - Determinism::Deterministic + Determinism::Enforced ), >::StorageDepositNotEnoughFunds, ); @@ -3013,7 +3008,7 @@ fn remove_code_works() { RuntimeOrigin::signed(ALICE), wasm, Some(codec::Compact(1_000)), - Determinism::Deterministic, + Determinism::Enforced, )); assert!(>::contains_key(code_hash)); @@ -3068,7 +3063,7 @@ fn remove_code_wrong_origin() { RuntimeOrigin::signed(ALICE), wasm, Some(codec::Compact(1_000)), - Determinism::Deterministic, + Determinism::Enforced, )); assert_noop!( @@ -3538,7 +3533,7 @@ fn set_code_extrinsic() { RuntimeOrigin::signed(ALICE), new_wasm, None, - Determinism::Deterministic + Determinism::Enforced )); // Drop previous events @@ -3658,7 +3653,7 @@ fn contract_reverted() { RuntimeOrigin::signed(ALICE), wasm.clone(), None, - Determinism::Deterministic + Determinism::Enforced )); // Calling extrinsic: revert leads to an error @@ -3746,7 +3741,7 @@ fn contract_reverted() { None, input, false, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -3766,7 +3761,7 @@ fn code_rejected_error_works() { RuntimeOrigin::signed(ALICE), wasm.clone(), None, - Determinism::Deterministic + Determinism::Enforced ), >::CodeRejected, ); @@ -3792,7 +3787,7 @@ fn code_rejected_error_works() { RuntimeOrigin::signed(ALICE), wasm.clone(), None, - Determinism::Deterministic + Determinism::Enforced ), >::CodeRejected, ); @@ -3842,7 +3837,7 @@ fn set_code_hash() { RuntimeOrigin::signed(ALICE), new_wasm.clone(), None, - Determinism::Deterministic + Determinism::Enforced )); System::reset_events(); @@ -3856,7 +3851,7 @@ fn set_code_hash() { None, new_code_hash.as_ref().to_vec(), true, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -3871,7 +3866,7 @@ fn set_code_hash() { None, vec![], true, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -4268,7 +4263,7 @@ fn cannot_instantiate_indeterministic_code() { RuntimeOrigin::signed(ALICE), wasm.clone(), None, - Determinism::Deterministic + Determinism::Enforced ), >::CodeRejected, ); @@ -4278,7 +4273,7 @@ fn cannot_instantiate_indeterministic_code() { RuntimeOrigin::signed(ALICE), wasm, None, - Determinism::AllowIndeterminism, + Determinism::Relaxed, )); assert_err_ignore_postinfo!( Contracts::instantiate( @@ -4332,7 +4327,7 @@ fn cannot_instantiate_indeterministic_code() { None, code_hash.encode(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result, >::Indeterministic, @@ -4348,7 +4343,7 @@ fn cannot_instantiate_indeterministic_code() { None, code_hash.encode(), false, - Determinism::AllowIndeterminism, + Determinism::Relaxed, ) .result, >::Indeterministic, @@ -4368,7 +4363,7 @@ fn cannot_set_code_indeterministic_code() { RuntimeOrigin::signed(ALICE), wasm, None, - Determinism::AllowIndeterminism, + Determinism::Relaxed, )); // Create the contract that will call `seal_set_code_hash` @@ -4396,7 +4391,7 @@ fn cannot_set_code_indeterministic_code() { None, code_hash.encode(), false, - Determinism::AllowIndeterminism, + Determinism::Relaxed, ) .result, >::Indeterministic, @@ -4416,7 +4411,7 @@ fn delegate_call_indeterministic_code() { RuntimeOrigin::signed(ALICE), wasm, None, - Determinism::AllowIndeterminism, + Determinism::Relaxed, )); // Create the contract that will call `seal_delegate_call` @@ -4444,7 +4439,7 @@ fn delegate_call_indeterministic_code() { None, code_hash.encode(), false, - Determinism::Deterministic, + Determinism::Enforced, ) .result, >::Indeterministic, @@ -4460,7 +4455,7 @@ fn delegate_call_indeterministic_code() { None, code_hash.encode(), false, - Determinism::AllowIndeterminism, + Determinism::Relaxed, ) .result ); @@ -4499,7 +4494,7 @@ fn reentrance_count_works_with_call() { None, input, true, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -4538,7 +4533,7 @@ fn reentrance_count_works_with_delegated_call() { None, input, true, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -4590,7 +4585,7 @@ fn account_reentrance_count_works() { None, contract_addr.encode(), true, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); @@ -4603,7 +4598,7 @@ fn account_reentrance_count_works() { None, another_contract_addr.encode(), true, - Determinism::Deterministic, + Determinism::Enforced, ) .result .unwrap(); diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index cfda9c37611b9..5e4ffcfe0a598 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -127,7 +127,7 @@ pub enum Determinism { /// allowed. /// /// Dispatchables always use this mode in order to make on-chain execution deterministic. - Deterministic, + Enforced, /// Allow calling or uploading an indeterministic code. /// /// This is only possible when calling into `pallet-contracts` directly via @@ -136,7 +136,7 @@ pub enum Determinism { /// # Note /// /// **Never** use this mode for on-chain execution. - AllowIndeterminism, + Relaxed, } impl ExportedFunction { @@ -225,7 +225,7 @@ impl PrefabWasmModule { let engine = Engine::new(&config); let module = Module::new(&engine, code)?; let mut store = Store::new(&engine, host_state); - let mut linker = Linker::new(); + let mut linker = Linker::new(&engine); E::define( &mut store, &mut linker, @@ -329,7 +329,7 @@ impl Executable for PrefabWasmModule { log::debug!(target: "runtime::contracts", "failed to instantiate code: {}", msg); Error::::CodeRejected })?; - store.state_mut().set_memory(memory); + store.data_mut().set_memory(memory); let exported_func = instance .get_export(&store, function.identifier()) @@ -346,7 +346,7 @@ impl Executable for PrefabWasmModule { let result = exported_func.call(&mut store, &[], &mut []); - store.into_state().to_execution_result(result) + store.into_data().to_execution_result(result) } fn code_hash(&self) -> &CodeHash { @@ -358,7 +358,7 @@ impl Executable for PrefabWasmModule { } fn is_deterministic(&self) -> bool { - matches!(self.determinism, Determinism::Deterministic) + matches!(self.determinism, Determinism::Enforced) } } @@ -653,7 +653,7 @@ mod tests { wasm, &schedule, ALICE, - Determinism::Deterministic, + Determinism::Enforced, TryInstantiate::Instantiate, ) .map_err(|err| err.0)? @@ -3058,12 +3058,8 @@ mod tests { let schedule = crate::Schedule::::default(); #[cfg(not(feature = "runtime-benchmarks"))] assert_err!(execute(CODE_RANDOM, vec![], MockExt::default()), >::CodeRejected); - self::prepare::reinstrument::( - &wasm, - &schedule, - Determinism::Deterministic, - ) - .unwrap(); + self::prepare::reinstrument::(&wasm, &schedule, Determinism::Enforced) + .unwrap(); } /// This test check that an unstable interface cannot be deployed. In case of runtime diff --git a/frame/contracts/src/wasm/prepare.rs b/frame/contracts/src/wasm/prepare.rs index 6a2eb6a769ecc..f0065d77a1c9a 100644 --- a/frame/contracts/src/wasm/prepare.rs +++ b/frame/contracts/src/wasm/prepare.rs @@ -155,52 +155,6 @@ impl<'a, T: Config> ContractModule<'a, T> { Ok(()) } - /// Ensures that no floating point types are in use. - fn ensure_no_floating_types(&self) -> Result<(), &'static str> { - if let Some(global_section) = self.module.global_section() { - for global in global_section.entries() { - match global.global_type().content_type() { - ValueType::F32 | ValueType::F64 => - return Err("use of floating point type in globals is forbidden"), - _ => {}, - } - } - } - - if let Some(code_section) = self.module.code_section() { - for func_body in code_section.bodies() { - for local in func_body.locals() { - match local.value_type() { - ValueType::F32 | ValueType::F64 => - return Err("use of floating point type in locals is forbidden"), - _ => {}, - } - } - } - } - - if let Some(type_section) = self.module.type_section() { - for wasm_type in type_section.types() { - match wasm_type { - Type::Function(func_type) => { - let return_type = func_type.results().get(0); - for value_type in func_type.params().iter().chain(return_type) { - match value_type { - ValueType::F32 | ValueType::F64 => - return Err( - "use of floating point type in function types is forbidden", - ), - _ => {}, - } - } - }, - } - } - } - - Ok(()) - } - /// Ensure that no function exists that has more parameters than allowed. fn ensure_parameter_limit(&self, limit: u32) -> Result<(), &'static str> { let type_section = if let Some(type_section) = self.module.type_section() { @@ -411,10 +365,9 @@ where memory64: false, extended_const: false, component_model: false, - // This is not our only defense: We check for float types later in the preparation - // process. Additionally, all instructions explicitly need to have weights assigned + // This is not our only defense: All instructions explicitly need to have weights assigned // or the deployment will fail. We have none assigned for float instructions. - deterministic_only: matches!(determinism, Determinism::Deterministic), + floats: matches!(determinism, Determinism::Relaxed), mutable_global: false, saturating_float_to_int: false, sign_extension: false, @@ -422,6 +375,7 @@ where multi_value: false, reference_types: false, simd: false, + memory_control: false, }) .validate_all(original_code) .map_err(|err| { @@ -439,10 +393,6 @@ where contract_module.ensure_parameter_limit(schedule.limits.parameters)?; contract_module.ensure_br_table_size_limit(schedule.limits.br_table_size)?; - if matches!(determinism, Determinism::Deterministic) { - contract_module.ensure_no_floating_types()?; - } - // We disallow importing `gas` function here since it is treated as implementation detail. let disallowed_imports = [b"gas".as_ref()]; let memory_limits = @@ -608,7 +558,7 @@ pub mod benchmarking { deposit: Default::default(), refcount: 0, }), - determinism: Determinism::Deterministic, + determinism: Determinism::Enforced, }) } } @@ -682,7 +632,7 @@ mod tests { wasm, &schedule, ALICE, - Determinism::Deterministic, + Determinism::Enforced, TryInstantiate::Instantiate, ); assert_matches::assert_matches!(r.map_err(|(_, msg)| msg), $($expected)*); @@ -704,7 +654,7 @@ mod tests { ) (func (export "deploy")) )"#, - Err("gas instrumentation failed") + Err("validation of new code failed") ); mod functions { @@ -1214,7 +1164,7 @@ mod tests { (func (export "deploy")) ) "#, - Err("use of floating point type in globals is forbidden") + Err("validation of new code failed") ); prepare_test!( @@ -1226,7 +1176,7 @@ mod tests { (func (export "deploy")) ) "#, - Err("use of floating point type in locals is forbidden") + Err("validation of new code failed") ); prepare_test!( @@ -1238,7 +1188,7 @@ mod tests { (func (export "deploy")) ) "#, - Err("use of floating point type in function types is forbidden") + Err("validation of new code failed") ); prepare_test!( @@ -1250,7 +1200,7 @@ mod tests { (func (export "deploy")) ) "#, - Err("use of floating point type in function types is forbidden") + Err("validation of new code failed") ); } } diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index a8a19e6f95150..43a029eadfc07 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -482,11 +482,7 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> { Err(wasmi::Error::Trap(trap)) => { // If we encoded a reason then it is some abort generated by a host function. // Otherwise the trap came from the contract. - let reason: TrapReason = *trap - .into_host() - .ok_or(Error::::ContractTrapped)? - .downcast() - .expect("`TrapReason` is the only type we use to encode host errors; qed"); + let reason: TrapReason = trap.downcast().ok_or(Error::::ContractTrapped)?; match reason { Return(ReturnData { flags, data }) => { let flags = diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index b16f11eb7f50a..4333f26c5fc5c 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_contracts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-17, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -177,8 +177,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `109` // Estimated: `1594` - // Minimum execution time: 2_736_000 picoseconds. - Weight::from_parts(2_931_000, 1594) + // Minimum execution time: 2_567_000 picoseconds. + Weight::from_parts(2_711_000, 1594) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Skipped Metadata (r:0 w:0) @@ -186,12 +186,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `481 + k * (69 ±0)` - // Estimated: `471 + k * (70 ±0)` - // Minimum execution time: 10_759_000 picoseconds. - Weight::from_parts(6_965_683, 471) - // Standard Error: 1_019 - .saturating_add(Weight::from_parts(961_947, 0).saturating_mul(k.into())) + // Measured: `450 + k * (69 ±0)` + // Estimated: `440 + k * (70 ±0)` + // Minimum execution time: 11_048_000 picoseconds. + Weight::from_parts(7_029_322, 440) + // Standard Error: 1_158 + .saturating_add(Weight::from_parts(975_010, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -203,12 +203,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `q` is `[0, 128]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `281 + q * (33 ±0)` - // Estimated: `1753 + q * (33 ±0)` - // Minimum execution time: 2_633_000 picoseconds. - Weight::from_parts(10_668_837, 1753) - // Standard Error: 3_538 - .saturating_add(Weight::from_parts(1_277_168, 0).saturating_mul(q.into())) + // Measured: `250 + q * (33 ±0)` + // Estimated: `1725 + q * (33 ±0)` + // Minimum execution time: 2_645_000 picoseconds. + Weight::from_parts(10_865_477, 1725) + // Standard Error: 3_383 + .saturating_add(Weight::from_parts(1_295_351, 0).saturating_mul(q.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 33).saturating_mul(q.into())) @@ -220,12 +220,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 61717]`. fn reinstrument(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `270 + c * (1 ±0)` - // Estimated: `4015 + c * (2 ±0)` - // Minimum execution time: 30_264_000 picoseconds. - Weight::from_parts(27_106_554, 4015) - // Standard Error: 53 - .saturating_add(Weight::from_parts(49_705, 0).saturating_mul(c.into())) + // Measured: `238 + c * (1 ±0)` + // Estimated: `3951 + c * (2 ±0)` + // Minimum execution time: 30_817_000 picoseconds. + Weight::from_parts(29_762_622, 3951) + // Standard Error: 62 + .saturating_add(Weight::from_parts(54_714, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 2).saturating_mul(c.into())) @@ -243,12 +243,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `803` - // Estimated: `21880 + c * (5 ±0)` - // Minimum execution time: 309_249_000 picoseconds. - Weight::from_parts(323_353_590, 21880) - // Standard Error: 25 - .saturating_add(Weight::from_parts(31_359, 0).saturating_mul(c.into())) + // Measured: `707` + // Estimated: `21400 + c * (5 ±0)` + // Minimum execution time: 245_493_000 picoseconds. + Weight::from_parts(253_703_384, 21400) + // Standard Error: 27 + .saturating_add(Weight::from_parts(38_078, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(c.into())) @@ -276,14 +276,14 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `270` // Estimated: `26207` - // Minimum execution time: 3_136_707_000 picoseconds. - Weight::from_parts(564_055_378, 26207) - // Standard Error: 286 - .saturating_add(Weight::from_parts(93_308, 0).saturating_mul(c.into())) - // Standard Error: 16 - .saturating_add(Weight::from_parts(1_165, 0).saturating_mul(i.into())) - // Standard Error: 16 - .saturating_add(Weight::from_parts(1_435, 0).saturating_mul(s.into())) + // Minimum execution time: 3_079_430_000 picoseconds. + Weight::from_parts(555_022_483, 26207) + // Standard Error: 290 + .saturating_add(Weight::from_parts(107_411, 0).saturating_mul(c.into())) + // Standard Error: 17 + .saturating_add(Weight::from_parts(1_123, 0).saturating_mul(i.into())) + // Standard Error: 17 + .saturating_add(Weight::from_parts(1_434, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } @@ -305,14 +305,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `546` - // Estimated: `28969` - // Minimum execution time: 1_631_314_000 picoseconds. - Weight::from_parts(236_693_159, 28969) + // Measured: `482` + // Estimated: `28521` + // Minimum execution time: 1_600_733_000 picoseconds. + Weight::from_parts(228_681_962, 28521) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_434, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_445, 0).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_445, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_456, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -328,10 +328,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) fn call() -> Weight { // Proof Size summary in bytes: - // Measured: `855` - // Estimated: `22095` - // Minimum execution time: 167_139_000 picoseconds. - Weight::from_parts(168_034_000, 22095) + // Measured: `759` + // Estimated: `21615` + // Minimum execution time: 172_310_000 picoseconds. + Weight::from_parts(176_655_000, 21615) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -348,10 +348,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `109` // Estimated: `7366` - // Minimum execution time: 306_518_000 picoseconds. - Weight::from_parts(325_652_407, 7366) - // Standard Error: 134 - .saturating_add(Weight::from_parts(93_502, 0).saturating_mul(c.into())) + // Minimum execution time: 246_364_000 picoseconds. + Weight::from_parts(262_887_234, 7366) + // Standard Error: 90 + .saturating_add(Weight::from_parts(107_926, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -365,10 +365,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `287` - // Estimated: `8078` - // Minimum execution time: 29_084_000 picoseconds. - Weight::from_parts(29_350_000, 8078) + // Measured: `255` + // Estimated: `7950` + // Minimum execution time: 29_226_000 picoseconds. + Weight::from_parts(29_542_000, 7950) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -380,10 +380,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `666` - // Estimated: `19818` - // Minimum execution time: 32_996_000 picoseconds. - Weight::from_parts(33_365_000, 19818) + // Measured: `570` + // Estimated: `19530` + // Minimum execution time: 33_921_000 picoseconds. + Weight::from_parts(35_056_000, 19530) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -400,12 +400,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_caller(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `877 + r * (6 ±0)` - // Estimated: `22210 + r * (30 ±0)` - // Minimum execution time: 298_315_000 picoseconds. - Weight::from_parts(304_612_433, 22210) - // Standard Error: 904 - .saturating_add(Weight::from_parts(285_473, 0).saturating_mul(r.into())) + // Measured: `781 + r * (6 ±0)` + // Estimated: `21730 + r * (30 ±0)` + // Minimum execution time: 232_118_000 picoseconds. + Weight::from_parts(233_883_823, 21730) + // Standard Error: 642 + .saturating_add(Weight::from_parts(340_543, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -423,16 +423,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_is_contract(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `935 + r * (272 ±0)` - // Estimated: `22315 + r * (3835 ±0)` - // Minimum execution time: 299_169_000 picoseconds. - Weight::from_parts(138_157_704, 22315) - // Standard Error: 6_115 - .saturating_add(Weight::from_parts(3_244_482, 0).saturating_mul(r.into())) + // Measured: `839 + r * (240 ±0)` + // Estimated: `21835 + r * (3675 ±0)` + // Minimum execution time: 231_712_000 picoseconds. + Weight::from_parts(74_297_097, 21835) + // Standard Error: 6_099 + .saturating_add(Weight::from_parts(3_322_192, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 3835).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 3675).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -447,16 +447,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `927 + r * (276 ±0)` - // Estimated: `22335 + r * (3855 ±0)` - // Minimum execution time: 299_262_000 picoseconds. - Weight::from_parts(157_105_627, 22335) - // Standard Error: 5_634 - .saturating_add(Weight::from_parts(3_995_666, 0).saturating_mul(r.into())) + // Measured: `831 + r * (244 ±0)` + // Estimated: `21855 + r * (3695 ±0)` + // Minimum execution time: 233_122_000 picoseconds. + Weight::from_parts(74_369_473, 21855) + // Standard Error: 6_027 + .saturating_add(Weight::from_parts(4_177_187, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 3855).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 3695).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -471,12 +471,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_own_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `884 + r * (6 ±0)` - // Estimated: `22250 + r * (30 ±0)` - // Minimum execution time: 298_259_000 picoseconds. - Weight::from_parts(303_498_245, 22250) - // Standard Error: 874 - .saturating_add(Weight::from_parts(352_839, 0).saturating_mul(r.into())) + // Measured: `788 + r * (6 ±0)` + // Estimated: `21770 + r * (30 ±0)` + // Minimum execution time: 232_822_000 picoseconds. + Weight::from_parts(232_507_418, 21770) + // Standard Error: 961 + .saturating_add(Weight::from_parts(419_331, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -494,12 +494,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_origin(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874 + r * (3 ±0)` - // Estimated: `22215 + r * (15 ±0)` - // Minimum execution time: 295_689_000 picoseconds. - Weight::from_parts(314_004_541, 22215) - // Standard Error: 1_803 - .saturating_add(Weight::from_parts(131_102, 0).saturating_mul(r.into())) + // Measured: `778 + r * (3 ±0)` + // Estimated: `21735 + r * (15 ±0)` + // Minimum execution time: 229_719_000 picoseconds. + Weight::from_parts(235_257_789, 21735) + // Standard Error: 451 + .saturating_add(Weight::from_parts(161_101, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) @@ -517,12 +517,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `878 + r * (6 ±0)` - // Estimated: `22220 + r * (30 ±0)` - // Minimum execution time: 297_579_000 picoseconds. - Weight::from_parts(299_326_920, 22220) - // Standard Error: 990 - .saturating_add(Weight::from_parts(284_789, 0).saturating_mul(r.into())) + // Measured: `782 + r * (6 ±0)` + // Estimated: `21740 + r * (30 ±0)` + // Minimum execution time: 231_517_000 picoseconds. + Weight::from_parts(236_185_452, 21740) + // Standard Error: 651 + .saturating_add(Weight::from_parts(334_659, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -540,12 +540,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_gas_left(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `879 + r * (6 ±0)` - // Estimated: `22205 + r * (30 ±0)` - // Minimum execution time: 297_651_000 picoseconds. - Weight::from_parts(304_465_467, 22205) - // Standard Error: 736 - .saturating_add(Weight::from_parts(272_149, 0).saturating_mul(r.into())) + // Measured: `783 + r * (6 ±0)` + // Estimated: `21725 + r * (30 ±0)` + // Minimum execution time: 232_855_000 picoseconds. + Weight::from_parts(239_986_328, 21725) + // Standard Error: 4_075 + .saturating_add(Weight::from_parts(345_726, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -563,12 +563,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1050 + r * (6 ±0)` - // Estimated: `25258 + r * (30 ±0)` - // Minimum execution time: 296_957_000 picoseconds. - Weight::from_parts(308_680_068, 25258) - // Standard Error: 1_377 - .saturating_add(Weight::from_parts(1_419_294, 0).saturating_mul(r.into())) + // Measured: `922 + r * (6 ±0)` + // Estimated: `24633 + r * (30 ±0)` + // Minimum execution time: 231_685_000 picoseconds. + Weight::from_parts(245_514_261, 24633) + // Standard Error: 1_635 + .saturating_add(Weight::from_parts(1_523_359, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -586,12 +586,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_value_transferred(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `888 + r * (6 ±0)` - // Estimated: `22305 + r * (30 ±0)` - // Minimum execution time: 297_735_000 picoseconds. - Weight::from_parts(301_533_807, 22305) - // Standard Error: 1_119 - .saturating_add(Weight::from_parts(277_289, 0).saturating_mul(r.into())) + // Measured: `792 + r * (6 ±0)` + // Estimated: `21825 + r * (30 ±0)` + // Minimum execution time: 233_361_000 picoseconds. + Weight::from_parts(234_553_471, 21825) + // Standard Error: 1_108 + .saturating_add(Weight::from_parts(330_383, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -609,12 +609,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_minimum_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `886 + r * (6 ±0)` - // Estimated: `22295 + r * (30 ±0)` - // Minimum execution time: 299_599_000 picoseconds. - Weight::from_parts(303_664_496, 22295) - // Standard Error: 1_009 - .saturating_add(Weight::from_parts(280_353, 0).saturating_mul(r.into())) + // Measured: `790 + r * (6 ±0)` + // Estimated: `21815 + r * (30 ±0)` + // Minimum execution time: 231_918_000 picoseconds. + Weight::from_parts(239_128_416, 21815) + // Standard Error: 1_473 + .saturating_add(Weight::from_parts(317_879, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -632,12 +632,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_block_number(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `883 + r * (6 ±0)` - // Estimated: `22285 + r * (30 ±0)` - // Minimum execution time: 297_641_000 picoseconds. - Weight::from_parts(302_437_979, 22285) - // Standard Error: 669 - .saturating_add(Weight::from_parts(270_403, 0).saturating_mul(r.into())) + // Measured: `787 + r * (6 ±0)` + // Estimated: `21805 + r * (30 ±0)` + // Minimum execution time: 231_936_000 picoseconds. + Weight::from_parts(232_240_207, 21805) + // Standard Error: 731 + .saturating_add(Weight::from_parts(330_713, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -655,12 +655,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_now(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874 + r * (6 ±0)` - // Estimated: `22215 + r * (30 ±0)` - // Minimum execution time: 297_217_000 picoseconds. - Weight::from_parts(299_538_157, 22215) - // Standard Error: 732 - .saturating_add(Weight::from_parts(280_800, 0).saturating_mul(r.into())) + // Measured: `778 + r * (6 ±0)` + // Estimated: `21735 + r * (30 ±0)` + // Minimum execution time: 231_978_000 picoseconds. + Weight::from_parts(224_881_201, 21735) + // Standard Error: 1_296 + .saturating_add(Weight::from_parts(346_872, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -680,12 +680,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_weight_to_fee(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `952 + r * (10 ±0)` - // Estimated: `25022 + r * (60 ±0)` - // Minimum execution time: 297_286_000 picoseconds. - Weight::from_parts(311_436_352, 25022) - // Standard Error: 6_811 - .saturating_add(Weight::from_parts(1_291_941, 0).saturating_mul(r.into())) + // Measured: `856 + r * (10 ±0)` + // Estimated: `24446 + r * (60 ±0)` + // Minimum execution time: 231_707_000 picoseconds. + Weight::from_parts(245_939_854, 24446) + // Standard Error: 1_369 + .saturating_add(Weight::from_parts(1_380_453, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) @@ -703,12 +703,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_gas(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `841 + r * (4 ±0)` - // Estimated: `22035 + r * (20 ±0)` - // Minimum execution time: 154_772_000 picoseconds. - Weight::from_parts(159_224_457, 22035) - // Standard Error: 212 - .saturating_add(Weight::from_parts(102_264, 0).saturating_mul(r.into())) + // Measured: `745 + r * (4 ±0)` + // Estimated: `21555 + r * (20 ±0)` + // Minimum execution time: 157_429_000 picoseconds. + Weight::from_parts(161_047_355, 21555) + // Standard Error: 1_220 + .saturating_add(Weight::from_parts(134_497, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 20).saturating_mul(r.into())) @@ -726,12 +726,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_input(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `876 + r * (6 ±0)` - // Estimated: `22220 + r * (30 ±0)` - // Minimum execution time: 297_248_000 picoseconds. - Weight::from_parts(303_805_584, 22220) - // Standard Error: 858 - .saturating_add(Weight::from_parts(223_587, 0).saturating_mul(r.into())) + // Measured: `780 + r * (6 ±0)` + // Estimated: `21740 + r * (30 ±0)` + // Minimum execution time: 232_561_000 picoseconds. + Weight::from_parts(230_989_499, 21740) + // Standard Error: 848 + .saturating_add(Weight::from_parts(282_053, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -749,12 +749,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1048576]`. fn seal_input_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `880` - // Estimated: `22220` - // Minimum execution time: 298_464_000 picoseconds. - Weight::from_parts(300_996_431, 22220) - // Standard Error: 1 - .saturating_add(Weight::from_parts(600, 0).saturating_mul(n.into())) + // Measured: `784` + // Estimated: `21740` + // Minimum execution time: 237_080_000 picoseconds. + Weight::from_parts(239_380_994, 21740) + // Standard Error: 2 + .saturating_add(Weight::from_parts(592, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -771,12 +771,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `864 + r * (45 ±0)` - // Estimated: `22140 + r * (225 ±0)` - // Minimum execution time: 294_347_000 picoseconds. - Weight::from_parts(296_793_034, 22140) - // Standard Error: 277_251 - .saturating_add(Weight::from_parts(1_711_665, 0).saturating_mul(r.into())) + // Measured: `768 + r * (45 ±0)` + // Estimated: `21660 + r * (225 ±0)` + // Minimum execution time: 228_669_000 picoseconds. + Weight::from_parts(230_916_471, 21660) + // Standard Error: 295_520 + .saturating_add(Weight::from_parts(1_420_928, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 225).saturating_mul(r.into())) @@ -794,12 +794,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1048576]`. fn seal_return_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874` - // Estimated: `22255` - // Minimum execution time: 297_257_000 picoseconds. - Weight::from_parts(300_088_288, 22255) + // Measured: `778` + // Estimated: `21775` + // Minimum execution time: 231_626_000 picoseconds. + Weight::from_parts(232_097_413, 21775) // Standard Error: 1 - .saturating_add(Weight::from_parts(181, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(185, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -820,17 +820,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `906 + r * (452 ±0)` - // Estimated: `26183 + r * (15994 ±0)` - // Minimum execution time: 296_510_000 picoseconds. - Weight::from_parts(299_169_757, 26183) - // Standard Error: 205_313 - .saturating_add(Weight::from_parts(78_059_642, 0).saturating_mul(r.into())) + // Measured: `810 + r * (356 ±0)` + // Estimated: `25511 + r * (15321 ±0)` + // Minimum execution time: 230_758_000 picoseconds. + Weight::from_parts(233_235_993, 25511) + // Standard Error: 196_168 + .saturating_add(Weight::from_parts(81_177_506, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 15994).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 15321).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -847,12 +847,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_random(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `921 + r * (10 ±0)` - // Estimated: `24859 + r * (60 ±0)` - // Minimum execution time: 299_299_000 picoseconds. - Weight::from_parts(314_487_015, 24859) - // Standard Error: 1_552 - .saturating_add(Weight::from_parts(1_753_960, 0).saturating_mul(r.into())) + // Measured: `825 + r * (10 ±0)` + // Estimated: `24283 + r * (60 ±0)` + // Minimum execution time: 232_457_000 picoseconds. + Weight::from_parts(240_943_161, 24283) + // Standard Error: 3_085 + .saturating_add(Weight::from_parts(1_837_168, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) @@ -870,12 +870,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_deposit_event(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874 + r * (10 ±0)` - // Estimated: `22215 + r * (50 ±0)` - // Minimum execution time: 296_188_000 picoseconds. - Weight::from_parts(305_901_539, 22215) - // Standard Error: 2_782 - .saturating_add(Weight::from_parts(3_456_054, 0).saturating_mul(r.into())) + // Measured: `778 + r * (10 ±0)` + // Estimated: `21735 + r * (50 ±0)` + // Minimum execution time: 229_788_000 picoseconds. + Weight::from_parts(233_520_858, 21735) + // Standard Error: 9_561 + .saturating_add(Weight::from_parts(3_596_294, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 50).saturating_mul(r.into())) @@ -894,14 +894,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_deposit_event_per_topic_and_byte(t: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `893 + t * (32 ±0)` - // Estimated: `22320 + t * (2640 ±0)` - // Minimum execution time: 313_860_000 picoseconds. - Weight::from_parts(312_473_092, 22320) - // Standard Error: 250_852 - .saturating_add(Weight::from_parts(2_258_502, 0).saturating_mul(t.into())) - // Standard Error: 70 - .saturating_add(Weight::from_parts(312, 0).saturating_mul(n.into())) + // Measured: `797 + t * (32 ±0)` + // Estimated: `21840 + t * (2640 ±0)` + // Minimum execution time: 248_294_000 picoseconds. + Weight::from_parts(239_709_759, 21840) + // Standard Error: 66_903 + .saturating_add(Weight::from_parts(2_880_732, 0).saturating_mul(t.into())) + // Standard Error: 18 + .saturating_add(Weight::from_parts(725, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -921,12 +921,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_debug_message(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (7 ±0)` - // Estimated: `22205 + r * (35 ±0)` - // Minimum execution time: 162_043_000 picoseconds. - Weight::from_parts(166_132_332, 22205) - // Standard Error: 716 - .saturating_add(Weight::from_parts(184_981, 0).saturating_mul(r.into())) + // Measured: `777 + r * (7 ±0)` + // Estimated: `21725 + r * (35 ±0)` + // Minimum execution time: 170_601_000 picoseconds. + Weight::from_parts(165_819_714, 21725) + // Standard Error: 452 + .saturating_add(Weight::from_parts(240_362, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 35).saturating_mul(r.into())) @@ -944,12 +944,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 1048576]`. fn seal_debug_message_per_byte(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `125824` - // Estimated: `270073` - // Minimum execution time: 414_433_000 picoseconds. - Weight::from_parts(417_483_627, 270073) - // Standard Error: 1 - .saturating_add(Weight::from_parts(748, 0).saturating_mul(i.into())) + // Measured: `125728` + // Estimated: `269977` + // Minimum execution time: 349_543_000 picoseconds. + Weight::from_parts(352_945_102, 269977) + // Standard Error: 2 + .saturating_add(Weight::from_parts(749, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -958,12 +958,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 800]`. fn seal_set_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `941 + r * (292 ±0)` - // Estimated: `939 + r * (293 ±0)` - // Minimum execution time: 299_500_000 picoseconds. - Weight::from_parts(194_466_413, 939) - // Standard Error: 9_986 - .saturating_add(Weight::from_parts(6_010_112, 0).saturating_mul(r.into())) + // Measured: `845 + r * (292 ±0)` + // Estimated: `843 + r * (293 ±0)` + // Minimum execution time: 238_766_000 picoseconds. + Weight::from_parts(130_994_282, 843) + // Standard Error: 10_413 + .saturating_add(Weight::from_parts(6_134_087, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -975,12 +975,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_set_storage_per_new_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1432` - // Estimated: `1405` - // Minimum execution time: 314_171_000 picoseconds. - Weight::from_parts(335_595_397, 1405) - // Standard Error: 67 - .saturating_add(Weight::from_parts(90, 0).saturating_mul(n.into())) + // Measured: `1304` + // Estimated: `1280` + // Minimum execution time: 248_137_000 picoseconds. + Weight::from_parts(265_535_917, 1280) + // Standard Error: 28 + .saturating_add(Weight::from_parts(387, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -989,12 +989,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_set_storage_per_old_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1295 + n * (1 ±0)` - // Estimated: `1292 + n * (1 ±0)` - // Minimum execution time: 313_479_000 picoseconds. - Weight::from_parts(317_435_100, 1292) - // Standard Error: 41 - .saturating_add(Weight::from_parts(106, 0).saturating_mul(n.into())) + // Measured: `1167 + n * (1 ±0)` + // Estimated: `1167 + n * (1 ±0)` + // Minimum execution time: 246_752_000 picoseconds. + Weight::from_parts(250_315_210, 1167) + // Standard Error: 42 + .saturating_add(Weight::from_parts(135, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1004,12 +1004,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 800]`. fn seal_clear_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `937 + r * (288 ±0)` - // Estimated: `941 + r * (289 ±0)` - // Minimum execution time: 297_831_000 picoseconds. - Weight::from_parts(196_983_778, 941) - // Standard Error: 9_899 - .saturating_add(Weight::from_parts(5_904_642, 0).saturating_mul(r.into())) + // Measured: `841 + r * (288 ±0)` + // Estimated: `845 + r * (289 ±0)` + // Minimum execution time: 232_873_000 picoseconds. + Weight::from_parts(130_360_558, 845) + // Standard Error: 10_026 + .saturating_add(Weight::from_parts(6_023_862, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1021,10 +1021,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_clear_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1291 + n * (1 ±0)` - // Estimated: `1288 + n * (1 ±0)` - // Minimum execution time: 320_156_000 picoseconds. - Weight::from_parts(327_504_368, 1288) + // Measured: `1163 + n * (1 ±0)` + // Estimated: `1163 + n * (1 ±0)` + // Minimum execution time: 247_079_000 picoseconds. + Weight::from_parts(248_922_003, 1163) + // Standard Error: 22 + .saturating_add(Weight::from_parts(201, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1034,12 +1036,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 800]`. fn seal_get_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `931 + r * (296 ±0)` - // Estimated: `936 + r * (297 ±0)` - // Minimum execution time: 305_849_000 picoseconds. - Weight::from_parts(219_649_351, 936) - // Standard Error: 9_157 - .saturating_add(Weight::from_parts(4_846_108, 0).saturating_mul(r.into())) + // Measured: `835 + r * (296 ±0)` + // Estimated: `840 + r * (297 ±0)` + // Minimum execution time: 232_696_000 picoseconds. + Weight::from_parts(144_147_151, 840) + // Standard Error: 8_846 + .saturating_add(Weight::from_parts(4_931_414, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1050,12 +1052,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_get_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1307 + n * (1 ±0)` - // Estimated: `1304 + n * (1 ±0)` - // Minimum execution time: 312_106_000 picoseconds. - Weight::from_parts(315_905_779, 1304) - // Standard Error: 44 - .saturating_add(Weight::from_parts(674, 0).saturating_mul(n.into())) + // Measured: `1179 + n * (1 ±0)` + // Estimated: `1179 + n * (1 ±0)` + // Minimum execution time: 247_795_000 picoseconds. + Weight::from_parts(252_944_118, 1179) + // Standard Error: 45 + .saturating_add(Weight::from_parts(480, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1065,12 +1067,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 800]`. fn seal_contains_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `952 + r * (288 ±0)` - // Estimated: `953 + r * (289 ±0)` - // Minimum execution time: 299_372_000 picoseconds. - Weight::from_parts(211_293_493, 953) - // Standard Error: 8_509 - .saturating_add(Weight::from_parts(4_688_993, 0).saturating_mul(r.into())) + // Measured: `856 + r * (288 ±0)` + // Estimated: `857 + r * (289 ±0)` + // Minimum execution time: 232_166_000 picoseconds. + Weight::from_parts(148_503_428, 857) + // Standard Error: 8_704 + .saturating_add(Weight::from_parts(4_766_055, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1081,12 +1083,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_contains_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1294 + n * (1 ±0)` - // Estimated: `1291 + n * (1 ±0)` - // Minimum execution time: 311_605_000 picoseconds. - Weight::from_parts(315_473_850, 1291) - // Standard Error: 37 - .saturating_add(Weight::from_parts(3, 0).saturating_mul(n.into())) + // Measured: `1166 + n * (1 ±0)` + // Estimated: `1166 + n * (1 ±0)` + // Minimum execution time: 246_128_000 picoseconds. + Weight::from_parts(248_323_705, 1166) + // Standard Error: 21 + .saturating_add(Weight::from_parts(92, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1096,12 +1098,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 800]`. fn seal_take_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `925 + r * (296 ±0)` - // Estimated: `932 + r * (297 ±0)` - // Minimum execution time: 298_231_000 picoseconds. - Weight::from_parts(200_178_698, 932) - // Standard Error: 10_452 - .saturating_add(Weight::from_parts(6_107_653, 0).saturating_mul(r.into())) + // Measured: `829 + r * (296 ±0)` + // Estimated: `836 + r * (297 ±0)` + // Minimum execution time: 232_976_000 picoseconds. + Weight::from_parts(132_373_848, 836) + // Standard Error: 9_855 + .saturating_add(Weight::from_parts(6_181_821, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1113,12 +1115,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_take_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1308 + n * (1 ±0)` - // Estimated: `1305 + n * (1 ±0)` - // Minimum execution time: 314_970_000 picoseconds. - Weight::from_parts(318_135_821, 1305) - // Standard Error: 26 - .saturating_add(Weight::from_parts(630, 0).saturating_mul(n.into())) + // Measured: `1180 + n * (1 ±0)` + // Estimated: `1180 + n * (1 ±0)` + // Minimum execution time: 247_907_000 picoseconds. + Weight::from_parts(251_984_133, 1180) + // Standard Error: 41 + .saturating_add(Weight::from_parts(639, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1136,12 +1138,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_transfer(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1501 + r * (45 ±0)` - // Estimated: `27383 + r * (2700 ±0)` - // Minimum execution time: 299_629_000 picoseconds. - Weight::from_parts(150_915_187, 27383) - // Standard Error: 25_604 - .saturating_add(Weight::from_parts(20_859_844, 0).saturating_mul(r.into())) + // Measured: `1373 + r * (45 ±0)` + // Estimated: `26753 + r * (2700 ±0)` + // Minimum execution time: 232_614_000 picoseconds. + Weight::from_parts(127_024_367, 26753) + // Standard Error: 54_521 + .saturating_add(Weight::from_parts(20_975_575, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) @@ -1161,17 +1163,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1670 + r * (288 ±0)` - // Estimated: `27813 + r * (6391 ±0)` - // Minimum execution time: 299_578_000 picoseconds. - Weight::from_parts(300_036_000, 27813) - // Standard Error: 102_709 - .saturating_add(Weight::from_parts(283_767_316, 0).saturating_mul(r.into())) + // Measured: `1512 + r * (256 ±0)` + // Estimated: `27163 + r * (6231 ±0)` + // Minimum execution time: 233_446_000 picoseconds. + Weight::from_parts(234_338_000, 27163) + // Standard Error: 122_754 + .saturating_add(Weight::from_parts(216_709_600, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 6391).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 6231).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1186,17 +1188,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (935 ±0)` - // Estimated: `22235 + r * (8322 ±10)` - // Minimum execution time: 298_943_000 picoseconds. - Weight::from_parts(299_619_000, 22235) - // Standard Error: 117_493 - .saturating_add(Weight::from_parts(280_555_517, 0).saturating_mul(r.into())) + // Measured: `0 + r * (902 ±0)` + // Estimated: `21755 + r * (8167 ±7)` + // Minimum execution time: 232_717_000 picoseconds. + Weight::from_parts(233_405_000, 21755) + // Standard Error: 98_607 + .saturating_add(Weight::from_parts(212_329_100, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 8322).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 8167).saturating_mul(r.into())) } /// Storage: System Account (r:3 w:2) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1212,19 +1214,19 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 1048576]`. fn seal_call_per_transfer_clone_byte(t: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1314 + t * (268 ±0)` - // Estimated: `31815 + t * (6290 ±0)` - // Minimum execution time: 453_013_000 picoseconds. - Weight::from_parts(442_536_283, 31815) - // Standard Error: 1_339_541 - .saturating_add(Weight::from_parts(17_062_445, 0).saturating_mul(t.into())) - // Standard Error: 1 - .saturating_add(Weight::from_parts(604, 0).saturating_mul(c.into())) + // Measured: `1154 + t * (204 ±0)` + // Estimated: `31015 + t * (5970 ±0)` + // Minimum execution time: 392_113_000 picoseconds. + Weight::from_parts(376_522_702, 31015) + // Standard Error: 1_388_011 + .saturating_add(Weight::from_parts(19_125_093, 0).saturating_mul(t.into())) + // Standard Error: 2 + .saturating_add(Weight::from_parts(609, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(5_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 6290).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 5970).saturating_mul(t.into())) } /// Storage: System Account (r:3202 w:3202) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1243,17 +1245,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_instantiate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1988 + r * (319 ±0)` - // Estimated: `34745 + r * (17090 ±0)` - // Minimum execution time: 300_123_000 picoseconds. - Weight::from_parts(300_406_000, 34745) - // Standard Error: 420_997 - .saturating_add(Weight::from_parts(382_704_025, 0).saturating_mul(r.into())) + // Measured: `1859 + r * (253 ±0)` + // Estimated: `33859 + r * (16628 ±0)` + // Minimum execution time: 234_438_000 picoseconds. + Weight::from_parts(234_751_000, 33859) + // Standard Error: 450_507 + .saturating_add(Weight::from_parts(313_121_404, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) .saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 17090).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 16628).saturating_mul(r.into())) } /// Storage: System Account (r:4 w:4) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1274,21 +1276,21 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 983040]`. fn seal_instantiate_per_transfer_input_salt_byte(t: u32, i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1231 + t * (219 ±0)` - // Estimated: `43797 + t * (3812 ±2)` - // Minimum execution time: 1_636_322_000 picoseconds. - Weight::from_parts(360_859_331, 43797) - // Standard Error: 4_816_923 - .saturating_add(Weight::from_parts(109_179_023, 0).saturating_mul(t.into())) + // Measured: `1071 + t * (187 ±0)` + // Estimated: `42684 + t * (3588 ±2)` + // Minimum execution time: 1_570_178_000 picoseconds. + Weight::from_parts(284_062_841, 42684) + // Standard Error: 4_396_597 + .saturating_add(Weight::from_parts(106_424_960, 0).saturating_mul(t.into())) // Standard Error: 7 - .saturating_add(Weight::from_parts(1_180, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_183, 0).saturating_mul(i.into())) // Standard Error: 7 - .saturating_add(Weight::from_parts(1_344, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_354, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(10_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 3812).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 3588).saturating_mul(t.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1303,12 +1305,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (8 ±0)` - // Estimated: `22190 + r * (40 ±0)` - // Minimum execution time: 297_521_000 picoseconds. - Weight::from_parts(303_523_260, 22190) - // Standard Error: 1_162 - .saturating_add(Weight::from_parts(542_201, 0).saturating_mul(r.into())) + // Measured: `777 + r * (8 ±0)` + // Estimated: `21710 + r * (40 ±0)` + // Minimum execution time: 230_557_000 picoseconds. + Weight::from_parts(233_276_698, 21710) + // Standard Error: 1_026 + .saturating_add(Weight::from_parts(587_723, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1326,12 +1328,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_sha2_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `881` - // Estimated: `22225` - // Minimum execution time: 299_877_000 picoseconds. - Weight::from_parts(293_538_014, 22225) - // Standard Error: 2 - .saturating_add(Weight::from_parts(3_967, 0).saturating_mul(n.into())) + // Measured: `785` + // Estimated: `21745` + // Minimum execution time: 234_151_000 picoseconds. + Weight::from_parts(240_199_365, 21745) + // Standard Error: 3 + .saturating_add(Weight::from_parts(3_941, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1348,12 +1350,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `875 + r * (8 ±0)` - // Estimated: `22205 + r * (40 ±0)` - // Minimum execution time: 297_672_000 picoseconds. - Weight::from_parts(299_933_312, 22205) - // Standard Error: 1_138 - .saturating_add(Weight::from_parts(713_189, 0).saturating_mul(r.into())) + // Measured: `779 + r * (8 ±0)` + // Estimated: `21725 + r * (40 ±0)` + // Minimum execution time: 229_931_000 picoseconds. + Weight::from_parts(234_961_690, 21725) + // Standard Error: 1_073 + .saturating_add(Weight::from_parts(758_259, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1371,12 +1373,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_keccak_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `883` - // Estimated: `22245` - // Minimum execution time: 299_048_000 picoseconds. - Weight::from_parts(293_055_982, 22245) + // Measured: `787` + // Estimated: `21765` + // Minimum execution time: 232_448_000 picoseconds. + Weight::from_parts(225_974_008, 21765) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_179, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(3_174, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1393,12 +1395,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `875 + r * (8 ±0)` - // Estimated: `22220 + r * (40 ±0)` - // Minimum execution time: 301_991_000 picoseconds. - Weight::from_parts(300_027_441, 22220) - // Standard Error: 981 - .saturating_add(Weight::from_parts(391_319, 0).saturating_mul(r.into())) + // Measured: `779 + r * (8 ±0)` + // Estimated: `21740 + r * (40 ±0)` + // Minimum execution time: 229_251_000 picoseconds. + Weight::from_parts(234_182_627, 21740) + // Standard Error: 836 + .saturating_add(Weight::from_parts(424_375, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1416,12 +1418,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `883` - // Estimated: `22265` - // Minimum execution time: 296_522_000 picoseconds. - Weight::from_parts(296_121_638, 22265) + // Measured: `787` + // Estimated: `21785` + // Minimum execution time: 230_896_000 picoseconds. + Weight::from_parts(224_913_556, 21785) // Standard Error: 2 - .saturating_add(Weight::from_parts(916, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(919, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1438,12 +1440,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `875 + r * (8 ±0)` - // Estimated: `22225 + r * (40 ±0)` - // Minimum execution time: 296_228_000 picoseconds. - Weight::from_parts(301_472_299, 22225) - // Standard Error: 875 - .saturating_add(Weight::from_parts(381_027, 0).saturating_mul(r.into())) + // Measured: `779 + r * (8 ±0)` + // Estimated: `21745 + r * (40 ±0)` + // Minimum execution time: 230_314_000 picoseconds. + Weight::from_parts(233_426_327, 21745) + // Standard Error: 926 + .saturating_add(Weight::from_parts(425_341, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1461,12 +1463,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_128_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `883` - // Estimated: `22235` - // Minimum execution time: 296_644_000 picoseconds. - Weight::from_parts(289_879_744, 22235) + // Measured: `787` + // Estimated: `21755` + // Minimum execution time: 230_424_000 picoseconds. + Weight::from_parts(231_136_218, 21755) // Standard Error: 2 - .saturating_add(Weight::from_parts(925, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(917, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1483,12 +1485,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `800 + r * (78 ±0)` - // Estimated: `21845 + r * (390 ±0)` - // Minimum execution time: 297_804_000 picoseconds. - Weight::from_parts(471_994_534, 21845) - // Standard Error: 9_479 - .saturating_add(Weight::from_parts(36_886_028, 0).saturating_mul(r.into())) + // Measured: `704 + r * (78 ±0)` + // Estimated: `21370 + r * (390 ±0)` + // Minimum execution time: 232_862_000 picoseconds. + Weight::from_parts(379_152_870, 21370) + // Standard Error: 11_607 + .saturating_add(Weight::from_parts(36_955_410, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 390).saturating_mul(r.into())) @@ -1506,12 +1508,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `645 + r * (44 ±0)` - // Estimated: `21110 + r * (220 ±0)` - // Minimum execution time: 298_623_000 picoseconds. - Weight::from_parts(322_192_102, 21110) - // Standard Error: 3_207 - .saturating_add(Weight::from_parts(9_243_653, 0).saturating_mul(r.into())) + // Measured: `549 + r * (44 ±0)` + // Estimated: `20630 + r * (220 ±0)` + // Minimum execution time: 232_668_000 picoseconds. + Weight::from_parts(253_308_468, 20630) + // Standard Error: 3_022 + .saturating_add(Weight::from_parts(9_249_849, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 220).saturating_mul(r.into())) @@ -1531,17 +1533,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (1030 ±0)` - // Estimated: `30592 + r * (11919 ±7)` - // Minimum execution time: 298_574_000 picoseconds. - Weight::from_parts(299_383_000, 30592) - // Standard Error: 44_061 - .saturating_add(Weight::from_parts(21_625_366, 0).saturating_mul(r.into())) + // Measured: `0 + r * (964 ±0)` + // Estimated: `29920 + r * (11544 ±7)` + // Minimum execution time: 233_910_000 picoseconds. + Weight::from_parts(234_607_000, 29920) + // Standard Error: 46_118 + .saturating_add(Weight::from_parts(21_927_957, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 11919).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 11544).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1556,12 +1558,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `869 + r * (3 ±0)` - // Estimated: `22215 + r * (15 ±0)` - // Minimum execution time: 297_014_000 picoseconds. - Weight::from_parts(301_226_615, 22215) - // Standard Error: 439 - .saturating_add(Weight::from_parts(143_017, 0).saturating_mul(r.into())) + // Measured: `773 + r * (3 ±0)` + // Estimated: `21735 + r * (15 ±0)` + // Minimum execution time: 231_823_000 picoseconds. + Weight::from_parts(237_996_137, 21735) + // Standard Error: 598 + .saturating_add(Weight::from_parts(163_106, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) @@ -1579,12 +1581,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2072 + r * (39 ±0)` - // Estimated: `27645 + r * (200 ±0)` - // Minimum execution time: 299_074_000 picoseconds. - Weight::from_parts(336_979_016, 27645) - // Standard Error: 1_163 - .saturating_add(Weight::from_parts(227_998, 0).saturating_mul(r.into())) + // Measured: `1975 + r * (39 ±0)` + // Estimated: `27145 + r * (200 ±0)` + // Minimum execution time: 235_077_000 picoseconds. + Weight::from_parts(267_876_360, 27145) + // Standard Error: 1_147 + .saturating_add(Weight::from_parts(256_275, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 200).saturating_mul(r.into())) @@ -1604,12 +1606,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `872 + r * (3 ±0)` - // Estimated: `24580 + r * (18 ±0)` - // Minimum execution time: 296_959_000 picoseconds. - Weight::from_parts(303_796_839, 24580) + // Measured: `776 + r * (3 ±0)` + // Estimated: `24004 + r * (18 ±0)` + // Minimum execution time: 231_384_000 picoseconds. + Weight::from_parts(237_086_900, 24004) // Standard Error: 534 - .saturating_add(Weight::from_parts(118_978, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(140_842, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 18).saturating_mul(r.into())) @@ -1619,508 +1621,510 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_020_000 picoseconds. - Weight::from_parts(1_355_107, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(4_110, 0).saturating_mul(r.into())) + // Minimum execution time: 1_721_000 picoseconds. + Weight::from_parts(2_456_746, 0) + // Standard Error: 30 + .saturating_add(Weight::from_parts(2_788, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64load(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_224_000 picoseconds. - Weight::from_parts(1_819_284, 0) - // Standard Error: 10 - .saturating_add(Weight::from_parts(10_803, 0).saturating_mul(r.into())) + // Minimum execution time: 1_824_000 picoseconds. + Weight::from_parts(2_366_036, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(6_446, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64store(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_216_000 picoseconds. - Weight::from_parts(1_795_011, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(10_000, 0).saturating_mul(r.into())) + // Minimum execution time: 1_840_000 picoseconds. + Weight::from_parts(2_332_115, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(6_012, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_select(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_127_000 picoseconds. - Weight::from_parts(1_491_730, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(11_471, 0).saturating_mul(r.into())) + // Minimum execution time: 1_731_000 picoseconds. + Weight::from_parts(2_078_873, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(7_931, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_044_000 picoseconds. - Weight::from_parts(2_330_852, 0) - // Standard Error: 69 - .saturating_add(Weight::from_parts(12_866, 0).saturating_mul(r.into())) + // Minimum execution time: 1_768_000 picoseconds. + Weight::from_parts(1_916_551, 0) + // Standard Error: 8 + .saturating_add(Weight::from_parts(10_597, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_067_000 picoseconds. - Weight::from_parts(1_399_626, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(6_430, 0).saturating_mul(r.into())) + // Minimum execution time: 1_735_000 picoseconds. + Weight::from_parts(1_962_845, 0) + // Standard Error: 14 + .saturating_add(Weight::from_parts(4_631, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_087_000 picoseconds. - Weight::from_parts(1_463_592, 0) - // Standard Error: 12 - .saturating_add(Weight::from_parts(9_707, 0).saturating_mul(r.into())) + // Minimum execution time: 1_688_000 picoseconds. + Weight::from_parts(1_172_825, 0) + // Standard Error: 76 + .saturating_add(Weight::from_parts(8_007, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br_table(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_110_000 picoseconds. - Weight::from_parts(1_058_258, 0) - // Standard Error: 22 - .saturating_add(Weight::from_parts(11_713, 0).saturating_mul(r.into())) + // Minimum execution time: 1_725_000 picoseconds. + Weight::from_parts(1_535_833, 0) + // Standard Error: 26 + .saturating_add(Weight::from_parts(9_489, 0).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. - fn instr_br_table_per_entry(_e: u32, ) -> Weight { + fn instr_br_table_per_entry(e: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_189_000 picoseconds. - Weight::from_parts(1_416_188, 0) + // Minimum execution time: 1_814_000 picoseconds. + Weight::from_parts(1_926_367, 0) + // Standard Error: 16 + .saturating_add(Weight::from_parts(219, 0).saturating_mul(e.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_201_000 picoseconds. - Weight::from_parts(3_375_851, 0) - // Standard Error: 96 - .saturating_add(Weight::from_parts(22_970, 0).saturating_mul(r.into())) + // Minimum execution time: 1_770_000 picoseconds. + Weight::from_parts(2_436_918, 0) + // Standard Error: 8 + .saturating_add(Weight::from_parts(17_890, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_call_indirect(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_286_000 picoseconds. - Weight::from_parts(2_817_725, 0) - // Standard Error: 55 - .saturating_add(Weight::from_parts(29_437, 0).saturating_mul(r.into())) + // Minimum execution time: 1_920_000 picoseconds. + Weight::from_parts(2_729_712, 0) + // Standard Error: 39 + .saturating_add(Weight::from_parts(24_853, 0).saturating_mul(r.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_319_000 picoseconds. - Weight::from_parts(1_636_286, 0) - // Standard Error: 31 - .saturating_add(Weight::from_parts(1_240, 0).saturating_mul(l.into())) + // Minimum execution time: 1_869_000 picoseconds. + Weight::from_parts(2_147_970, 0) + // Standard Error: 46 + .saturating_add(Weight::from_parts(1_237, 0).saturating_mul(l.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_507_000 picoseconds. - Weight::from_parts(2_785_119, 0) + // Minimum execution time: 3_012_000 picoseconds. + Weight::from_parts(3_234_440, 0) // Standard Error: 1 - .saturating_add(Weight::from_parts(4_601, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(2_433, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_494_000 picoseconds. - Weight::from_parts(2_948_015, 0) - // Standard Error: 14 - .saturating_add(Weight::from_parts(4_788, 0).saturating_mul(r.into())) + // Minimum execution time: 3_037_000 picoseconds. + Weight::from_parts(3_204_600, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_627, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_tee(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_443_000 picoseconds. - Weight::from_parts(3_065_273, 0) - // Standard Error: 15 - .saturating_add(Weight::from_parts(6_489, 0).saturating_mul(r.into())) + // Minimum execution time: 2_974_000 picoseconds. + Weight::from_parts(3_301_366, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_836, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_global_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_214_000 picoseconds. - Weight::from_parts(1_634_049, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(8_960, 0).saturating_mul(r.into())) + // Minimum execution time: 1_853_000 picoseconds. + Weight::from_parts(2_310_141, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(8_387, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_global_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_180_000 picoseconds. - Weight::from_parts(1_555_599, 0) + // Minimum execution time: 1_828_000 picoseconds. + Weight::from_parts(2_315_323, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(9_205, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(8_797, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_memory_current(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_223_000 picoseconds. - Weight::from_parts(1_626_002, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(8_181, 0).saturating_mul(r.into())) + // Minimum execution time: 1_800_000 picoseconds. + Weight::from_parts(2_117_252, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(3_741, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 16]`. fn instr_memory_grow(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_148_000 picoseconds. - Weight::from_parts(307_155, 0) - // Standard Error: 138_541 - .saturating_add(Weight::from_parts(13_291_570, 0).saturating_mul(r.into())) + // Minimum execution time: 1_743_000 picoseconds. + Weight::from_parts(1_054_728, 0) + // Standard Error: 137_128 + .saturating_add(Weight::from_parts(13_179_446, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64clz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_079_000 picoseconds. - Weight::from_parts(1_372_409, 0) - // Standard Error: 50 - .saturating_add(Weight::from_parts(6_427, 0).saturating_mul(r.into())) + // Minimum execution time: 1_735_000 picoseconds. + Weight::from_parts(2_026_568, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_802, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ctz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_116_000 picoseconds. - Weight::from_parts(1_415_180, 0) + // Minimum execution time: 1_630_000 picoseconds. + Weight::from_parts(1_980_222, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(6_353, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_735, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64popcnt(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_058_000 picoseconds. - Weight::from_parts(1_314_206, 0) - // Standard Error: 35 - .saturating_add(Weight::from_parts(6_431, 0).saturating_mul(r.into())) + // Minimum execution time: 1_695_000 picoseconds. + Weight::from_parts(2_040_266, 0) + // Standard Error: 8 + .saturating_add(Weight::from_parts(3_718, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64eqz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_059_000 picoseconds. - Weight::from_parts(1_455_331, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_507, 0).saturating_mul(r.into())) + // Minimum execution time: 1_697_000 picoseconds. + Weight::from_parts(2_004_663, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(3_661, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64extendsi32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_057_000 picoseconds. - Weight::from_parts(1_421_085, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_177, 0).saturating_mul(r.into())) + // Minimum execution time: 1_705_000 picoseconds. + Weight::from_parts(2_682_122, 0) + // Standard Error: 98 + .saturating_add(Weight::from_parts(3_705, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64extendui32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_079_000 picoseconds. - Weight::from_parts(1_429_275, 0) + // Minimum execution time: 1_674_000 picoseconds. + Weight::from_parts(1_989_835, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(6_175, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_801, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i32wrapi64(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_065_000 picoseconds. - Weight::from_parts(1_403_813, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(6_192, 0).saturating_mul(r.into())) + // Minimum execution time: 1_695_000 picoseconds. + Weight::from_parts(2_083_824, 0) + // Standard Error: 17 + .saturating_add(Weight::from_parts(3_719, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64eq(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_061_000 picoseconds. - Weight::from_parts(1_421_984, 0) + // Minimum execution time: 1_678_000 picoseconds. + Weight::from_parts(1_996_335, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(9_094, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_995, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ne(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_075_000 picoseconds. - Weight::from_parts(1_431_453, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(9_084, 0).saturating_mul(r.into())) + // Minimum execution time: 1_697_000 picoseconds. + Weight::from_parts(2_046_566, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(5_936, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64lts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_100_000 picoseconds. - Weight::from_parts(1_452_384, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(9_081, 0).saturating_mul(r.into())) + // Minimum execution time: 1_721_000 picoseconds. + Weight::from_parts(2_406_930, 0) + // Standard Error: 150 + .saturating_add(Weight::from_parts(5_992, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ltu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_090_000 picoseconds. - Weight::from_parts(1_466_416, 0) - // Standard Error: 17 - .saturating_add(Weight::from_parts(9_091, 0).saturating_mul(r.into())) + // Minimum execution time: 1_749_000 picoseconds. + Weight::from_parts(1_987_158, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_994, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64gts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_056_000 picoseconds. - Weight::from_parts(1_676_091, 0) - // Standard Error: 47 - .saturating_add(Weight::from_parts(9_082, 0).saturating_mul(r.into())) + // Minimum execution time: 1_706_000 picoseconds. + Weight::from_parts(2_038_138, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_802, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64gtu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_053_000 picoseconds. - Weight::from_parts(1_232_790, 0) - // Standard Error: 43 - .saturating_add(Weight::from_parts(9_329, 0).saturating_mul(r.into())) + // Minimum execution time: 1_670_000 picoseconds. + Weight::from_parts(2_555_035, 0) + // Standard Error: 74 + .saturating_add(Weight::from_parts(5_958, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64les(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_091_000 picoseconds. - Weight::from_parts(1_476_212, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(9_074, 0).saturating_mul(r.into())) + // Minimum execution time: 1_694_000 picoseconds. + Weight::from_parts(1_991_929, 0) + // Standard Error: 27 + .saturating_add(Weight::from_parts(6_037, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64leu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_083_000 picoseconds. - Weight::from_parts(1_484_966, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(9_184, 0).saturating_mul(r.into())) + // Minimum execution time: 1_684_000 picoseconds. + Weight::from_parts(1_969_284, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_104, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ges(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_089_000 picoseconds. - Weight::from_parts(1_516_766, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(9_063, 0).saturating_mul(r.into())) + // Minimum execution time: 1_697_000 picoseconds. + Weight::from_parts(2_023_608, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(5_946, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64geu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 996_000 picoseconds. - Weight::from_parts(1_460_638, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(9_076, 0).saturating_mul(r.into())) + // Minimum execution time: 1_659_000 picoseconds. + Weight::from_parts(1_963_145, 0) + // Standard Error: 6 + .saturating_add(Weight::from_parts(6_014, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64add(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_095_000 picoseconds. - Weight::from_parts(1_448_412, 0) + // Minimum execution time: 1_722_000 picoseconds. + Weight::from_parts(2_016_286, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(8_977, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_889, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64sub(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_071_000 picoseconds. - Weight::from_parts(1_459_165, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(8_852, 0).saturating_mul(r.into())) + // Minimum execution time: 1_656_000 picoseconds. + Weight::from_parts(1_966_234, 0) + // Standard Error: 17 + .saturating_add(Weight::from_parts(6_171, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64mul(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_082_000 picoseconds. - Weight::from_parts(1_450_718, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(8_860, 0).saturating_mul(r.into())) + // Minimum execution time: 1_695_000 picoseconds. + Weight::from_parts(2_004_559, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_785, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64divs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_065_000 picoseconds. - Weight::from_parts(1_436_871, 0) - // Standard Error: 9 - .saturating_add(Weight::from_parts(15_241, 0).saturating_mul(r.into())) + // Minimum execution time: 1_681_000 picoseconds. + Weight::from_parts(2_135_505, 0) + // Standard Error: 6 + .saturating_add(Weight::from_parts(11_761, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64divu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_065_000 picoseconds. - Weight::from_parts(1_423_806, 0) - // Standard Error: 17 - .saturating_add(Weight::from_parts(14_706, 0).saturating_mul(r.into())) + // Minimum execution time: 1_653_000 picoseconds. + Weight::from_parts(2_153_167, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(10_523, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rems(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_059_000 picoseconds. - Weight::from_parts(1_735_816, 0) - // Standard Error: 66 - .saturating_add(Weight::from_parts(15_230, 0).saturating_mul(r.into())) + // Minimum execution time: 1_697_000 picoseconds. + Weight::from_parts(2_570_266, 0) + // Standard Error: 50 + .saturating_add(Weight::from_parts(11_971, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64remu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_076_000 picoseconds. - Weight::from_parts(1_451_290, 0) - // Standard Error: 6 - .saturating_add(Weight::from_parts(14_530, 0).saturating_mul(r.into())) + // Minimum execution time: 1_719_000 picoseconds. + Weight::from_parts(2_101_082, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(10_709, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64and(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_079_000 picoseconds. - Weight::from_parts(1_457_537, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(8_963, 0).saturating_mul(r.into())) + // Minimum execution time: 1_745_000 picoseconds. + Weight::from_parts(2_621_890, 0) + // Standard Error: 94 + .saturating_add(Weight::from_parts(5_545, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64or(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_032_000 picoseconds. - Weight::from_parts(1_475_315, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(8_956, 0).saturating_mul(r.into())) + // Minimum execution time: 1_670_000 picoseconds. + Weight::from_parts(2_046_821, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_762, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64xor(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_056_000 picoseconds. - Weight::from_parts(1_450_071, 0) + // Minimum execution time: 1_714_000 picoseconds. + Weight::from_parts(2_010_173, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(8_960, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_911, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_116_000 picoseconds. - Weight::from_parts(1_429_705, 0) + // Minimum execution time: 1_756_000 picoseconds. + Weight::from_parts(2_044_772, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(9_027, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_857, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shrs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_059_000 picoseconds. - Weight::from_parts(1_429_307, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(9_048, 0).saturating_mul(r.into())) + // Minimum execution time: 1_741_000 picoseconds. + Weight::from_parts(2_012_819, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_127, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shru(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_093_000 picoseconds. - Weight::from_parts(1_411_827, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(9_528, 0).saturating_mul(r.into())) + // Minimum execution time: 1_693_000 picoseconds. + Weight::from_parts(2_090_981, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_839, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rotl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_115_000 picoseconds. - Weight::from_parts(1_441_025, 0) + // Minimum execution time: 1_704_000 picoseconds. + Weight::from_parts(2_014_108, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(9_043, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(6_005, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rotr(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_077_000 picoseconds. - Weight::from_parts(1_480_666, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(9_031, 0).saturating_mul(r.into())) + // Minimum execution time: 1_715_000 picoseconds. + Weight::from_parts(2_053_720, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(5_860, 0).saturating_mul(r.into())) } } @@ -2132,8 +2136,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `109` // Estimated: `1594` - // Minimum execution time: 2_736_000 picoseconds. - Weight::from_parts(2_931_000, 1594) + // Minimum execution time: 2_567_000 picoseconds. + Weight::from_parts(2_711_000, 1594) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Skipped Metadata (r:0 w:0) @@ -2141,12 +2145,12 @@ impl WeightInfo for () { /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `481 + k * (69 ±0)` - // Estimated: `471 + k * (70 ±0)` - // Minimum execution time: 10_759_000 picoseconds. - Weight::from_parts(6_965_683, 471) - // Standard Error: 1_019 - .saturating_add(Weight::from_parts(961_947, 0).saturating_mul(k.into())) + // Measured: `450 + k * (69 ±0)` + // Estimated: `440 + k * (70 ±0)` + // Minimum execution time: 11_048_000 picoseconds. + Weight::from_parts(7_029_322, 440) + // Standard Error: 1_158 + .saturating_add(Weight::from_parts(975_010, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -2158,12 +2162,12 @@ impl WeightInfo for () { /// The range of component `q` is `[0, 128]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `281 + q * (33 ±0)` - // Estimated: `1753 + q * (33 ±0)` - // Minimum execution time: 2_633_000 picoseconds. - Weight::from_parts(10_668_837, 1753) - // Standard Error: 3_538 - .saturating_add(Weight::from_parts(1_277_168, 0).saturating_mul(q.into())) + // Measured: `250 + q * (33 ±0)` + // Estimated: `1725 + q * (33 ±0)` + // Minimum execution time: 2_645_000 picoseconds. + Weight::from_parts(10_865_477, 1725) + // Standard Error: 3_383 + .saturating_add(Weight::from_parts(1_295_351, 0).saturating_mul(q.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 33).saturating_mul(q.into())) @@ -2175,12 +2179,12 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 61717]`. fn reinstrument(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `270 + c * (1 ±0)` - // Estimated: `4015 + c * (2 ±0)` - // Minimum execution time: 30_264_000 picoseconds. - Weight::from_parts(27_106_554, 4015) - // Standard Error: 53 - .saturating_add(Weight::from_parts(49_705, 0).saturating_mul(c.into())) + // Measured: `238 + c * (1 ±0)` + // Estimated: `3951 + c * (2 ±0)` + // Minimum execution time: 30_817_000 picoseconds. + Weight::from_parts(29_762_622, 3951) + // Standard Error: 62 + .saturating_add(Weight::from_parts(54_714, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 2).saturating_mul(c.into())) @@ -2198,12 +2202,12 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `803` - // Estimated: `21880 + c * (5 ±0)` - // Minimum execution time: 309_249_000 picoseconds. - Weight::from_parts(323_353_590, 21880) - // Standard Error: 25 - .saturating_add(Weight::from_parts(31_359, 0).saturating_mul(c.into())) + // Measured: `707` + // Estimated: `21400 + c * (5 ±0)` + // Minimum execution time: 245_493_000 picoseconds. + Weight::from_parts(253_703_384, 21400) + // Standard Error: 27 + .saturating_add(Weight::from_parts(38_078, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(c.into())) @@ -2231,14 +2235,14 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `270` // Estimated: `26207` - // Minimum execution time: 3_136_707_000 picoseconds. - Weight::from_parts(564_055_378, 26207) - // Standard Error: 286 - .saturating_add(Weight::from_parts(93_308, 0).saturating_mul(c.into())) - // Standard Error: 16 - .saturating_add(Weight::from_parts(1_165, 0).saturating_mul(i.into())) - // Standard Error: 16 - .saturating_add(Weight::from_parts(1_435, 0).saturating_mul(s.into())) + // Minimum execution time: 3_079_430_000 picoseconds. + Weight::from_parts(555_022_483, 26207) + // Standard Error: 290 + .saturating_add(Weight::from_parts(107_411, 0).saturating_mul(c.into())) + // Standard Error: 17 + .saturating_add(Weight::from_parts(1_123, 0).saturating_mul(i.into())) + // Standard Error: 17 + .saturating_add(Weight::from_parts(1_434, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(10_u64)) } @@ -2260,14 +2264,14 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `546` - // Estimated: `28969` - // Minimum execution time: 1_631_314_000 picoseconds. - Weight::from_parts(236_693_159, 28969) + // Measured: `482` + // Estimated: `28521` + // Minimum execution time: 1_600_733_000 picoseconds. + Weight::from_parts(228_681_962, 28521) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_434, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_445, 0).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_445, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_456, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -2283,10 +2287,10 @@ impl WeightInfo for () { /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) fn call() -> Weight { // Proof Size summary in bytes: - // Measured: `855` - // Estimated: `22095` - // Minimum execution time: 167_139_000 picoseconds. - Weight::from_parts(168_034_000, 22095) + // Measured: `759` + // Estimated: `21615` + // Minimum execution time: 172_310_000 picoseconds. + Weight::from_parts(176_655_000, 21615) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2303,10 +2307,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `109` // Estimated: `7366` - // Minimum execution time: 306_518_000 picoseconds. - Weight::from_parts(325_652_407, 7366) - // Standard Error: 134 - .saturating_add(Weight::from_parts(93_502, 0).saturating_mul(c.into())) + // Minimum execution time: 246_364_000 picoseconds. + Weight::from_parts(262_887_234, 7366) + // Standard Error: 90 + .saturating_add(Weight::from_parts(107_926, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2320,10 +2324,10 @@ impl WeightInfo for () { /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `287` - // Estimated: `8078` - // Minimum execution time: 29_084_000 picoseconds. - Weight::from_parts(29_350_000, 8078) + // Measured: `255` + // Estimated: `7950` + // Minimum execution time: 29_226_000 picoseconds. + Weight::from_parts(29_542_000, 7950) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2335,10 +2339,10 @@ impl WeightInfo for () { /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `666` - // Estimated: `19818` - // Minimum execution time: 32_996_000 picoseconds. - Weight::from_parts(33_365_000, 19818) + // Measured: `570` + // Estimated: `19530` + // Minimum execution time: 33_921_000 picoseconds. + Weight::from_parts(35_056_000, 19530) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -2355,12 +2359,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_caller(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `877 + r * (6 ±0)` - // Estimated: `22210 + r * (30 ±0)` - // Minimum execution time: 298_315_000 picoseconds. - Weight::from_parts(304_612_433, 22210) - // Standard Error: 904 - .saturating_add(Weight::from_parts(285_473, 0).saturating_mul(r.into())) + // Measured: `781 + r * (6 ±0)` + // Estimated: `21730 + r * (30 ±0)` + // Minimum execution time: 232_118_000 picoseconds. + Weight::from_parts(233_883_823, 21730) + // Standard Error: 642 + .saturating_add(Weight::from_parts(340_543, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2378,16 +2382,16 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_is_contract(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `935 + r * (272 ±0)` - // Estimated: `22315 + r * (3835 ±0)` - // Minimum execution time: 299_169_000 picoseconds. - Weight::from_parts(138_157_704, 22315) - // Standard Error: 6_115 - .saturating_add(Weight::from_parts(3_244_482, 0).saturating_mul(r.into())) + // Measured: `839 + r * (240 ±0)` + // Estimated: `21835 + r * (3675 ±0)` + // Minimum execution time: 231_712_000 picoseconds. + Weight::from_parts(74_297_097, 21835) + // Standard Error: 6_099 + .saturating_add(Weight::from_parts(3_322_192, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 3835).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 3675).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2402,16 +2406,16 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `927 + r * (276 ±0)` - // Estimated: `22335 + r * (3855 ±0)` - // Minimum execution time: 299_262_000 picoseconds. - Weight::from_parts(157_105_627, 22335) - // Standard Error: 5_634 - .saturating_add(Weight::from_parts(3_995_666, 0).saturating_mul(r.into())) + // Measured: `831 + r * (244 ±0)` + // Estimated: `21855 + r * (3695 ±0)` + // Minimum execution time: 233_122_000 picoseconds. + Weight::from_parts(74_369_473, 21855) + // Standard Error: 6_027 + .saturating_add(Weight::from_parts(4_177_187, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 3855).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 3695).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2426,12 +2430,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_own_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `884 + r * (6 ±0)` - // Estimated: `22250 + r * (30 ±0)` - // Minimum execution time: 298_259_000 picoseconds. - Weight::from_parts(303_498_245, 22250) - // Standard Error: 874 - .saturating_add(Weight::from_parts(352_839, 0).saturating_mul(r.into())) + // Measured: `788 + r * (6 ±0)` + // Estimated: `21770 + r * (30 ±0)` + // Minimum execution time: 232_822_000 picoseconds. + Weight::from_parts(232_507_418, 21770) + // Standard Error: 961 + .saturating_add(Weight::from_parts(419_331, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2449,12 +2453,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_origin(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874 + r * (3 ±0)` - // Estimated: `22215 + r * (15 ±0)` - // Minimum execution time: 295_689_000 picoseconds. - Weight::from_parts(314_004_541, 22215) - // Standard Error: 1_803 - .saturating_add(Weight::from_parts(131_102, 0).saturating_mul(r.into())) + // Measured: `778 + r * (3 ±0)` + // Estimated: `21735 + r * (15 ±0)` + // Minimum execution time: 229_719_000 picoseconds. + Weight::from_parts(235_257_789, 21735) + // Standard Error: 451 + .saturating_add(Weight::from_parts(161_101, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) @@ -2472,12 +2476,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `878 + r * (6 ±0)` - // Estimated: `22220 + r * (30 ±0)` - // Minimum execution time: 297_579_000 picoseconds. - Weight::from_parts(299_326_920, 22220) - // Standard Error: 990 - .saturating_add(Weight::from_parts(284_789, 0).saturating_mul(r.into())) + // Measured: `782 + r * (6 ±0)` + // Estimated: `21740 + r * (30 ±0)` + // Minimum execution time: 231_517_000 picoseconds. + Weight::from_parts(236_185_452, 21740) + // Standard Error: 651 + .saturating_add(Weight::from_parts(334_659, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2495,12 +2499,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_gas_left(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `879 + r * (6 ±0)` - // Estimated: `22205 + r * (30 ±0)` - // Minimum execution time: 297_651_000 picoseconds. - Weight::from_parts(304_465_467, 22205) - // Standard Error: 736 - .saturating_add(Weight::from_parts(272_149, 0).saturating_mul(r.into())) + // Measured: `783 + r * (6 ±0)` + // Estimated: `21725 + r * (30 ±0)` + // Minimum execution time: 232_855_000 picoseconds. + Weight::from_parts(239_986_328, 21725) + // Standard Error: 4_075 + .saturating_add(Weight::from_parts(345_726, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2518,12 +2522,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1050 + r * (6 ±0)` - // Estimated: `25258 + r * (30 ±0)` - // Minimum execution time: 296_957_000 picoseconds. - Weight::from_parts(308_680_068, 25258) - // Standard Error: 1_377 - .saturating_add(Weight::from_parts(1_419_294, 0).saturating_mul(r.into())) + // Measured: `922 + r * (6 ±0)` + // Estimated: `24633 + r * (30 ±0)` + // Minimum execution time: 231_685_000 picoseconds. + Weight::from_parts(245_514_261, 24633) + // Standard Error: 1_635 + .saturating_add(Weight::from_parts(1_523_359, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2541,12 +2545,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_value_transferred(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `888 + r * (6 ±0)` - // Estimated: `22305 + r * (30 ±0)` - // Minimum execution time: 297_735_000 picoseconds. - Weight::from_parts(301_533_807, 22305) - // Standard Error: 1_119 - .saturating_add(Weight::from_parts(277_289, 0).saturating_mul(r.into())) + // Measured: `792 + r * (6 ±0)` + // Estimated: `21825 + r * (30 ±0)` + // Minimum execution time: 233_361_000 picoseconds. + Weight::from_parts(234_553_471, 21825) + // Standard Error: 1_108 + .saturating_add(Weight::from_parts(330_383, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2564,12 +2568,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_minimum_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `886 + r * (6 ±0)` - // Estimated: `22295 + r * (30 ±0)` - // Minimum execution time: 299_599_000 picoseconds. - Weight::from_parts(303_664_496, 22295) - // Standard Error: 1_009 - .saturating_add(Weight::from_parts(280_353, 0).saturating_mul(r.into())) + // Measured: `790 + r * (6 ±0)` + // Estimated: `21815 + r * (30 ±0)` + // Minimum execution time: 231_918_000 picoseconds. + Weight::from_parts(239_128_416, 21815) + // Standard Error: 1_473 + .saturating_add(Weight::from_parts(317_879, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2587,12 +2591,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_block_number(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `883 + r * (6 ±0)` - // Estimated: `22285 + r * (30 ±0)` - // Minimum execution time: 297_641_000 picoseconds. - Weight::from_parts(302_437_979, 22285) - // Standard Error: 669 - .saturating_add(Weight::from_parts(270_403, 0).saturating_mul(r.into())) + // Measured: `787 + r * (6 ±0)` + // Estimated: `21805 + r * (30 ±0)` + // Minimum execution time: 231_936_000 picoseconds. + Weight::from_parts(232_240_207, 21805) + // Standard Error: 731 + .saturating_add(Weight::from_parts(330_713, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2610,12 +2614,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_now(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874 + r * (6 ±0)` - // Estimated: `22215 + r * (30 ±0)` - // Minimum execution time: 297_217_000 picoseconds. - Weight::from_parts(299_538_157, 22215) - // Standard Error: 732 - .saturating_add(Weight::from_parts(280_800, 0).saturating_mul(r.into())) + // Measured: `778 + r * (6 ±0)` + // Estimated: `21735 + r * (30 ±0)` + // Minimum execution time: 231_978_000 picoseconds. + Weight::from_parts(224_881_201, 21735) + // Standard Error: 1_296 + .saturating_add(Weight::from_parts(346_872, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2635,12 +2639,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_weight_to_fee(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `952 + r * (10 ±0)` - // Estimated: `25022 + r * (60 ±0)` - // Minimum execution time: 297_286_000 picoseconds. - Weight::from_parts(311_436_352, 25022) - // Standard Error: 6_811 - .saturating_add(Weight::from_parts(1_291_941, 0).saturating_mul(r.into())) + // Measured: `856 + r * (10 ±0)` + // Estimated: `24446 + r * (60 ±0)` + // Minimum execution time: 231_707_000 picoseconds. + Weight::from_parts(245_939_854, 24446) + // Standard Error: 1_369 + .saturating_add(Weight::from_parts(1_380_453, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) @@ -2658,12 +2662,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_gas(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `841 + r * (4 ±0)` - // Estimated: `22035 + r * (20 ±0)` - // Minimum execution time: 154_772_000 picoseconds. - Weight::from_parts(159_224_457, 22035) - // Standard Error: 212 - .saturating_add(Weight::from_parts(102_264, 0).saturating_mul(r.into())) + // Measured: `745 + r * (4 ±0)` + // Estimated: `21555 + r * (20 ±0)` + // Minimum execution time: 157_429_000 picoseconds. + Weight::from_parts(161_047_355, 21555) + // Standard Error: 1_220 + .saturating_add(Weight::from_parts(134_497, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 20).saturating_mul(r.into())) @@ -2681,12 +2685,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_input(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `876 + r * (6 ±0)` - // Estimated: `22220 + r * (30 ±0)` - // Minimum execution time: 297_248_000 picoseconds. - Weight::from_parts(303_805_584, 22220) - // Standard Error: 858 - .saturating_add(Weight::from_parts(223_587, 0).saturating_mul(r.into())) + // Measured: `780 + r * (6 ±0)` + // Estimated: `21740 + r * (30 ±0)` + // Minimum execution time: 232_561_000 picoseconds. + Weight::from_parts(230_989_499, 21740) + // Standard Error: 848 + .saturating_add(Weight::from_parts(282_053, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2704,12 +2708,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1048576]`. fn seal_input_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `880` - // Estimated: `22220` - // Minimum execution time: 298_464_000 picoseconds. - Weight::from_parts(300_996_431, 22220) - // Standard Error: 1 - .saturating_add(Weight::from_parts(600, 0).saturating_mul(n.into())) + // Measured: `784` + // Estimated: `21740` + // Minimum execution time: 237_080_000 picoseconds. + Weight::from_parts(239_380_994, 21740) + // Standard Error: 2 + .saturating_add(Weight::from_parts(592, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2726,12 +2730,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `864 + r * (45 ±0)` - // Estimated: `22140 + r * (225 ±0)` - // Minimum execution time: 294_347_000 picoseconds. - Weight::from_parts(296_793_034, 22140) - // Standard Error: 277_251 - .saturating_add(Weight::from_parts(1_711_665, 0).saturating_mul(r.into())) + // Measured: `768 + r * (45 ±0)` + // Estimated: `21660 + r * (225 ±0)` + // Minimum execution time: 228_669_000 picoseconds. + Weight::from_parts(230_916_471, 21660) + // Standard Error: 295_520 + .saturating_add(Weight::from_parts(1_420_928, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 225).saturating_mul(r.into())) @@ -2749,12 +2753,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1048576]`. fn seal_return_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874` - // Estimated: `22255` - // Minimum execution time: 297_257_000 picoseconds. - Weight::from_parts(300_088_288, 22255) + // Measured: `778` + // Estimated: `21775` + // Minimum execution time: 231_626_000 picoseconds. + Weight::from_parts(232_097_413, 21775) // Standard Error: 1 - .saturating_add(Weight::from_parts(181, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(185, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2775,17 +2779,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `906 + r * (452 ±0)` - // Estimated: `26183 + r * (15994 ±0)` - // Minimum execution time: 296_510_000 picoseconds. - Weight::from_parts(299_169_757, 26183) - // Standard Error: 205_313 - .saturating_add(Weight::from_parts(78_059_642, 0).saturating_mul(r.into())) + // Measured: `810 + r * (356 ±0)` + // Estimated: `25511 + r * (15321 ±0)` + // Minimum execution time: 230_758_000 picoseconds. + Weight::from_parts(233_235_993, 25511) + // Standard Error: 196_168 + .saturating_add(Weight::from_parts(81_177_506, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 15994).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 15321).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2802,12 +2806,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_random(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `921 + r * (10 ±0)` - // Estimated: `24859 + r * (60 ±0)` - // Minimum execution time: 299_299_000 picoseconds. - Weight::from_parts(314_487_015, 24859) - // Standard Error: 1_552 - .saturating_add(Weight::from_parts(1_753_960, 0).saturating_mul(r.into())) + // Measured: `825 + r * (10 ±0)` + // Estimated: `24283 + r * (60 ±0)` + // Minimum execution time: 232_457_000 picoseconds. + Weight::from_parts(240_943_161, 24283) + // Standard Error: 3_085 + .saturating_add(Weight::from_parts(1_837_168, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) @@ -2825,12 +2829,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_deposit_event(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `874 + r * (10 ±0)` - // Estimated: `22215 + r * (50 ±0)` - // Minimum execution time: 296_188_000 picoseconds. - Weight::from_parts(305_901_539, 22215) - // Standard Error: 2_782 - .saturating_add(Weight::from_parts(3_456_054, 0).saturating_mul(r.into())) + // Measured: `778 + r * (10 ±0)` + // Estimated: `21735 + r * (50 ±0)` + // Minimum execution time: 229_788_000 picoseconds. + Weight::from_parts(233_520_858, 21735) + // Standard Error: 9_561 + .saturating_add(Weight::from_parts(3_596_294, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 50).saturating_mul(r.into())) @@ -2849,14 +2853,14 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_deposit_event_per_topic_and_byte(t: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `893 + t * (32 ±0)` - // Estimated: `22320 + t * (2640 ±0)` - // Minimum execution time: 313_860_000 picoseconds. - Weight::from_parts(312_473_092, 22320) - // Standard Error: 250_852 - .saturating_add(Weight::from_parts(2_258_502, 0).saturating_mul(t.into())) - // Standard Error: 70 - .saturating_add(Weight::from_parts(312, 0).saturating_mul(n.into())) + // Measured: `797 + t * (32 ±0)` + // Estimated: `21840 + t * (2640 ±0)` + // Minimum execution time: 248_294_000 picoseconds. + Weight::from_parts(239_709_759, 21840) + // Standard Error: 66_903 + .saturating_add(Weight::from_parts(2_880_732, 0).saturating_mul(t.into())) + // Standard Error: 18 + .saturating_add(Weight::from_parts(725, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2876,12 +2880,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_debug_message(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (7 ±0)` - // Estimated: `22205 + r * (35 ±0)` - // Minimum execution time: 162_043_000 picoseconds. - Weight::from_parts(166_132_332, 22205) - // Standard Error: 716 - .saturating_add(Weight::from_parts(184_981, 0).saturating_mul(r.into())) + // Measured: `777 + r * (7 ±0)` + // Estimated: `21725 + r * (35 ±0)` + // Minimum execution time: 170_601_000 picoseconds. + Weight::from_parts(165_819_714, 21725) + // Standard Error: 452 + .saturating_add(Weight::from_parts(240_362, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 35).saturating_mul(r.into())) @@ -2899,12 +2903,12 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 1048576]`. fn seal_debug_message_per_byte(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `125824` - // Estimated: `270073` - // Minimum execution time: 414_433_000 picoseconds. - Weight::from_parts(417_483_627, 270073) - // Standard Error: 1 - .saturating_add(Weight::from_parts(748, 0).saturating_mul(i.into())) + // Measured: `125728` + // Estimated: `269977` + // Minimum execution time: 349_543_000 picoseconds. + Weight::from_parts(352_945_102, 269977) + // Standard Error: 2 + .saturating_add(Weight::from_parts(749, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2913,12 +2917,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 800]`. fn seal_set_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `941 + r * (292 ±0)` - // Estimated: `939 + r * (293 ±0)` - // Minimum execution time: 299_500_000 picoseconds. - Weight::from_parts(194_466_413, 939) - // Standard Error: 9_986 - .saturating_add(Weight::from_parts(6_010_112, 0).saturating_mul(r.into())) + // Measured: `845 + r * (292 ±0)` + // Estimated: `843 + r * (293 ±0)` + // Minimum execution time: 238_766_000 picoseconds. + Weight::from_parts(130_994_282, 843) + // Standard Error: 10_413 + .saturating_add(Weight::from_parts(6_134_087, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2930,12 +2934,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_set_storage_per_new_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1432` - // Estimated: `1405` - // Minimum execution time: 314_171_000 picoseconds. - Weight::from_parts(335_595_397, 1405) - // Standard Error: 67 - .saturating_add(Weight::from_parts(90, 0).saturating_mul(n.into())) + // Measured: `1304` + // Estimated: `1280` + // Minimum execution time: 248_137_000 picoseconds. + Weight::from_parts(265_535_917, 1280) + // Standard Error: 28 + .saturating_add(Weight::from_parts(387, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -2944,12 +2948,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_set_storage_per_old_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1295 + n * (1 ±0)` - // Estimated: `1292 + n * (1 ±0)` - // Minimum execution time: 313_479_000 picoseconds. - Weight::from_parts(317_435_100, 1292) - // Standard Error: 41 - .saturating_add(Weight::from_parts(106, 0).saturating_mul(n.into())) + // Measured: `1167 + n * (1 ±0)` + // Estimated: `1167 + n * (1 ±0)` + // Minimum execution time: 246_752_000 picoseconds. + Weight::from_parts(250_315_210, 1167) + // Standard Error: 42 + .saturating_add(Weight::from_parts(135, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -2959,12 +2963,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 800]`. fn seal_clear_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `937 + r * (288 ±0)` - // Estimated: `941 + r * (289 ±0)` - // Minimum execution time: 297_831_000 picoseconds. - Weight::from_parts(196_983_778, 941) - // Standard Error: 9_899 - .saturating_add(Weight::from_parts(5_904_642, 0).saturating_mul(r.into())) + // Measured: `841 + r * (288 ±0)` + // Estimated: `845 + r * (289 ±0)` + // Minimum execution time: 232_873_000 picoseconds. + Weight::from_parts(130_360_558, 845) + // Standard Error: 10_026 + .saturating_add(Weight::from_parts(6_023_862, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2976,10 +2980,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_clear_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1291 + n * (1 ±0)` - // Estimated: `1288 + n * (1 ±0)` - // Minimum execution time: 320_156_000 picoseconds. - Weight::from_parts(327_504_368, 1288) + // Measured: `1163 + n * (1 ±0)` + // Estimated: `1163 + n * (1 ±0)` + // Minimum execution time: 247_079_000 picoseconds. + Weight::from_parts(248_922_003, 1163) + // Standard Error: 22 + .saturating_add(Weight::from_parts(201, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -2989,12 +2995,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 800]`. fn seal_get_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `931 + r * (296 ±0)` - // Estimated: `936 + r * (297 ±0)` - // Minimum execution time: 305_849_000 picoseconds. - Weight::from_parts(219_649_351, 936) - // Standard Error: 9_157 - .saturating_add(Weight::from_parts(4_846_108, 0).saturating_mul(r.into())) + // Measured: `835 + r * (296 ±0)` + // Estimated: `840 + r * (297 ±0)` + // Minimum execution time: 232_696_000 picoseconds. + Weight::from_parts(144_147_151, 840) + // Standard Error: 8_846 + .saturating_add(Weight::from_parts(4_931_414, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3005,12 +3011,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_get_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1307 + n * (1 ±0)` - // Estimated: `1304 + n * (1 ±0)` - // Minimum execution time: 312_106_000 picoseconds. - Weight::from_parts(315_905_779, 1304) - // Standard Error: 44 - .saturating_add(Weight::from_parts(674, 0).saturating_mul(n.into())) + // Measured: `1179 + n * (1 ±0)` + // Estimated: `1179 + n * (1 ±0)` + // Minimum execution time: 247_795_000 picoseconds. + Weight::from_parts(252_944_118, 1179) + // Standard Error: 45 + .saturating_add(Weight::from_parts(480, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3020,12 +3026,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 800]`. fn seal_contains_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `952 + r * (288 ±0)` - // Estimated: `953 + r * (289 ±0)` - // Minimum execution time: 299_372_000 picoseconds. - Weight::from_parts(211_293_493, 953) - // Standard Error: 8_509 - .saturating_add(Weight::from_parts(4_688_993, 0).saturating_mul(r.into())) + // Measured: `856 + r * (288 ±0)` + // Estimated: `857 + r * (289 ±0)` + // Minimum execution time: 232_166_000 picoseconds. + Weight::from_parts(148_503_428, 857) + // Standard Error: 8_704 + .saturating_add(Weight::from_parts(4_766_055, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3036,12 +3042,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_contains_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1294 + n * (1 ±0)` - // Estimated: `1291 + n * (1 ±0)` - // Minimum execution time: 311_605_000 picoseconds. - Weight::from_parts(315_473_850, 1291) - // Standard Error: 37 - .saturating_add(Weight::from_parts(3, 0).saturating_mul(n.into())) + // Measured: `1166 + n * (1 ±0)` + // Estimated: `1166 + n * (1 ±0)` + // Minimum execution time: 246_128_000 picoseconds. + Weight::from_parts(248_323_705, 1166) + // Standard Error: 21 + .saturating_add(Weight::from_parts(92, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3051,12 +3057,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 800]`. fn seal_take_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `925 + r * (296 ±0)` - // Estimated: `932 + r * (297 ±0)` - // Minimum execution time: 298_231_000 picoseconds. - Weight::from_parts(200_178_698, 932) - // Standard Error: 10_452 - .saturating_add(Weight::from_parts(6_107_653, 0).saturating_mul(r.into())) + // Measured: `829 + r * (296 ±0)` + // Estimated: `836 + r * (297 ±0)` + // Minimum execution time: 232_976_000 picoseconds. + Weight::from_parts(132_373_848, 836) + // Standard Error: 9_855 + .saturating_add(Weight::from_parts(6_181_821, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3068,12 +3074,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_take_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1308 + n * (1 ±0)` - // Estimated: `1305 + n * (1 ±0)` - // Minimum execution time: 314_970_000 picoseconds. - Weight::from_parts(318_135_821, 1305) - // Standard Error: 26 - .saturating_add(Weight::from_parts(630, 0).saturating_mul(n.into())) + // Measured: `1180 + n * (1 ±0)` + // Estimated: `1180 + n * (1 ±0)` + // Minimum execution time: 247_907_000 picoseconds. + Weight::from_parts(251_984_133, 1180) + // Standard Error: 41 + .saturating_add(Weight::from_parts(639, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3091,12 +3097,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_transfer(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1501 + r * (45 ±0)` - // Estimated: `27383 + r * (2700 ±0)` - // Minimum execution time: 299_629_000 picoseconds. - Weight::from_parts(150_915_187, 27383) - // Standard Error: 25_604 - .saturating_add(Weight::from_parts(20_859_844, 0).saturating_mul(r.into())) + // Measured: `1373 + r * (45 ±0)` + // Estimated: `26753 + r * (2700 ±0)` + // Minimum execution time: 232_614_000 picoseconds. + Weight::from_parts(127_024_367, 26753) + // Standard Error: 54_521 + .saturating_add(Weight::from_parts(20_975_575, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) @@ -3116,17 +3122,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1670 + r * (288 ±0)` - // Estimated: `27813 + r * (6391 ±0)` - // Minimum execution time: 299_578_000 picoseconds. - Weight::from_parts(300_036_000, 27813) - // Standard Error: 102_709 - .saturating_add(Weight::from_parts(283_767_316, 0).saturating_mul(r.into())) + // Measured: `1512 + r * (256 ±0)` + // Estimated: `27163 + r * (6231 ±0)` + // Minimum execution time: 233_446_000 picoseconds. + Weight::from_parts(234_338_000, 27163) + // Standard Error: 122_754 + .saturating_add(Weight::from_parts(216_709_600, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 6391).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 6231).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3141,17 +3147,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (935 ±0)` - // Estimated: `22235 + r * (8322 ±10)` - // Minimum execution time: 298_943_000 picoseconds. - Weight::from_parts(299_619_000, 22235) - // Standard Error: 117_493 - .saturating_add(Weight::from_parts(280_555_517, 0).saturating_mul(r.into())) + // Measured: `0 + r * (902 ±0)` + // Estimated: `21755 + r * (8167 ±7)` + // Minimum execution time: 232_717_000 picoseconds. + Weight::from_parts(233_405_000, 21755) + // Standard Error: 98_607 + .saturating_add(Weight::from_parts(212_329_100, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 8322).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 8167).saturating_mul(r.into())) } /// Storage: System Account (r:3 w:2) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3167,19 +3173,19 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 1048576]`. fn seal_call_per_transfer_clone_byte(t: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1314 + t * (268 ±0)` - // Estimated: `31815 + t * (6290 ±0)` - // Minimum execution time: 453_013_000 picoseconds. - Weight::from_parts(442_536_283, 31815) - // Standard Error: 1_339_541 - .saturating_add(Weight::from_parts(17_062_445, 0).saturating_mul(t.into())) - // Standard Error: 1 - .saturating_add(Weight::from_parts(604, 0).saturating_mul(c.into())) + // Measured: `1154 + t * (204 ±0)` + // Estimated: `31015 + t * (5970 ±0)` + // Minimum execution time: 392_113_000 picoseconds. + Weight::from_parts(376_522_702, 31015) + // Standard Error: 1_388_011 + .saturating_add(Weight::from_parts(19_125_093, 0).saturating_mul(t.into())) + // Standard Error: 2 + .saturating_add(Weight::from_parts(609, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(5_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 6290).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 5970).saturating_mul(t.into())) } /// Storage: System Account (r:3202 w:3202) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3198,17 +3204,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_instantiate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1988 + r * (319 ±0)` - // Estimated: `34745 + r * (17090 ±0)` - // Minimum execution time: 300_123_000 picoseconds. - Weight::from_parts(300_406_000, 34745) - // Standard Error: 420_997 - .saturating_add(Weight::from_parts(382_704_025, 0).saturating_mul(r.into())) + // Measured: `1859 + r * (253 ±0)` + // Estimated: `33859 + r * (16628 ±0)` + // Minimum execution time: 234_438_000 picoseconds. + Weight::from_parts(234_751_000, 33859) + // Standard Error: 450_507 + .saturating_add(Weight::from_parts(313_121_404, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) .saturating_add(RocksDbWeight::get().writes((5_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 17090).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 16628).saturating_mul(r.into())) } /// Storage: System Account (r:4 w:4) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3229,21 +3235,21 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 983040]`. fn seal_instantiate_per_transfer_input_salt_byte(t: u32, i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1231 + t * (219 ±0)` - // Estimated: `43797 + t * (3812 ±2)` - // Minimum execution time: 1_636_322_000 picoseconds. - Weight::from_parts(360_859_331, 43797) - // Standard Error: 4_816_923 - .saturating_add(Weight::from_parts(109_179_023, 0).saturating_mul(t.into())) + // Measured: `1071 + t * (187 ±0)` + // Estimated: `42684 + t * (3588 ±2)` + // Minimum execution time: 1_570_178_000 picoseconds. + Weight::from_parts(284_062_841, 42684) + // Standard Error: 4_396_597 + .saturating_add(Weight::from_parts(106_424_960, 0).saturating_mul(t.into())) // Standard Error: 7 - .saturating_add(Weight::from_parts(1_180, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_183, 0).saturating_mul(i.into())) // Standard Error: 7 - .saturating_add(Weight::from_parts(1_344, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_354, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(10_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 3812).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 3588).saturating_mul(t.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3258,12 +3264,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (8 ±0)` - // Estimated: `22190 + r * (40 ±0)` - // Minimum execution time: 297_521_000 picoseconds. - Weight::from_parts(303_523_260, 22190) - // Standard Error: 1_162 - .saturating_add(Weight::from_parts(542_201, 0).saturating_mul(r.into())) + // Measured: `777 + r * (8 ±0)` + // Estimated: `21710 + r * (40 ±0)` + // Minimum execution time: 230_557_000 picoseconds. + Weight::from_parts(233_276_698, 21710) + // Standard Error: 1_026 + .saturating_add(Weight::from_parts(587_723, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3281,12 +3287,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_sha2_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `881` - // Estimated: `22225` - // Minimum execution time: 299_877_000 picoseconds. - Weight::from_parts(293_538_014, 22225) - // Standard Error: 2 - .saturating_add(Weight::from_parts(3_967, 0).saturating_mul(n.into())) + // Measured: `785` + // Estimated: `21745` + // Minimum execution time: 234_151_000 picoseconds. + Weight::from_parts(240_199_365, 21745) + // Standard Error: 3 + .saturating_add(Weight::from_parts(3_941, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3303,12 +3309,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `875 + r * (8 ±0)` - // Estimated: `22205 + r * (40 ±0)` - // Minimum execution time: 297_672_000 picoseconds. - Weight::from_parts(299_933_312, 22205) - // Standard Error: 1_138 - .saturating_add(Weight::from_parts(713_189, 0).saturating_mul(r.into())) + // Measured: `779 + r * (8 ±0)` + // Estimated: `21725 + r * (40 ±0)` + // Minimum execution time: 229_931_000 picoseconds. + Weight::from_parts(234_961_690, 21725) + // Standard Error: 1_073 + .saturating_add(Weight::from_parts(758_259, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3326,12 +3332,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_keccak_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `883` - // Estimated: `22245` - // Minimum execution time: 299_048_000 picoseconds. - Weight::from_parts(293_055_982, 22245) + // Measured: `787` + // Estimated: `21765` + // Minimum execution time: 232_448_000 picoseconds. + Weight::from_parts(225_974_008, 21765) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_179, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(3_174, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3348,12 +3354,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `875 + r * (8 ±0)` - // Estimated: `22220 + r * (40 ±0)` - // Minimum execution time: 301_991_000 picoseconds. - Weight::from_parts(300_027_441, 22220) - // Standard Error: 981 - .saturating_add(Weight::from_parts(391_319, 0).saturating_mul(r.into())) + // Measured: `779 + r * (8 ±0)` + // Estimated: `21740 + r * (40 ±0)` + // Minimum execution time: 229_251_000 picoseconds. + Weight::from_parts(234_182_627, 21740) + // Standard Error: 836 + .saturating_add(Weight::from_parts(424_375, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3371,12 +3377,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `883` - // Estimated: `22265` - // Minimum execution time: 296_522_000 picoseconds. - Weight::from_parts(296_121_638, 22265) + // Measured: `787` + // Estimated: `21785` + // Minimum execution time: 230_896_000 picoseconds. + Weight::from_parts(224_913_556, 21785) // Standard Error: 2 - .saturating_add(Weight::from_parts(916, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(919, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3393,12 +3399,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `875 + r * (8 ±0)` - // Estimated: `22225 + r * (40 ±0)` - // Minimum execution time: 296_228_000 picoseconds. - Weight::from_parts(301_472_299, 22225) - // Standard Error: 875 - .saturating_add(Weight::from_parts(381_027, 0).saturating_mul(r.into())) + // Measured: `779 + r * (8 ±0)` + // Estimated: `21745 + r * (40 ±0)` + // Minimum execution time: 230_314_000 picoseconds. + Weight::from_parts(233_426_327, 21745) + // Standard Error: 926 + .saturating_add(Weight::from_parts(425_341, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3416,12 +3422,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_128_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `883` - // Estimated: `22235` - // Minimum execution time: 296_644_000 picoseconds. - Weight::from_parts(289_879_744, 22235) + // Measured: `787` + // Estimated: `21755` + // Minimum execution time: 230_424_000 picoseconds. + Weight::from_parts(231_136_218, 21755) // Standard Error: 2 - .saturating_add(Weight::from_parts(925, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(917, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3438,12 +3444,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `800 + r * (78 ±0)` - // Estimated: `21845 + r * (390 ±0)` - // Minimum execution time: 297_804_000 picoseconds. - Weight::from_parts(471_994_534, 21845) - // Standard Error: 9_479 - .saturating_add(Weight::from_parts(36_886_028, 0).saturating_mul(r.into())) + // Measured: `704 + r * (78 ±0)` + // Estimated: `21370 + r * (390 ±0)` + // Minimum execution time: 232_862_000 picoseconds. + Weight::from_parts(379_152_870, 21370) + // Standard Error: 11_607 + .saturating_add(Weight::from_parts(36_955_410, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 390).saturating_mul(r.into())) @@ -3461,12 +3467,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `645 + r * (44 ±0)` - // Estimated: `21110 + r * (220 ±0)` - // Minimum execution time: 298_623_000 picoseconds. - Weight::from_parts(322_192_102, 21110) - // Standard Error: 3_207 - .saturating_add(Weight::from_parts(9_243_653, 0).saturating_mul(r.into())) + // Measured: `549 + r * (44 ±0)` + // Estimated: `20630 + r * (220 ±0)` + // Minimum execution time: 232_668_000 picoseconds. + Weight::from_parts(253_308_468, 20630) + // Standard Error: 3_022 + .saturating_add(Weight::from_parts(9_249_849, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 220).saturating_mul(r.into())) @@ -3486,17 +3492,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (1030 ±0)` - // Estimated: `30592 + r * (11919 ±7)` - // Minimum execution time: 298_574_000 picoseconds. - Weight::from_parts(299_383_000, 30592) - // Standard Error: 44_061 - .saturating_add(Weight::from_parts(21_625_366, 0).saturating_mul(r.into())) + // Measured: `0 + r * (964 ±0)` + // Estimated: `29920 + r * (11544 ±7)` + // Minimum execution time: 233_910_000 picoseconds. + Weight::from_parts(234_607_000, 29920) + // Standard Error: 46_118 + .saturating_add(Weight::from_parts(21_927_957, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 11919).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 11544).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3511,12 +3517,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `869 + r * (3 ±0)` - // Estimated: `22215 + r * (15 ±0)` - // Minimum execution time: 297_014_000 picoseconds. - Weight::from_parts(301_226_615, 22215) - // Standard Error: 439 - .saturating_add(Weight::from_parts(143_017, 0).saturating_mul(r.into())) + // Measured: `773 + r * (3 ±0)` + // Estimated: `21735 + r * (15 ±0)` + // Minimum execution time: 231_823_000 picoseconds. + Weight::from_parts(237_996_137, 21735) + // Standard Error: 598 + .saturating_add(Weight::from_parts(163_106, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) @@ -3534,12 +3540,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2072 + r * (39 ±0)` - // Estimated: `27645 + r * (200 ±0)` - // Minimum execution time: 299_074_000 picoseconds. - Weight::from_parts(336_979_016, 27645) - // Standard Error: 1_163 - .saturating_add(Weight::from_parts(227_998, 0).saturating_mul(r.into())) + // Measured: `1975 + r * (39 ±0)` + // Estimated: `27145 + r * (200 ±0)` + // Minimum execution time: 235_077_000 picoseconds. + Weight::from_parts(267_876_360, 27145) + // Standard Error: 1_147 + .saturating_add(Weight::from_parts(256_275, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 200).saturating_mul(r.into())) @@ -3559,12 +3565,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `872 + r * (3 ±0)` - // Estimated: `24580 + r * (18 ±0)` - // Minimum execution time: 296_959_000 picoseconds. - Weight::from_parts(303_796_839, 24580) + // Measured: `776 + r * (3 ±0)` + // Estimated: `24004 + r * (18 ±0)` + // Minimum execution time: 231_384_000 picoseconds. + Weight::from_parts(237_086_900, 24004) // Standard Error: 534 - .saturating_add(Weight::from_parts(118_978, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(140_842, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 18).saturating_mul(r.into())) @@ -3574,507 +3580,509 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_020_000 picoseconds. - Weight::from_parts(1_355_107, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(4_110, 0).saturating_mul(r.into())) + // Minimum execution time: 1_721_000 picoseconds. + Weight::from_parts(2_456_746, 0) + // Standard Error: 30 + .saturating_add(Weight::from_parts(2_788, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64load(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_224_000 picoseconds. - Weight::from_parts(1_819_284, 0) - // Standard Error: 10 - .saturating_add(Weight::from_parts(10_803, 0).saturating_mul(r.into())) + // Minimum execution time: 1_824_000 picoseconds. + Weight::from_parts(2_366_036, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(6_446, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64store(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_216_000 picoseconds. - Weight::from_parts(1_795_011, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(10_000, 0).saturating_mul(r.into())) + // Minimum execution time: 1_840_000 picoseconds. + Weight::from_parts(2_332_115, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(6_012, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_select(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_127_000 picoseconds. - Weight::from_parts(1_491_730, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(11_471, 0).saturating_mul(r.into())) + // Minimum execution time: 1_731_000 picoseconds. + Weight::from_parts(2_078_873, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(7_931, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_044_000 picoseconds. - Weight::from_parts(2_330_852, 0) - // Standard Error: 69 - .saturating_add(Weight::from_parts(12_866, 0).saturating_mul(r.into())) + // Minimum execution time: 1_768_000 picoseconds. + Weight::from_parts(1_916_551, 0) + // Standard Error: 8 + .saturating_add(Weight::from_parts(10_597, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_067_000 picoseconds. - Weight::from_parts(1_399_626, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(6_430, 0).saturating_mul(r.into())) + // Minimum execution time: 1_735_000 picoseconds. + Weight::from_parts(1_962_845, 0) + // Standard Error: 14 + .saturating_add(Weight::from_parts(4_631, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_087_000 picoseconds. - Weight::from_parts(1_463_592, 0) - // Standard Error: 12 - .saturating_add(Weight::from_parts(9_707, 0).saturating_mul(r.into())) + // Minimum execution time: 1_688_000 picoseconds. + Weight::from_parts(1_172_825, 0) + // Standard Error: 76 + .saturating_add(Weight::from_parts(8_007, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br_table(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_110_000 picoseconds. - Weight::from_parts(1_058_258, 0) - // Standard Error: 22 - .saturating_add(Weight::from_parts(11_713, 0).saturating_mul(r.into())) + // Minimum execution time: 1_725_000 picoseconds. + Weight::from_parts(1_535_833, 0) + // Standard Error: 26 + .saturating_add(Weight::from_parts(9_489, 0).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. - fn instr_br_table_per_entry(_e: u32, ) -> Weight { + fn instr_br_table_per_entry(e: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_189_000 picoseconds. - Weight::from_parts(1_416_188, 0) + // Minimum execution time: 1_814_000 picoseconds. + Weight::from_parts(1_926_367, 0) + // Standard Error: 16 + .saturating_add(Weight::from_parts(219, 0).saturating_mul(e.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_201_000 picoseconds. - Weight::from_parts(3_375_851, 0) - // Standard Error: 96 - .saturating_add(Weight::from_parts(22_970, 0).saturating_mul(r.into())) + // Minimum execution time: 1_770_000 picoseconds. + Weight::from_parts(2_436_918, 0) + // Standard Error: 8 + .saturating_add(Weight::from_parts(17_890, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_call_indirect(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_286_000 picoseconds. - Weight::from_parts(2_817_725, 0) - // Standard Error: 55 - .saturating_add(Weight::from_parts(29_437, 0).saturating_mul(r.into())) + // Minimum execution time: 1_920_000 picoseconds. + Weight::from_parts(2_729_712, 0) + // Standard Error: 39 + .saturating_add(Weight::from_parts(24_853, 0).saturating_mul(r.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_319_000 picoseconds. - Weight::from_parts(1_636_286, 0) - // Standard Error: 31 - .saturating_add(Weight::from_parts(1_240, 0).saturating_mul(l.into())) + // Minimum execution time: 1_869_000 picoseconds. + Weight::from_parts(2_147_970, 0) + // Standard Error: 46 + .saturating_add(Weight::from_parts(1_237, 0).saturating_mul(l.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_507_000 picoseconds. - Weight::from_parts(2_785_119, 0) + // Minimum execution time: 3_012_000 picoseconds. + Weight::from_parts(3_234_440, 0) // Standard Error: 1 - .saturating_add(Weight::from_parts(4_601, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(2_433, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_494_000 picoseconds. - Weight::from_parts(2_948_015, 0) - // Standard Error: 14 - .saturating_add(Weight::from_parts(4_788, 0).saturating_mul(r.into())) + // Minimum execution time: 3_037_000 picoseconds. + Weight::from_parts(3_204_600, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_627, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_tee(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_443_000 picoseconds. - Weight::from_parts(3_065_273, 0) - // Standard Error: 15 - .saturating_add(Weight::from_parts(6_489, 0).saturating_mul(r.into())) + // Minimum execution time: 2_974_000 picoseconds. + Weight::from_parts(3_301_366, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_836, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_global_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_214_000 picoseconds. - Weight::from_parts(1_634_049, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(8_960, 0).saturating_mul(r.into())) + // Minimum execution time: 1_853_000 picoseconds. + Weight::from_parts(2_310_141, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(8_387, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_global_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_180_000 picoseconds. - Weight::from_parts(1_555_599, 0) + // Minimum execution time: 1_828_000 picoseconds. + Weight::from_parts(2_315_323, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(9_205, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(8_797, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_memory_current(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_223_000 picoseconds. - Weight::from_parts(1_626_002, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(8_181, 0).saturating_mul(r.into())) + // Minimum execution time: 1_800_000 picoseconds. + Weight::from_parts(2_117_252, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(3_741, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 16]`. fn instr_memory_grow(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_148_000 picoseconds. - Weight::from_parts(307_155, 0) - // Standard Error: 138_541 - .saturating_add(Weight::from_parts(13_291_570, 0).saturating_mul(r.into())) + // Minimum execution time: 1_743_000 picoseconds. + Weight::from_parts(1_054_728, 0) + // Standard Error: 137_128 + .saturating_add(Weight::from_parts(13_179_446, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64clz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_079_000 picoseconds. - Weight::from_parts(1_372_409, 0) - // Standard Error: 50 - .saturating_add(Weight::from_parts(6_427, 0).saturating_mul(r.into())) + // Minimum execution time: 1_735_000 picoseconds. + Weight::from_parts(2_026_568, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_802, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ctz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_116_000 picoseconds. - Weight::from_parts(1_415_180, 0) + // Minimum execution time: 1_630_000 picoseconds. + Weight::from_parts(1_980_222, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(6_353, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_735, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64popcnt(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_058_000 picoseconds. - Weight::from_parts(1_314_206, 0) - // Standard Error: 35 - .saturating_add(Weight::from_parts(6_431, 0).saturating_mul(r.into())) + // Minimum execution time: 1_695_000 picoseconds. + Weight::from_parts(2_040_266, 0) + // Standard Error: 8 + .saturating_add(Weight::from_parts(3_718, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64eqz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_059_000 picoseconds. - Weight::from_parts(1_455_331, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_507, 0).saturating_mul(r.into())) + // Minimum execution time: 1_697_000 picoseconds. + Weight::from_parts(2_004_663, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(3_661, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64extendsi32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_057_000 picoseconds. - Weight::from_parts(1_421_085, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_177, 0).saturating_mul(r.into())) + // Minimum execution time: 1_705_000 picoseconds. + Weight::from_parts(2_682_122, 0) + // Standard Error: 98 + .saturating_add(Weight::from_parts(3_705, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64extendui32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_079_000 picoseconds. - Weight::from_parts(1_429_275, 0) + // Minimum execution time: 1_674_000 picoseconds. + Weight::from_parts(1_989_835, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(6_175, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_801, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i32wrapi64(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_065_000 picoseconds. - Weight::from_parts(1_403_813, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(6_192, 0).saturating_mul(r.into())) + // Minimum execution time: 1_695_000 picoseconds. + Weight::from_parts(2_083_824, 0) + // Standard Error: 17 + .saturating_add(Weight::from_parts(3_719, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64eq(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_061_000 picoseconds. - Weight::from_parts(1_421_984, 0) + // Minimum execution time: 1_678_000 picoseconds. + Weight::from_parts(1_996_335, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(9_094, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_995, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ne(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_075_000 picoseconds. - Weight::from_parts(1_431_453, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(9_084, 0).saturating_mul(r.into())) + // Minimum execution time: 1_697_000 picoseconds. + Weight::from_parts(2_046_566, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(5_936, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64lts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_100_000 picoseconds. - Weight::from_parts(1_452_384, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(9_081, 0).saturating_mul(r.into())) + // Minimum execution time: 1_721_000 picoseconds. + Weight::from_parts(2_406_930, 0) + // Standard Error: 150 + .saturating_add(Weight::from_parts(5_992, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ltu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_090_000 picoseconds. - Weight::from_parts(1_466_416, 0) - // Standard Error: 17 - .saturating_add(Weight::from_parts(9_091, 0).saturating_mul(r.into())) + // Minimum execution time: 1_749_000 picoseconds. + Weight::from_parts(1_987_158, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_994, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64gts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_056_000 picoseconds. - Weight::from_parts(1_676_091, 0) - // Standard Error: 47 - .saturating_add(Weight::from_parts(9_082, 0).saturating_mul(r.into())) + // Minimum execution time: 1_706_000 picoseconds. + Weight::from_parts(2_038_138, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_802, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64gtu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_053_000 picoseconds. - Weight::from_parts(1_232_790, 0) - // Standard Error: 43 - .saturating_add(Weight::from_parts(9_329, 0).saturating_mul(r.into())) + // Minimum execution time: 1_670_000 picoseconds. + Weight::from_parts(2_555_035, 0) + // Standard Error: 74 + .saturating_add(Weight::from_parts(5_958, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64les(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_091_000 picoseconds. - Weight::from_parts(1_476_212, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(9_074, 0).saturating_mul(r.into())) + // Minimum execution time: 1_694_000 picoseconds. + Weight::from_parts(1_991_929, 0) + // Standard Error: 27 + .saturating_add(Weight::from_parts(6_037, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64leu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_083_000 picoseconds. - Weight::from_parts(1_484_966, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(9_184, 0).saturating_mul(r.into())) + // Minimum execution time: 1_684_000 picoseconds. + Weight::from_parts(1_969_284, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_104, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ges(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_089_000 picoseconds. - Weight::from_parts(1_516_766, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(9_063, 0).saturating_mul(r.into())) + // Minimum execution time: 1_697_000 picoseconds. + Weight::from_parts(2_023_608, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(5_946, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64geu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 996_000 picoseconds. - Weight::from_parts(1_460_638, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(9_076, 0).saturating_mul(r.into())) + // Minimum execution time: 1_659_000 picoseconds. + Weight::from_parts(1_963_145, 0) + // Standard Error: 6 + .saturating_add(Weight::from_parts(6_014, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64add(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_095_000 picoseconds. - Weight::from_parts(1_448_412, 0) + // Minimum execution time: 1_722_000 picoseconds. + Weight::from_parts(2_016_286, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(8_977, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_889, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64sub(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_071_000 picoseconds. - Weight::from_parts(1_459_165, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(8_852, 0).saturating_mul(r.into())) + // Minimum execution time: 1_656_000 picoseconds. + Weight::from_parts(1_966_234, 0) + // Standard Error: 17 + .saturating_add(Weight::from_parts(6_171, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64mul(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_082_000 picoseconds. - Weight::from_parts(1_450_718, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(8_860, 0).saturating_mul(r.into())) + // Minimum execution time: 1_695_000 picoseconds. + Weight::from_parts(2_004_559, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_785, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64divs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_065_000 picoseconds. - Weight::from_parts(1_436_871, 0) - // Standard Error: 9 - .saturating_add(Weight::from_parts(15_241, 0).saturating_mul(r.into())) + // Minimum execution time: 1_681_000 picoseconds. + Weight::from_parts(2_135_505, 0) + // Standard Error: 6 + .saturating_add(Weight::from_parts(11_761, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64divu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_065_000 picoseconds. - Weight::from_parts(1_423_806, 0) - // Standard Error: 17 - .saturating_add(Weight::from_parts(14_706, 0).saturating_mul(r.into())) + // Minimum execution time: 1_653_000 picoseconds. + Weight::from_parts(2_153_167, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(10_523, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rems(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_059_000 picoseconds. - Weight::from_parts(1_735_816, 0) - // Standard Error: 66 - .saturating_add(Weight::from_parts(15_230, 0).saturating_mul(r.into())) + // Minimum execution time: 1_697_000 picoseconds. + Weight::from_parts(2_570_266, 0) + // Standard Error: 50 + .saturating_add(Weight::from_parts(11_971, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64remu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_076_000 picoseconds. - Weight::from_parts(1_451_290, 0) - // Standard Error: 6 - .saturating_add(Weight::from_parts(14_530, 0).saturating_mul(r.into())) + // Minimum execution time: 1_719_000 picoseconds. + Weight::from_parts(2_101_082, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(10_709, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64and(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_079_000 picoseconds. - Weight::from_parts(1_457_537, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(8_963, 0).saturating_mul(r.into())) + // Minimum execution time: 1_745_000 picoseconds. + Weight::from_parts(2_621_890, 0) + // Standard Error: 94 + .saturating_add(Weight::from_parts(5_545, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64or(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_032_000 picoseconds. - Weight::from_parts(1_475_315, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(8_956, 0).saturating_mul(r.into())) + // Minimum execution time: 1_670_000 picoseconds. + Weight::from_parts(2_046_821, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_762, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64xor(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_056_000 picoseconds. - Weight::from_parts(1_450_071, 0) + // Minimum execution time: 1_714_000 picoseconds. + Weight::from_parts(2_010_173, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(8_960, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_911, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_116_000 picoseconds. - Weight::from_parts(1_429_705, 0) + // Minimum execution time: 1_756_000 picoseconds. + Weight::from_parts(2_044_772, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(9_027, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_857, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shrs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_059_000 picoseconds. - Weight::from_parts(1_429_307, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(9_048, 0).saturating_mul(r.into())) + // Minimum execution time: 1_741_000 picoseconds. + Weight::from_parts(2_012_819, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_127, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shru(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_093_000 picoseconds. - Weight::from_parts(1_411_827, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(9_528, 0).saturating_mul(r.into())) + // Minimum execution time: 1_693_000 picoseconds. + Weight::from_parts(2_090_981, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_839, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rotl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_115_000 picoseconds. - Weight::from_parts(1_441_025, 0) + // Minimum execution time: 1_704_000 picoseconds. + Weight::from_parts(2_014_108, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(9_043, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(6_005, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rotr(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_077_000 picoseconds. - Weight::from_parts(1_480_666, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(9_031, 0).saturating_mul(r.into())) + // Minimum execution time: 1_715_000 picoseconds. + Weight::from_parts(2_053_720, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(5_860, 0).saturating_mul(r.into())) } } From cb7e510ee0df351e26c8032eabe19b8f3948d35f Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Tue, 21 Mar 2023 08:56:33 +0100 Subject: [PATCH 47/80] zombienet: renamed deprecated transfer function (#13652) * zombienet: renamed deprecated transfer function * camelCase --- zombienet/0000-block-building/transaction-gets-finalized.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zombienet/0000-block-building/transaction-gets-finalized.js b/zombienet/0000-block-building/transaction-gets-finalized.js index a38cf603fc57e..d16e85f2c4e60 100644 --- a/zombienet/0000-block-building/transaction-gets-finalized.js +++ b/zombienet/0000-block-building/transaction-gets-finalized.js @@ -14,7 +14,7 @@ async function run(nodeName, networkInfo, args) { const bob = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty'; // Create a extrinsic, transferring 10^20 units to Bob - const transfer = api.tx.balances.transfer(bob, 10n**20n); + const transfer = api.tx.balances.transferAllowDeath(bob, 10n**20n); let transaction_success_event = false; try { From 6e71ebb00a06605fd45d236e17be741055f37ccd Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Tue, 21 Mar 2023 10:45:40 +0100 Subject: [PATCH 48/80] Bump parity-db (#13656) --- Cargo.lock | 16 ++++++++-------- bin/node/bench/Cargo.toml | 2 +- client/db/Cargo.toml | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5306d2015b17b..e2ec461e1e03e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -652,9 +652,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array 0.14.6", ] @@ -1706,7 +1706,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", "crypto-common", "subtle", ] @@ -3667,9 +3667,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "libgit2-sys" @@ -6925,9 +6925,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df89dd8311063c54ae4e03d9aeb597b04212a57e82c339344130a9cad9b3e2d9" +checksum = "00bfb81cf5c90a222db2fb7b3a7cbf8cc7f38dfb6647aca4d98edf8281f56ed5" dependencies = [ "blake2", "crc32fast", @@ -11820,7 +11820,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.6", - "rand 0.8.5", + "rand 0.7.3", "static_assertions", ] diff --git a/bin/node/bench/Cargo.toml b/bin/node/bench/Cargo.toml index be5e94ee4df8b..153a721da41f8 100644 --- a/bin/node/bench/Cargo.toml +++ b/bin/node/bench/Cargo.toml @@ -38,7 +38,7 @@ tempfile = "3.1.0" fs_extra = "1" rand = { version = "0.8.5", features = ["small_rng"] } lazy_static = "1.4.0" -parity-db = "0.4.4" +parity-db = "0.4.6" sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" } sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" } futures = { version = "0.3.21", features = ["thread-pool"] } diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index c96e5c7405e74..8e4bcf18a2d04 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -22,7 +22,7 @@ kvdb-memorydb = "0.13.0" kvdb-rocksdb = { version = "0.17.0", optional = true } linked-hash-map = "0.5.4" log = "0.4.17" -parity-db = "0.4.4" +parity-db = "0.4.6" parking_lot = "0.12.1" sc-client-api = { version = "4.0.0-dev", path = "../api" } sc-state-db = { version = "0.10.0-dev", path = "../state-db" } From 859bb12cd83b685f1c128133412b3afd8cc6de68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 21 Mar 2023 10:46:25 +0100 Subject: [PATCH 49/80] contracts: Follow up for benchmark simplification (#13635) * Rename BATCHES -> RUNS * Reduce runs of slow benchmarks * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts --------- Co-authored-by: command-bot <> --- frame/contracts/src/benchmarking/mod.rs | 188 +-- frame/contracts/src/weights.rs | 1930 +++++++++++------------ 2 files changed, 1060 insertions(+), 1058 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 9b75b140f03d8..5494b57b65a2a 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -45,18 +45,18 @@ use sp_runtime::{ use sp_std::prelude::*; use wasm_instrument::parity_wasm::elements::{BlockType, BrTableData, Instruction, ValueType}; -/// How many batches we do per API benchmark. +/// How many runs we do per API benchmark. /// /// This is picked more or less arbitrary. We experimented with different numbers until /// the results appeared to be stable. Reducing the number would speed up the benchmarks /// but might make the results less precise. -const API_BENCHMARK_BATCHES: u32 = 1600; +const API_BENCHMARK_RUNS: u32 = 1600; -/// How many batches we do per instruction benchmark. +/// How many runs we do per instruction benchmark. /// -/// Same rationale as for [`API_BENCHMARK_BATCHES`]. The number is bigger because instruction +/// Same rationale as for [`API_BENCHMARK_RUNS`]. The number is bigger because instruction /// benchmarks are faster. -const INSTR_BENCHMARK_BATCHES: u32 = 5000; +const INSTR_BENCHMARK_RUNS: u32 = 5000; /// An instantiated and deployed contract. struct Contract { @@ -425,7 +425,7 @@ benchmarks! { #[pov_mode = Measured] seal_caller { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::getter( "seal0", "seal_caller", r ), vec![])?; @@ -434,7 +434,7 @@ benchmarks! { #[pov_mode = Measured] seal_is_contract { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let accounts = (0 .. r) .map(|n| account::("account", n, 0)) .collect::>(); @@ -472,7 +472,7 @@ benchmarks! { #[pov_mode = Measured] seal_code_hash { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let accounts = (0 .. r) .map(|n| account::("account", n, 0)) .collect::>(); @@ -518,7 +518,7 @@ benchmarks! { #[pov_mode = Measured] seal_own_code_hash { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::getter( "seal0", "seal_own_code_hash", r ), vec![])?; @@ -527,7 +527,7 @@ benchmarks! { #[pov_mode = Measured] seal_caller_is_origin { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -548,7 +548,7 @@ benchmarks! { #[pov_mode = Measured] seal_address { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::getter( "seal0", "seal_address", r ), vec![])?; @@ -557,7 +557,7 @@ benchmarks! { #[pov_mode = Measured] seal_gas_left { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::getter( "seal0", "seal_gas_left", r ), vec![])?; @@ -566,7 +566,7 @@ benchmarks! { #[pov_mode = Measured] seal_balance { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::getter( "seal0", "seal_balance", r ), vec![])?; @@ -575,7 +575,7 @@ benchmarks! { #[pov_mode = Measured] seal_value_transferred { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::getter( "seal0", "seal_value_transferred", r ), vec![])?; @@ -584,7 +584,7 @@ benchmarks! { #[pov_mode = Measured] seal_minimum_balance { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::getter( "seal0", "seal_minimum_balance", r ), vec![])?; @@ -593,7 +593,7 @@ benchmarks! { #[pov_mode = Measured] seal_block_number { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::getter( "seal0", "seal_block_number", r ), vec![])?; @@ -602,7 +602,7 @@ benchmarks! { #[pov_mode = Measured] seal_now { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::getter( "seal0", "seal_now", r ), vec![])?; @@ -611,7 +611,7 @@ benchmarks! { #[pov_mode = Measured] seal_weight_to_fee { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let pages = code::max_pages::(); let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), @@ -639,7 +639,7 @@ benchmarks! { #[pov_mode = Measured] seal_gas { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let code = WasmModule::::from(ModuleDefinition { imported_functions: vec![ImportedFunction { module: "seal0", @@ -660,7 +660,7 @@ benchmarks! { #[pov_mode = Measured] seal_input { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -815,7 +815,7 @@ benchmarks! { // used. #[pov_mode = Measured] seal_random { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let pages = code::max_pages::(); let subject_len = T::Schedule::get().limits.subject_len; assert!(subject_len < 1024); @@ -850,7 +850,7 @@ benchmarks! { // We benchmark for the worst case (largest event). #[pov_mode = Measured] seal_deposit_event { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -914,7 +914,7 @@ benchmarks! { // against an excessive use. #[pov_mode = Measured] seal_debug_message { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory { min_pages: 1, max_pages: 1 }), imported_functions: vec![ImportedFunction { @@ -1009,7 +1009,7 @@ benchmarks! { #[skip_meta] #[pov_mode = Measured] seal_set_storage { - let r in 0 .. API_BENCHMARK_BATCHES/2; + let r in 0 .. API_BENCHMARK_RUNS/2; let max_key_len = T::MaxStorageKeyLen::get(); let keys = (0 .. r) .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); @@ -1143,11 +1143,11 @@ benchmarks! { // Similar to seal_set_storage. We store all the keys that we are about to // delete beforehand in order to prevent any optimizations that could occur when // deleting a non existing key. We generate keys of a maximum length, and have to - // reduce batch size in order to make resulting contract code size less than MaxCodeLen. + // the amount of runs in order to make resulting contract code size less than MaxCodeLen. #[skip_meta] #[pov_mode = Measured] seal_clear_storage { - let r in 0 .. API_BENCHMARK_BATCHES/2; + let r in 0 .. API_BENCHMARK_RUNS/2; let max_key_len = T::MaxStorageKeyLen::get(); let keys = (0 .. r) .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); @@ -1236,7 +1236,7 @@ benchmarks! { #[skip_meta] #[pov_mode = Measured] seal_get_storage { - let r in 0 .. API_BENCHMARK_BATCHES/2; + let r in 0 .. API_BENCHMARK_RUNS/2; let max_key_len = T::MaxStorageKeyLen::get(); let keys = (0 .. r) .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); @@ -1339,7 +1339,7 @@ benchmarks! { #[skip_meta] #[pov_mode = Measured] seal_contains_storage { - let r in 0 .. API_BENCHMARK_BATCHES/2; + let r in 0 .. API_BENCHMARK_RUNS/2; let max_key_len = T::MaxStorageKeyLen::get(); let keys = (0 .. r) .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); @@ -1429,7 +1429,7 @@ benchmarks! { #[skip_meta] #[pov_mode = Measured] seal_take_storage { - let r in 0 .. API_BENCHMARK_BATCHES/2; + let r in 0 .. API_BENCHMARK_RUNS/2; let max_key_len = T::MaxStorageKeyLen::get(); let keys = (0 .. r) .map(|n| { let mut h = T::Hashing::hash_of(&n).as_ref().to_vec(); @@ -1531,7 +1531,7 @@ benchmarks! { // We transfer to unique accounts. #[pov_mode = Measured] seal_transfer { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let accounts = (0..r) .map(|i| account::("receiver", i, 0)) .collect::>(); @@ -1583,9 +1583,11 @@ benchmarks! { } // We call unique accounts. + // + // This is a slow call: We redeuce the number of runs. #[pov_mode = Measured] seal_call { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS / 2; let dummy_code = WasmModule::::dummy_with_bytes(0); let callees = (0..r) .map(|i| Contract::with_index(i + 1, dummy_code.clone(), vec![])) @@ -1642,9 +1644,10 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + // This is a slow call: We redeuce the number of runs. #[pov_mode = Measured] seal_delegate_call { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS / 2; let hashes = (0..r) .map(|i| { let code = WasmModule::::dummy_with_bytes(i); @@ -1751,9 +1754,10 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, bytes) // We assume that every instantiate sends at least the minimum balance. + // This is a slow call: We redeuce the number of runs. #[pov_mode = Measured] seal_instantiate { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS / 2; let hashes = (0..r) .map(|i| { let code = WasmModule::::from(ModuleDefinition { @@ -1939,7 +1943,7 @@ benchmarks! { // Only the overhead of calling the function itself with minimal arguments. #[pov_mode = Measured] seal_hash_sha2_256 { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::hasher( "seal_hash_sha2_256", r, 0, ), vec![])?; @@ -1959,7 +1963,7 @@ benchmarks! { // Only the overhead of calling the function itself with minimal arguments. #[pov_mode = Measured] seal_hash_keccak_256 { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::hasher( "seal_hash_keccak_256", r, 0, ), vec![])?; @@ -1979,7 +1983,7 @@ benchmarks! { // Only the overhead of calling the function itself with minimal arguments. #[pov_mode = Measured] seal_hash_blake2_256 { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::hasher( "seal_hash_blake2_256", r, 0, ), vec![])?; @@ -1999,7 +2003,7 @@ benchmarks! { // Only the overhead of calling the function itself with minimal arguments. #[pov_mode = Measured] seal_hash_blake2_128 { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let instance = Contract::::new(WasmModule::hasher( "seal_hash_blake2_128", r, 0, ), vec![])?; @@ -2018,9 +2022,10 @@ benchmarks! { // Only calling the function itself with valid arguments. // It generates different private keys and signatures for the message "Hello world". + // This is a slow call: We redeuce the number of runs. #[pov_mode = Measured] seal_ecdsa_recover { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS / 10; let message_hash = sp_io::hashing::blake2_256("Hello world".as_bytes()); let key_type = sp_core::crypto::KeyTypeId(*b"code"); @@ -2067,9 +2072,10 @@ benchmarks! { // Only calling the function itself for the list of // generated different ECDSA keys. + // This is a slow call: We redeuce the number of runs. #[pov_mode = Measured] seal_ecdsa_to_eth_address { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS / 10; let key_type = sp_core::crypto::KeyTypeId(*b"code"); let pub_keys_bytes = (0..r) .flat_map(|_| { @@ -2105,7 +2111,7 @@ benchmarks! { #[pov_mode = Measured] seal_set_code_hash { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let code_hashes = (0..r) .map(|i| { let new_code = WasmModule::::dummy_with_bytes(i); @@ -2146,7 +2152,7 @@ benchmarks! { #[pov_mode = Measured] seal_reentrance_count { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -2167,7 +2173,7 @@ benchmarks! { #[pov_mode = Measured] seal_account_reentrance_count { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let dummy_code = WasmModule::::dummy_with_bytes(0); let accounts = (0..r) .map(|i| Contract::with_index(i + 1, dummy_code.clone(), vec![])) @@ -2201,7 +2207,7 @@ benchmarks! { #[pov_mode = Measured] seal_instantiation_nonce { - let r in 0 .. API_BENCHMARK_BATCHES; + let r in 0 .. API_BENCHMARK_RUNS; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { @@ -2232,7 +2238,7 @@ benchmarks! { // w_i{32,64}const = w_drop = w_bench / 2 #[pov_mode = Ignored] instr_i64const { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { call_body: Some(body::repeated_dyn(r, vec![ RandomI64Repeated(1), @@ -2247,7 +2253,7 @@ benchmarks! { // w_i{32,64}load = w_bench - 2 * w_param #[pov_mode = Ignored] instr_i64load { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), call_body: Some(body::repeated_dyn(r, vec![ @@ -2264,7 +2270,7 @@ benchmarks! { // w_i{32,64}store{...} = w_bench - 2 * w_param #[pov_mode = Ignored] instr_i64store { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), call_body: Some(body::repeated_dyn(r, vec![ @@ -2281,7 +2287,7 @@ benchmarks! { // w_select = w_bench - 4 * w_param #[pov_mode = Ignored] instr_select { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { call_body: Some(body::repeated_dyn(r, vec![ RandomI64Repeated(1), @@ -2299,7 +2305,7 @@ benchmarks! { // w_if = w_bench - 3 * w_param #[pov_mode = Ignored] instr_if { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { call_body: Some(body::repeated_dyn(r, vec![ RandomI32(0, 2), @@ -2320,7 +2326,7 @@ benchmarks! { // Block instructions are not counted. #[pov_mode = Ignored] instr_br { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { call_body: Some(body::repeated_dyn(r, vec![ Regular(Instruction::Block(BlockType::NoResult)), @@ -2347,7 +2353,7 @@ benchmarks! { // Block instructions are not counted. #[pov_mode = Ignored] instr_br_if { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { call_body: Some(body::repeated_dyn(r, vec![ Regular(Instruction::Block(BlockType::NoResult)), @@ -2375,7 +2381,7 @@ benchmarks! { // Block instructions are not counted. #[pov_mode = Ignored] instr_br_table { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let table = Box::new(BrTableData { table: Box::new([1, 1, 1]), default: 1, @@ -2442,7 +2448,7 @@ benchmarks! { // w_call = w_bench - 2 * w_param #[pov_mode = Ignored] instr_call { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { // We need to make use of the stack here in order to trigger stack height // instrumentation. @@ -2463,7 +2469,7 @@ benchmarks! { // w_call_indrect = w_bench - 3 * w_param #[pov_mode = Ignored] instr_call_indirect { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let num_elements = T::Schedule::get().limits.table_size; use self::code::TableSegment; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { @@ -2511,7 +2517,7 @@ benchmarks! { // w_local_get = w_bench - 1 * w_param #[pov_mode = Ignored] instr_local_get { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let max_locals = T::Schedule::get().limits.locals; let mut call_body = body::repeated_dyn(r, vec![ RandomGetLocal(0, max_locals), @@ -2529,7 +2535,7 @@ benchmarks! { // w_local_set = w_bench - 1 * w_param #[pov_mode = Ignored] instr_local_set { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let max_locals = T::Schedule::get().limits.locals; let mut call_body = body::repeated_dyn(r, vec![ RandomI64Repeated(1), @@ -2547,7 +2553,7 @@ benchmarks! { // w_local_tee = w_bench - 2 * w_param #[pov_mode = Ignored] instr_local_tee { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let max_locals = T::Schedule::get().limits.locals; let mut call_body = body::repeated_dyn(r, vec![ RandomI64Repeated(1), @@ -2566,7 +2572,7 @@ benchmarks! { // w_global_get = w_bench - 1 * w_param #[pov_mode = Ignored] instr_global_get { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let max_globals = T::Schedule::get().limits.globals; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { call_body: Some(body::repeated_dyn(r, vec![ @@ -2583,7 +2589,7 @@ benchmarks! { // w_global_set = w_bench - 1 * w_param #[pov_mode = Ignored] instr_global_set { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let max_globals = T::Schedule::get().limits.globals; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { call_body: Some(body::repeated_dyn(r, vec![ @@ -2600,7 +2606,7 @@ benchmarks! { // w_memory_get = w_bench - 1 * w_param #[pov_mode = Ignored] instr_memory_current { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), call_body: Some(body::repeated(r, &[ @@ -2642,7 +2648,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64clz { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( Instruction::I64Clz, r, @@ -2653,7 +2659,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64ctz { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( Instruction::I64Ctz, r, @@ -2664,7 +2670,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64popcnt { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( Instruction::I64Popcnt, r, @@ -2675,7 +2681,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64eqz { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( Instruction::I64Eqz, r, @@ -2686,7 +2692,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64extendsi32 { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { call_body: Some(body::repeated_dyn(r, vec![ RandomI32Repeated(1), @@ -2701,7 +2707,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64extendui32 { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { call_body: Some(body::repeated_dyn(r, vec![ RandomI32Repeated(1), @@ -2716,7 +2722,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i32wrapi64 { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( Instruction::I32WrapI64, r, @@ -2730,7 +2736,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64eq { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Eq, r, @@ -2741,7 +2747,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64ne { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Ne, r, @@ -2752,7 +2758,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64lts { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64LtS, r, @@ -2763,7 +2769,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64ltu { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64LtU, r, @@ -2774,7 +2780,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64gts { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64GtS, r, @@ -2785,7 +2791,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64gtu { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64GtU, r, @@ -2796,7 +2802,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64les { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64LeS, r, @@ -2807,7 +2813,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64leu { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64LeU, r, @@ -2818,7 +2824,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64ges { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64GeS, r, @@ -2829,7 +2835,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64geu { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64GeU, r, @@ -2840,7 +2846,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64add { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Add, r, @@ -2851,7 +2857,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64sub { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Sub, r, @@ -2862,7 +2868,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64mul { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Mul, r, @@ -2873,7 +2879,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64divs { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64DivS, r, @@ -2884,7 +2890,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64divu { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64DivU, r, @@ -2895,7 +2901,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64rems { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64RemS, r, @@ -2906,7 +2912,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64remu { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64RemU, r, @@ -2917,7 +2923,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64and { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64And, r, @@ -2928,7 +2934,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64or { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Or, r, @@ -2939,7 +2945,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64xor { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Xor, r, @@ -2950,7 +2956,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64shl { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Shl, r, @@ -2961,7 +2967,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64shrs { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64ShrS, r, @@ -2972,7 +2978,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64shru { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64ShrU, r, @@ -2983,7 +2989,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64rotl { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Rotl, r, @@ -2994,7 +3000,7 @@ benchmarks! { #[pov_mode = Ignored] instr_i64rotr { - let r in 0 .. INSTR_BENCHMARK_BATCHES; + let r in 0 .. INSTR_BENCHMARK_RUNS; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( Instruction::I64Rotr, r, diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index 4333f26c5fc5c..dfe6fb20de7bc 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_contracts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-17, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -177,8 +177,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `109` // Estimated: `1594` - // Minimum execution time: 2_567_000 picoseconds. - Weight::from_parts(2_711_000, 1594) + // Minimum execution time: 2_585_000 picoseconds. + Weight::from_parts(2_802_000, 1594) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Skipped Metadata (r:0 w:0) @@ -188,10 +188,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `450 + k * (69 ±0)` // Estimated: `440 + k * (70 ±0)` - // Minimum execution time: 11_048_000 picoseconds. - Weight::from_parts(7_029_322, 440) - // Standard Error: 1_158 - .saturating_add(Weight::from_parts(975_010, 0).saturating_mul(k.into())) + // Minimum execution time: 10_825_000 picoseconds. + Weight::from_parts(5_747_064, 440) + // Standard Error: 1_037 + .saturating_add(Weight::from_parts(973_689, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -205,10 +205,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `250 + q * (33 ±0)` // Estimated: `1725 + q * (33 ±0)` - // Minimum execution time: 2_645_000 picoseconds. - Weight::from_parts(10_865_477, 1725) - // Standard Error: 3_383 - .saturating_add(Weight::from_parts(1_295_351, 0).saturating_mul(q.into())) + // Minimum execution time: 2_718_000 picoseconds. + Weight::from_parts(11_436_305, 1725) + // Standard Error: 3_619 + .saturating_add(Weight::from_parts(1_296_955, 0).saturating_mul(q.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 33).saturating_mul(q.into())) @@ -222,10 +222,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `238 + c * (1 ±0)` // Estimated: `3951 + c * (2 ±0)` - // Minimum execution time: 30_817_000 picoseconds. - Weight::from_parts(29_762_622, 3951) - // Standard Error: 62 - .saturating_add(Weight::from_parts(54_714, 0).saturating_mul(c.into())) + // Minimum execution time: 37_882_000 picoseconds. + Weight::from_parts(43_548_816, 3951) + // Standard Error: 49 + .saturating_add(Weight::from_parts(53_936, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 2).saturating_mul(c.into())) @@ -245,10 +245,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `707` // Estimated: `21400 + c * (5 ±0)` - // Minimum execution time: 245_493_000 picoseconds. - Weight::from_parts(253_703_384, 21400) - // Standard Error: 27 - .saturating_add(Weight::from_parts(38_078, 0).saturating_mul(c.into())) + // Minimum execution time: 313_392_000 picoseconds. + Weight::from_parts(325_419_093, 21400) + // Standard Error: 25 + .saturating_add(Weight::from_parts(37_877, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(c.into())) @@ -276,14 +276,14 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `270` // Estimated: `26207` - // Minimum execution time: 3_079_430_000 picoseconds. - Weight::from_parts(555_022_483, 26207) - // Standard Error: 290 - .saturating_add(Weight::from_parts(107_411, 0).saturating_mul(c.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(1_123, 0).saturating_mul(i.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(1_434, 0).saturating_mul(s.into())) + // Minimum execution time: 3_274_352_000 picoseconds. + Weight::from_parts(681_171_416, 26207) + // Standard Error: 336 + .saturating_add(Weight::from_parts(106_391, 0).saturating_mul(c.into())) + // Standard Error: 19 + .saturating_add(Weight::from_parts(1_147, 0).saturating_mul(i.into())) + // Standard Error: 19 + .saturating_add(Weight::from_parts(1_493, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } @@ -307,12 +307,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `482` // Estimated: `28521` - // Minimum execution time: 1_600_733_000 picoseconds. - Weight::from_parts(228_681_962, 28521) + // Minimum execution time: 1_692_637_000 picoseconds. + Weight::from_parts(283_252_265, 28521) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_445, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_498, 0).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_456, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_487, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -330,8 +330,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `759` // Estimated: `21615` - // Minimum execution time: 172_310_000 picoseconds. - Weight::from_parts(176_655_000, 21615) + // Minimum execution time: 192_369_000 picoseconds. + Weight::from_parts(193_417_000, 21615) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -348,10 +348,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `109` // Estimated: `7366` - // Minimum execution time: 246_364_000 picoseconds. - Weight::from_parts(262_887_234, 7366) - // Standard Error: 90 - .saturating_add(Weight::from_parts(107_926, 0).saturating_mul(c.into())) + // Minimum execution time: 301_972_000 picoseconds. + Weight::from_parts(313_248_051, 7366) + // Standard Error: 82 + .saturating_add(Weight::from_parts(107_321, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -367,8 +367,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `255` // Estimated: `7950` - // Minimum execution time: 29_226_000 picoseconds. - Weight::from_parts(29_542_000, 7950) + // Minimum execution time: 33_013_000 picoseconds. + Weight::from_parts(33_622_000, 7950) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -382,8 +382,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `570` // Estimated: `19530` - // Minimum execution time: 33_921_000 picoseconds. - Weight::from_parts(35_056_000, 19530) + // Minimum execution time: 33_518_000 picoseconds. + Weight::from_parts(33_819_000, 19530) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -402,10 +402,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `781 + r * (6 ±0)` // Estimated: `21730 + r * (30 ±0)` - // Minimum execution time: 232_118_000 picoseconds. - Weight::from_parts(233_883_823, 21730) - // Standard Error: 642 - .saturating_add(Weight::from_parts(340_543, 0).saturating_mul(r.into())) + // Minimum execution time: 283_945_000 picoseconds. + Weight::from_parts(289_209_599, 21730) + // Standard Error: 901 + .saturating_add(Weight::from_parts(327_601, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -425,10 +425,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `839 + r * (240 ±0)` // Estimated: `21835 + r * (3675 ±0)` - // Minimum execution time: 231_712_000 picoseconds. - Weight::from_parts(74_297_097, 21835) - // Standard Error: 6_099 - .saturating_add(Weight::from_parts(3_322_192, 0).saturating_mul(r.into())) + // Minimum execution time: 284_949_000 picoseconds. + Weight::from_parts(126_196_485, 21835) + // Standard Error: 6_260 + .saturating_add(Weight::from_parts(3_368_849, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -449,10 +449,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `831 + r * (244 ±0)` // Estimated: `21855 + r * (3695 ±0)` - // Minimum execution time: 233_122_000 picoseconds. - Weight::from_parts(74_369_473, 21855) - // Standard Error: 6_027 - .saturating_add(Weight::from_parts(4_177_187, 0).saturating_mul(r.into())) + // Minimum execution time: 286_429_000 picoseconds. + Weight::from_parts(124_820_396, 21855) + // Standard Error: 6_539 + .saturating_add(Weight::from_parts(4_163_535, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -473,10 +473,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `788 + r * (6 ±0)` // Estimated: `21770 + r * (30 ±0)` - // Minimum execution time: 232_822_000 picoseconds. - Weight::from_parts(232_507_418, 21770) - // Standard Error: 961 - .saturating_add(Weight::from_parts(419_331, 0).saturating_mul(r.into())) + // Minimum execution time: 285_042_000 picoseconds. + Weight::from_parts(288_096_303, 21770) + // Standard Error: 972 + .saturating_add(Weight::from_parts(409_782, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -496,10 +496,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `778 + r * (3 ±0)` // Estimated: `21735 + r * (15 ±0)` - // Minimum execution time: 229_719_000 picoseconds. - Weight::from_parts(235_257_789, 21735) - // Standard Error: 451 - .saturating_add(Weight::from_parts(161_101, 0).saturating_mul(r.into())) + // Minimum execution time: 282_820_000 picoseconds. + Weight::from_parts(287_104_710, 21735) + // Standard Error: 421 + .saturating_add(Weight::from_parts(167_907, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) @@ -519,10 +519,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `782 + r * (6 ±0)` // Estimated: `21740 + r * (30 ±0)` - // Minimum execution time: 231_517_000 picoseconds. - Weight::from_parts(236_185_452, 21740) - // Standard Error: 651 - .saturating_add(Weight::from_parts(334_659, 0).saturating_mul(r.into())) + // Minimum execution time: 284_619_000 picoseconds. + Weight::from_parts(281_326_785, 21740) + // Standard Error: 1_379 + .saturating_add(Weight::from_parts(342_779, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -542,10 +542,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `783 + r * (6 ±0)` // Estimated: `21725 + r * (30 ±0)` - // Minimum execution time: 232_855_000 picoseconds. - Weight::from_parts(239_986_328, 21725) - // Standard Error: 4_075 - .saturating_add(Weight::from_parts(345_726, 0).saturating_mul(r.into())) + // Minimum execution time: 284_703_000 picoseconds. + Weight::from_parts(289_479_932, 21725) + // Standard Error: 745 + .saturating_add(Weight::from_parts(323_625, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -565,10 +565,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `922 + r * (6 ±0)` // Estimated: `24633 + r * (30 ±0)` - // Minimum execution time: 231_685_000 picoseconds. - Weight::from_parts(245_514_261, 24633) - // Standard Error: 1_635 - .saturating_add(Weight::from_parts(1_523_359, 0).saturating_mul(r.into())) + // Minimum execution time: 283_610_000 picoseconds. + Weight::from_parts(299_901_534, 24633) + // Standard Error: 1_177 + .saturating_add(Weight::from_parts(1_474_603, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -588,10 +588,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `792 + r * (6 ±0)` // Estimated: `21825 + r * (30 ±0)` - // Minimum execution time: 233_361_000 picoseconds. - Weight::from_parts(234_553_471, 21825) - // Standard Error: 1_108 - .saturating_add(Weight::from_parts(330_383, 0).saturating_mul(r.into())) + // Minimum execution time: 284_474_000 picoseconds. + Weight::from_parts(283_540_273, 21825) + // Standard Error: 1_164 + .saturating_add(Weight::from_parts(339_262, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -611,10 +611,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `790 + r * (6 ±0)` // Estimated: `21815 + r * (30 ±0)` - // Minimum execution time: 231_918_000 picoseconds. - Weight::from_parts(239_128_416, 21815) - // Standard Error: 1_473 - .saturating_add(Weight::from_parts(317_879, 0).saturating_mul(r.into())) + // Minimum execution time: 284_521_000 picoseconds. + Weight::from_parts(285_747_754, 21815) + // Standard Error: 889 + .saturating_add(Weight::from_parts(326_428, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -634,10 +634,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `787 + r * (6 ±0)` // Estimated: `21805 + r * (30 ±0)` - // Minimum execution time: 231_936_000 picoseconds. - Weight::from_parts(232_240_207, 21805) - // Standard Error: 731 - .saturating_add(Weight::from_parts(330_713, 0).saturating_mul(r.into())) + // Minimum execution time: 284_103_000 picoseconds. + Weight::from_parts(283_801_256, 21805) + // Standard Error: 1_051 + .saturating_add(Weight::from_parts(334_081, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -657,10 +657,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `778 + r * (6 ±0)` // Estimated: `21735 + r * (30 ±0)` - // Minimum execution time: 231_978_000 picoseconds. - Weight::from_parts(224_881_201, 21735) - // Standard Error: 1_296 - .saturating_add(Weight::from_parts(346_872, 0).saturating_mul(r.into())) + // Minimum execution time: 284_187_000 picoseconds. + Weight::from_parts(289_414_364, 21735) + // Standard Error: 796 + .saturating_add(Weight::from_parts(324_603, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -682,10 +682,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `856 + r * (10 ±0)` // Estimated: `24446 + r * (60 ±0)` - // Minimum execution time: 231_707_000 picoseconds. - Weight::from_parts(245_939_854, 24446) - // Standard Error: 1_369 - .saturating_add(Weight::from_parts(1_380_453, 0).saturating_mul(r.into())) + // Minimum execution time: 284_953_000 picoseconds. + Weight::from_parts(290_535_752, 24446) + // Standard Error: 2_462 + .saturating_add(Weight::from_parts(1_361_518, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) @@ -705,10 +705,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `745 + r * (4 ±0)` // Estimated: `21555 + r * (20 ±0)` - // Minimum execution time: 157_429_000 picoseconds. - Weight::from_parts(161_047_355, 21555) - // Standard Error: 1_220 - .saturating_add(Weight::from_parts(134_497, 0).saturating_mul(r.into())) + // Minimum execution time: 160_775_000 picoseconds. + Weight::from_parts(164_652_364, 21555) + // Standard Error: 284 + .saturating_add(Weight::from_parts(132_574, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 20).saturating_mul(r.into())) @@ -728,10 +728,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `780 + r * (6 ±0)` // Estimated: `21740 + r * (30 ±0)` - // Minimum execution time: 232_561_000 picoseconds. - Weight::from_parts(230_989_499, 21740) - // Standard Error: 848 - .saturating_add(Weight::from_parts(282_053, 0).saturating_mul(r.into())) + // Minimum execution time: 284_072_000 picoseconds. + Weight::from_parts(288_418_644, 21740) + // Standard Error: 792 + .saturating_add(Weight::from_parts(272_881, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -751,10 +751,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `784` // Estimated: `21740` - // Minimum execution time: 237_080_000 picoseconds. - Weight::from_parts(239_380_994, 21740) - // Standard Error: 2 - .saturating_add(Weight::from_parts(592, 0).saturating_mul(n.into())) + // Minimum execution time: 286_671_000 picoseconds. + Weight::from_parts(292_151_662, 21740) + // Standard Error: 1 + .saturating_add(Weight::from_parts(638, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -773,10 +773,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `768 + r * (45 ±0)` // Estimated: `21660 + r * (225 ±0)` - // Minimum execution time: 228_669_000 picoseconds. - Weight::from_parts(230_916_471, 21660) - // Standard Error: 295_520 - .saturating_add(Weight::from_parts(1_420_928, 0).saturating_mul(r.into())) + // Minimum execution time: 280_334_000 picoseconds. + Weight::from_parts(283_487_571, 21660) + // Standard Error: 267_797 + .saturating_add(Weight::from_parts(3_803_128, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 225).saturating_mul(r.into())) @@ -796,10 +796,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `778` // Estimated: `21775` - // Minimum execution time: 231_626_000 picoseconds. - Weight::from_parts(232_097_413, 21775) + // Minimum execution time: 284_004_000 picoseconds. + Weight::from_parts(283_681_350, 21775) // Standard Error: 1 - .saturating_add(Weight::from_parts(185, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(232, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -822,10 +822,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `810 + r * (356 ±0)` // Estimated: `25511 + r * (15321 ±0)` - // Minimum execution time: 230_758_000 picoseconds. - Weight::from_parts(233_235_993, 25511) - // Standard Error: 196_168 - .saturating_add(Weight::from_parts(81_177_506, 0).saturating_mul(r.into())) + // Minimum execution time: 284_143_000 picoseconds. + Weight::from_parts(287_218_324, 25511) + // Standard Error: 343_611 + .saturating_add(Weight::from_parts(109_895_675, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -849,10 +849,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `825 + r * (10 ±0)` // Estimated: `24283 + r * (60 ±0)` - // Minimum execution time: 232_457_000 picoseconds. - Weight::from_parts(240_943_161, 24283) - // Standard Error: 3_085 - .saturating_add(Weight::from_parts(1_837_168, 0).saturating_mul(r.into())) + // Minimum execution time: 285_037_000 picoseconds. + Weight::from_parts(299_804_606, 24283) + // Standard Error: 5_518 + .saturating_add(Weight::from_parts(1_848_164, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) @@ -872,10 +872,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `778 + r * (10 ±0)` // Estimated: `21735 + r * (50 ±0)` - // Minimum execution time: 229_788_000 picoseconds. - Weight::from_parts(233_520_858, 21735) - // Standard Error: 9_561 - .saturating_add(Weight::from_parts(3_596_294, 0).saturating_mul(r.into())) + // Minimum execution time: 282_886_000 picoseconds. + Weight::from_parts(293_171_736, 21735) + // Standard Error: 2_171 + .saturating_add(Weight::from_parts(3_491_303, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 50).saturating_mul(r.into())) @@ -896,12 +896,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `797 + t * (32 ±0)` // Estimated: `21840 + t * (2640 ±0)` - // Minimum execution time: 248_294_000 picoseconds. - Weight::from_parts(239_709_759, 21840) - // Standard Error: 66_903 - .saturating_add(Weight::from_parts(2_880_732, 0).saturating_mul(t.into())) - // Standard Error: 18 - .saturating_add(Weight::from_parts(725, 0).saturating_mul(n.into())) + // Minimum execution time: 300_675_000 picoseconds. + Weight::from_parts(296_092_420, 21840) + // Standard Error: 130_733 + .saturating_add(Weight::from_parts(2_487_957, 0).saturating_mul(t.into())) + // Standard Error: 36 + .saturating_add(Weight::from_parts(565, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -923,10 +923,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `777 + r * (7 ±0)` // Estimated: `21725 + r * (35 ±0)` - // Minimum execution time: 170_601_000 picoseconds. - Weight::from_parts(165_819_714, 21725) - // Standard Error: 452 - .saturating_add(Weight::from_parts(240_362, 0).saturating_mul(r.into())) + // Minimum execution time: 166_638_000 picoseconds. + Weight::from_parts(171_353_083, 21725) + // Standard Error: 550 + .saturating_add(Weight::from_parts(238_768, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 35).saturating_mul(r.into())) @@ -946,10 +946,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `125728` // Estimated: `269977` - // Minimum execution time: 349_543_000 picoseconds. - Weight::from_parts(352_945_102, 269977) - // Standard Error: 2 - .saturating_add(Weight::from_parts(749, 0).saturating_mul(i.into())) + // Minimum execution time: 414_136_000 picoseconds. + Weight::from_parts(416_093_921, 269977) + // Standard Error: 3 + .saturating_add(Weight::from_parts(794, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -960,10 +960,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `845 + r * (292 ±0)` // Estimated: `843 + r * (293 ±0)` - // Minimum execution time: 238_766_000 picoseconds. - Weight::from_parts(130_994_282, 843) - // Standard Error: 10_413 - .saturating_add(Weight::from_parts(6_134_087, 0).saturating_mul(r.into())) + // Minimum execution time: 285_920_000 picoseconds. + Weight::from_parts(184_945_789, 843) + // Standard Error: 9_604 + .saturating_add(Weight::from_parts(6_012_522, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -977,10 +977,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1304` // Estimated: `1280` - // Minimum execution time: 248_137_000 picoseconds. - Weight::from_parts(265_535_917, 1280) - // Standard Error: 28 - .saturating_add(Weight::from_parts(387, 0).saturating_mul(n.into())) + // Minimum execution time: 299_772_000 picoseconds. + Weight::from_parts(333_451_106, 1280) + // Standard Error: 54 + .saturating_add(Weight::from_parts(579, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -991,10 +991,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1167 + n * (1 ±0)` // Estimated: `1167 + n * (1 ±0)` - // Minimum execution time: 246_752_000 picoseconds. - Weight::from_parts(250_315_210, 1167) - // Standard Error: 42 - .saturating_add(Weight::from_parts(135, 0).saturating_mul(n.into())) + // Minimum execution time: 299_279_000 picoseconds. + Weight::from_parts(302_336_567, 1167) + // Standard Error: 25 + .saturating_add(Weight::from_parts(86, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1006,10 +1006,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `841 + r * (288 ±0)` // Estimated: `845 + r * (289 ±0)` - // Minimum execution time: 232_873_000 picoseconds. - Weight::from_parts(130_360_558, 845) - // Standard Error: 10_026 - .saturating_add(Weight::from_parts(6_023_862, 0).saturating_mul(r.into())) + // Minimum execution time: 284_689_000 picoseconds. + Weight::from_parts(185_207_302, 845) + // Standard Error: 10_030 + .saturating_add(Weight::from_parts(5_871_325, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1023,10 +1023,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1163 + n * (1 ±0)` // Estimated: `1163 + n * (1 ±0)` - // Minimum execution time: 247_079_000 picoseconds. - Weight::from_parts(248_922_003, 1163) - // Standard Error: 22 - .saturating_add(Weight::from_parts(201, 0).saturating_mul(n.into())) + // Minimum execution time: 299_364_000 picoseconds. + Weight::from_parts(302_089_070, 1163) + // Standard Error: 23 + .saturating_add(Weight::from_parts(128, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1038,10 +1038,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `835 + r * (296 ±0)` // Estimated: `840 + r * (297 ±0)` - // Minimum execution time: 232_696_000 picoseconds. - Weight::from_parts(144_147_151, 840) - // Standard Error: 8_846 - .saturating_add(Weight::from_parts(4_931_414, 0).saturating_mul(r.into())) + // Minimum execution time: 285_175_000 picoseconds. + Weight::from_parts(200_262_957, 840) + // Standard Error: 8_681 + .saturating_add(Weight::from_parts(4_899_266, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1054,10 +1054,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1179 + n * (1 ±0)` // Estimated: `1179 + n * (1 ±0)` - // Minimum execution time: 247_795_000 picoseconds. - Weight::from_parts(252_944_118, 1179) - // Standard Error: 45 - .saturating_add(Weight::from_parts(480, 0).saturating_mul(n.into())) + // Minimum execution time: 299_459_000 picoseconds. + Weight::from_parts(302_451_160, 1179) + // Standard Error: 36 + .saturating_add(Weight::from_parts(731, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1069,10 +1069,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `856 + r * (288 ±0)` // Estimated: `857 + r * (289 ±0)` - // Minimum execution time: 232_166_000 picoseconds. - Weight::from_parts(148_503_428, 857) - // Standard Error: 8_704 - .saturating_add(Weight::from_parts(4_766_055, 0).saturating_mul(r.into())) + // Minimum execution time: 286_384_000 picoseconds. + Weight::from_parts(203_389_467, 857) + // Standard Error: 8_817 + .saturating_add(Weight::from_parts(4_692_347, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1085,10 +1085,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1166 + n * (1 ±0)` // Estimated: `1166 + n * (1 ±0)` - // Minimum execution time: 246_128_000 picoseconds. - Weight::from_parts(248_323_705, 1166) - // Standard Error: 21 - .saturating_add(Weight::from_parts(92, 0).saturating_mul(n.into())) + // Minimum execution time: 297_450_000 picoseconds. + Weight::from_parts(300_459_851, 1166) + // Standard Error: 39 + .saturating_add(Weight::from_parts(108, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1100,10 +1100,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `829 + r * (296 ±0)` // Estimated: `836 + r * (297 ±0)` - // Minimum execution time: 232_976_000 picoseconds. - Weight::from_parts(132_373_848, 836) - // Standard Error: 9_855 - .saturating_add(Weight::from_parts(6_181_821, 0).saturating_mul(r.into())) + // Minimum execution time: 285_572_000 picoseconds. + Weight::from_parts(182_642_557, 836) + // Standard Error: 9_977 + .saturating_add(Weight::from_parts(6_090_684, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1117,10 +1117,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1180 + n * (1 ±0)` // Estimated: `1180 + n * (1 ±0)` - // Minimum execution time: 247_907_000 picoseconds. - Weight::from_parts(251_984_133, 1180) - // Standard Error: 41 - .saturating_add(Weight::from_parts(639, 0).saturating_mul(n.into())) + // Minimum execution time: 301_344_000 picoseconds. + Weight::from_parts(303_770_522, 1180) + // Standard Error: 29 + .saturating_add(Weight::from_parts(807, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1140,10 +1140,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1373 + r * (45 ±0)` // Estimated: `26753 + r * (2700 ±0)` - // Minimum execution time: 232_614_000 picoseconds. - Weight::from_parts(127_024_367, 26753) - // Standard Error: 54_521 - .saturating_add(Weight::from_parts(20_975_575, 0).saturating_mul(r.into())) + // Minimum execution time: 286_835_000 picoseconds. + Weight::from_parts(245_206_457, 26753) + // Standard Error: 73_782 + .saturating_add(Weight::from_parts(36_414_448, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) @@ -1152,53 +1152,53 @@ impl WeightInfo for SubstrateWeight { } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1601 w:1601) + /// Storage: Contracts ContractInfoOf (r:801 w:801) /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) /// Storage: Contracts CodeStorage (r:2 w:0) /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:1602 w:1602) + /// Storage: System EventTopics (r:802 w:802) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1600]`. + /// The range of component `r` is `[0, 800]`. fn seal_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1512 + r * (256 ±0)` - // Estimated: `27163 + r * (6231 ±0)` - // Minimum execution time: 233_446_000 picoseconds. - Weight::from_parts(234_338_000, 27163) - // Standard Error: 122_754 - .saturating_add(Weight::from_parts(216_709_600, 0).saturating_mul(r.into())) + // Measured: `1237 + r * (256 ±0)` + // Estimated: `26028 + r * (6235 ±0)` + // Minimum execution time: 287_184_000 picoseconds. + Weight::from_parts(287_525_000, 26028) + // Standard Error: 66_791 + .saturating_add(Weight::from_parts(261_473_539, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 6231).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 6235).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) /// Storage: Contracts ContractInfoOf (r:1 w:1) /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts CodeStorage (r:1536 w:0) + /// Storage: Contracts CodeStorage (r:736 w:0) /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:1537 w:1537) + /// Storage: System EventTopics (r:737 w:737) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1600]`. + /// The range of component `r` is `[0, 800]`. fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (902 ±0)` - // Estimated: `21755 + r * (8167 ±7)` - // Minimum execution time: 232_717_000 picoseconds. - Weight::from_parts(233_405_000, 21755) - // Standard Error: 98_607 - .saturating_add(Weight::from_parts(212_329_100, 0).saturating_mul(r.into())) + // Measured: `0 + r * (502 ±0)` + // Estimated: `21755 + r * (6329 ±10)` + // Minimum execution time: 285_759_000 picoseconds. + Weight::from_parts(286_643_000, 21755) + // Standard Error: 133_180 + .saturating_add(Weight::from_parts(257_186_897, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 8167).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 6329).saturating_mul(r.into())) } /// Storage: System Account (r:3 w:2) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1216,46 +1216,46 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1154 + t * (204 ±0)` // Estimated: `31015 + t * (5970 ±0)` - // Minimum execution time: 392_113_000 picoseconds. - Weight::from_parts(376_522_702, 31015) - // Standard Error: 1_388_011 - .saturating_add(Weight::from_parts(19_125_093, 0).saturating_mul(t.into())) - // Standard Error: 2 - .saturating_add(Weight::from_parts(609, 0).saturating_mul(c.into())) + // Minimum execution time: 459_675_000 picoseconds. + Weight::from_parts(427_010_987, 31015) + // Standard Error: 1_277_377 + .saturating_add(Weight::from_parts(36_899_889, 0).saturating_mul(t.into())) + // Standard Error: 1 + .saturating_add(Weight::from_parts(651, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(5_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(t.into()))) .saturating_add(Weight::from_parts(0, 5970).saturating_mul(t.into())) } - /// Storage: System Account (r:3202 w:3202) + /// Storage: System Account (r:1602 w:1602) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1601 w:1601) + /// Storage: Contracts ContractInfoOf (r:801 w:801) /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts CodeStorage (r:1601 w:0) + /// Storage: Contracts CodeStorage (r:801 w:0) /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: Contracts Nonce (r:1 w:1) /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: Contracts OwnerInfoOf (r:1600 w:1600) + /// Storage: Contracts OwnerInfoOf (r:800 w:800) /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) - /// Storage: System EventTopics (r:1602 w:1602) + /// Storage: System EventTopics (r:802 w:802) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1600]`. + /// The range of component `r` is `[0, 800]`. fn seal_instantiate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1859 + r * (253 ±0)` - // Estimated: `33859 + r * (16628 ±0)` - // Minimum execution time: 234_438_000 picoseconds. - Weight::from_parts(234_751_000, 33859) - // Standard Error: 450_507 - .saturating_add(Weight::from_parts(313_121_404, 0).saturating_mul(r.into())) + // Measured: `1301 + r * (254 ±0)` + // Estimated: `30977 + r * (16635 ±0)` + // Minimum execution time: 285_816_000 picoseconds. + Weight::from_parts(286_349_000, 30977) + // Standard Error: 269_144 + .saturating_add(Weight::from_parts(394_282_520, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) .saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 16628).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 16635).saturating_mul(r.into())) } /// Storage: System Account (r:4 w:4) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1278,14 +1278,14 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1071 + t * (187 ±0)` // Estimated: `42684 + t * (3588 ±2)` - // Minimum execution time: 1_570_178_000 picoseconds. - Weight::from_parts(284_062_841, 42684) - // Standard Error: 4_396_597 - .saturating_add(Weight::from_parts(106_424_960, 0).saturating_mul(t.into())) + // Minimum execution time: 1_708_330_000 picoseconds. + Weight::from_parts(395_059_764, 42684) + // Standard Error: 4_545_552 + .saturating_add(Weight::from_parts(114_039_862, 0).saturating_mul(t.into())) // Standard Error: 7 - .saturating_add(Weight::from_parts(1_183, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_213, 0).saturating_mul(i.into())) // Standard Error: 7 - .saturating_add(Weight::from_parts(1_354, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_379, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(10_u64)) @@ -1307,10 +1307,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `777 + r * (8 ±0)` // Estimated: `21710 + r * (40 ±0)` - // Minimum execution time: 230_557_000 picoseconds. - Weight::from_parts(233_276_698, 21710) - // Standard Error: 1_026 - .saturating_add(Weight::from_parts(587_723, 0).saturating_mul(r.into())) + // Minimum execution time: 283_738_000 picoseconds. + Weight::from_parts(289_885_978, 21710) + // Standard Error: 1_057 + .saturating_add(Weight::from_parts(575_432, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1330,10 +1330,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `785` // Estimated: `21745` - // Minimum execution time: 234_151_000 picoseconds. - Weight::from_parts(240_199_365, 21745) - // Standard Error: 3 - .saturating_add(Weight::from_parts(3_941, 0).saturating_mul(n.into())) + // Minimum execution time: 285_070_000 picoseconds. + Weight::from_parts(283_987_687, 21745) + // Standard Error: 6 + .saturating_add(Weight::from_parts(4_008, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1352,10 +1352,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `779 + r * (8 ±0)` // Estimated: `21725 + r * (40 ±0)` - // Minimum execution time: 229_931_000 picoseconds. - Weight::from_parts(234_961_690, 21725) - // Standard Error: 1_073 - .saturating_add(Weight::from_parts(758_259, 0).saturating_mul(r.into())) + // Minimum execution time: 281_613_000 picoseconds. + Weight::from_parts(285_429_053, 21725) + // Standard Error: 1_164 + .saturating_add(Weight::from_parts(756_244, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1375,10 +1375,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `787` // Estimated: `21765` - // Minimum execution time: 232_448_000 picoseconds. - Weight::from_parts(225_974_008, 21765) + // Minimum execution time: 284_593_000 picoseconds. + Weight::from_parts(278_467_111, 21765) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_174, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(3_217, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1397,10 +1397,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `779 + r * (8 ±0)` // Estimated: `21740 + r * (40 ±0)` - // Minimum execution time: 229_251_000 picoseconds. - Weight::from_parts(234_182_627, 21740) - // Standard Error: 836 - .saturating_add(Weight::from_parts(424_375, 0).saturating_mul(r.into())) + // Minimum execution time: 281_759_000 picoseconds. + Weight::from_parts(288_807_137, 21740) + // Standard Error: 805 + .saturating_add(Weight::from_parts(424_378, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1420,10 +1420,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `787` // Estimated: `21785` - // Minimum execution time: 230_896_000 picoseconds. - Weight::from_parts(224_913_556, 21785) + // Minimum execution time: 282_666_000 picoseconds. + Weight::from_parts(274_357_944, 21785) // Standard Error: 2 - .saturating_add(Weight::from_parts(919, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(974, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1442,10 +1442,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `779 + r * (8 ±0)` // Estimated: `21745 + r * (40 ±0)` - // Minimum execution time: 230_314_000 picoseconds. - Weight::from_parts(233_426_327, 21745) - // Standard Error: 926 - .saturating_add(Weight::from_parts(425_341, 0).saturating_mul(r.into())) + // Minimum execution time: 285_073_000 picoseconds. + Weight::from_parts(287_226_796, 21745) + // Standard Error: 951 + .saturating_add(Weight::from_parts(425_368, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1465,10 +1465,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `787` // Estimated: `21755` - // Minimum execution time: 230_424_000 picoseconds. - Weight::from_parts(231_136_218, 21755) + // Minimum execution time: 283_407_000 picoseconds. + Weight::from_parts(276_737_242, 21755) // Standard Error: 2 - .saturating_add(Weight::from_parts(917, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(967, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1482,18 +1482,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1600]`. + /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `704 + r * (78 ±0)` - // Estimated: `21370 + r * (390 ±0)` - // Minimum execution time: 232_862_000 picoseconds. - Weight::from_parts(379_152_870, 21370) - // Standard Error: 11_607 - .saturating_add(Weight::from_parts(36_955_410, 0).saturating_mul(r.into())) + // Measured: `822 + r * (76 ±0)` + // Estimated: `21705 + r * (385 ±0)` + // Minimum execution time: 285_130_000 picoseconds. + Weight::from_parts(299_449_202, 21705) + // Standard Error: 16_535 + .saturating_add(Weight::from_parts(37_655_189, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 390).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 385).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1505,18 +1505,18 @@ impl WeightInfo for SubstrateWeight { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1600]`. + /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `549 + r * (44 ±0)` - // Estimated: `20630 + r * (220 ±0)` - // Minimum execution time: 232_668_000 picoseconds. - Weight::from_parts(253_308_468, 20630) - // Standard Error: 3_022 - .saturating_add(Weight::from_parts(9_249_849, 0).saturating_mul(r.into())) + // Measured: `792 + r * (42 ±0)` + // Estimated: `21780 + r * (210 ±0)` + // Minimum execution time: 284_494_000 picoseconds. + Weight::from_parts(282_154_339, 21780) + // Standard Error: 12_278 + .saturating_add(Weight::from_parts(9_501_559, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 220).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 210).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -1535,10 +1535,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0 + r * (964 ±0)` // Estimated: `29920 + r * (11544 ±7)` - // Minimum execution time: 233_910_000 picoseconds. - Weight::from_parts(234_607_000, 29920) - // Standard Error: 46_118 - .saturating_add(Weight::from_parts(21_927_957, 0).saturating_mul(r.into())) + // Minimum execution time: 285_306_000 picoseconds. + Weight::from_parts(286_080_000, 29920) + // Standard Error: 43_813 + .saturating_add(Weight::from_parts(21_758_329, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1560,10 +1560,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `773 + r * (3 ±0)` // Estimated: `21735 + r * (15 ±0)` - // Minimum execution time: 231_823_000 picoseconds. - Weight::from_parts(237_996_137, 21735) - // Standard Error: 598 - .saturating_add(Weight::from_parts(163_106, 0).saturating_mul(r.into())) + // Minimum execution time: 283_487_000 picoseconds. + Weight::from_parts(289_280_189, 21735) + // Standard Error: 829 + .saturating_add(Weight::from_parts(168_973, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) @@ -1583,10 +1583,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1975 + r * (39 ±0)` // Estimated: `27145 + r * (200 ±0)` - // Minimum execution time: 235_077_000 picoseconds. - Weight::from_parts(267_876_360, 27145) - // Standard Error: 1_147 - .saturating_add(Weight::from_parts(256_275, 0).saturating_mul(r.into())) + // Minimum execution time: 287_413_000 picoseconds. + Weight::from_parts(314_662_286, 27145) + // Standard Error: 1_099 + .saturating_add(Weight::from_parts(262_201, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 200).saturating_mul(r.into())) @@ -1608,10 +1608,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `776 + r * (3 ±0)` // Estimated: `24004 + r * (18 ±0)` - // Minimum execution time: 231_384_000 picoseconds. - Weight::from_parts(237_086_900, 24004) - // Standard Error: 534 - .saturating_add(Weight::from_parts(140_842, 0).saturating_mul(r.into())) + // Minimum execution time: 282_601_000 picoseconds. + Weight::from_parts(289_374_203, 24004) + // Standard Error: 452 + .saturating_add(Weight::from_parts(142_661, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 18).saturating_mul(r.into())) @@ -1621,510 +1621,508 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_721_000 picoseconds. - Weight::from_parts(2_456_746, 0) - // Standard Error: 30 - .saturating_add(Weight::from_parts(2_788, 0).saturating_mul(r.into())) + // Minimum execution time: 1_692_000 picoseconds. + Weight::from_parts(2_069_482, 0) + // Standard Error: 40 + .saturating_add(Weight::from_parts(2_922, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64load(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_824_000 picoseconds. - Weight::from_parts(2_366_036, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(6_446, 0).saturating_mul(r.into())) + // Minimum execution time: 1_690_000 picoseconds. + Weight::from_parts(2_303_602, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(6_433, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64store(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_840_000 picoseconds. - Weight::from_parts(2_332_115, 0) + // Minimum execution time: 1_701_000 picoseconds. + Weight::from_parts(2_321_142, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(6_012, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(6_025, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_select(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_731_000 picoseconds. - Weight::from_parts(2_078_873, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(7_931, 0).saturating_mul(r.into())) + // Minimum execution time: 1_656_000 picoseconds. + Weight::from_parts(2_090_881, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(7_941, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_768_000 picoseconds. - Weight::from_parts(1_916_551, 0) - // Standard Error: 8 - .saturating_add(Weight::from_parts(10_597, 0).saturating_mul(r.into())) + // Minimum execution time: 1_659_000 picoseconds. + Weight::from_parts(1_816_547, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(10_578, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_735_000 picoseconds. - Weight::from_parts(1_962_845, 0) - // Standard Error: 14 - .saturating_add(Weight::from_parts(4_631, 0).saturating_mul(r.into())) + // Minimum execution time: 1_683_000 picoseconds. + Weight::from_parts(1_970_907, 0) + // Standard Error: 12 + .saturating_add(Weight::from_parts(4_636, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_688_000 picoseconds. - Weight::from_parts(1_172_825, 0) - // Standard Error: 76 - .saturating_add(Weight::from_parts(8_007, 0).saturating_mul(r.into())) + // Minimum execution time: 1_651_000 picoseconds. + Weight::from_parts(2_263_817, 0) + // Standard Error: 68 + .saturating_add(Weight::from_parts(7_529, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br_table(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_725_000 picoseconds. - Weight::from_parts(1_535_833, 0) - // Standard Error: 26 - .saturating_add(Weight::from_parts(9_489, 0).saturating_mul(r.into())) + // Minimum execution time: 1_687_000 picoseconds. + Weight::from_parts(1_349_186, 0) + // Standard Error: 31 + .saturating_add(Weight::from_parts(9_732, 0).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. - fn instr_br_table_per_entry(e: u32, ) -> Weight { + fn instr_br_table_per_entry(_e: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_814_000 picoseconds. - Weight::from_parts(1_926_367, 0) - // Standard Error: 16 - .saturating_add(Weight::from_parts(219, 0).saturating_mul(e.into())) + // Minimum execution time: 1_777_000 picoseconds. + Weight::from_parts(2_036_446, 0) } /// The range of component `r` is `[0, 5000]`. fn instr_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_770_000 picoseconds. - Weight::from_parts(2_436_918, 0) - // Standard Error: 8 - .saturating_add(Weight::from_parts(17_890, 0).saturating_mul(r.into())) + // Minimum execution time: 1_686_000 picoseconds. + Weight::from_parts(464_449, 0) + // Standard Error: 383 + .saturating_add(Weight::from_parts(19_121, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_call_indirect(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_920_000 picoseconds. - Weight::from_parts(2_729_712, 0) - // Standard Error: 39 - .saturating_add(Weight::from_parts(24_853, 0).saturating_mul(r.into())) + // Minimum execution time: 1_855_000 picoseconds. + Weight::from_parts(3_381_585, 0) + // Standard Error: 18 + .saturating_add(Weight::from_parts(24_245, 0).saturating_mul(r.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_869_000 picoseconds. - Weight::from_parts(2_147_970, 0) - // Standard Error: 46 - .saturating_add(Weight::from_parts(1_237, 0).saturating_mul(l.into())) + // Minimum execution time: 1_792_000 picoseconds. + Weight::from_parts(2_006_024, 0) + // Standard Error: 16 + .saturating_add(Weight::from_parts(2_181, 0).saturating_mul(l.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_012_000 picoseconds. - Weight::from_parts(3_234_440, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(2_433, 0).saturating_mul(r.into())) + // Minimum execution time: 3_918_000 picoseconds. + Weight::from_parts(4_618_761, 0) + // Standard Error: 49 + .saturating_add(Weight::from_parts(2_312, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_037_000 picoseconds. - Weight::from_parts(3_204_600, 0) + // Minimum execution time: 3_889_000 picoseconds. + Weight::from_parts(4_151_280, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_627, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_623, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_tee(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_974_000 picoseconds. - Weight::from_parts(3_301_366, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(3_836, 0).saturating_mul(r.into())) + // Minimum execution time: 3_880_000 picoseconds. + Weight::from_parts(4_225_780, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(3_847, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_global_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_853_000 picoseconds. - Weight::from_parts(2_310_141, 0) + // Minimum execution time: 1_765_000 picoseconds. + Weight::from_parts(2_216_674, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(8_387, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(8_393, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_global_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_828_000 picoseconds. - Weight::from_parts(2_315_323, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(8_797, 0).saturating_mul(r.into())) + // Minimum execution time: 1_764_000 picoseconds. + Weight::from_parts(2_246_735, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(8_877, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_memory_current(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_800_000 picoseconds. - Weight::from_parts(2_117_252, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(3_741, 0).saturating_mul(r.into())) + // Minimum execution time: 1_758_000 picoseconds. + Weight::from_parts(1_922_386, 0) + // Standard Error: 94 + .saturating_add(Weight::from_parts(3_868, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 16]`. fn instr_memory_grow(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_743_000 picoseconds. - Weight::from_parts(1_054_728, 0) - // Standard Error: 137_128 - .saturating_add(Weight::from_parts(13_179_446, 0).saturating_mul(r.into())) + // Minimum execution time: 1_635_000 picoseconds. + Weight::from_parts(1_118_785, 0) + // Standard Error: 134_978 + .saturating_add(Weight::from_parts(16_343_664, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64clz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_735_000 picoseconds. - Weight::from_parts(2_026_568, 0) + // Minimum execution time: 1_648_000 picoseconds. + Weight::from_parts(2_012_545, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_802, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_824, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ctz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_630_000 picoseconds. - Weight::from_parts(1_980_222, 0) + // Minimum execution time: 1_688_000 picoseconds. + Weight::from_parts(1_995_956, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_735, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_757, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64popcnt(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_695_000 picoseconds. - Weight::from_parts(2_040_266, 0) - // Standard Error: 8 - .saturating_add(Weight::from_parts(3_718, 0).saturating_mul(r.into())) + // Minimum execution time: 1_631_000 picoseconds. + Weight::from_parts(2_011_493, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(3_755, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64eqz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_697_000 picoseconds. - Weight::from_parts(2_004_663, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(3_661, 0).saturating_mul(r.into())) + // Minimum execution time: 1_667_000 picoseconds. + Weight::from_parts(1_958_798, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_677, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64extendsi32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_705_000 picoseconds. - Weight::from_parts(2_682_122, 0) - // Standard Error: 98 - .saturating_add(Weight::from_parts(3_705, 0).saturating_mul(r.into())) + // Minimum execution time: 1_674_000 picoseconds. + Weight::from_parts(2_009_555, 0) + // Standard Error: 7 + .saturating_add(Weight::from_parts(3_863, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64extendui32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_674_000 picoseconds. - Weight::from_parts(1_989_835, 0) + // Minimum execution time: 1_659_000 picoseconds. + Weight::from_parts(2_014_985, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_801, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_821, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i32wrapi64(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_695_000 picoseconds. - Weight::from_parts(2_083_824, 0) - // Standard Error: 17 - .saturating_add(Weight::from_parts(3_719, 0).saturating_mul(r.into())) + // Minimum execution time: 1_640_000 picoseconds. + Weight::from_parts(2_013_939, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_708, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64eq(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_678_000 picoseconds. - Weight::from_parts(1_996_335, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(5_995, 0).saturating_mul(r.into())) + // Minimum execution time: 1_631_000 picoseconds. + Weight::from_parts(2_002_814, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_008, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ne(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_697_000 picoseconds. - Weight::from_parts(2_046_566, 0) + // Minimum execution time: 1_647_000 picoseconds. + Weight::from_parts(2_032_158, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(5_936, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_944, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64lts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_721_000 picoseconds. - Weight::from_parts(2_406_930, 0) - // Standard Error: 150 - .saturating_add(Weight::from_parts(5_992, 0).saturating_mul(r.into())) + // Minimum execution time: 1_669_000 picoseconds. + Weight::from_parts(2_040_386, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(6_009, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ltu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_749_000 picoseconds. - Weight::from_parts(1_987_158, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_994, 0).saturating_mul(r.into())) + // Minimum execution time: 1_637_000 picoseconds. + Weight::from_parts(1_983_695, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(6_027, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64gts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_706_000 picoseconds. - Weight::from_parts(2_038_138, 0) + // Minimum execution time: 1_701_000 picoseconds. + Weight::from_parts(2_054_295, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(5_802, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_799, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64gtu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_670_000 picoseconds. - Weight::from_parts(2_555_035, 0) - // Standard Error: 74 - .saturating_add(Weight::from_parts(5_958, 0).saturating_mul(r.into())) + // Minimum execution time: 1_653_000 picoseconds. + Weight::from_parts(2_749_807, 0) + // Standard Error: 90 + .saturating_add(Weight::from_parts(5_945, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64les(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_694_000 picoseconds. - Weight::from_parts(1_991_929, 0) - // Standard Error: 27 - .saturating_add(Weight::from_parts(6_037, 0).saturating_mul(r.into())) + // Minimum execution time: 1_651_000 picoseconds. + Weight::from_parts(1_979_111, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(6_011, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64leu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_684_000 picoseconds. - Weight::from_parts(1_969_284, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_104, 0).saturating_mul(r.into())) + // Minimum execution time: 1_743_000 picoseconds. + Weight::from_parts(2_058_081, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(6_085, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ges(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_697_000 picoseconds. - Weight::from_parts(2_023_608, 0) + // Minimum execution time: 1_638_000 picoseconds. + Weight::from_parts(2_038_929, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(5_946, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_941, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64geu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_659_000 picoseconds. - Weight::from_parts(1_963_145, 0) - // Standard Error: 6 - .saturating_add(Weight::from_parts(6_014, 0).saturating_mul(r.into())) + // Minimum execution time: 1_641_000 picoseconds. + Weight::from_parts(2_036_587, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_008, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64add(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_722_000 picoseconds. - Weight::from_parts(2_016_286, 0) + // Minimum execution time: 1_624_000 picoseconds. + Weight::from_parts(2_080_562, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(5_889, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_826, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64sub(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_656_000 picoseconds. - Weight::from_parts(1_966_234, 0) - // Standard Error: 17 - .saturating_add(Weight::from_parts(6_171, 0).saturating_mul(r.into())) + // Minimum execution time: 1_652_000 picoseconds. + Weight::from_parts(2_039_535, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_137, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64mul(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_695_000 picoseconds. - Weight::from_parts(2_004_559, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_785, 0).saturating_mul(r.into())) + // Minimum execution time: 1_666_000 picoseconds. + Weight::from_parts(2_056_354, 0) + // Standard Error: 6 + .saturating_add(Weight::from_parts(5_780, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64divs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_681_000 picoseconds. - Weight::from_parts(2_135_505, 0) - // Standard Error: 6 - .saturating_add(Weight::from_parts(11_761, 0).saturating_mul(r.into())) + // Minimum execution time: 1_648_000 picoseconds. + Weight::from_parts(2_077_695, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(11_775, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64divu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_653_000 picoseconds. - Weight::from_parts(2_153_167, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(10_523, 0).saturating_mul(r.into())) + // Minimum execution time: 1_797_000 picoseconds. + Weight::from_parts(2_772_388, 0) + // Standard Error: 33 + .saturating_add(Weight::from_parts(10_333, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rems(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_697_000 picoseconds. - Weight::from_parts(2_570_266, 0) - // Standard Error: 50 - .saturating_add(Weight::from_parts(11_971, 0).saturating_mul(r.into())) + // Minimum execution time: 1_699_000 picoseconds. + Weight::from_parts(2_174_288, 0) + // Standard Error: 6 + .saturating_add(Weight::from_parts(11_778, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64remu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_719_000 picoseconds. - Weight::from_parts(2_101_082, 0) + // Minimum execution time: 1_685_000 picoseconds. + Weight::from_parts(2_091_037, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(10_709, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(10_694, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64and(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_745_000 picoseconds. - Weight::from_parts(2_621_890, 0) - // Standard Error: 94 - .saturating_add(Weight::from_parts(5_545, 0).saturating_mul(r.into())) + // Minimum execution time: 1_636_000 picoseconds. + Weight::from_parts(1_975_521, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_695, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64or(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_670_000 picoseconds. - Weight::from_parts(2_046_821, 0) + // Minimum execution time: 1_619_000 picoseconds. + Weight::from_parts(2_045_492, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(5_762, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_770, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64xor(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_714_000 picoseconds. - Weight::from_parts(2_010_173, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_911, 0).saturating_mul(r.into())) + // Minimum execution time: 1_668_000 picoseconds. + Weight::from_parts(2_055_460, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(5_851, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_756_000 picoseconds. - Weight::from_parts(2_044_772, 0) + // Minimum execution time: 1_681_000 picoseconds. + Weight::from_parts(2_023_370, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(5_857, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_853, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shrs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_741_000 picoseconds. - Weight::from_parts(2_012_819, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_127, 0).saturating_mul(r.into())) + // Minimum execution time: 1_714_000 picoseconds. + Weight::from_parts(2_067_584, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(6_133, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shru(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_693_000 picoseconds. - Weight::from_parts(2_090_981, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_839, 0).saturating_mul(r.into())) + // Minimum execution time: 1_602_000 picoseconds. + Weight::from_parts(2_055_530, 0) + // Standard Error: 138 + .saturating_add(Weight::from_parts(6_014, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rotl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_704_000 picoseconds. - Weight::from_parts(2_014_108, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(6_005, 0).saturating_mul(r.into())) + // Minimum execution time: 1_709_000 picoseconds. + Weight::from_parts(2_016_365, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_985, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rotr(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_715_000 picoseconds. - Weight::from_parts(2_053_720, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(5_860, 0).saturating_mul(r.into())) + // Minimum execution time: 1_661_000 picoseconds. + Weight::from_parts(2_003_063, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_863, 0).saturating_mul(r.into())) } } @@ -2136,8 +2134,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `109` // Estimated: `1594` - // Minimum execution time: 2_567_000 picoseconds. - Weight::from_parts(2_711_000, 1594) + // Minimum execution time: 2_585_000 picoseconds. + Weight::from_parts(2_802_000, 1594) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Skipped Metadata (r:0 w:0) @@ -2147,10 +2145,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `450 + k * (69 ±0)` // Estimated: `440 + k * (70 ±0)` - // Minimum execution time: 11_048_000 picoseconds. - Weight::from_parts(7_029_322, 440) - // Standard Error: 1_158 - .saturating_add(Weight::from_parts(975_010, 0).saturating_mul(k.into())) + // Minimum execution time: 10_825_000 picoseconds. + Weight::from_parts(5_747_064, 440) + // Standard Error: 1_037 + .saturating_add(Weight::from_parts(973_689, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -2164,10 +2162,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `250 + q * (33 ±0)` // Estimated: `1725 + q * (33 ±0)` - // Minimum execution time: 2_645_000 picoseconds. - Weight::from_parts(10_865_477, 1725) - // Standard Error: 3_383 - .saturating_add(Weight::from_parts(1_295_351, 0).saturating_mul(q.into())) + // Minimum execution time: 2_718_000 picoseconds. + Weight::from_parts(11_436_305, 1725) + // Standard Error: 3_619 + .saturating_add(Weight::from_parts(1_296_955, 0).saturating_mul(q.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 33).saturating_mul(q.into())) @@ -2181,10 +2179,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `238 + c * (1 ±0)` // Estimated: `3951 + c * (2 ±0)` - // Minimum execution time: 30_817_000 picoseconds. - Weight::from_parts(29_762_622, 3951) - // Standard Error: 62 - .saturating_add(Weight::from_parts(54_714, 0).saturating_mul(c.into())) + // Minimum execution time: 37_882_000 picoseconds. + Weight::from_parts(43_548_816, 3951) + // Standard Error: 49 + .saturating_add(Weight::from_parts(53_936, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 2).saturating_mul(c.into())) @@ -2204,10 +2202,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `707` // Estimated: `21400 + c * (5 ±0)` - // Minimum execution time: 245_493_000 picoseconds. - Weight::from_parts(253_703_384, 21400) - // Standard Error: 27 - .saturating_add(Weight::from_parts(38_078, 0).saturating_mul(c.into())) + // Minimum execution time: 313_392_000 picoseconds. + Weight::from_parts(325_419_093, 21400) + // Standard Error: 25 + .saturating_add(Weight::from_parts(37_877, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(c.into())) @@ -2235,14 +2233,14 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `270` // Estimated: `26207` - // Minimum execution time: 3_079_430_000 picoseconds. - Weight::from_parts(555_022_483, 26207) - // Standard Error: 290 - .saturating_add(Weight::from_parts(107_411, 0).saturating_mul(c.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(1_123, 0).saturating_mul(i.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(1_434, 0).saturating_mul(s.into())) + // Minimum execution time: 3_274_352_000 picoseconds. + Weight::from_parts(681_171_416, 26207) + // Standard Error: 336 + .saturating_add(Weight::from_parts(106_391, 0).saturating_mul(c.into())) + // Standard Error: 19 + .saturating_add(Weight::from_parts(1_147, 0).saturating_mul(i.into())) + // Standard Error: 19 + .saturating_add(Weight::from_parts(1_493, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(10_u64)) } @@ -2266,12 +2264,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `482` // Estimated: `28521` - // Minimum execution time: 1_600_733_000 picoseconds. - Weight::from_parts(228_681_962, 28521) + // Minimum execution time: 1_692_637_000 picoseconds. + Weight::from_parts(283_252_265, 28521) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_445, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_498, 0).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_456, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_487, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -2289,8 +2287,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `759` // Estimated: `21615` - // Minimum execution time: 172_310_000 picoseconds. - Weight::from_parts(176_655_000, 21615) + // Minimum execution time: 192_369_000 picoseconds. + Weight::from_parts(193_417_000, 21615) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2307,10 +2305,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `109` // Estimated: `7366` - // Minimum execution time: 246_364_000 picoseconds. - Weight::from_parts(262_887_234, 7366) - // Standard Error: 90 - .saturating_add(Weight::from_parts(107_926, 0).saturating_mul(c.into())) + // Minimum execution time: 301_972_000 picoseconds. + Weight::from_parts(313_248_051, 7366) + // Standard Error: 82 + .saturating_add(Weight::from_parts(107_321, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2326,8 +2324,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `255` // Estimated: `7950` - // Minimum execution time: 29_226_000 picoseconds. - Weight::from_parts(29_542_000, 7950) + // Minimum execution time: 33_013_000 picoseconds. + Weight::from_parts(33_622_000, 7950) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2341,8 +2339,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `570` // Estimated: `19530` - // Minimum execution time: 33_921_000 picoseconds. - Weight::from_parts(35_056_000, 19530) + // Minimum execution time: 33_518_000 picoseconds. + Weight::from_parts(33_819_000, 19530) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -2361,10 +2359,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `781 + r * (6 ±0)` // Estimated: `21730 + r * (30 ±0)` - // Minimum execution time: 232_118_000 picoseconds. - Weight::from_parts(233_883_823, 21730) - // Standard Error: 642 - .saturating_add(Weight::from_parts(340_543, 0).saturating_mul(r.into())) + // Minimum execution time: 283_945_000 picoseconds. + Weight::from_parts(289_209_599, 21730) + // Standard Error: 901 + .saturating_add(Weight::from_parts(327_601, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2384,10 +2382,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `839 + r * (240 ±0)` // Estimated: `21835 + r * (3675 ±0)` - // Minimum execution time: 231_712_000 picoseconds. - Weight::from_parts(74_297_097, 21835) - // Standard Error: 6_099 - .saturating_add(Weight::from_parts(3_322_192, 0).saturating_mul(r.into())) + // Minimum execution time: 284_949_000 picoseconds. + Weight::from_parts(126_196_485, 21835) + // Standard Error: 6_260 + .saturating_add(Weight::from_parts(3_368_849, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2408,10 +2406,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `831 + r * (244 ±0)` // Estimated: `21855 + r * (3695 ±0)` - // Minimum execution time: 233_122_000 picoseconds. - Weight::from_parts(74_369_473, 21855) - // Standard Error: 6_027 - .saturating_add(Weight::from_parts(4_177_187, 0).saturating_mul(r.into())) + // Minimum execution time: 286_429_000 picoseconds. + Weight::from_parts(124_820_396, 21855) + // Standard Error: 6_539 + .saturating_add(Weight::from_parts(4_163_535, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2432,10 +2430,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `788 + r * (6 ±0)` // Estimated: `21770 + r * (30 ±0)` - // Minimum execution time: 232_822_000 picoseconds. - Weight::from_parts(232_507_418, 21770) - // Standard Error: 961 - .saturating_add(Weight::from_parts(419_331, 0).saturating_mul(r.into())) + // Minimum execution time: 285_042_000 picoseconds. + Weight::from_parts(288_096_303, 21770) + // Standard Error: 972 + .saturating_add(Weight::from_parts(409_782, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2455,10 +2453,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `778 + r * (3 ±0)` // Estimated: `21735 + r * (15 ±0)` - // Minimum execution time: 229_719_000 picoseconds. - Weight::from_parts(235_257_789, 21735) - // Standard Error: 451 - .saturating_add(Weight::from_parts(161_101, 0).saturating_mul(r.into())) + // Minimum execution time: 282_820_000 picoseconds. + Weight::from_parts(287_104_710, 21735) + // Standard Error: 421 + .saturating_add(Weight::from_parts(167_907, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) @@ -2478,10 +2476,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `782 + r * (6 ±0)` // Estimated: `21740 + r * (30 ±0)` - // Minimum execution time: 231_517_000 picoseconds. - Weight::from_parts(236_185_452, 21740) - // Standard Error: 651 - .saturating_add(Weight::from_parts(334_659, 0).saturating_mul(r.into())) + // Minimum execution time: 284_619_000 picoseconds. + Weight::from_parts(281_326_785, 21740) + // Standard Error: 1_379 + .saturating_add(Weight::from_parts(342_779, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2501,10 +2499,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `783 + r * (6 ±0)` // Estimated: `21725 + r * (30 ±0)` - // Minimum execution time: 232_855_000 picoseconds. - Weight::from_parts(239_986_328, 21725) - // Standard Error: 4_075 - .saturating_add(Weight::from_parts(345_726, 0).saturating_mul(r.into())) + // Minimum execution time: 284_703_000 picoseconds. + Weight::from_parts(289_479_932, 21725) + // Standard Error: 745 + .saturating_add(Weight::from_parts(323_625, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2524,10 +2522,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `922 + r * (6 ±0)` // Estimated: `24633 + r * (30 ±0)` - // Minimum execution time: 231_685_000 picoseconds. - Weight::from_parts(245_514_261, 24633) - // Standard Error: 1_635 - .saturating_add(Weight::from_parts(1_523_359, 0).saturating_mul(r.into())) + // Minimum execution time: 283_610_000 picoseconds. + Weight::from_parts(299_901_534, 24633) + // Standard Error: 1_177 + .saturating_add(Weight::from_parts(1_474_603, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2547,10 +2545,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `792 + r * (6 ±0)` // Estimated: `21825 + r * (30 ±0)` - // Minimum execution time: 233_361_000 picoseconds. - Weight::from_parts(234_553_471, 21825) - // Standard Error: 1_108 - .saturating_add(Weight::from_parts(330_383, 0).saturating_mul(r.into())) + // Minimum execution time: 284_474_000 picoseconds. + Weight::from_parts(283_540_273, 21825) + // Standard Error: 1_164 + .saturating_add(Weight::from_parts(339_262, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2570,10 +2568,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `790 + r * (6 ±0)` // Estimated: `21815 + r * (30 ±0)` - // Minimum execution time: 231_918_000 picoseconds. - Weight::from_parts(239_128_416, 21815) - // Standard Error: 1_473 - .saturating_add(Weight::from_parts(317_879, 0).saturating_mul(r.into())) + // Minimum execution time: 284_521_000 picoseconds. + Weight::from_parts(285_747_754, 21815) + // Standard Error: 889 + .saturating_add(Weight::from_parts(326_428, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2593,10 +2591,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `787 + r * (6 ±0)` // Estimated: `21805 + r * (30 ±0)` - // Minimum execution time: 231_936_000 picoseconds. - Weight::from_parts(232_240_207, 21805) - // Standard Error: 731 - .saturating_add(Weight::from_parts(330_713, 0).saturating_mul(r.into())) + // Minimum execution time: 284_103_000 picoseconds. + Weight::from_parts(283_801_256, 21805) + // Standard Error: 1_051 + .saturating_add(Weight::from_parts(334_081, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2616,10 +2614,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `778 + r * (6 ±0)` // Estimated: `21735 + r * (30 ±0)` - // Minimum execution time: 231_978_000 picoseconds. - Weight::from_parts(224_881_201, 21735) - // Standard Error: 1_296 - .saturating_add(Weight::from_parts(346_872, 0).saturating_mul(r.into())) + // Minimum execution time: 284_187_000 picoseconds. + Weight::from_parts(289_414_364, 21735) + // Standard Error: 796 + .saturating_add(Weight::from_parts(324_603, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2641,10 +2639,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `856 + r * (10 ±0)` // Estimated: `24446 + r * (60 ±0)` - // Minimum execution time: 231_707_000 picoseconds. - Weight::from_parts(245_939_854, 24446) - // Standard Error: 1_369 - .saturating_add(Weight::from_parts(1_380_453, 0).saturating_mul(r.into())) + // Minimum execution time: 284_953_000 picoseconds. + Weight::from_parts(290_535_752, 24446) + // Standard Error: 2_462 + .saturating_add(Weight::from_parts(1_361_518, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) @@ -2664,10 +2662,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `745 + r * (4 ±0)` // Estimated: `21555 + r * (20 ±0)` - // Minimum execution time: 157_429_000 picoseconds. - Weight::from_parts(161_047_355, 21555) - // Standard Error: 1_220 - .saturating_add(Weight::from_parts(134_497, 0).saturating_mul(r.into())) + // Minimum execution time: 160_775_000 picoseconds. + Weight::from_parts(164_652_364, 21555) + // Standard Error: 284 + .saturating_add(Weight::from_parts(132_574, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 20).saturating_mul(r.into())) @@ -2687,10 +2685,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `780 + r * (6 ±0)` // Estimated: `21740 + r * (30 ±0)` - // Minimum execution time: 232_561_000 picoseconds. - Weight::from_parts(230_989_499, 21740) - // Standard Error: 848 - .saturating_add(Weight::from_parts(282_053, 0).saturating_mul(r.into())) + // Minimum execution time: 284_072_000 picoseconds. + Weight::from_parts(288_418_644, 21740) + // Standard Error: 792 + .saturating_add(Weight::from_parts(272_881, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2710,10 +2708,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `784` // Estimated: `21740` - // Minimum execution time: 237_080_000 picoseconds. - Weight::from_parts(239_380_994, 21740) - // Standard Error: 2 - .saturating_add(Weight::from_parts(592, 0).saturating_mul(n.into())) + // Minimum execution time: 286_671_000 picoseconds. + Weight::from_parts(292_151_662, 21740) + // Standard Error: 1 + .saturating_add(Weight::from_parts(638, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2732,10 +2730,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `768 + r * (45 ±0)` // Estimated: `21660 + r * (225 ±0)` - // Minimum execution time: 228_669_000 picoseconds. - Weight::from_parts(230_916_471, 21660) - // Standard Error: 295_520 - .saturating_add(Weight::from_parts(1_420_928, 0).saturating_mul(r.into())) + // Minimum execution time: 280_334_000 picoseconds. + Weight::from_parts(283_487_571, 21660) + // Standard Error: 267_797 + .saturating_add(Weight::from_parts(3_803_128, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 225).saturating_mul(r.into())) @@ -2755,10 +2753,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `778` // Estimated: `21775` - // Minimum execution time: 231_626_000 picoseconds. - Weight::from_parts(232_097_413, 21775) + // Minimum execution time: 284_004_000 picoseconds. + Weight::from_parts(283_681_350, 21775) // Standard Error: 1 - .saturating_add(Weight::from_parts(185, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(232, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2781,10 +2779,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `810 + r * (356 ±0)` // Estimated: `25511 + r * (15321 ±0)` - // Minimum execution time: 230_758_000 picoseconds. - Weight::from_parts(233_235_993, 25511) - // Standard Error: 196_168 - .saturating_add(Weight::from_parts(81_177_506, 0).saturating_mul(r.into())) + // Minimum execution time: 284_143_000 picoseconds. + Weight::from_parts(287_218_324, 25511) + // Standard Error: 343_611 + .saturating_add(Weight::from_parts(109_895_675, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2808,10 +2806,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `825 + r * (10 ±0)` // Estimated: `24283 + r * (60 ±0)` - // Minimum execution time: 232_457_000 picoseconds. - Weight::from_parts(240_943_161, 24283) - // Standard Error: 3_085 - .saturating_add(Weight::from_parts(1_837_168, 0).saturating_mul(r.into())) + // Minimum execution time: 285_037_000 picoseconds. + Weight::from_parts(299_804_606, 24283) + // Standard Error: 5_518 + .saturating_add(Weight::from_parts(1_848_164, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) @@ -2831,10 +2829,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `778 + r * (10 ±0)` // Estimated: `21735 + r * (50 ±0)` - // Minimum execution time: 229_788_000 picoseconds. - Weight::from_parts(233_520_858, 21735) - // Standard Error: 9_561 - .saturating_add(Weight::from_parts(3_596_294, 0).saturating_mul(r.into())) + // Minimum execution time: 282_886_000 picoseconds. + Weight::from_parts(293_171_736, 21735) + // Standard Error: 2_171 + .saturating_add(Weight::from_parts(3_491_303, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 50).saturating_mul(r.into())) @@ -2855,12 +2853,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `797 + t * (32 ±0)` // Estimated: `21840 + t * (2640 ±0)` - // Minimum execution time: 248_294_000 picoseconds. - Weight::from_parts(239_709_759, 21840) - // Standard Error: 66_903 - .saturating_add(Weight::from_parts(2_880_732, 0).saturating_mul(t.into())) - // Standard Error: 18 - .saturating_add(Weight::from_parts(725, 0).saturating_mul(n.into())) + // Minimum execution time: 300_675_000 picoseconds. + Weight::from_parts(296_092_420, 21840) + // Standard Error: 130_733 + .saturating_add(Weight::from_parts(2_487_957, 0).saturating_mul(t.into())) + // Standard Error: 36 + .saturating_add(Weight::from_parts(565, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2882,10 +2880,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `777 + r * (7 ±0)` // Estimated: `21725 + r * (35 ±0)` - // Minimum execution time: 170_601_000 picoseconds. - Weight::from_parts(165_819_714, 21725) - // Standard Error: 452 - .saturating_add(Weight::from_parts(240_362, 0).saturating_mul(r.into())) + // Minimum execution time: 166_638_000 picoseconds. + Weight::from_parts(171_353_083, 21725) + // Standard Error: 550 + .saturating_add(Weight::from_parts(238_768, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 35).saturating_mul(r.into())) @@ -2905,10 +2903,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `125728` // Estimated: `269977` - // Minimum execution time: 349_543_000 picoseconds. - Weight::from_parts(352_945_102, 269977) - // Standard Error: 2 - .saturating_add(Weight::from_parts(749, 0).saturating_mul(i.into())) + // Minimum execution time: 414_136_000 picoseconds. + Weight::from_parts(416_093_921, 269977) + // Standard Error: 3 + .saturating_add(Weight::from_parts(794, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2919,10 +2917,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `845 + r * (292 ±0)` // Estimated: `843 + r * (293 ±0)` - // Minimum execution time: 238_766_000 picoseconds. - Weight::from_parts(130_994_282, 843) - // Standard Error: 10_413 - .saturating_add(Weight::from_parts(6_134_087, 0).saturating_mul(r.into())) + // Minimum execution time: 285_920_000 picoseconds. + Weight::from_parts(184_945_789, 843) + // Standard Error: 9_604 + .saturating_add(Weight::from_parts(6_012_522, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2936,10 +2934,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1304` // Estimated: `1280` - // Minimum execution time: 248_137_000 picoseconds. - Weight::from_parts(265_535_917, 1280) - // Standard Error: 28 - .saturating_add(Weight::from_parts(387, 0).saturating_mul(n.into())) + // Minimum execution time: 299_772_000 picoseconds. + Weight::from_parts(333_451_106, 1280) + // Standard Error: 54 + .saturating_add(Weight::from_parts(579, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -2950,10 +2948,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1167 + n * (1 ±0)` // Estimated: `1167 + n * (1 ±0)` - // Minimum execution time: 246_752_000 picoseconds. - Weight::from_parts(250_315_210, 1167) - // Standard Error: 42 - .saturating_add(Weight::from_parts(135, 0).saturating_mul(n.into())) + // Minimum execution time: 299_279_000 picoseconds. + Weight::from_parts(302_336_567, 1167) + // Standard Error: 25 + .saturating_add(Weight::from_parts(86, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -2965,10 +2963,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `841 + r * (288 ±0)` // Estimated: `845 + r * (289 ±0)` - // Minimum execution time: 232_873_000 picoseconds. - Weight::from_parts(130_360_558, 845) - // Standard Error: 10_026 - .saturating_add(Weight::from_parts(6_023_862, 0).saturating_mul(r.into())) + // Minimum execution time: 284_689_000 picoseconds. + Weight::from_parts(185_207_302, 845) + // Standard Error: 10_030 + .saturating_add(Weight::from_parts(5_871_325, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2982,10 +2980,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1163 + n * (1 ±0)` // Estimated: `1163 + n * (1 ±0)` - // Minimum execution time: 247_079_000 picoseconds. - Weight::from_parts(248_922_003, 1163) - // Standard Error: 22 - .saturating_add(Weight::from_parts(201, 0).saturating_mul(n.into())) + // Minimum execution time: 299_364_000 picoseconds. + Weight::from_parts(302_089_070, 1163) + // Standard Error: 23 + .saturating_add(Weight::from_parts(128, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -2997,10 +2995,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `835 + r * (296 ±0)` // Estimated: `840 + r * (297 ±0)` - // Minimum execution time: 232_696_000 picoseconds. - Weight::from_parts(144_147_151, 840) - // Standard Error: 8_846 - .saturating_add(Weight::from_parts(4_931_414, 0).saturating_mul(r.into())) + // Minimum execution time: 285_175_000 picoseconds. + Weight::from_parts(200_262_957, 840) + // Standard Error: 8_681 + .saturating_add(Weight::from_parts(4_899_266, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3013,10 +3011,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1179 + n * (1 ±0)` // Estimated: `1179 + n * (1 ±0)` - // Minimum execution time: 247_795_000 picoseconds. - Weight::from_parts(252_944_118, 1179) - // Standard Error: 45 - .saturating_add(Weight::from_parts(480, 0).saturating_mul(n.into())) + // Minimum execution time: 299_459_000 picoseconds. + Weight::from_parts(302_451_160, 1179) + // Standard Error: 36 + .saturating_add(Weight::from_parts(731, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3028,10 +3026,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `856 + r * (288 ±0)` // Estimated: `857 + r * (289 ±0)` - // Minimum execution time: 232_166_000 picoseconds. - Weight::from_parts(148_503_428, 857) - // Standard Error: 8_704 - .saturating_add(Weight::from_parts(4_766_055, 0).saturating_mul(r.into())) + // Minimum execution time: 286_384_000 picoseconds. + Weight::from_parts(203_389_467, 857) + // Standard Error: 8_817 + .saturating_add(Weight::from_parts(4_692_347, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3044,10 +3042,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1166 + n * (1 ±0)` // Estimated: `1166 + n * (1 ±0)` - // Minimum execution time: 246_128_000 picoseconds. - Weight::from_parts(248_323_705, 1166) - // Standard Error: 21 - .saturating_add(Weight::from_parts(92, 0).saturating_mul(n.into())) + // Minimum execution time: 297_450_000 picoseconds. + Weight::from_parts(300_459_851, 1166) + // Standard Error: 39 + .saturating_add(Weight::from_parts(108, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3059,10 +3057,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `829 + r * (296 ±0)` // Estimated: `836 + r * (297 ±0)` - // Minimum execution time: 232_976_000 picoseconds. - Weight::from_parts(132_373_848, 836) - // Standard Error: 9_855 - .saturating_add(Weight::from_parts(6_181_821, 0).saturating_mul(r.into())) + // Minimum execution time: 285_572_000 picoseconds. + Weight::from_parts(182_642_557, 836) + // Standard Error: 9_977 + .saturating_add(Weight::from_parts(6_090_684, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3076,10 +3074,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1180 + n * (1 ±0)` // Estimated: `1180 + n * (1 ±0)` - // Minimum execution time: 247_907_000 picoseconds. - Weight::from_parts(251_984_133, 1180) - // Standard Error: 41 - .saturating_add(Weight::from_parts(639, 0).saturating_mul(n.into())) + // Minimum execution time: 301_344_000 picoseconds. + Weight::from_parts(303_770_522, 1180) + // Standard Error: 29 + .saturating_add(Weight::from_parts(807, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3099,10 +3097,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1373 + r * (45 ±0)` // Estimated: `26753 + r * (2700 ±0)` - // Minimum execution time: 232_614_000 picoseconds. - Weight::from_parts(127_024_367, 26753) - // Standard Error: 54_521 - .saturating_add(Weight::from_parts(20_975_575, 0).saturating_mul(r.into())) + // Minimum execution time: 286_835_000 picoseconds. + Weight::from_parts(245_206_457, 26753) + // Standard Error: 73_782 + .saturating_add(Weight::from_parts(36_414_448, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) @@ -3111,53 +3109,53 @@ impl WeightInfo for () { } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1601 w:1601) + /// Storage: Contracts ContractInfoOf (r:801 w:801) /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) /// Storage: Contracts CodeStorage (r:2 w:0) /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:1602 w:1602) + /// Storage: System EventTopics (r:802 w:802) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1600]`. + /// The range of component `r` is `[0, 800]`. fn seal_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1512 + r * (256 ±0)` - // Estimated: `27163 + r * (6231 ±0)` - // Minimum execution time: 233_446_000 picoseconds. - Weight::from_parts(234_338_000, 27163) - // Standard Error: 122_754 - .saturating_add(Weight::from_parts(216_709_600, 0).saturating_mul(r.into())) + // Measured: `1237 + r * (256 ±0)` + // Estimated: `26028 + r * (6235 ±0)` + // Minimum execution time: 287_184_000 picoseconds. + Weight::from_parts(287_525_000, 26028) + // Standard Error: 66_791 + .saturating_add(Weight::from_parts(261_473_539, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 6231).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 6235).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) /// Storage: Contracts ContractInfoOf (r:1 w:1) /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts CodeStorage (r:1536 w:0) + /// Storage: Contracts CodeStorage (r:736 w:0) /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:1537 w:1537) + /// Storage: System EventTopics (r:737 w:737) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1600]`. + /// The range of component `r` is `[0, 800]`. fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (902 ±0)` - // Estimated: `21755 + r * (8167 ±7)` - // Minimum execution time: 232_717_000 picoseconds. - Weight::from_parts(233_405_000, 21755) - // Standard Error: 98_607 - .saturating_add(Weight::from_parts(212_329_100, 0).saturating_mul(r.into())) + // Measured: `0 + r * (502 ±0)` + // Estimated: `21755 + r * (6329 ±10)` + // Minimum execution time: 285_759_000 picoseconds. + Weight::from_parts(286_643_000, 21755) + // Standard Error: 133_180 + .saturating_add(Weight::from_parts(257_186_897, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 8167).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 6329).saturating_mul(r.into())) } /// Storage: System Account (r:3 w:2) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3175,46 +3173,46 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1154 + t * (204 ±0)` // Estimated: `31015 + t * (5970 ±0)` - // Minimum execution time: 392_113_000 picoseconds. - Weight::from_parts(376_522_702, 31015) - // Standard Error: 1_388_011 - .saturating_add(Weight::from_parts(19_125_093, 0).saturating_mul(t.into())) - // Standard Error: 2 - .saturating_add(Weight::from_parts(609, 0).saturating_mul(c.into())) + // Minimum execution time: 459_675_000 picoseconds. + Weight::from_parts(427_010_987, 31015) + // Standard Error: 1_277_377 + .saturating_add(Weight::from_parts(36_899_889, 0).saturating_mul(t.into())) + // Standard Error: 1 + .saturating_add(Weight::from_parts(651, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(5_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(t.into()))) .saturating_add(Weight::from_parts(0, 5970).saturating_mul(t.into())) } - /// Storage: System Account (r:3202 w:3202) + /// Storage: System Account (r:1602 w:1602) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1601 w:1601) + /// Storage: Contracts ContractInfoOf (r:801 w:801) /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts CodeStorage (r:1601 w:0) + /// Storage: Contracts CodeStorage (r:801 w:0) /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: Contracts Nonce (r:1 w:1) /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: Contracts OwnerInfoOf (r:1600 w:1600) + /// Storage: Contracts OwnerInfoOf (r:800 w:800) /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) - /// Storage: System EventTopics (r:1602 w:1602) + /// Storage: System EventTopics (r:802 w:802) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1600]`. + /// The range of component `r` is `[0, 800]`. fn seal_instantiate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1859 + r * (253 ±0)` - // Estimated: `33859 + r * (16628 ±0)` - // Minimum execution time: 234_438_000 picoseconds. - Weight::from_parts(234_751_000, 33859) - // Standard Error: 450_507 - .saturating_add(Weight::from_parts(313_121_404, 0).saturating_mul(r.into())) + // Measured: `1301 + r * (254 ±0)` + // Estimated: `30977 + r * (16635 ±0)` + // Minimum execution time: 285_816_000 picoseconds. + Weight::from_parts(286_349_000, 30977) + // Standard Error: 269_144 + .saturating_add(Weight::from_parts(394_282_520, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) .saturating_add(RocksDbWeight::get().writes((5_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 16628).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 16635).saturating_mul(r.into())) } /// Storage: System Account (r:4 w:4) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3237,14 +3235,14 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1071 + t * (187 ±0)` // Estimated: `42684 + t * (3588 ±2)` - // Minimum execution time: 1_570_178_000 picoseconds. - Weight::from_parts(284_062_841, 42684) - // Standard Error: 4_396_597 - .saturating_add(Weight::from_parts(106_424_960, 0).saturating_mul(t.into())) + // Minimum execution time: 1_708_330_000 picoseconds. + Weight::from_parts(395_059_764, 42684) + // Standard Error: 4_545_552 + .saturating_add(Weight::from_parts(114_039_862, 0).saturating_mul(t.into())) // Standard Error: 7 - .saturating_add(Weight::from_parts(1_183, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_213, 0).saturating_mul(i.into())) // Standard Error: 7 - .saturating_add(Weight::from_parts(1_354, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_379, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(10_u64)) @@ -3266,10 +3264,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `777 + r * (8 ±0)` // Estimated: `21710 + r * (40 ±0)` - // Minimum execution time: 230_557_000 picoseconds. - Weight::from_parts(233_276_698, 21710) - // Standard Error: 1_026 - .saturating_add(Weight::from_parts(587_723, 0).saturating_mul(r.into())) + // Minimum execution time: 283_738_000 picoseconds. + Weight::from_parts(289_885_978, 21710) + // Standard Error: 1_057 + .saturating_add(Weight::from_parts(575_432, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3289,10 +3287,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `785` // Estimated: `21745` - // Minimum execution time: 234_151_000 picoseconds. - Weight::from_parts(240_199_365, 21745) - // Standard Error: 3 - .saturating_add(Weight::from_parts(3_941, 0).saturating_mul(n.into())) + // Minimum execution time: 285_070_000 picoseconds. + Weight::from_parts(283_987_687, 21745) + // Standard Error: 6 + .saturating_add(Weight::from_parts(4_008, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3311,10 +3309,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `779 + r * (8 ±0)` // Estimated: `21725 + r * (40 ±0)` - // Minimum execution time: 229_931_000 picoseconds. - Weight::from_parts(234_961_690, 21725) - // Standard Error: 1_073 - .saturating_add(Weight::from_parts(758_259, 0).saturating_mul(r.into())) + // Minimum execution time: 281_613_000 picoseconds. + Weight::from_parts(285_429_053, 21725) + // Standard Error: 1_164 + .saturating_add(Weight::from_parts(756_244, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3334,10 +3332,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `787` // Estimated: `21765` - // Minimum execution time: 232_448_000 picoseconds. - Weight::from_parts(225_974_008, 21765) + // Minimum execution time: 284_593_000 picoseconds. + Weight::from_parts(278_467_111, 21765) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_174, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(3_217, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3356,10 +3354,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `779 + r * (8 ±0)` // Estimated: `21740 + r * (40 ±0)` - // Minimum execution time: 229_251_000 picoseconds. - Weight::from_parts(234_182_627, 21740) - // Standard Error: 836 - .saturating_add(Weight::from_parts(424_375, 0).saturating_mul(r.into())) + // Minimum execution time: 281_759_000 picoseconds. + Weight::from_parts(288_807_137, 21740) + // Standard Error: 805 + .saturating_add(Weight::from_parts(424_378, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3379,10 +3377,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `787` // Estimated: `21785` - // Minimum execution time: 230_896_000 picoseconds. - Weight::from_parts(224_913_556, 21785) + // Minimum execution time: 282_666_000 picoseconds. + Weight::from_parts(274_357_944, 21785) // Standard Error: 2 - .saturating_add(Weight::from_parts(919, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(974, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3401,10 +3399,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `779 + r * (8 ±0)` // Estimated: `21745 + r * (40 ±0)` - // Minimum execution time: 230_314_000 picoseconds. - Weight::from_parts(233_426_327, 21745) - // Standard Error: 926 - .saturating_add(Weight::from_parts(425_341, 0).saturating_mul(r.into())) + // Minimum execution time: 285_073_000 picoseconds. + Weight::from_parts(287_226_796, 21745) + // Standard Error: 951 + .saturating_add(Weight::from_parts(425_368, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3424,10 +3422,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `787` // Estimated: `21755` - // Minimum execution time: 230_424_000 picoseconds. - Weight::from_parts(231_136_218, 21755) + // Minimum execution time: 283_407_000 picoseconds. + Weight::from_parts(276_737_242, 21755) // Standard Error: 2 - .saturating_add(Weight::from_parts(917, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(967, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3441,18 +3439,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1600]`. + /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `704 + r * (78 ±0)` - // Estimated: `21370 + r * (390 ±0)` - // Minimum execution time: 232_862_000 picoseconds. - Weight::from_parts(379_152_870, 21370) - // Standard Error: 11_607 - .saturating_add(Weight::from_parts(36_955_410, 0).saturating_mul(r.into())) + // Measured: `822 + r * (76 ±0)` + // Estimated: `21705 + r * (385 ±0)` + // Minimum execution time: 285_130_000 picoseconds. + Weight::from_parts(299_449_202, 21705) + // Standard Error: 16_535 + .saturating_add(Weight::from_parts(37_655_189, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 390).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 385).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3464,18 +3462,18 @@ impl WeightInfo for () { /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: System EventTopics (r:2 w:2) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// The range of component `r` is `[0, 1600]`. + /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `549 + r * (44 ±0)` - // Estimated: `20630 + r * (220 ±0)` - // Minimum execution time: 232_668_000 picoseconds. - Weight::from_parts(253_308_468, 20630) - // Standard Error: 3_022 - .saturating_add(Weight::from_parts(9_249_849, 0).saturating_mul(r.into())) + // Measured: `792 + r * (42 ±0)` + // Estimated: `21780 + r * (210 ±0)` + // Minimum execution time: 284_494_000 picoseconds. + Weight::from_parts(282_154_339, 21780) + // Standard Error: 12_278 + .saturating_add(Weight::from_parts(9_501_559, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 220).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 210).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -3494,10 +3492,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0 + r * (964 ±0)` // Estimated: `29920 + r * (11544 ±7)` - // Minimum execution time: 233_910_000 picoseconds. - Weight::from_parts(234_607_000, 29920) - // Standard Error: 46_118 - .saturating_add(Weight::from_parts(21_927_957, 0).saturating_mul(r.into())) + // Minimum execution time: 285_306_000 picoseconds. + Weight::from_parts(286_080_000, 29920) + // Standard Error: 43_813 + .saturating_add(Weight::from_parts(21_758_329, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3519,10 +3517,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `773 + r * (3 ±0)` // Estimated: `21735 + r * (15 ±0)` - // Minimum execution time: 231_823_000 picoseconds. - Weight::from_parts(237_996_137, 21735) - // Standard Error: 598 - .saturating_add(Weight::from_parts(163_106, 0).saturating_mul(r.into())) + // Minimum execution time: 283_487_000 picoseconds. + Weight::from_parts(289_280_189, 21735) + // Standard Error: 829 + .saturating_add(Weight::from_parts(168_973, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) @@ -3542,10 +3540,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1975 + r * (39 ±0)` // Estimated: `27145 + r * (200 ±0)` - // Minimum execution time: 235_077_000 picoseconds. - Weight::from_parts(267_876_360, 27145) - // Standard Error: 1_147 - .saturating_add(Weight::from_parts(256_275, 0).saturating_mul(r.into())) + // Minimum execution time: 287_413_000 picoseconds. + Weight::from_parts(314_662_286, 27145) + // Standard Error: 1_099 + .saturating_add(Weight::from_parts(262_201, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 200).saturating_mul(r.into())) @@ -3567,10 +3565,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `776 + r * (3 ±0)` // Estimated: `24004 + r * (18 ±0)` - // Minimum execution time: 231_384_000 picoseconds. - Weight::from_parts(237_086_900, 24004) - // Standard Error: 534 - .saturating_add(Weight::from_parts(140_842, 0).saturating_mul(r.into())) + // Minimum execution time: 282_601_000 picoseconds. + Weight::from_parts(289_374_203, 24004) + // Standard Error: 452 + .saturating_add(Weight::from_parts(142_661, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 18).saturating_mul(r.into())) @@ -3580,509 +3578,507 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_721_000 picoseconds. - Weight::from_parts(2_456_746, 0) - // Standard Error: 30 - .saturating_add(Weight::from_parts(2_788, 0).saturating_mul(r.into())) + // Minimum execution time: 1_692_000 picoseconds. + Weight::from_parts(2_069_482, 0) + // Standard Error: 40 + .saturating_add(Weight::from_parts(2_922, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64load(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_824_000 picoseconds. - Weight::from_parts(2_366_036, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(6_446, 0).saturating_mul(r.into())) + // Minimum execution time: 1_690_000 picoseconds. + Weight::from_parts(2_303_602, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(6_433, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64store(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_840_000 picoseconds. - Weight::from_parts(2_332_115, 0) + // Minimum execution time: 1_701_000 picoseconds. + Weight::from_parts(2_321_142, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(6_012, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(6_025, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_select(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_731_000 picoseconds. - Weight::from_parts(2_078_873, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(7_931, 0).saturating_mul(r.into())) + // Minimum execution time: 1_656_000 picoseconds. + Weight::from_parts(2_090_881, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(7_941, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_768_000 picoseconds. - Weight::from_parts(1_916_551, 0) - // Standard Error: 8 - .saturating_add(Weight::from_parts(10_597, 0).saturating_mul(r.into())) + // Minimum execution time: 1_659_000 picoseconds. + Weight::from_parts(1_816_547, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(10_578, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_735_000 picoseconds. - Weight::from_parts(1_962_845, 0) - // Standard Error: 14 - .saturating_add(Weight::from_parts(4_631, 0).saturating_mul(r.into())) + // Minimum execution time: 1_683_000 picoseconds. + Weight::from_parts(1_970_907, 0) + // Standard Error: 12 + .saturating_add(Weight::from_parts(4_636, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_688_000 picoseconds. - Weight::from_parts(1_172_825, 0) - // Standard Error: 76 - .saturating_add(Weight::from_parts(8_007, 0).saturating_mul(r.into())) + // Minimum execution time: 1_651_000 picoseconds. + Weight::from_parts(2_263_817, 0) + // Standard Error: 68 + .saturating_add(Weight::from_parts(7_529, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br_table(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_725_000 picoseconds. - Weight::from_parts(1_535_833, 0) - // Standard Error: 26 - .saturating_add(Weight::from_parts(9_489, 0).saturating_mul(r.into())) + // Minimum execution time: 1_687_000 picoseconds. + Weight::from_parts(1_349_186, 0) + // Standard Error: 31 + .saturating_add(Weight::from_parts(9_732, 0).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. - fn instr_br_table_per_entry(e: u32, ) -> Weight { + fn instr_br_table_per_entry(_e: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_814_000 picoseconds. - Weight::from_parts(1_926_367, 0) - // Standard Error: 16 - .saturating_add(Weight::from_parts(219, 0).saturating_mul(e.into())) + // Minimum execution time: 1_777_000 picoseconds. + Weight::from_parts(2_036_446, 0) } /// The range of component `r` is `[0, 5000]`. fn instr_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_770_000 picoseconds. - Weight::from_parts(2_436_918, 0) - // Standard Error: 8 - .saturating_add(Weight::from_parts(17_890, 0).saturating_mul(r.into())) + // Minimum execution time: 1_686_000 picoseconds. + Weight::from_parts(464_449, 0) + // Standard Error: 383 + .saturating_add(Weight::from_parts(19_121, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_call_indirect(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_920_000 picoseconds. - Weight::from_parts(2_729_712, 0) - // Standard Error: 39 - .saturating_add(Weight::from_parts(24_853, 0).saturating_mul(r.into())) + // Minimum execution time: 1_855_000 picoseconds. + Weight::from_parts(3_381_585, 0) + // Standard Error: 18 + .saturating_add(Weight::from_parts(24_245, 0).saturating_mul(r.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_869_000 picoseconds. - Weight::from_parts(2_147_970, 0) - // Standard Error: 46 - .saturating_add(Weight::from_parts(1_237, 0).saturating_mul(l.into())) + // Minimum execution time: 1_792_000 picoseconds. + Weight::from_parts(2_006_024, 0) + // Standard Error: 16 + .saturating_add(Weight::from_parts(2_181, 0).saturating_mul(l.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_012_000 picoseconds. - Weight::from_parts(3_234_440, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(2_433, 0).saturating_mul(r.into())) + // Minimum execution time: 3_918_000 picoseconds. + Weight::from_parts(4_618_761, 0) + // Standard Error: 49 + .saturating_add(Weight::from_parts(2_312, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_037_000 picoseconds. - Weight::from_parts(3_204_600, 0) + // Minimum execution time: 3_889_000 picoseconds. + Weight::from_parts(4_151_280, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_627, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_623, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_tee(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_974_000 picoseconds. - Weight::from_parts(3_301_366, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(3_836, 0).saturating_mul(r.into())) + // Minimum execution time: 3_880_000 picoseconds. + Weight::from_parts(4_225_780, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(3_847, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_global_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_853_000 picoseconds. - Weight::from_parts(2_310_141, 0) + // Minimum execution time: 1_765_000 picoseconds. + Weight::from_parts(2_216_674, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(8_387, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(8_393, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_global_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_828_000 picoseconds. - Weight::from_parts(2_315_323, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(8_797, 0).saturating_mul(r.into())) + // Minimum execution time: 1_764_000 picoseconds. + Weight::from_parts(2_246_735, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(8_877, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_memory_current(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_800_000 picoseconds. - Weight::from_parts(2_117_252, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(3_741, 0).saturating_mul(r.into())) + // Minimum execution time: 1_758_000 picoseconds. + Weight::from_parts(1_922_386, 0) + // Standard Error: 94 + .saturating_add(Weight::from_parts(3_868, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 16]`. fn instr_memory_grow(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_743_000 picoseconds. - Weight::from_parts(1_054_728, 0) - // Standard Error: 137_128 - .saturating_add(Weight::from_parts(13_179_446, 0).saturating_mul(r.into())) + // Minimum execution time: 1_635_000 picoseconds. + Weight::from_parts(1_118_785, 0) + // Standard Error: 134_978 + .saturating_add(Weight::from_parts(16_343_664, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64clz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_735_000 picoseconds. - Weight::from_parts(2_026_568, 0) + // Minimum execution time: 1_648_000 picoseconds. + Weight::from_parts(2_012_545, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_802, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_824, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ctz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_630_000 picoseconds. - Weight::from_parts(1_980_222, 0) + // Minimum execution time: 1_688_000 picoseconds. + Weight::from_parts(1_995_956, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_735, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_757, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64popcnt(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_695_000 picoseconds. - Weight::from_parts(2_040_266, 0) - // Standard Error: 8 - .saturating_add(Weight::from_parts(3_718, 0).saturating_mul(r.into())) + // Minimum execution time: 1_631_000 picoseconds. + Weight::from_parts(2_011_493, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(3_755, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64eqz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_697_000 picoseconds. - Weight::from_parts(2_004_663, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(3_661, 0).saturating_mul(r.into())) + // Minimum execution time: 1_667_000 picoseconds. + Weight::from_parts(1_958_798, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_677, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64extendsi32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_705_000 picoseconds. - Weight::from_parts(2_682_122, 0) - // Standard Error: 98 - .saturating_add(Weight::from_parts(3_705, 0).saturating_mul(r.into())) + // Minimum execution time: 1_674_000 picoseconds. + Weight::from_parts(2_009_555, 0) + // Standard Error: 7 + .saturating_add(Weight::from_parts(3_863, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64extendui32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_674_000 picoseconds. - Weight::from_parts(1_989_835, 0) + // Minimum execution time: 1_659_000 picoseconds. + Weight::from_parts(2_014_985, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_801, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_821, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i32wrapi64(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_695_000 picoseconds. - Weight::from_parts(2_083_824, 0) - // Standard Error: 17 - .saturating_add(Weight::from_parts(3_719, 0).saturating_mul(r.into())) + // Minimum execution time: 1_640_000 picoseconds. + Weight::from_parts(2_013_939, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_708, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64eq(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_678_000 picoseconds. - Weight::from_parts(1_996_335, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(5_995, 0).saturating_mul(r.into())) + // Minimum execution time: 1_631_000 picoseconds. + Weight::from_parts(2_002_814, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_008, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ne(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_697_000 picoseconds. - Weight::from_parts(2_046_566, 0) + // Minimum execution time: 1_647_000 picoseconds. + Weight::from_parts(2_032_158, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(5_936, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_944, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64lts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_721_000 picoseconds. - Weight::from_parts(2_406_930, 0) - // Standard Error: 150 - .saturating_add(Weight::from_parts(5_992, 0).saturating_mul(r.into())) + // Minimum execution time: 1_669_000 picoseconds. + Weight::from_parts(2_040_386, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(6_009, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ltu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_749_000 picoseconds. - Weight::from_parts(1_987_158, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_994, 0).saturating_mul(r.into())) + // Minimum execution time: 1_637_000 picoseconds. + Weight::from_parts(1_983_695, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(6_027, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64gts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_706_000 picoseconds. - Weight::from_parts(2_038_138, 0) + // Minimum execution time: 1_701_000 picoseconds. + Weight::from_parts(2_054_295, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(5_802, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_799, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64gtu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_670_000 picoseconds. - Weight::from_parts(2_555_035, 0) - // Standard Error: 74 - .saturating_add(Weight::from_parts(5_958, 0).saturating_mul(r.into())) + // Minimum execution time: 1_653_000 picoseconds. + Weight::from_parts(2_749_807, 0) + // Standard Error: 90 + .saturating_add(Weight::from_parts(5_945, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64les(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_694_000 picoseconds. - Weight::from_parts(1_991_929, 0) - // Standard Error: 27 - .saturating_add(Weight::from_parts(6_037, 0).saturating_mul(r.into())) + // Minimum execution time: 1_651_000 picoseconds. + Weight::from_parts(1_979_111, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(6_011, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64leu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_684_000 picoseconds. - Weight::from_parts(1_969_284, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_104, 0).saturating_mul(r.into())) + // Minimum execution time: 1_743_000 picoseconds. + Weight::from_parts(2_058_081, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(6_085, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ges(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_697_000 picoseconds. - Weight::from_parts(2_023_608, 0) + // Minimum execution time: 1_638_000 picoseconds. + Weight::from_parts(2_038_929, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(5_946, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_941, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64geu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_659_000 picoseconds. - Weight::from_parts(1_963_145, 0) - // Standard Error: 6 - .saturating_add(Weight::from_parts(6_014, 0).saturating_mul(r.into())) + // Minimum execution time: 1_641_000 picoseconds. + Weight::from_parts(2_036_587, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_008, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64add(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_722_000 picoseconds. - Weight::from_parts(2_016_286, 0) + // Minimum execution time: 1_624_000 picoseconds. + Weight::from_parts(2_080_562, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(5_889, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_826, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64sub(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_656_000 picoseconds. - Weight::from_parts(1_966_234, 0) - // Standard Error: 17 - .saturating_add(Weight::from_parts(6_171, 0).saturating_mul(r.into())) + // Minimum execution time: 1_652_000 picoseconds. + Weight::from_parts(2_039_535, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_137, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64mul(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_695_000 picoseconds. - Weight::from_parts(2_004_559, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_785, 0).saturating_mul(r.into())) + // Minimum execution time: 1_666_000 picoseconds. + Weight::from_parts(2_056_354, 0) + // Standard Error: 6 + .saturating_add(Weight::from_parts(5_780, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64divs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_681_000 picoseconds. - Weight::from_parts(2_135_505, 0) - // Standard Error: 6 - .saturating_add(Weight::from_parts(11_761, 0).saturating_mul(r.into())) + // Minimum execution time: 1_648_000 picoseconds. + Weight::from_parts(2_077_695, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(11_775, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64divu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_653_000 picoseconds. - Weight::from_parts(2_153_167, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(10_523, 0).saturating_mul(r.into())) + // Minimum execution time: 1_797_000 picoseconds. + Weight::from_parts(2_772_388, 0) + // Standard Error: 33 + .saturating_add(Weight::from_parts(10_333, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rems(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_697_000 picoseconds. - Weight::from_parts(2_570_266, 0) - // Standard Error: 50 - .saturating_add(Weight::from_parts(11_971, 0).saturating_mul(r.into())) + // Minimum execution time: 1_699_000 picoseconds. + Weight::from_parts(2_174_288, 0) + // Standard Error: 6 + .saturating_add(Weight::from_parts(11_778, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64remu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_719_000 picoseconds. - Weight::from_parts(2_101_082, 0) + // Minimum execution time: 1_685_000 picoseconds. + Weight::from_parts(2_091_037, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(10_709, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(10_694, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64and(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_745_000 picoseconds. - Weight::from_parts(2_621_890, 0) - // Standard Error: 94 - .saturating_add(Weight::from_parts(5_545, 0).saturating_mul(r.into())) + // Minimum execution time: 1_636_000 picoseconds. + Weight::from_parts(1_975_521, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_695, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64or(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_670_000 picoseconds. - Weight::from_parts(2_046_821, 0) + // Minimum execution time: 1_619_000 picoseconds. + Weight::from_parts(2_045_492, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(5_762, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_770, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64xor(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_714_000 picoseconds. - Weight::from_parts(2_010_173, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_911, 0).saturating_mul(r.into())) + // Minimum execution time: 1_668_000 picoseconds. + Weight::from_parts(2_055_460, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(5_851, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_756_000 picoseconds. - Weight::from_parts(2_044_772, 0) + // Minimum execution time: 1_681_000 picoseconds. + Weight::from_parts(2_023_370, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(5_857, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_853, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shrs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_741_000 picoseconds. - Weight::from_parts(2_012_819, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_127, 0).saturating_mul(r.into())) + // Minimum execution time: 1_714_000 picoseconds. + Weight::from_parts(2_067_584, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(6_133, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shru(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_693_000 picoseconds. - Weight::from_parts(2_090_981, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_839, 0).saturating_mul(r.into())) + // Minimum execution time: 1_602_000 picoseconds. + Weight::from_parts(2_055_530, 0) + // Standard Error: 138 + .saturating_add(Weight::from_parts(6_014, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rotl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_704_000 picoseconds. - Weight::from_parts(2_014_108, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(6_005, 0).saturating_mul(r.into())) + // Minimum execution time: 1_709_000 picoseconds. + Weight::from_parts(2_016_365, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_985, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rotr(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_715_000 picoseconds. - Weight::from_parts(2_053_720, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(5_860, 0).saturating_mul(r.into())) + // Minimum execution time: 1_661_000 picoseconds. + Weight::from_parts(2_003_063, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(5_863, 0).saturating_mul(r.into())) } } From a1cf6ee484c28e313df8082c1efc643ba54810b7 Mon Sep 17 00:00:00 2001 From: Sergejs Kostjucenko <85877331+sergejparity@users.noreply.github.com> Date: Tue, 21 Mar 2023 14:05:26 +0200 Subject: [PATCH 50/80] fix publish docker description ci job (#13663) * fix publish docker description ci job * remove publish-refs from docker description jobs --- scripts/ci/gitlab/pipeline/publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/ci/gitlab/pipeline/publish.yml b/scripts/ci/gitlab/pipeline/publish.yml index 188a093864cc0..6a3d928f6e0f9 100644 --- a/scripts/ci/gitlab/pipeline/publish.yml +++ b/scripts/ci/gitlab/pipeline/publish.yml @@ -52,7 +52,6 @@ stage: publish extends: - .kubernetes-env - - .publish-refs variables: CI_IMAGE: paritytech/dockerhub-description DOCKERHUB_REPOSITORY: parity/$PRODUCT @@ -63,6 +62,8 @@ - if: $CI_COMMIT_REF_NAME == "master" changes: - scripts/ci/docker/$PRODUCT.Dockerfile.README.md + before_script: + - echo script: - cd / && sh entrypoint.sh From b3cacfb059e9d79d1cde270c796dc0f33ff3ef20 Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Tue, 21 Mar 2023 13:06:55 +0100 Subject: [PATCH 51/80] only push docker descriptions on master branch pipelines (#13664) Currently those jobs also get included in multi-project pipelines such as https://gitlab.parity.io/parity/mirrors/scripts/-/pipelines/255546, even when the description hasn't actually changed, because `changes:` conditions always evaluate to true on non-branch pipelines. --- scripts/ci/gitlab/pipeline/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/gitlab/pipeline/publish.yml b/scripts/ci/gitlab/pipeline/publish.yml index 6a3d928f6e0f9..a772096447663 100644 --- a/scripts/ci/gitlab/pipeline/publish.yml +++ b/scripts/ci/gitlab/pipeline/publish.yml @@ -59,7 +59,7 @@ DOCKER_PASSWORD: $Docker_Hub_Pass_Parity README_FILEPATH: $CI_PROJECT_DIR/scripts/ci/docker/$PRODUCT.Dockerfile.README.md rules: - - if: $CI_COMMIT_REF_NAME == "master" + - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" changes: - scripts/ci/docker/$PRODUCT.Dockerfile.README.md before_script: From a14236059c2d3da052fb08295082341aa7b87240 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Mar 2023 13:53:04 +0000 Subject: [PATCH 52/80] Bump k256 from 0.11.6 to 0.13.0 (#13624) Bumps [k256](https://github.com/RustCrypto/elliptic-curves) from 0.11.6 to 0.13.0. - [Release notes](https://github.com/RustCrypto/elliptic-curves/releases) - [Commits](https://github.com/RustCrypto/elliptic-curves/compare/k256/v0.11.6...k256/v0.13.0) --- updated-dependencies: - dependency-name: k256 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> Co-authored-by: Davide Galassi --- Cargo.lock | 202 ++++++++++++++++++++++++++++++++------- frame/support/Cargo.toml | 2 +- 2 files changed, 170 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e2ec461e1e03e..4a0cc4cd38a96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -484,6 +484,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "base58" version = "0.2.0" @@ -1374,6 +1380,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "crypto-bigint" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c2538c4e68e52548bacb3e83ac549f903d44f011ac9d5abb5e132e67d0808f7" +dependencies = [ + "generic-array 0.14.6", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -1589,6 +1607,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "der" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc906908ea6458456e5eaa160a9c08543ec3d1e6f71e2235cedd660cb65f9df0" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "der-parser" version = "7.0.0" @@ -1826,10 +1854,22 @@ version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", + "der 0.6.1", + "elliptic-curve 0.12.3", + "rfc6979 0.3.1", + "signature 1.6.4", +] + +[[package]] +name = "ecdsa" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1b0a1222f8072619e8a6b667a854020a03d363738303203c09468b3424a420a" +dependencies = [ + "der 0.7.1", + "elliptic-curve 0.13.2", + "rfc6979 0.4.0", + "signature 2.0.0", ] [[package]] @@ -1838,7 +1878,7 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "signature", + "signature 1.6.4", ] [[package]] @@ -1881,18 +1921,37 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" dependencies = [ - "base16ct", - "crypto-bigint", - "der", + "base16ct 0.1.1", + "crypto-bigint 0.4.9", + "der 0.6.1", "digest 0.10.6", - "ff", + "ff 0.12.1", "generic-array 0.14.6", - "group", + "group 0.12.1", "hkdf", "pem-rfc7468", - "pkcs8", + "pkcs8 0.9.0", "rand_core 0.6.4", - "sec1", + "sec1 0.3.0", + "subtle", + "zeroize", +] + +[[package]] +name = "elliptic-curve" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea5a92946e8614bb585254898bb7dd1ddad241ace60c52149e3765e34cc039d" +dependencies = [ + "base16ct 0.2.0", + "crypto-bigint 0.5.1", + "digest 0.10.6", + "ff 0.13.0", + "generic-array 0.14.6", + "group 0.13.0", + "pkcs8 0.10.1", + "rand_core 0.6.4", + "sec1 0.7.1", "subtle", "zeroize", ] @@ -2050,6 +2109,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "fiat-crypto" version = "0.1.17" @@ -2720,6 +2789,7 @@ checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -2829,7 +2899,18 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ - "ff", + "ff 0.12.1", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", "rand_core 0.6.4", "subtle", ] @@ -3482,13 +3563,14 @@ dependencies = [ [[package]] name = "k256" -version = "0.11.6" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +checksum = "955890845095ccf31ef83ad41a05aabb4d8cc23dc3cac5a9f5c89cf26dd0da75" dependencies = [ "cfg-if", - "ecdsa", - "elliptic-curve", + "ecdsa 0.16.1", + "elliptic-curve 0.13.2", + "once_cell", "sha2 0.10.6", ] @@ -3764,7 +3846,7 @@ dependencies = [ "prost-build", "rand 0.8.5", "rw-stream-sink", - "sec1", + "sec1 0.3.0", "sha2 0.10.6", "smallvec", "thiserror", @@ -3798,7 +3880,7 @@ dependencies = [ "prost-build", "rand 0.8.5", "rw-stream-sink", - "sec1", + "sec1 0.3.0", "sha2 0.10.6", "smallvec", "thiserror", @@ -5372,8 +5454,8 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" dependencies = [ - "ecdsa", - "elliptic-curve", + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", "sha2 0.10.6", ] @@ -5383,8 +5465,8 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" dependencies = [ - "ecdsa", - "elliptic-curve", + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", "sha2 0.10.6", ] @@ -7188,8 +7270,18 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" dependencies = [ - "der", - "spki", + "der 0.6.1", + "spki 0.6.0", +] + +[[package]] +name = "pkcs8" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d2820d87d2b008616e5c27212dd9e0e694fb4c6b522de06094106813328cb49" +dependencies = [ + "der 0.7.1", + "spki 0.7.0", ] [[package]] @@ -7822,11 +7914,21 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ - "crypto-bigint", + "crypto-bigint 0.4.9", "hmac 0.12.1", "zeroize", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac 0.12.1", + "subtle", +] + [[package]] name = "ring" version = "0.16.20" @@ -9605,10 +9707,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ - "base16ct", - "der", + "base16ct 0.1.1", + "der 0.6.1", "generic-array 0.14.6", - "pkcs8", + "pkcs8 0.9.0", + "subtle", + "zeroize", +] + +[[package]] +name = "sec1" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48518a2b5775ba8ca5b46596aae011caa431e6ce7e4a67ead66d92f08884220e" +dependencies = [ + "base16ct 0.2.0", + "der 0.7.1", + "generic-array 0.14.6", + "pkcs8 0.10.1", "subtle", "zeroize", ] @@ -9831,6 +9947,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "signature" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fe458c98333f9c8152221191a77e2a44e8325d0193484af2e9421a53019e57d" +dependencies = [ + "digest 0.10.6", + "rand_core 0.6.4", +] + [[package]] name = "simba" version = "0.8.0" @@ -10764,7 +10890,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" dependencies = [ "base64ct", - "der", + "der 0.6.1", +] + +[[package]] +name = "spki" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0445c905640145c7ea8c1993555957f65e7c46d0535b91ba501bc9bfc85522f" +dependencies = [ + "base64ct", + "der 0.7.1", ] [[package]] @@ -12568,7 +12704,7 @@ dependencies = [ "ccm", "curve25519-dalek 3.2.0", "der-parser 8.1.0", - "elliptic-curve", + "elliptic-curve 0.12.3", "hkdf", "hmac 0.12.1", "log", @@ -12580,11 +12716,11 @@ dependencies = [ "rcgen 0.9.3", "ring", "rustls 0.19.1", - "sec1", + "sec1 0.3.0", "serde", "sha1", "sha2 0.10.6", - "signature", + "signature 1.6.4", "subtle", "thiserror", "tokio", diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index 008d4b3f26015..820658372afd9 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -37,7 +37,7 @@ impl-trait-for-tuples = "0.2.2" smallvec = "1.8.0" log = { version = "0.4.17", default-features = false } sp-core-hashing-proc-macro = { version = "5.0.0", path = "../../primitives/core/hashing/proc-macro" } -k256 = { version = "0.11.5", default-features = false, features = ["ecdsa"] } +k256 = { version = "0.13.0", default-features = false, features = ["ecdsa"] } environmental = { version = "1.1.4", default-features = false } [dev-dependencies] From 936e995d91be03f8efe7e75b1be2f6ad1e3a60e9 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 21 Mar 2023 16:25:33 +0100 Subject: [PATCH 53/80] refactor: state RPC remove `max_rpc_payload_size` (#13649) This limit is not needed anymore as the JSON-RPC servers doesn't terminate the connection if the RPC max limit is exceeded anymore --- client/rpc/src/state/mod.rs | 10 ++---- client/rpc/src/state/state_full.rs | 10 ++---- client/rpc/src/state/tests.rs | 24 +++++++------- client/service/src/builder.rs | 8 ++--- client/tracing/src/block/mod.rs | 53 +++++++----------------------- 5 files changed, 30 insertions(+), 75 deletions(-) diff --git a/client/rpc/src/state/mod.rs b/client/rpc/src/state/mod.rs index 12d59ad3b382d..f81ec991db133 100644 --- a/client/rpc/src/state/mod.rs +++ b/client/rpc/src/state/mod.rs @@ -169,7 +169,6 @@ pub fn new_full( client: Arc, executor: SubscriptionTaskExecutor, deny_unsafe: DenyUnsafe, - rpc_max_payload: Option, ) -> (State, ChildState) where Block: BlockT + 'static, @@ -189,12 +188,9 @@ where + 'static, Client::Api: Metadata, { - let child_backend = Box::new(self::state_full::FullState::new( - client.clone(), - executor.clone(), - rpc_max_payload, - )); - let backend = Box::new(self::state_full::FullState::new(client, executor, rpc_max_payload)); + let child_backend = + Box::new(self::state_full::FullState::new(client.clone(), executor.clone())); + let backend = Box::new(self::state_full::FullState::new(client, executor)); (State { backend, deny_unsafe }, ChildState { backend: child_backend }) } diff --git a/client/rpc/src/state/state_full.rs b/client/rpc/src/state/state_full.rs index f26d42484f24f..20ca5f7131e71 100644 --- a/client/rpc/src/state/state_full.rs +++ b/client/rpc/src/state/state_full.rs @@ -66,7 +66,6 @@ pub struct FullState { client: Arc, executor: SubscriptionTaskExecutor, _phantom: PhantomData<(BE, Block)>, - rpc_max_payload: Option, } impl FullState @@ -79,12 +78,8 @@ where Block: BlockT + 'static, { /// Create new state API backend for full nodes. - pub fn new( - client: Arc, - executor: SubscriptionTaskExecutor, - rpc_max_payload: Option, - ) -> Self { - Self { client, executor, _phantom: PhantomData, rpc_max_payload } + pub fn new(client: Arc, executor: SubscriptionTaskExecutor) -> Self { + Self { client, executor, _phantom: PhantomData } } /// Returns given block hash or best block hash if None is passed. @@ -481,7 +476,6 @@ where targets, storage_keys, methods, - self.rpc_max_payload, ) .trace_block() .map_err(|e| invalid_block::(block, None, e.to_string())) diff --git a/client/rpc/src/state/tests.rs b/client/rpc/src/state/tests.rs index 1ccc609e4f0e4..ae193e662b0e7 100644 --- a/client/rpc/src/state/tests.rs +++ b/client/rpc/src/state/tests.rs @@ -55,7 +55,7 @@ async fn should_return_storage() { .add_extra_storage(b":map:acc2".to_vec(), vec![1, 2, 3]) .build(); let genesis_hash = client.genesis_hash(); - let (client, child) = new_full(Arc::new(client), test_executor(), DenyUnsafe::No, None); + let (client, child) = new_full(Arc::new(client), test_executor(), DenyUnsafe::No); let key = StorageKey(KEY.to_vec()); assert_eq!( @@ -103,7 +103,7 @@ async fn should_return_storage_entries() { .add_extra_child_storage(&child_info, KEY2.to_vec(), CHILD_VALUE2.to_vec()) .build(); let genesis_hash = client.genesis_hash(); - let (_client, child) = new_full(Arc::new(client), test_executor(), DenyUnsafe::No, None); + let (_client, child) = new_full(Arc::new(client), test_executor(), DenyUnsafe::No); let keys = &[StorageKey(KEY1.to_vec()), StorageKey(KEY2.to_vec())]; assert_eq!( @@ -134,7 +134,7 @@ async fn should_return_child_storage() { .build(), ); let genesis_hash = client.genesis_hash(); - let (_client, child) = new_full(client, test_executor(), DenyUnsafe::No, None); + let (_client, child) = new_full(client, test_executor(), DenyUnsafe::No); let child_key = prefixed_storage_key(); let key = StorageKey(b"key".to_vec()); @@ -165,7 +165,7 @@ async fn should_return_child_storage_entries() { .build(), ); let genesis_hash = client.genesis_hash(); - let (_client, child) = new_full(client, test_executor(), DenyUnsafe::No, None); + let (_client, child) = new_full(client, test_executor(), DenyUnsafe::No); let child_key = prefixed_storage_key(); let keys = vec![StorageKey(b"key1".to_vec()), StorageKey(b"key2".to_vec())]; @@ -196,7 +196,7 @@ async fn should_return_child_storage_entries() { async fn should_call_contract() { let client = Arc::new(substrate_test_runtime_client::new()); let genesis_hash = client.genesis_hash(); - let (client, _child) = new_full(client, test_executor(), DenyUnsafe::No, None); + let (client, _child) = new_full(client, test_executor(), DenyUnsafe::No); use jsonrpsee::{core::Error, types::error::CallError}; @@ -210,7 +210,7 @@ async fn should_call_contract() { async fn should_notify_about_storage_changes() { let mut sub = { let mut client = Arc::new(substrate_test_runtime_client::new()); - let (api, _child) = new_full(client.clone(), test_executor(), DenyUnsafe::No, None); + let (api, _child) = new_full(client.clone(), test_executor(), DenyUnsafe::No); let api_rpc = api.into_rpc(); let sub = api_rpc.subscribe("state_subscribeStorage", EmptyParams::new()).await.unwrap(); @@ -242,7 +242,7 @@ async fn should_notify_about_storage_changes() { async fn should_send_initial_storage_changes_and_notifications() { let mut sub = { let mut client = Arc::new(substrate_test_runtime_client::new()); - let (api, _child) = new_full(client.clone(), test_executor(), DenyUnsafe::No, None); + let (api, _child) = new_full(client.clone(), test_executor(), DenyUnsafe::No); let alice_balance_key = blake2_256(&runtime::system::balance_of_key(AccountKeyring::Alice.into())); @@ -278,7 +278,7 @@ async fn should_send_initial_storage_changes_and_notifications() { #[tokio::test] async fn should_query_storage() { async fn run_tests(mut client: Arc) { - let (api, _child) = new_full(client.clone(), test_executor(), DenyUnsafe::No, None); + let (api, _child) = new_full(client.clone(), test_executor(), DenyUnsafe::No); let mut add_block = |nonce| { let mut builder = client.new_block(Default::default()).unwrap(); @@ -480,7 +480,7 @@ async fn should_query_storage() { #[tokio::test] async fn should_return_runtime_version() { let client = Arc::new(substrate_test_runtime_client::new()); - let (api, _child) = new_full(client.clone(), test_executor(), DenyUnsafe::No, None); + let (api, _child) = new_full(client.clone(), test_executor(), DenyUnsafe::No); let result = "{\"specName\":\"test\",\"implName\":\"parity-test\",\"authoringVersion\":1,\ \"specVersion\":2,\"implVersion\":2,\"apis\":[[\"0xdf6acb689907609b\",4],\ @@ -501,7 +501,7 @@ async fn should_return_runtime_version() { async fn should_notify_on_runtime_version_initially() { let mut sub = { let client = Arc::new(substrate_test_runtime_client::new()); - let (api, _child) = new_full(client, test_executor(), DenyUnsafe::No, None); + let (api, _child) = new_full(client, test_executor(), DenyUnsafe::No); let api_rpc = api.into_rpc(); let sub = api_rpc @@ -530,7 +530,7 @@ fn should_deserialize_storage_key() { #[tokio::test] async fn wildcard_storage_subscriptions_are_rpc_unsafe() { let client = Arc::new(substrate_test_runtime_client::new()); - let (api, _child) = new_full(client, test_executor(), DenyUnsafe::Yes, None); + let (api, _child) = new_full(client, test_executor(), DenyUnsafe::Yes); let api_rpc = api.into_rpc(); let err = api_rpc.subscribe("state_subscribeStorage", EmptyParams::new()).await; @@ -540,7 +540,7 @@ async fn wildcard_storage_subscriptions_are_rpc_unsafe() { #[tokio::test] async fn concrete_storage_subscriptions_are_rpc_safe() { let client = Arc::new(substrate_test_runtime_client::new()); - let (api, _child) = new_full(client, test_executor(), DenyUnsafe::Yes, None); + let (api, _child) = new_full(client, test_executor(), DenyUnsafe::Yes); let api_rpc = api.into_rpc(); let key = StorageKey(STORAGE_KEY.to_vec()); diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index bee40e9a3da0c..f0f9a7ed0d4d7 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -631,12 +631,8 @@ where let (chain, state, child_state) = { let chain = sc_rpc::chain::new_full(client.clone(), task_executor.clone()).into_rpc(); - let (state, child_state) = sc_rpc::state::new_full( - client.clone(), - task_executor.clone(), - deny_unsafe, - config.rpc_max_payload, - ); + let (state, child_state) = + sc_rpc::state::new_full(client.clone(), task_executor.clone(), deny_unsafe); let state = state.into_rpc(); let child_state = child_state.into_rpc(); diff --git a/client/tracing/src/block/mod.rs b/client/tracing/src/block/mod.rs index f5efadc34fb92..c0442abc125b9 100644 --- a/client/tracing/src/block/mod.rs +++ b/client/tracing/src/block/mod.rs @@ -34,38 +34,21 @@ use tracing::{ use crate::{SpanDatum, TraceEvent, Values}; use sc_client_api::BlockBackend; -use sc_rpc_server::RPC_MAX_PAYLOAD_DEFAULT; use sp_api::{Core, Encode, Metadata, ProvideRuntimeApi}; use sp_blockchain::HeaderBackend; use sp_core::hexdisplay::HexDisplay; -use sp_rpc::tracing::{BlockTrace, Span, TraceBlockResponse, TraceError}; +use sp_rpc::tracing::{BlockTrace, Span, TraceBlockResponse}; use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, Header}, }; use sp_tracing::{WASM_NAME_KEY, WASM_TARGET_KEY, WASM_TRACE_IDENTIFIER}; -// Heuristic for average event size in bytes. -const AVG_EVENT: usize = 600 * 8; -// Heuristic for average span size in bytes. -const AVG_SPAN: usize = 100 * 8; -// Estimate of the max base RPC payload size when the Id is bound as a u64. If strings -// are used for the RPC Id this may need to be adjusted. Note: The base payload -// does not include the RPC result. -// -// The estimate is based on the JSON-RPC response message which has the following format: -// `{"jsonrpc":"2.0","result":[],"id":18446744073709551615}`. -// -// We care about the total size of the payload because jsonrpc-server will simply ignore -// messages larger than `sc_rpc_server::MAX_PAYLOAD` and the caller will not get any -// response. -const BASE_PAYLOAD: usize = 100; // Default to only pallet, frame support and state related traces const DEFAULT_TARGETS: &str = "pallet,frame,state"; const TRACE_TARGET: &str = "block_trace"; // The name of a field required for all events. const REQUIRED_EVENT_FIELD: &str = "method"; -const MEGABYTE: usize = 1024 * 1024; /// Tracing Block Result type alias pub type TraceBlockResult = Result; @@ -182,7 +165,6 @@ pub struct BlockExecutor { targets: Option, storage_keys: Option, methods: Option, - rpc_max_payload: usize, } impl BlockExecutor @@ -203,12 +185,8 @@ where targets: Option, storage_keys: Option, methods: Option, - rpc_max_payload: Option, ) -> Self { - let rpc_max_payload = rpc_max_payload - .map(|mb| mb.saturating_mul(MEGABYTE)) - .unwrap_or(RPC_MAX_PAYLOAD_DEFAULT); - Self { client, block, targets, storage_keys, methods, rpc_max_payload } + Self { client, block, targets, storage_keys, methods } } /// Execute block, record all spans and events belonging to `Self::targets` @@ -289,24 +267,15 @@ where .collect(); tracing::debug!(target: "state_tracing", "Captured {} spans and {} events", spans.len(), events.len()); - let approx_payload_size = BASE_PAYLOAD + events.len() * AVG_EVENT + spans.len() * AVG_SPAN; - let response = if approx_payload_size > self.rpc_max_payload { - TraceBlockResponse::TraceError(TraceError { - error: "Payload likely exceeds max payload size of RPC server.".to_string(), - }) - } else { - TraceBlockResponse::BlockTrace(BlockTrace { - block_hash: block_id_as_string(BlockId::::Hash(self.block)), - parent_hash: block_id_as_string(BlockId::::Hash(parent_hash)), - tracing_targets: targets.to_string(), - storage_keys: self.storage_keys.clone().unwrap_or_default(), - methods: self.methods.clone().unwrap_or_default(), - spans, - events, - }) - }; - - Ok(response) + Ok(TraceBlockResponse::BlockTrace(BlockTrace { + block_hash: block_id_as_string(BlockId::::Hash(self.block)), + parent_hash: block_id_as_string(BlockId::::Hash(parent_hash)), + tracing_targets: targets.to_string(), + storage_keys: self.storage_keys.clone().unwrap_or_default(), + methods: self.methods.clone().unwrap_or_default(), + spans, + events, + })) } } From 81aa7f317d0bb8476ab660bc67853f59aed84d4e Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Tue, 21 Mar 2023 13:05:06 +0100 Subject: [PATCH 54/80] core-fellowship: Remove unused dev-dependencies --- frame/core-fellowship/Cargo.toml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/frame/core-fellowship/Cargo.toml b/frame/core-fellowship/Cargo.toml index 2785346c7341f..16b673fb41b98 100644 --- a/frame/core-fellowship/Cargo.toml +++ b/frame/core-fellowship/Cargo.toml @@ -25,10 +25,6 @@ sp-io = { version = "7.0.0", default-features = false, path = "../../primitives/ sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" } sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" } -[dev-dependencies] -pallet-ranked-collective = { version = "4.0.0-dev", default-features = false, path = "../ranked-collective" } -pallet-salary = { version = "4.0.0-dev", default-features = false, path = "../salary" } - [features] default = ["std"] std = [ @@ -49,7 +45,5 @@ runtime-benchmarks = [ "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "pallet-ranked-collective/runtime-benchmarks", - "pallet-salary/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] From 6f79a5a26480cca90727edd0e9193c876788dcc3 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Tue, 21 Mar 2023 17:27:45 +0100 Subject: [PATCH 55/80] Update lockfile The CI needs this. Signed-off-by: Oliver Tale-Yazdi --- Cargo.lock | 2 -- 1 file changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a0cc4cd38a96..5b2879e1ba9b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5886,8 +5886,6 @@ dependencies = [ "frame-support", "frame-system", "log", - "pallet-ranked-collective", - "pallet-salary", "parity-scale-codec", "scale-info", "sp-arithmetic", From 5b29f150365cc6eacb1f618e8797d81f0aada46a Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Wed, 22 Mar 2023 09:33:06 +0100 Subject: [PATCH 56/80] move back to ci-linux@production image (#13669) --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f9e74364a0d6c..6cf06273650f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,7 +48,7 @@ variables: CARGO_INCREMENTAL: 0 DOCKER_OS: "debian:stretch" ARCH: "x86_64" - CI_IMAGE: "paritytech/ci-linux@sha256:7c76c3f9639f919447abbf9db535588178fde4df583d6926444d44cc20c094e6" # staging 2023-03-20 + CI_IMAGE: "paritytech/ci-linux:production" BUILDAH_IMAGE: "quay.io/buildah/stable:v1.27" RUSTY_CACHIER_SINGLE_BRANCH: master RUSTY_CACHIER_DONT_OPERATE_ON_MAIN_BRANCH: "true" From 2b42fbd860d7034ce9c716a37016b0101be69491 Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Wed, 22 Mar 2023 11:09:10 +0100 Subject: [PATCH 57/80] Crypto Pair trait refactory (#13657) * Crypto pair refactory * Remove unused method * Apply review suggestions * Remove leftovers * Associated type is not really required * Fix after refactory * Fix benchmark-ui test --------- Co-authored-by: Anton --- ...bad_return_type_blank_with_question.stderr | 2 +- primitives/application-crypto/src/lib.rs | 5 +- primitives/core/src/crypto.rs | 79 ++++++++++++----- primitives/core/src/ecdsa.rs | 49 +---------- primitives/core/src/ed25519.rs | 51 +---------- primitives/core/src/sr25519.rs | 85 +++---------------- 6 files changed, 75 insertions(+), 196 deletions(-) diff --git a/frame/support/test/tests/benchmark_ui/bad_return_type_blank_with_question.stderr b/frame/support/test/tests/benchmark_ui/bad_return_type_blank_with_question.stderr index 1f8c9f1e171eb..601bbd20fb73d 100644 --- a/frame/support/test/tests/benchmark_ui/bad_return_type_blank_with_question.stderr +++ b/frame/support/test/tests/benchmark_ui/bad_return_type_blank_with_question.stderr @@ -7,4 +7,4 @@ error[E0277]: the `?` operator can only be used in a function that returns `Resu 15 | something()?; | ^ cannot use the `?` operator in a function that returns `()` | - = help: the trait `FromResidual>` is not implemented for `()` + = help: the trait `FromResidual>` is not implemented for `()` diff --git a/primitives/application-crypto/src/lib.rs b/primitives/application-crypto/src/lib.rs index 992ecd1d05621..0685477ddff8d 100644 --- a/primitives/application-crypto/src/lib.rs +++ b/primitives/application-crypto/src/lib.rs @@ -23,7 +23,7 @@ pub use sp_core::crypto::{key_types, CryptoTypeId, KeyTypeId}; #[doc(hidden)] #[cfg(feature = "full_crypto")] -pub use sp_core::crypto::{DeriveJunction, Pair, SecretStringError, Ss58Codec}; +pub use sp_core::crypto::{DeriveError, DeriveJunction, Pair, SecretStringError, Ss58Codec}; #[doc(hidden)] pub use sp_core::{ self, @@ -129,7 +129,6 @@ macro_rules! app_crypto_pair { type Public = Public; type Seed = <$pair as $crate::Pair>::Seed; type Signature = Signature; - type DeriveError = <$pair as $crate::Pair>::DeriveError; $crate::app_crypto_pair_functions_if_std!($pair); @@ -137,7 +136,7 @@ macro_rules! app_crypto_pair { &self, path: Iter, seed: Option, - ) -> Result<(Self, Option), Self::DeriveError> { + ) -> Result<(Self, Option), $crate::DeriveError> { self.0.derive(path, seed).map(|x| (Self(x.0), x.1)) } fn from_seed(seed: &Self::Seed) -> Self { diff --git a/primitives/core/src/crypto.rs b/primitives/core/src/crypto.rs index 16af3d06963ab..80e65b342cbd7 100644 --- a/primitives/core/src/crypto.rs +++ b/primitives/core/src/crypto.rs @@ -24,6 +24,8 @@ use crate::hexdisplay::HexDisplay; use crate::{ed25519, sr25519}; #[cfg(feature = "std")] use base58::{FromBase58, ToBase58}; +#[cfg(feature = "std")] +use bip39::{Language, Mnemonic, MnemonicType}; use codec::{Decode, Encode, MaxEncodedLen}; #[cfg(feature = "std")] use rand::{rngs::OsRng, RngCore}; @@ -52,10 +54,6 @@ pub const DEV_PHRASE: &str = /// The address of the associated root phrase for our publicly known keys. pub const DEV_ADDRESS: &str = "5DfhGyQdFobKM8NsWvEeAKk5EQQgYe9AydgJ7rMB6E1EqRzV"; -/// The infallible type. -#[derive(crate::RuntimeDebug)] -pub enum Infallible {} - /// The length of the junction identifier. Note that this is also referred to as the /// `CHAIN_CODE_LENGTH` in the context of Schnorrkel. #[cfg(feature = "full_crypto")] @@ -108,6 +106,16 @@ pub enum SecretStringError { InvalidPath, } +/// An error when deriving a key. +#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, Clone, PartialEq, Eq)] +#[cfg(feature = "full_crypto")] +pub enum DeriveError { + /// A soft key was found in the path (and is unsupported). + #[cfg_attr(feature = "std", error("Soft key in path"))] + SoftKeyInPath, +} + /// A since derivation junction description. It is the single parameter used when creating /// a new secret key from an existing secret key and, in the case of `SoftRaw` and `SoftIndex` /// a new public key from an existing public key. @@ -691,40 +699,45 @@ mod dummy { type Public = Dummy; type Seed = Dummy; type Signature = Dummy; - type DeriveError = (); + #[cfg(feature = "std")] fn generate_with_phrase(_: Option<&str>) -> (Self, String, Self::Seed) { Default::default() } + #[cfg(feature = "std")] fn from_phrase(_: &str, _: Option<&str>) -> Result<(Self, Self::Seed), SecretStringError> { Ok(Default::default()) } + fn derive>( &self, _: Iter, _: Option, - ) -> Result<(Self, Option), Self::DeriveError> { + ) -> Result<(Self, Option), DeriveError> { Ok((Self, None)) } - fn from_seed(_: &Self::Seed) -> Self { - Self - } + fn from_seed_slice(_: &[u8]) -> Result { Ok(Self) } + fn sign(&self, _: &[u8]) -> Self::Signature { Self } + fn verify>(_: &Self::Signature, _: M, _: &Self::Public) -> bool { true } + fn verify_weak, M: AsRef<[u8]>>(_: &[u8], _: M, _: P) -> bool { true } + fn public(&self) -> Self::Public { Self } + fn to_raw_vec(&self) -> Vec { vec![] } @@ -845,9 +858,6 @@ pub trait Pair: CryptoType + Sized + Clone + Send + Sync + 'static { /// and verified with the message and a public key. type Signature: AsRef<[u8]>; - /// Error returned from the `derive` function. - type DeriveError; - /// Generate new secure (random) key pair. /// /// This is only for ephemeral keys really, since you won't have access to the secret key @@ -866,27 +876,47 @@ pub trait Pair: CryptoType + Sized + Clone + Send + Sync + 'static { /// This is generally slower than `generate()`, so prefer that unless you need to persist /// the key from the current session. #[cfg(feature = "std")] - fn generate_with_phrase(password: Option<&str>) -> (Self, String, Self::Seed); + fn generate_with_phrase(password: Option<&str>) -> (Self, String, Self::Seed) { + let mnemonic = Mnemonic::new(MnemonicType::Words12, Language::English); + let phrase = mnemonic.phrase(); + let (pair, seed) = Self::from_phrase(phrase, password) + .expect("All phrases generated by Mnemonic are valid; qed"); + (pair, phrase.to_owned(), seed) + } /// Returns the KeyPair from the English BIP39 seed `phrase`, or `None` if it's invalid. #[cfg(feature = "std")] fn from_phrase( phrase: &str, password: Option<&str>, - ) -> Result<(Self, Self::Seed), SecretStringError>; + ) -> Result<(Self, Self::Seed), SecretStringError> { + let mnemonic = Mnemonic::from_phrase(phrase, Language::English) + .map_err(|_| SecretStringError::InvalidPhrase)?; + let big_seed = + substrate_bip39::seed_from_entropy(mnemonic.entropy(), password.unwrap_or("")) + .map_err(|_| SecretStringError::InvalidSeed)?; + let mut seed = Self::Seed::default(); + let seed_slice = seed.as_mut(); + let seed_len = seed_slice.len(); + debug_assert!(seed_len <= big_seed.len()); + seed_slice[..seed_len].copy_from_slice(&big_seed[..seed_len]); + Self::from_seed_slice(seed_slice).map(|x| (x, seed)) + } /// Derive a child key from a series of given junctions. fn derive>( &self, path: Iter, seed: Option, - ) -> Result<(Self, Option), Self::DeriveError>; + ) -> Result<(Self, Option), DeriveError>; /// Generate new key pair from the provided `seed`. /// /// @WARNING: THIS WILL ONLY BE SECURE IF THE `seed` IS SECURE. If it can be guessed /// by an attacker then they can also derive your key. - fn from_seed(seed: &Self::Seed) -> Self; + fn from_seed(seed: &Self::Seed) -> Self { + Self::from_seed_slice(seed.as_ref()).expect("seed has valid length; qed") + } /// Make a new key pair from secret seed material. The slice must be the correct size or /// it will return `None`. @@ -1202,14 +1232,15 @@ mod tests { type Public = TestPublic; type Seed = [u8; 8]; type Signature = [u8; 0]; - type DeriveError = (); fn generate() -> (Self, ::Seed) { (TestPair::Generated, [0u8; 8]) } + fn generate_with_phrase(_password: Option<&str>) -> (Self, String, ::Seed) { (TestPair::GeneratedWithPhrase, "".into(), [0u8; 8]) } + fn from_phrase( phrase: &str, password: Option<&str>, @@ -1222,11 +1253,12 @@ mod tests { [0u8; 8], )) } + fn derive>( &self, path_iter: Iter, _: Option<[u8; 8]>, - ) -> Result<(Self, Option<[u8; 8]>), Self::DeriveError> { + ) -> Result<(Self, Option<[u8; 8]>), DeriveError> { Ok(( match self.clone() { TestPair::Standard { phrase, password, path } => TestPair::Standard { @@ -1240,21 +1272,21 @@ mod tests { if path_iter.count() == 0 { x } else { - return Err(()) + return Err(DeriveError::SoftKeyInPath) }, }, None, )) } - fn from_seed(_seed: &::Seed) -> Self { - TestPair::Seed(_seed.as_ref().to_owned()) - } + fn sign(&self, _message: &[u8]) -> Self::Signature { [] } + fn verify>(_: &Self::Signature, _: M, _: &Self::Public) -> bool { true } + fn verify_weak, M: AsRef<[u8]>>( _sig: &[u8], _message: M, @@ -1262,12 +1294,15 @@ mod tests { ) -> bool { true } + fn public(&self) -> Self::Public { TestPublic } + fn from_seed_slice(seed: &[u8]) -> Result { Ok(TestPair::Seed(seed.to_owned())) } + fn to_raw_vec(&self) -> Vec { vec![] } diff --git a/primitives/core/src/ecdsa.rs b/primitives/core/src/ecdsa.rs index d68ba39a0fb79..e63b283d26ee3 100644 --- a/primitives/core/src/ecdsa.rs +++ b/primitives/core/src/ecdsa.rs @@ -29,11 +29,9 @@ use crate::crypto::{ }; #[cfg(feature = "full_crypto")] use crate::{ - crypto::{DeriveJunction, Pair as TraitPair, SecretStringError}, + crypto::{DeriveError, DeriveJunction, Pair as TraitPair, SecretStringError}, hashing::blake2_256, }; -#[cfg(feature = "std")] -use bip39::{Language, Mnemonic, MnemonicType}; #[cfg(all(feature = "full_crypto", not(feature = "std")))] use secp256k1::Secp256k1; #[cfg(feature = "std")] @@ -367,13 +365,6 @@ fn derive_hard_junction(secret_seed: &Seed, cc: &[u8; 32]) -> Seed { ("Secp256k1HDKD", secret_seed, cc).using_encoded(sp_core_hashing::blake2_256) } -/// An error when deriving a key. -#[cfg(feature = "full_crypto")] -pub enum DeriveError { - /// A soft key was found in the path (and is unsupported). - SoftKeyInPath, -} - /// A key pair. #[cfg(feature = "full_crypto")] #[derive(Clone)] @@ -387,44 +378,6 @@ impl TraitPair for Pair { type Public = Public; type Seed = Seed; type Signature = Signature; - type DeriveError = DeriveError; - - /// Generate new secure (random) key pair and provide the recovery phrase. - /// - /// You can recover the same key later with `from_phrase`. - #[cfg(feature = "std")] - fn generate_with_phrase(password: Option<&str>) -> (Pair, String, Seed) { - let mnemonic = Mnemonic::new(MnemonicType::Words12, Language::English); - let phrase = mnemonic.phrase(); - let (pair, seed) = Self::from_phrase(phrase, password) - .expect("All phrases generated by Mnemonic are valid; qed"); - (pair, phrase.to_owned(), seed) - } - - /// Generate key pair from given recovery phrase and password. - #[cfg(feature = "std")] - fn from_phrase( - phrase: &str, - password: Option<&str>, - ) -> Result<(Pair, Seed), SecretStringError> { - let big_seed = substrate_bip39::seed_from_entropy( - Mnemonic::from_phrase(phrase, Language::English) - .map_err(|_| SecretStringError::InvalidPhrase)? - .entropy(), - password.unwrap_or(""), - ) - .map_err(|_| SecretStringError::InvalidSeed)?; - let mut seed = Seed::default(); - seed.copy_from_slice(&big_seed[0..32]); - Self::from_seed_slice(&big_seed[0..32]).map(|x| (x, seed)) - } - - /// Make a new key pair from secret seed material. - /// - /// You should never need to use this; generate(), generate_with_phrase - fn from_seed(seed: &Seed) -> Pair { - Self::from_seed_slice(&seed[..]).expect("seed has valid length; qed") - } /// Make a new key pair from secret seed material. The slice must be 32 bytes long or it /// will return `None`. diff --git a/primitives/core/src/ed25519.rs b/primitives/core/src/ed25519.rs index 76b3064ad5a44..503c127a9e06b 100644 --- a/primitives/core/src/ed25519.rs +++ b/primitives/core/src/ed25519.rs @@ -35,9 +35,7 @@ use crate::crypto::{ CryptoType, CryptoTypeId, CryptoTypePublicPair, Derive, Public as TraitPublic, UncheckedFrom, }; #[cfg(feature = "full_crypto")] -use crate::crypto::{DeriveJunction, Pair as TraitPair, SecretStringError}; -#[cfg(feature = "std")] -use bip39::{Language, Mnemonic, MnemonicType}; +use crate::crypto::{DeriveError, DeriveJunction, Pair as TraitPair, SecretStringError}; #[cfg(feature = "full_crypto")] use core::convert::TryFrom; #[cfg(feature = "full_crypto")] @@ -46,8 +44,6 @@ use ed25519_zebra::{SigningKey, VerificationKey}; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use sp_runtime_interface::pass_by::PassByInner; use sp_std::ops::Deref; -#[cfg(feature = "std")] -use substrate_bip39::seed_from_entropy; /// An identifier used to match public keys against ed25519 keys pub const CRYPTO_ID: CryptoTypeId = CryptoTypeId(*b"ed25"); @@ -385,56 +381,11 @@ fn derive_hard_junction(secret_seed: &Seed, cc: &[u8; 32]) -> Seed { ("Ed25519HDKD", secret_seed, cc).using_encoded(sp_core_hashing::blake2_256) } -/// An error when deriving a key. -#[cfg(feature = "full_crypto")] -pub enum DeriveError { - /// A soft key was found in the path (and is unsupported). - SoftKeyInPath, -} - #[cfg(feature = "full_crypto")] impl TraitPair for Pair { type Public = Public; type Seed = Seed; type Signature = Signature; - type DeriveError = DeriveError; - - /// Generate new secure (random) key pair and provide the recovery phrase. - /// - /// You can recover the same key later with `from_phrase`. - #[cfg(feature = "std")] - fn generate_with_phrase(password: Option<&str>) -> (Pair, String, Seed) { - let mnemonic = Mnemonic::new(MnemonicType::Words12, Language::English); - let phrase = mnemonic.phrase(); - let (pair, seed) = Self::from_phrase(phrase, password) - .expect("All phrases generated by Mnemonic are valid; qed"); - (pair, phrase.to_owned(), seed) - } - - /// Generate key pair from given recovery phrase and password. - #[cfg(feature = "std")] - fn from_phrase( - phrase: &str, - password: Option<&str>, - ) -> Result<(Pair, Seed), SecretStringError> { - let big_seed = seed_from_entropy( - Mnemonic::from_phrase(phrase, Language::English) - .map_err(|_| SecretStringError::InvalidPhrase)? - .entropy(), - password.unwrap_or(""), - ) - .map_err(|_| SecretStringError::InvalidSeed)?; - let mut seed = Seed::default(); - seed.copy_from_slice(&big_seed[0..32]); - Self::from_seed_slice(&big_seed[0..32]).map(|x| (x, seed)) - } - - /// Make a new key pair from secret seed material. - /// - /// You should never need to use this; generate(), generate_with_phrase - fn from_seed(seed: &Seed) -> Pair { - Self::from_seed_slice(&seed[..]).expect("seed has valid length; qed") - } /// Make a new key pair from secret seed material. The slice must be 32 bytes long or it /// will return `None`. diff --git a/primitives/core/src/sr25519.rs b/primitives/core/src/sr25519.rs index 809d83aaf08a8..8dbcca9e2673e 100644 --- a/primitives/core/src/sr25519.rs +++ b/primitives/core/src/sr25519.rs @@ -24,9 +24,7 @@ #[cfg(feature = "std")] use crate::crypto::Ss58Codec; #[cfg(feature = "full_crypto")] -use crate::crypto::{DeriveJunction, Infallible, Pair as TraitPair, SecretStringError}; -#[cfg(feature = "std")] -use bip39::{Language, Mnemonic, MnemonicType}; +use crate::crypto::{DeriveError, DeriveJunction, Pair as TraitPair, SecretStringError}; #[cfg(feature = "full_crypto")] use schnorrkel::{ derive::{ChainCode, Derivation, CHAIN_CODE_LENGTH}, @@ -34,8 +32,6 @@ use schnorrkel::{ }; #[cfg(feature = "full_crypto")] use sp_std::vec::Vec; -#[cfg(feature = "std")] -use substrate_bip39::mini_secret_from_entropy; use crate::{ crypto::{ @@ -458,16 +454,6 @@ impl TraitPair for Pair { type Public = Public; type Seed = Seed; type Signature = Signature; - type DeriveError = Infallible; - - /// Make a new key pair from raw secret seed material. - /// - /// This is generated using schnorrkel's Mini-Secret-Keys. - /// - /// A MiniSecretKey is literally what Ed25519 calls a SecretKey, which is just 32 random bytes. - fn from_seed(seed: &Seed) -> Pair { - Self::from_seed_slice(&seed[..]).expect("32 bytes can always build a key; qed") - } /// Get the public key. fn public(&self) -> Public { @@ -476,10 +462,12 @@ impl TraitPair for Pair { Public(pk) } - /// Make a new key pair from secret seed material. The slice must be 32 bytes long or it - /// will return `None`. + /// Make a new key pair from raw secret seed material. + /// + /// This is generated using schnorrkel's Mini-Secret-Keys. /// - /// You should never need to use this; generate(), generate_with_phrase(), from_phrase() + /// A `MiniSecretKey` is literally what Ed25519 calls a `SecretKey`, which is just 32 random + /// bytes. fn from_seed_slice(seed: &[u8]) -> Result { match seed.len() { MINI_SECRET_KEY_LENGTH => Ok(Pair( @@ -495,42 +483,16 @@ impl TraitPair for Pair { _ => Err(SecretStringError::InvalidSeedLength), } } - #[cfg(feature = "std")] - fn generate_with_phrase(password: Option<&str>) -> (Pair, String, Seed) { - let mnemonic = Mnemonic::new(MnemonicType::Words12, Language::English); - let phrase = mnemonic.phrase(); - let (pair, seed) = Self::from_phrase(phrase, password) - .expect("All phrases generated by Mnemonic are valid; qed"); - (pair, phrase.to_owned(), seed) - } - #[cfg(feature = "std")] - fn from_phrase( - phrase: &str, - password: Option<&str>, - ) -> Result<(Pair, Seed), SecretStringError> { - Mnemonic::from_phrase(phrase, Language::English) - .map_err(|_| SecretStringError::InvalidPhrase) - .map(|m| Self::from_entropy(m.entropy(), password)) - } fn derive>( &self, path: Iter, seed: Option, - ) -> Result<(Pair, Option), Self::DeriveError> { - let seed = if let Some(s) = seed { - if let Ok(msk) = MiniSecretKey::from_bytes(&s) { - if msk.expand(ExpansionMode::Ed25519) == self.0.secret { - Some(msk) - } else { - None - } - } else { - None - } - } else { - None - }; + ) -> Result<(Pair, Option), DeriveError> { + let seed = seed + .and_then(|s| MiniSecretKey::from_bytes(&s).ok()) + .filter(|msk| msk.expand(ExpansionMode::Ed25519) == self.0.secret); + let init = self.0.secret.clone(); let (result, seed) = path.fold((init, seed), |(acc, acc_seed), j| match (j, acc_seed) { (DeriveJunction::Soft(cc), _) => (acc.derived_key_simple(ChainCode(cc), &[]).0, None), @@ -572,18 +534,6 @@ impl TraitPair for Pair { #[cfg(feature = "std")] impl Pair { - /// Make a new key pair from binary data derived from a valid seed phrase. - /// - /// This uses a key derivation function to convert the entropy into a seed, then returns - /// the pair generated from it. - pub fn from_entropy(entropy: &[u8], password: Option<&str>) -> (Pair, Seed) { - let mini_key: MiniSecretKey = mini_secret_from_entropy(entropy, password.unwrap_or("")) - .expect("32 bytes can always build a key; qed"); - - let kp = mini_key.expand_to_keypair(ExpansionMode::Ed25519); - (Pair(kp), mini_key.to_bytes()) - } - /// Verify a signature on a message. Returns `true` if the signature is good. /// Supports old 0.1.1 deprecated signatures and should be used only for backward /// compatibility. @@ -652,10 +602,8 @@ pub fn verify_batch( #[cfg(test)] mod compatibility_test { use super::*; - use crate::crypto::DEV_PHRASE; - - // NOTE: tests to ensure addresses that are created with the `0.1.x` version (pre-audit) are - // still functional. + use crate::crypto::{Ss58Codec, DEV_ADDRESS, DEV_PHRASE}; + use serde_json; #[test] fn derive_soft_known_pair_should_work() { @@ -690,13 +638,6 @@ mod compatibility_test { assert!(Pair::verify_deprecated(&signature, &message[..], &public)); assert!(!Pair::verify(&signature, &message[..], &public)); } -} - -#[cfg(test)] -mod test { - use super::*; - use crate::crypto::{Ss58Codec, DEV_ADDRESS, DEV_PHRASE}; - use serde_json; #[test] fn default_phrase_should_be_used() { From c120cd35b2e087ff4ee54683f9ead3d93e4a30f1 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 22 Mar 2023 21:47:44 +1100 Subject: [PATCH 58/80] Fix try_runtime_cli doc broken links (#13672) --- utils/frame/try-runtime/cli/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index 34966fc2a1197..0a521d1215562 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -29,9 +29,9 @@ //! //! Some resources about the above: //! -//! 1. +//! 1. //! 2. -//! 3. +//! 3. //! //! --- //! From d6899f8215810975defe48b423f4b1b1b6fcc17e Mon Sep 17 00:00:00 2001 From: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Date: Wed, 22 Mar 2023 12:52:10 +0200 Subject: [PATCH 59/80] fix/chain_head: Ensure correct events for finalized branch (#13632) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chain_head/follow: Ensure correct events for finalized branch Signed-off-by: Alexandru Vasile * Reenable tests Signed-off-by: Alexandru Vasile * Do some clean ups and add some more docs * Fix gramatic * Update client/rpc-spec-v2/src/chain_head/chain_head_follow.rs Co-authored-by: Sebastian Kunert * rpc/chain_head: Introduce error for absent headers Signed-off-by: Alexandru Vasile --------- Signed-off-by: Alexandru Vasile Co-authored-by: Bastian Köcher Co-authored-by: Bastian Köcher Co-authored-by: Sebastian Kunert --- .../src/chain_head/chain_head_follow.rs | 100 ++++++------------ .../src/chain_head/subscription.rs | 6 +- client/rpc-spec-v2/src/chain_head/tests.rs | 6 -- 3 files changed, 34 insertions(+), 78 deletions(-) diff --git a/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs b/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs index 9173b7340b7e5..a0d19654e7959 100644 --- a/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs +++ b/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs @@ -40,10 +40,7 @@ use sp_api::CallApiAt; use sp_blockchain::{ Backend as BlockChainBackend, Error as BlockChainError, HeaderBackend, HeaderMetadata, Info, }; -use sp_runtime::{ - traits::{Block as BlockT, Header as HeaderT, One}, - Saturating, -}; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; use std::{collections::HashSet, sync::Arc}; /// Generates the events of the `chainHead_follow` method. @@ -116,7 +113,7 @@ struct StartupPoint { /// The head of the finalized chain. pub finalized_hash: Block::Hash, /// Last finalized block number. - pub finalized_number: <::Header as HeaderT>::Number, + pub finalized_number: NumberFor, } impl From> for StartupPoint { @@ -318,10 +315,7 @@ where } // Ensure we are only reporting blocks after the starting point. - let Some(block_number) = self.client.number(notification.hash)? else { - return Err(SubscriptionManagementError::BlockNumberAbsent) - }; - if block_number < startup_point.finalized_number { + if *notification.header.number() < startup_point.finalized_number { return Ok(Default::default()) } @@ -349,59 +343,48 @@ where return Ok(Default::default()) }; - // Find the parent hash. - let Some(first_number) = self.client.number(*first_hash)? else { - return Err(SubscriptionManagementError::BlockNumberAbsent) - }; - let Some(parent) = self.client.hash(first_number.saturating_sub(One::one()))? else { - return Err(SubscriptionManagementError::BlockHashAbsent) + // Find the parent header. + let Some(first_header) = self.client.header(*first_hash)? else { + return Err(SubscriptionManagementError::BlockHeaderAbsent) }; - let last_finalized = finalized_block_hashes - .last() - .expect("At least one finalized hash inserted; qed"); - let parents = std::iter::once(&parent).chain(finalized_block_hashes.iter()); - for (hash, parent) in finalized_block_hashes.iter().zip(parents) { - // This block is already reported by the import notification. + let parents = + std::iter::once(first_header.parent_hash()).chain(finalized_block_hashes.iter()); + for (i, (hash, parent)) in finalized_block_hashes.iter().zip(parents).enumerate() { + // Check if the block was already reported and thus, is already pinned. if !self.sub_handle.pin_block(*hash)? { continue } - // Generate only the `NewBlock` event for this block. - if hash != last_finalized { + // Generate `NewBlock` events for all blocks beside the last block in the list + if i + 1 != finalized_block_hashes.len() { + // Generate only the `NewBlock` event for this block. events.extend(self.generate_import_events(*hash, *parent, false)); - continue - } - - match self.best_block_cache { - Some(best_block_hash) => { - // If the best reported block is a children of the last finalized, - // then we had a gap in notification. + } else { + // If we end up here and the `best_block` is a descendent of the finalized block + // (last block in the list), it means that there were skipped notifications. + // Otherwise `pin_block` would had returned `true`. + // + // When the node falls out of sync and then syncs up to the tip of the chain, it can + // happen that we skip notifications. Then it is better to terminate the connection + // instead of trying to send notifications for all missed blocks. + if let Some(best_block_hash) = self.best_block_cache { let ancestor = sp_blockchain::lowest_common_ancestor( &*self.client, - *last_finalized, + *hash, best_block_hash, )?; - // A descendent of the finalized block was already reported - // before the `NewBlock` event containing the finalized block - // is reported. - if ancestor.hash == *last_finalized { + if ancestor.hash == *hash { return Err(SubscriptionManagementError::Custom( "A descendent of the finalized block was already reported".into(), )) } - self.best_block_cache = Some(*hash); - }, - // This is the first best block event that we generate. - None => { - self.best_block_cache = Some(*hash); - }, - }; + } - // This is the first time we see this block. Generate the `NewBlock` event; if this is - // the last block, also generate the `BestBlock` event. - events.extend(self.generate_import_events(*hash, *parent, true)) + // Let's generate the `NewBlock` and `NewBestBlock` events for the block. + events.extend(self.generate_import_events(*hash, *parent, true)) + } } Ok(events) @@ -448,17 +431,13 @@ where let last_finalized = notification.hash; // Ensure we are only reporting blocks after the starting point. - let Some(block_number) = self.client.number(last_finalized)? else { - return Err(SubscriptionManagementError::BlockNumberAbsent) - }; - if block_number < startup_point.finalized_number { + if *notification.header.number() < startup_point.finalized_number { return Ok(Default::default()) } // The tree route contains the exclusive path from the last finalized block to the block // reported by the notification. Ensure the finalized block is also reported. - let mut finalized_block_hashes = - notification.tree_route.iter().cloned().collect::>(); + let mut finalized_block_hashes = notification.tree_route.to_vec(); finalized_block_hashes.push(last_finalized); // If the finalized hashes were not reported yet, generate the `NewBlock` events. @@ -476,9 +455,8 @@ where match self.best_block_cache { Some(block_cache) => { - // Check if the current best block is also reported as pruned. - let reported_pruned = pruned_block_hashes.iter().find(|&&hash| hash == block_cache); - if reported_pruned.is_none() { + // If the best block wasn't pruned, we are done here. + if !pruned_block_hashes.iter().any(|hash| *hash == block_cache) { events.push(finalized_event); return Ok(events) } @@ -499,20 +477,6 @@ where events.push(finalized_event); Ok(events) } else { - let ancestor = sp_blockchain::lowest_common_ancestor( - &*self.client, - last_finalized, - best_block_hash, - )?; - - // The client's best block must be a descendent of the last finalized block. - // In other words, the lowest common ancestor must be the last finalized block. - if ancestor.hash != last_finalized { - return Err(SubscriptionManagementError::Custom( - "The finalized block is not an ancestor of the best block".into(), - )) - } - // The RPC needs to also submit a new best block changed before the // finalized event. self.best_block_cache = Some(best_block_hash); diff --git a/client/rpc-spec-v2/src/chain_head/subscription.rs b/client/rpc-spec-v2/src/chain_head/subscription.rs index 77d57e747ebc1..687374bba5e00 100644 --- a/client/rpc-spec-v2/src/chain_head/subscription.rs +++ b/client/rpc-spec-v2/src/chain_head/subscription.rs @@ -36,10 +36,8 @@ pub enum SubscriptionManagementError { ExceededLimits, /// Error originated from the blockchain (client or backend). Blockchain(Error), - /// The database does not contain a block number. - BlockNumberAbsent, - /// The database does not contain a block hash. - BlockHashAbsent, + /// The database does not contain a block header. + BlockHeaderAbsent, /// Custom error. Custom(String), } diff --git a/client/rpc-spec-v2/src/chain_head/tests.rs b/client/rpc-spec-v2/src/chain_head/tests.rs index 0110c97a05910..fcd906dcf5be0 100644 --- a/client/rpc-spec-v2/src/chain_head/tests.rs +++ b/client/rpc-spec-v2/src/chain_head/tests.rs @@ -1024,9 +1024,6 @@ async fn follow_prune_best_block() { } #[tokio::test] -#[cfg(disable_flaky)] -#[allow(dead_code)] -// FIXME: https://github.com/paritytech/substrate/issues/11321 async fn follow_forks_pruned_block() { let builder = TestClientBuilder::new(); let backend = builder.backend(); @@ -1140,9 +1137,6 @@ async fn follow_forks_pruned_block() { } #[tokio::test] -#[cfg(disable_flaky)] -#[allow(dead_code)] -// FIXME: https://github.com/paritytech/substrate/issues/11321 async fn follow_report_multiple_pruned_block() { let builder = TestClientBuilder::new(); let backend = builder.backend(); From 8bd57418b79d2450079755c0d631168b8fad2e97 Mon Sep 17 00:00:00 2001 From: Kasper Ziemianek Date: Wed, 22 Mar 2023 13:13:31 +0100 Subject: [PATCH 60/80] GetCallIndex trait (#13558) * GetCallIndex trait * final impl * ".git/.scripts/commands/fmt/fmt.sh" * Docs Signed-off-by: Oliver Tale-Yazdi * One more test Signed-off-by: Oliver Tale-Yazdi * Doc Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi Co-authored-by: command-bot <> Co-authored-by: Oliver Tale-Yazdi --- frame/support/procedural/src/lib.rs | 3 +- .../procedural/src/pallet/expand/call.rs | 15 ++++++++++ frame/support/src/dispatch.rs | 3 +- frame/support/src/traits.rs | 4 +-- frame/support/src/traits/metadata.rs | 10 ++++++- frame/support/test/tests/pallet.rs | 29 +++++++++++++++++-- 6 files changed, 56 insertions(+), 8 deletions(-) diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 0515a4b7d2f91..45f22202991e8 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -984,7 +984,8 @@ pub fn compact(_: TokenStream, _: TokenStream) -> TokenStream { /// /// The macro creates an enum `Call` with one variant per dispatchable. This enum implements: /// [`Clone`], [`Eq`], [`PartialEq`], [`Debug`] (with stripped implementation in `not("std")`), -/// `Encode`, `Decode`, `GetDispatchInfo`, `GetCallName`, and `UnfilteredDispatchable`. +/// `Encode`, `Decode`, `GetDispatchInfo`, `GetCallName`, `GetCallIndex` and +/// `UnfilteredDispatchable`. /// /// The macro implements the `Callable` trait on `Pallet` and a function `call_functions` /// which returns the dispatchable metadata. diff --git a/frame/support/procedural/src/pallet/expand/call.rs b/frame/support/procedural/src/pallet/expand/call.rs index 7672609a9881e..0fdf4455ae7d0 100644 --- a/frame/support/procedural/src/pallet/expand/call.rs +++ b/frame/support/procedural/src/pallet/expand/call.rs @@ -324,6 +324,21 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { } } + impl<#type_impl_gen> #frame_support::dispatch::GetCallIndex for #call_ident<#type_use_gen> + #where_clause + { + fn get_call_index(&self) -> u8 { + match *self { + #( Self::#fn_name { .. } => #call_index, )* + Self::__Ignore(_, _) => unreachable!("__PhantomItem cannot be used."), + } + } + + fn get_call_indices() -> &'static [u8] { + &[ #( #call_index, )* ] + } + } + impl<#type_impl_gen> #frame_support::traits::UnfilteredDispatchable for #call_ident<#type_use_gen> #where_clause diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 390555b02d1bb..1b87acb4db8dd 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -29,7 +29,8 @@ pub use crate::{ result, }, traits::{ - CallMetadata, GetCallMetadata, GetCallName, GetStorageVersion, UnfilteredDispatchable, + CallMetadata, GetCallIndex, GetCallMetadata, GetCallName, GetStorageVersion, + UnfilteredDispatchable, }, }; #[cfg(feature = "std")] diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index 4b92cfbaee69c..17d2fb06c8118 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -74,8 +74,8 @@ pub use randomness::Randomness; mod metadata; pub use metadata::{ - CallMetadata, CrateVersion, GetCallMetadata, GetCallName, GetStorageVersion, PalletInfo, - PalletInfoAccess, PalletInfoData, PalletsInfoAccess, StorageVersion, + CallMetadata, CrateVersion, GetCallIndex, GetCallMetadata, GetCallName, GetStorageVersion, + PalletInfo, PalletInfoAccess, PalletInfoData, PalletsInfoAccess, StorageVersion, STORAGE_VERSION_STORAGE_KEY_POSTFIX, }; diff --git a/frame/support/src/traits/metadata.rs b/frame/support/src/traits/metadata.rs index f3e4b955da4a9..20ddb1d34ca1a 100644 --- a/frame/support/src/traits/metadata.rs +++ b/frame/support/src/traits/metadata.rs @@ -101,12 +101,20 @@ pub struct CallMetadata { /// Gets the function name of the Call. pub trait GetCallName { - /// Return all function names. + /// Return all function names in the same order as [`GetCallIndex`]. fn get_call_names() -> &'static [&'static str]; /// Return the function name of the Call. fn get_call_name(&self) -> &'static str; } +/// Gets the function index of the Call. +pub trait GetCallIndex { + /// Return all call indices in the same order as [`GetCallName`]. + fn get_call_indices() -> &'static [u8]; + /// Return the index of this Call. + fn get_call_index(&self) -> u8; +} + /// Gets the metadata for the Call - function name and pallet name. pub trait GetCallMetadata { /// Return all module names. diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index b9e531fb42105..52acdc5c26e03 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -25,8 +25,8 @@ use frame_support::{ pallet_prelude::{StorageInfoTrait, ValueQuery}, storage::unhashed, traits::{ - ConstU32, GetCallName, GetStorageVersion, OnFinalize, OnGenesis, OnInitialize, - OnRuntimeUpgrade, PalletError, PalletInfoAccess, StorageVersion, + ConstU32, GetCallIndex, GetCallName, GetStorageVersion, OnFinalize, OnGenesis, + OnInitialize, OnRuntimeUpgrade, PalletError, PalletInfoAccess, StorageVersion, }, weights::{RuntimeDbWeight, Weight}, }; @@ -231,6 +231,12 @@ pub mod pallet { Ok(().into()) } + #[pallet::call_index(4)] + #[pallet::weight(1)] + pub fn foo_index_out_of_order(_origin: OriginFor) -> DispatchResult { + Ok(()) + } + // Test for DispatchResult return type #[pallet::call_index(2)] #[pallet::weight(1)] @@ -728,8 +734,25 @@ fn call_expand() { assert_eq!(call_foo.get_call_name(), "foo"); assert_eq!( pallet::Call::::get_call_names(), - &["foo", "foo_storage_layer", "foo_no_post_info", "check_for_dispatch_context"], + &[ + "foo", + "foo_storage_layer", + "foo_index_out_of_order", + "foo_no_post_info", + "check_for_dispatch_context" + ], ); + + assert_eq!(call_foo.get_call_index(), 0u8); + assert_eq!(pallet::Call::::get_call_indices(), &[0u8, 1u8, 4u8, 2u8, 3u8]) +} + +#[test] +fn call_expand_index() { + let call_foo = pallet::Call::::foo_index_out_of_order {}; + + assert_eq!(call_foo.get_call_index(), 4u8); + assert_eq!(pallet::Call::::get_call_indices(), &[0u8, 1u8, 4u8, 2u8, 3u8]) } #[test] From a9e85ae50d0efbf66f9a715af3b31bf37b884a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 22 Mar 2023 20:46:35 +0100 Subject: [PATCH 61/80] Remove unused trait (#13682) --- primitives/core/src/traits.rs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/primitives/core/src/traits.rs b/primitives/core/src/traits.rs index 0e42ee3ad4b12..091b1cdb14a34 100644 --- a/primitives/core/src/traits.rs +++ b/primitives/core/src/traits.rs @@ -181,19 +181,6 @@ impl TaskExecutorExt { } } -/// Runtime spawn extension. -pub trait RuntimeSpawn: Send { - /// Create new runtime instance and use dynamic dispatch to invoke with specified payload. - /// - /// Returns handle of the spawned task. - /// - /// Function pointers (`dispatcher_ref`, `func`) are WASM pointer types. - fn spawn_call(&self, dispatcher_ref: u32, func: u32, payload: Vec) -> u64; - - /// Join the result of previously created runtime instance invocation. - fn join(&self, handle: u64) -> Vec; -} - /// Something that can spawn tasks (blocking and non-blocking) with an assigned name /// and optional group. #[dyn_clonable::clonable] From 118414302ace70fff0a913fe7ee825569c16c612 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Thu, 23 Mar 2023 11:35:39 +0100 Subject: [PATCH 62/80] Remove unused light-client leftover (#13687) * Remove unused light-client leftover * Remove more unused code --- client/network/sync/src/engine.rs | 39 +------------------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/client/network/sync/src/engine.rs b/client/network/sync/src/engine.rs index e6e62101ffcd0..a9c9afc3c6f4c 100644 --- a/client/network/sync/src/engine.rs +++ b/client/network/sync/src/engine.rs @@ -58,10 +58,7 @@ use sc_network_common::{ use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender}; use sp_blockchain::HeaderMetadata; use sp_consensus::block_validation::BlockAnnounceValidator; -use sp_runtime::{ - traits::{Block as BlockT, CheckedSub, Header, NumberFor, Zero}, - SaturatedConversion, -}; +use sp_runtime::traits::{Block as BlockT, Header, NumberFor, Zero}; use std::{ collections::{HashMap, HashSet}, @@ -77,24 +74,15 @@ use std::{ /// Interval at which we perform time based maintenance const TICK_TIMEOUT: std::time::Duration = std::time::Duration::from_millis(1100); -/// When light node connects to the full node and the full node is behind light node -/// for at least `LIGHT_MAXIMAL_BLOCKS_DIFFERENCE` blocks, we consider it not useful -/// and disconnect to free connection slot. -const LIGHT_MAXIMAL_BLOCKS_DIFFERENCE: u64 = 8192; - /// Maximum number of known block hashes to keep for a peer. const MAX_KNOWN_BLOCKS: usize = 1024; // ~32kb per peer + LruHashSet overhead mod rep { use sc_peerset::ReputationChange as Rep; - /// Reputation change when we are a light client and a peer is behind us. - pub const PEER_BEHIND_US_LIGHT: Rep = Rep::new(-(1 << 8), "Useless for a light peer"); /// We received a message that failed to decode. pub const BAD_MESSAGE: Rep = Rep::new(-(1 << 12), "Bad message"); /// Peer has different genesis. pub const GENESIS_MISMATCH: Rep = Rep::new_fatal("Genesis mismatch"); - /// Peer role does not match (e.g. light peer connecting to another light peer). - pub const BAD_ROLE: Rep = Rep::new_fatal("Unsupported role"); /// Peer send us a block announcement that failed at validation. pub const BAD_BLOCK_ANNOUNCEMENT: Rep = Rep::new(-(1 << 12), "Bad block announcement"); } @@ -834,31 +822,6 @@ where return Err(()) } - if self.roles.is_light() { - // we're not interested in light peers - if status.roles.is_light() { - log::debug!(target: "sync", "Peer {} is unable to serve light requests", who); - self.network_service.report_peer(who, rep::BAD_ROLE); - self.network_service - .disconnect_peer(who, self.block_announce_protocol_name.clone()); - return Err(()) - } - - // we don't interested in peers that are far behind us - let self_best_block = self.client.info().best_number; - let blocks_difference = self_best_block - .checked_sub(&status.best_number) - .unwrap_or_else(Zero::zero) - .saturated_into::(); - if blocks_difference > LIGHT_MAXIMAL_BLOCKS_DIFFERENCE { - log::debug!(target: "sync", "Peer {} is far behind us and will unable to serve light requests", who); - self.network_service.report_peer(who, rep::PEER_BEHIND_US_LIGHT); - self.network_service - .disconnect_peer(who, self.block_announce_protocol_name.clone()); - return Err(()) - } - } - let no_slot_peer = self.default_peers_set_no_slot_peers.contains(&who); let this_peer_reserved_slot: usize = if no_slot_peer { 1 } else { 0 }; From 988f6add941b57ceb2af00ab815b3727f03fc1fb Mon Sep 17 00:00:00 2001 From: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Date: Thu, 23 Mar 2023 15:40:02 +0200 Subject: [PATCH 63/80] chain_head/tests: Check finalized block event before new block (#13680) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chain_head/tests: Mock client for custom block notification Signed-off-by: Alexandru Vasile * chain_head/tests: Check finalized block event before new block Signed-off-by: Alexandru Vasile * Update client/rpc-spec-v2/src/chain_head/test_utils.rs Co-authored-by: Bastian Köcher * Update client/rpc-spec-v2/src/chain_head/test_utils.rs Co-authored-by: Bastian Köcher * Update client/rpc-spec-v2/src/chain_head/test_utils.rs Co-authored-by: Bastian Köcher * chain_head/tests: Run import events with 10min timeout Signed-off-by: Alexandru Vasile * chain_head/tests: Add comments about test Signed-off-by: Alexandru Vasile --------- Signed-off-by: Alexandru Vasile Co-authored-by: Bastian Köcher --- Cargo.lock | 3 +- client/rpc-spec-v2/Cargo.toml | 1 + client/rpc-spec-v2/src/chain_head/mod.rs | 2 + .../rpc-spec-v2/src/chain_head/test_utils.rs | 320 ++++++++++++++++++ client/rpc-spec-v2/src/chain_head/tests.rs | 103 +++++- 5 files changed, 427 insertions(+), 2 deletions(-) create mode 100644 client/rpc-spec-v2/src/chain_head/test_utils.rs diff --git a/Cargo.lock b/Cargo.lock index 5b2879e1ba9b6..a645ecec60d86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9275,6 +9275,7 @@ dependencies = [ "sc-chain-spec", "sc-client-api", "sc-transaction-pool-api", + "sc-utils", "serde", "serde_json", "sp-api", @@ -11954,7 +11955,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.6", - "rand 0.7.3", + "rand 0.8.5", "static_assertions", ] diff --git a/client/rpc-spec-v2/Cargo.toml b/client/rpc-spec-v2/Cargo.toml index 43fb189081bae..23b96877f3b17 100644 --- a/client/rpc-spec-v2/Cargo.toml +++ b/client/rpc-spec-v2/Cargo.toml @@ -43,4 +43,5 @@ substrate-test-runtime = { version = "2.0.0", path = "../../test-utils/runtime" sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" } sp-maybe-compressed-blob = { version = "4.1.0-dev", path = "../../primitives/maybe-compressed-blob" } sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" } +sc-utils = { version = "4.0.0-dev", path = "../utils" } assert_matches = "1.3.0" diff --git a/client/rpc-spec-v2/src/chain_head/mod.rs b/client/rpc-spec-v2/src/chain_head/mod.rs index afa8d3b2189ae..1c489d323f195 100644 --- a/client/rpc-spec-v2/src/chain_head/mod.rs +++ b/client/rpc-spec-v2/src/chain_head/mod.rs @@ -22,6 +22,8 @@ //! //! Methods are prefixed by `chainHead`. +#[cfg(test)] +mod test_utils; #[cfg(test)] mod tests; diff --git a/client/rpc-spec-v2/src/chain_head/test_utils.rs b/client/rpc-spec-v2/src/chain_head/test_utils.rs new file mode 100644 index 0000000000000..ee563debb4502 --- /dev/null +++ b/client/rpc-spec-v2/src/chain_head/test_utils.rs @@ -0,0 +1,320 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use parking_lot::Mutex; +use sc_client_api::{ + execution_extensions::ExecutionExtensions, BlockBackend, BlockImportNotification, + BlockchainEvents, CallExecutor, ChildInfo, ExecutorProvider, FinalityNotification, + FinalityNotifications, FinalizeSummary, ImportNotifications, KeysIter, PairsIter, StorageData, + StorageEventStream, StorageKey, StorageProvider, +}; +use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedSender}; +use sp_api::{CallApiAt, CallApiAtParams, NumberFor, RuntimeVersion}; +use sp_blockchain::{BlockStatus, CachedHeaderMetadata, HeaderBackend, HeaderMetadata, Info}; +use sp_consensus::BlockOrigin; +use sp_runtime::{ + generic::SignedBlock, + traits::{Block as BlockT, Header as HeaderT}, + Justifications, +}; +use std::sync::Arc; +use substrate_test_runtime::{Block, Hash, Header}; + +pub struct ChainHeadMockClient { + client: Arc, + import_sinks: Mutex>>>, + finality_sinks: Mutex>>>, +} + +impl ChainHeadMockClient { + pub fn new(client: Arc) -> Self { + ChainHeadMockClient { + client, + import_sinks: Default::default(), + finality_sinks: Default::default(), + } + } + + pub async fn trigger_import_stream(&self, header: Header) { + // Ensure the client called the `import_notification_stream`. + while self.import_sinks.lock().is_empty() { + tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; + } + + // Build the notification. + let (sink, _stream) = tracing_unbounded("test_sink", 100_000); + let notification = + BlockImportNotification::new(header.hash(), BlockOrigin::Own, header, true, None, sink); + + for sink in self.import_sinks.lock().iter_mut() { + sink.unbounded_send(notification.clone()).unwrap(); + } + } + + pub async fn trigger_finality_stream(&self, header: Header) { + // Ensure the client called the `finality_notification_stream`. + while self.finality_sinks.lock().is_empty() { + tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; + } + + // Build the notification. + let (sink, _stream) = tracing_unbounded("test_sink", 100_000); + let summary = FinalizeSummary { + header: header.clone(), + finalized: vec![header.hash()], + stale_heads: vec![], + }; + let notification = FinalityNotification::from_summary(summary, sink); + + for sink in self.finality_sinks.lock().iter_mut() { + sink.unbounded_send(notification.clone()).unwrap(); + } + } +} + +// ChainHead calls `import_notification_stream` and `finality_notification_stream` in order to +// subscribe to block events. +impl BlockchainEvents for ChainHeadMockClient { + fn import_notification_stream(&self) -> ImportNotifications { + let (sink, stream) = tracing_unbounded("import_notification_stream", 1024); + self.import_sinks.lock().push(sink); + stream + } + + fn every_import_notification_stream(&self) -> ImportNotifications { + unimplemented!() + } + + fn finality_notification_stream(&self) -> FinalityNotifications { + let (sink, stream) = tracing_unbounded("finality_notification_stream", 1024); + self.finality_sinks.lock().push(sink); + stream + } + + fn storage_changes_notification_stream( + &self, + _filter_keys: Option<&[StorageKey]>, + _child_filter_keys: Option<&[(StorageKey, Option>)]>, + ) -> sp_blockchain::Result> { + unimplemented!() + } +} + +// The following implementations are imposed by the `chainHead` trait bounds. + +impl, Client: ExecutorProvider> + ExecutorProvider for ChainHeadMockClient +{ + type Executor = >::Executor; + + fn executor(&self) -> &Self::Executor { + self.client.executor() + } + + fn execution_extensions(&self) -> &ExecutionExtensions { + self.client.execution_extensions() + } +} + +impl< + BE: sc_client_api::backend::Backend + Send + Sync + 'static, + Block: BlockT, + Client: StorageProvider, + > StorageProvider for ChainHeadMockClient +{ + fn storage( + &self, + hash: Block::Hash, + key: &StorageKey, + ) -> sp_blockchain::Result> { + self.client.storage(hash, key) + } + + fn storage_hash( + &self, + hash: Block::Hash, + key: &StorageKey, + ) -> sp_blockchain::Result> { + self.client.storage_hash(hash, key) + } + + fn storage_keys( + &self, + hash: Block::Hash, + prefix: Option<&StorageKey>, + start_key: Option<&StorageKey>, + ) -> sp_blockchain::Result> { + self.client.storage_keys(hash, prefix, start_key) + } + + fn storage_pairs( + &self, + hash: ::Hash, + prefix: Option<&StorageKey>, + start_key: Option<&StorageKey>, + ) -> sp_blockchain::Result> { + self.client.storage_pairs(hash, prefix, start_key) + } + + fn child_storage( + &self, + hash: Block::Hash, + child_info: &ChildInfo, + key: &StorageKey, + ) -> sp_blockchain::Result> { + self.client.child_storage(hash, child_info, key) + } + + fn child_storage_keys( + &self, + hash: Block::Hash, + child_info: ChildInfo, + prefix: Option<&StorageKey>, + start_key: Option<&StorageKey>, + ) -> sp_blockchain::Result> { + self.client.child_storage_keys(hash, child_info, prefix, start_key) + } + + fn child_storage_hash( + &self, + hash: Block::Hash, + child_info: &ChildInfo, + key: &StorageKey, + ) -> sp_blockchain::Result> { + self.client.child_storage_hash(hash, child_info, key) + } +} + +impl> CallApiAt for ChainHeadMockClient { + type StateBackend = >::StateBackend; + + fn call_api_at( + &self, + params: CallApiAtParams>::StateBackend>, + ) -> Result, sp_api::ApiError> { + self.client.call_api_at(params) + } + + fn runtime_version_at(&self, hash: Block::Hash) -> Result { + self.client.runtime_version_at(hash) + } + + fn state_at(&self, at: Block::Hash) -> Result { + self.client.state_at(at) + } +} + +impl> BlockBackend + for ChainHeadMockClient +{ + fn block_body( + &self, + hash: Block::Hash, + ) -> sp_blockchain::Result::Extrinsic>>> { + self.client.block_body(hash) + } + + fn block(&self, hash: Block::Hash) -> sp_blockchain::Result>> { + self.client.block(hash) + } + + fn block_status(&self, hash: Block::Hash) -> sp_blockchain::Result { + self.client.block_status(hash) + } + + fn justifications(&self, hash: Block::Hash) -> sp_blockchain::Result> { + self.client.justifications(hash) + } + + fn block_hash(&self, number: NumberFor) -> sp_blockchain::Result> { + self.client.block_hash(number) + } + + fn indexed_transaction(&self, hash: Block::Hash) -> sp_blockchain::Result>> { + self.client.indexed_transaction(hash) + } + + fn has_indexed_transaction(&self, hash: Block::Hash) -> sp_blockchain::Result { + self.client.has_indexed_transaction(hash) + } + + fn block_indexed_body(&self, hash: Block::Hash) -> sp_blockchain::Result>>> { + self.client.block_indexed_body(hash) + } + fn requires_full_sync(&self) -> bool { + self.client.requires_full_sync() + } +} + +impl + Send + Sync> HeaderMetadata + for ChainHeadMockClient +{ + type Error = >::Error; + + fn header_metadata( + &self, + hash: Block::Hash, + ) -> Result, Self::Error> { + self.client.header_metadata(hash) + } + + fn insert_header_metadata( + &self, + hash: Block::Hash, + header_metadata: CachedHeaderMetadata, + ) { + self.client.insert_header_metadata(hash, header_metadata) + } + + fn remove_header_metadata(&self, hash: Block::Hash) { + self.client.remove_header_metadata(hash) + } +} + +impl + Send + Sync> HeaderBackend + for ChainHeadMockClient +{ + fn header( + &self, + hash: Block::Hash, + ) -> sp_blockchain::Result::Header>> { + self.client.header(hash) + } + + fn info(&self) -> Info { + self.client.info() + } + + fn status(&self, hash: Block::Hash) -> sc_client_api::blockchain::Result { + self.client.status(hash) + } + + fn number( + &self, + hash: Block::Hash, + ) -> sc_client_api::blockchain::Result::Header as HeaderT>::Number>> { + self.client.number(hash) + } + + fn hash( + &self, + number: <::Header as HeaderT>::Number, + ) -> sp_blockchain::Result> { + self.client.hash(number) + } +} diff --git a/client/rpc-spec-v2/src/chain_head/tests.rs b/client/rpc-spec-v2/src/chain_head/tests.rs index fcd906dcf5be0..1d5cb8da26305 100644 --- a/client/rpc-spec-v2/src/chain_head/tests.rs +++ b/client/rpc-spec-v2/src/chain_head/tests.rs @@ -1,6 +1,9 @@ +use crate::chain_head::test_utils::ChainHeadMockClient; + use super::*; use assert_matches::assert_matches; use codec::{Decode, Encode}; +use futures::Future; use jsonrpsee::{ core::{error::Error, server::rpc_module::Subscription as RpcSubscription}, types::{error::CallError, EmptyServerParams as EmptyParams}, @@ -33,7 +36,7 @@ const CHILD_STORAGE_KEY: &[u8] = b"child"; const CHILD_VALUE: &[u8] = b"child value"; async fn get_next_event(sub: &mut RpcSubscription) -> T { - let (event, _sub_id) = tokio::time::timeout(std::time::Duration::from_secs(1), sub.next()) + let (event, _sub_id) = tokio::time::timeout(std::time::Duration::from_secs(60), sub.next()) .await .unwrap() .unwrap() @@ -41,6 +44,12 @@ async fn get_next_event(sub: &mut RpcSubscriptio event } +async fn run_with_timeout(future: F) -> ::Output { + tokio::time::timeout(std::time::Duration::from_secs(60 * 10), future) + .await + .unwrap() +} + async fn setup_api() -> ( Arc>, RpcModule>>, @@ -1317,3 +1326,95 @@ async fn follow_report_multiple_pruned_block() { }); assert_eq!(event, expected); } + +#[tokio::test] +async fn follow_finalized_before_new_block() { + let builder = TestClientBuilder::new(); + let backend = builder.backend(); + let mut client = Arc::new(builder.build()); + + let client_mock = Arc::new(ChainHeadMockClient::new(client.clone())); + + let api = ChainHead::new( + client_mock.clone(), + backend, + Arc::new(TaskExecutor::default()), + CHAIN_GENESIS, + MAX_PINNED_BLOCKS, + ) + .into_rpc(); + + // Make sure the block is imported for it to be pinned. + let block_1 = client.new_block(Default::default()).unwrap().build().unwrap().block; + let block_1_hash = block_1.header.hash(); + client.import(BlockOrigin::Own, block_1.clone()).await.unwrap(); + + let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap(); + + // Trigger the `FinalizedNotification` for block 1 before the `BlockImportNotification`, and + // expect for the `chainHead` to generate `NewBlock`, `BestBlock` and `Finalized` events. + + // Trigger the Finalized notification before the NewBlock one. + run_with_timeout(client_mock.trigger_finality_stream(block_1.header.clone())).await; + + // Initialized must always be reported first. + let finalized_hash = client.info().finalized_hash; + let event: FollowEvent = get_next_event(&mut sub).await; + let expected = FollowEvent::Initialized(Initialized { + finalized_block_hash: format!("{:?}", finalized_hash), + finalized_block_runtime: None, + runtime_updates: false, + }); + assert_eq!(event, expected); + + // Block 1 must be reported because we triggered the finalized notification. + let event: FollowEvent = get_next_event(&mut sub).await; + let expected = FollowEvent::NewBlock(NewBlock { + block_hash: format!("{:?}", block_1_hash), + parent_block_hash: format!("{:?}", finalized_hash), + new_runtime: None, + runtime_updates: false, + }); + assert_eq!(event, expected); + + let event: FollowEvent = get_next_event(&mut sub).await; + let expected = FollowEvent::BestBlockChanged(BestBlockChanged { + best_block_hash: format!("{:?}", block_1_hash), + }); + assert_eq!(event, expected); + + let event: FollowEvent = get_next_event(&mut sub).await; + let expected = FollowEvent::Finalized(Finalized { + finalized_block_hashes: vec![format!("{:?}", block_1_hash)], + pruned_block_hashes: vec![], + }); + assert_eq!(event, expected); + + let block_2 = client.new_block(Default::default()).unwrap().build().unwrap().block; + let block_2_hash = block_2.header.hash(); + client.import(BlockOrigin::Own, block_2.clone()).await.unwrap(); + + // Triggering the `BlockImportNotification` notification for block 1 should have no effect + // on the notification because the events were handled by the `FinalizedNotification`. + // Also trigger the `BlockImportNotification` notification for block 2 to ensure + // `NewBlock and `BestBlock` events are generated. + + // Trigger NewBlock notification for block 1 and block 2. + run_with_timeout(client_mock.trigger_import_stream(block_1.header)).await; + run_with_timeout(client_mock.trigger_import_stream(block_2.header)).await; + + let event: FollowEvent = get_next_event(&mut sub).await; + let expected = FollowEvent::NewBlock(NewBlock { + block_hash: format!("{:?}", block_2_hash), + parent_block_hash: format!("{:?}", block_1_hash), + new_runtime: None, + runtime_updates: false, + }); + assert_eq!(event, expected); + + let event: FollowEvent = get_next_event(&mut sub).await; + let expected = FollowEvent::BestBlockChanged(BestBlockChanged { + best_block_hash: format!("{:?}", block_2_hash), + }); + assert_eq!(event, expected); +} From 905861780ee0f6556d915a70a7a49371fc1fad2c Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 23 Mar 2023 18:09:29 +0100 Subject: [PATCH 64/80] Remove Weight::without_{ref_time, proof_size} (#13637) Signed-off-by: Oliver Tale-Yazdi --- primitives/weights/src/weight_v2.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/primitives/weights/src/weight_v2.rs b/primitives/weights/src/weight_v2.rs index 76c40c16cbf03..ca137145920bb 100644 --- a/primitives/weights/src/weight_v2.rs +++ b/primitives/weights/src/weight_v2.rs @@ -74,16 +74,6 @@ impl Weight { &mut self.proof_size } - /// Return self but discard any reference time. - pub const fn without_ref_time(&self) -> Self { - Self { ref_time: 0, proof_size: self.proof_size } - } - - /// Return self but discard any proof size. - pub const fn without_proof_size(&self) -> Self { - Self { ref_time: self.ref_time, proof_size: 0 } - } - pub const MAX: Self = Self { ref_time: u64::MAX, proof_size: u64::MAX }; /// Get the conservative min of `self` and `other` weight. From bf395c8308c481a9774373e0b0b14bd7a2e4b8d2 Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Fri, 24 Mar 2023 14:46:02 +0100 Subject: [PATCH 65/80] Keystore overhaul (final) (#13683) * Introduce keystore specialized sign methods * Get rid of 'AppKey::UntypedGeneric' associated type. Untyped generics are accessible using associated types 'Generic' associated type. I.e. ::Public::Generic * Get rid of 'CryptoTypePublicPair' * Trivial fix * Small refactory of local keystore implementations * Remove 'crypto_id' method from 'Public' * Trivial rename of 'AppKey' to 'AppCrypto' * Remove unused import * Improve docs * Better signature related errors for authority-discovery * Apply review suggestion * Apply review suggestions Co-authored-by: Koute * Authority discoverty signing error revisited * Signing error revisited for babe and aura as well * Further cleanup --------- Co-authored-by: Koute --- bin/node/cli/src/service.rs | 12 +- bin/node/executor/tests/submit_transaction.rs | 2 +- client/authority-discovery/src/error.rs | 9 +- client/authority-discovery/src/worker.rs | 27 ++- client/consensus/aura/src/lib.rs | 59 +++-- client/consensus/babe/rpc/src/lib.rs | 2 +- client/consensus/babe/src/authorship.rs | 2 +- client/consensus/babe/src/lib.rs | 47 ++-- client/consensus/grandpa/src/lib.rs | 2 +- client/consensus/slots/src/lib.rs | 2 +- client/keystore/src/local.rs | 214 +++++++++--------- client/rpc/src/author/tests.rs | 14 +- primitives/application-crypto/src/lib.rs | 39 +--- primitives/application-crypto/src/traits.rs | 29 ++- .../application-crypto/test/src/ecdsa.rs | 11 +- .../application-crypto/test/src/ed25519.rs | 11 +- .../application-crypto/test/src/sr25519.rs | 11 +- primitives/consensus/common/src/error.rs | 4 +- primitives/consensus/grandpa/src/lib.rs | 5 +- primitives/core/src/crypto.rs | 37 +-- primitives/core/src/ecdsa.rs | 21 +- primitives/core/src/ed25519.rs | 22 +- primitives/core/src/sr25519.rs | 23 +- primitives/io/src/lib.rs | 9 +- primitives/keystore/src/lib.rs | 191 ++++++++++------ primitives/keystore/src/testing.rs | 197 ++++++++-------- primitives/runtime/src/traits.rs | 18 +- 27 files changed, 478 insertions(+), 542 deletions(-) diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index be8553b7b3a98..ca6830085b055 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -592,7 +592,7 @@ mod tests { use sc_service_test::TestNetNode; use sc_transaction_pool_api::{ChainEvent, MaintainedTransactionPool}; use sp_consensus::{BlockOrigin, Environment, Proposer}; - use sp_core::{crypto::Pair as CryptoPair, Public}; + use sp_core::crypto::Pair; use sp_inherents::InherentDataProvider; use sp_keyring::AccountKeyring; use sp_keystore::KeystorePtr; @@ -737,16 +737,10 @@ mod tests { // add it to a digest item. let to_sign = pre_hash.encode(); let signature = keystore - .sign_with( - sp_consensus_babe::AuthorityId::ID, - &alice.to_public_crypto_pair(), - &to_sign, - ) - .unwrap() + .sr25519_sign(sp_consensus_babe::AuthorityId::ID, alice.as_ref(), &to_sign) .unwrap() - .try_into() .unwrap(); - let item = ::babe_seal(signature); + let item = ::babe_seal(signature.into()); slot += 1; let mut params = BlockImportParams::new(BlockOrigin::File, new_header); diff --git a/bin/node/executor/tests/submit_transaction.rs b/bin/node/executor/tests/submit_transaction.rs index 9bff415d27e45..b260f90a87466 100644 --- a/bin/node/executor/tests/submit_transaction.rs +++ b/bin/node/executor/tests/submit_transaction.rs @@ -18,7 +18,7 @@ use codec::Decode; use frame_system::offchain::{SendSignedTransaction, Signer, SubmitTransaction}; use kitchensink_runtime::{Executive, Indices, Runtime, UncheckedExtrinsic}; -use sp_application_crypto::AppKey; +use sp_application_crypto::AppCrypto; use sp_core::offchain::{testing::TestTransactionPoolExt, TransactionPoolExt}; use sp_keyring::sr25519::Keyring::Alice; use sp_keystore::{testing::MemoryKeystore, Keystore, KeystoreExt}; diff --git a/client/authority-discovery/src/error.rs b/client/authority-discovery/src/error.rs index 89c05b71b9ea6..447116b0f6b56 100644 --- a/client/authority-discovery/src/error.rs +++ b/client/authority-discovery/src/error.rs @@ -18,8 +18,6 @@ //! Authority discovery errors. -use sp_core::crypto::CryptoTypePublicPair; - /// AuthorityDiscovery Result. pub type Result = std::result::Result; @@ -59,11 +57,8 @@ pub enum Error { #[error("Failed to parse a libp2p key.")] ParsingLibp2pIdentity(#[from] libp2p::identity::error::DecodingError), - #[error("Failed to sign using a specific public key.")] - MissingSignature(CryptoTypePublicPair), - - #[error("Failed to sign using all public keys.")] - Signing, + #[error("Failed to sign: {0}.")] + CannotSign(String), #[error("Failed to register Prometheus metric.")] Prometheus(#[from] prometheus_endpoint::PrometheusError), diff --git a/client/authority-discovery/src/worker.rs b/client/authority-discovery/src/worker.rs index 5d7d21a5b6de4..43e44cac4d3fe 100644 --- a/client/authority-discovery/src/worker.rs +++ b/client/authority-discovery/src/worker.rs @@ -32,7 +32,7 @@ use std::{ use futures::{channel::mpsc, future, stream::Fuse, FutureExt, Stream, StreamExt}; use addr_cache::AddrCache; -use codec::Decode; +use codec::{Decode, Encode}; use ip_network::IpNetwork; use libp2p::{ core::multiaddr, @@ -43,6 +43,7 @@ use log::{debug, error, log_enabled}; use prometheus_endpoint::{register, Counter, CounterVec, Gauge, Opts, U64}; use prost::Message; use rand::{seq::SliceRandom, thread_rng}; + use sc_network::{ event::DhtEvent, KademliaKey, NetworkDHTProvider, NetworkSigner, NetworkStateInfo, Signature, }; @@ -51,8 +52,7 @@ use sp_authority_discovery::{ AuthorityDiscoveryApi, AuthorityId, AuthorityPair, AuthoritySignature, }; use sp_blockchain::HeaderBackend; - -use sp_core::crypto::{key_types, CryptoTypePublicPair, Pair}; +use sp_core::crypto::{key_types, ByteArray, Pair}; use sp_keystore::{Keystore, KeystorePtr}; use sp_runtime::traits::Block as BlockT; @@ -127,7 +127,7 @@ pub struct Worker { publish_if_changed_interval: ExpIncInterval, /// List of keys onto which addresses have been published at the latest publication. /// Used to check whether they have changed. - latest_published_keys: HashSet, + latest_published_keys: HashSet, /// Same value as in the configuration. publish_non_global_ips: bool, /// Same value as in the configuration. @@ -339,7 +339,7 @@ where let keys = Worker::::get_own_public_keys_within_authority_set( key_store.clone(), self.client.as_ref(), - ).await?.into_iter().map(Into::into).collect::>(); + ).await?.into_iter().collect::>(); if only_if_changed && keys == self.latest_published_keys { return Ok(()) @@ -654,7 +654,7 @@ fn sign_record_with_peer_id( ) -> Result { let signature = network .sign_with_local_identity(serialized_record) - .map_err(|_| Error::Signing)?; + .map_err(|e| Error::CannotSign(format!("{} (network packet)", e)))?; let public_key = signature.public_key.to_protobuf_encoding(); let signature = signature.bytes; Ok(schema::PeerSignature { signature, public_key }) @@ -664,15 +664,20 @@ fn sign_record_with_authority_ids( serialized_record: Vec, peer_signature: Option, key_store: &dyn Keystore, - keys: Vec, + keys: Vec, ) -> Result)>> { let mut result = Vec::with_capacity(keys.len()); for key in keys.iter() { let auth_signature = key_store - .sign_with(key_types::AUTHORITY_DISCOVERY, key, &serialized_record) - .map_err(|_| Error::Signing)? - .ok_or_else(|| Error::MissingSignature(key.clone()))?; + .sr25519_sign(key_types::AUTHORITY_DISCOVERY, key.as_ref(), &serialized_record) + .map_err(|e| Error::CannotSign(format!("{}. Key: {:?}", e, key)))? + .ok_or_else(|| { + Error::CannotSign(format!("Could not find key in keystore. Key: {:?}", key)) + })?; + + // Scale encode + let auth_signature = auth_signature.encode(); let signed_record = schema::SignedAuthorityRecord { record: serialized_record.clone(), @@ -681,7 +686,7 @@ fn sign_record_with_authority_ids( } .encode_to_vec(); - result.push((hash_authority_id(&key.1), signed_record)); + result.push((hash_authority_id(key.as_slice()), signed_record)); } Ok(result) diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index d06a6016a2297..a48eeac5ce8b2 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -45,7 +45,7 @@ use sc_consensus_slots::{ }; use sc_telemetry::TelemetryHandle; use sp_api::{Core, ProvideRuntimeApi}; -use sp_application_crypto::{AppKey, AppPublic}; +use sp_application_crypto::{AppCrypto, AppPublic}; use sp_blockchain::{HeaderBackend, Result as CResult}; use sp_consensus::{BlockOrigin, Environment, Error as ConsensusError, Proposer, SelectChain}; use sp_consensus_slots::Slot; @@ -205,7 +205,7 @@ pub fn start_aura( telemetry, compatibility_mode, }: StartAuraParams>, -) -> Result, sp_consensus::Error> +) -> Result, ConsensusError> where P: Pair + Send + Sync, P::Public: AppPublic + Hash + Member + Encode + Decode, @@ -222,7 +222,7 @@ where CIDP: CreateInherentDataProviders + Send + 'static, CIDP::InherentDataProviders: InherentDataProviderExt + Send, BS: BackoffAuthoringBlocksStrategy> + Send + Sync + 'static, - Error: std::error::Error + Send + From + 'static, + Error: std::error::Error + Send + From + 'static, { let worker = build_aura_worker::(BuildAuraWorkerParams { client, @@ -320,7 +320,7 @@ where P::Public: AppPublic + Hash + Member + Encode + Decode, P::Signature: TryFrom> + Hash + Member + Encode + Decode, I: BlockImport> + Send + Sync + 'static, - Error: std::error::Error + Send + From + 'static, + Error: std::error::Error + Send + From + 'static, SO: SyncOracle + Send + Sync + Clone, L: sc_consensus::JustificationSyncLink, BS: BackoffAuthoringBlocksStrategy> + Send + Sync + 'static, @@ -374,13 +374,13 @@ where SO: SyncOracle + Send + Clone + Sync, L: sc_consensus::JustificationSyncLink, BS: BackoffAuthoringBlocksStrategy> + Send + Sync + 'static, - Error: std::error::Error + Send + From + 'static, + Error: std::error::Error + Send + From + 'static, { type BlockImport = I; type SyncOracle = SO; type JustificationSyncLink = L; type CreateProposer = - Pin> + Send + 'static>>; + Pin> + Send + 'static>>; type Proposer = E::Proposer; type Claim = P::Public; type AuxData = Vec>; @@ -393,11 +393,7 @@ where &mut self.block_import } - fn aux_data( - &self, - header: &B::Header, - _slot: Slot, - ) -> Result { + fn aux_data(&self, header: &B::Header, _slot: Slot) -> Result { authorities( self.client.as_ref(), header.hash(), @@ -406,17 +402,17 @@ where ) } - fn authorities_len(&self, epoch_data: &Self::AuxData) -> Option { - Some(epoch_data.len()) + fn authorities_len(&self, authorities: &Self::AuxData) -> Option { + Some(authorities.len()) } async fn claim_slot( &self, _header: &B::Header, slot: Slot, - epoch_data: &Self::AuxData, + authorities: &Self::AuxData, ) -> Option { - let expected_author = slot_author::

(slot, epoch_data); + let expected_author = slot_author::

(slot, authorities); expected_author.and_then(|p| { if self .keystore @@ -440,29 +436,30 @@ where body: Vec, storage_changes: StorageChanges<>::Transaction, B>, public: Self::Claim, - _epoch: Self::AuxData, + _authorities: Self::AuxData, ) -> Result< sc_consensus::BlockImportParams>::Transaction>, - sp_consensus::Error, + ConsensusError, > { - // sign the pre-sealed hash of the block and then - // add it to a digest item. - let public_type_pair = public.to_public_crypto_pair(); - let public = public.to_raw_vec(); let signature = self .keystore - .sign_with( as AppKey>::ID, &public_type_pair, header_hash.as_ref()) - .map_err(|e| sp_consensus::Error::CannotSign(public.clone(), e.to_string()))? + .sign_with( + as AppCrypto>::ID, + as AppCrypto>::CRYPTO_ID, + public.as_slice(), + header_hash.as_ref(), + ) + .map_err(|e| ConsensusError::CannotSign(format!("{}. Key: {:?}", e, public)))? .ok_or_else(|| { - sp_consensus::Error::CannotSign( - public.clone(), - "Could not find key in keystore.".into(), - ) + ConsensusError::CannotSign(format!( + "Could not find key in keystore. Key: {:?}", + public + )) })?; let signature = signature .clone() .try_into() - .map_err(|_| sp_consensus::Error::InvalidSignature(signature, public))?; + .map_err(|_| ConsensusError::InvalidSignature(signature, public.to_raw_vec()))?; let signature_digest_item = >::aura_seal(signature); @@ -507,7 +504,7 @@ where fn proposer(&mut self, block: &B::Header) -> Self::CreateProposer { self.env .init(block) - .map_err(|e| sp_consensus::Error::ClientImport(format!("{:?}", e))) + .map_err(|e| ConsensusError::ClientImport(format!("{:?}", e))) .boxed() } @@ -620,14 +617,14 @@ where Default::default(), ), ) - .map_err(|_| sp_consensus::Error::InvalidAuthoritiesSet)?; + .map_err(|_| ConsensusError::InvalidAuthoritiesSet)?; }, } runtime_api .authorities(parent_hash) .ok() - .ok_or(sp_consensus::Error::InvalidAuthoritiesSet) + .ok_or(ConsensusError::InvalidAuthoritiesSet) } #[cfg(test)] diff --git a/client/consensus/babe/rpc/src/lib.rs b/client/consensus/babe/rpc/src/lib.rs index 005d84938e28e..cdc8dbfd80a34 100644 --- a/client/consensus/babe/rpc/src/lib.rs +++ b/client/consensus/babe/rpc/src/lib.rs @@ -30,7 +30,7 @@ use sc_consensus_epochs::{descendent_query, Epoch as EpochT, SharedEpochChanges} use sc_rpc_api::DenyUnsafe; use serde::{Deserialize, Serialize}; use sp_api::ProvideRuntimeApi; -use sp_application_crypto::AppKey; +use sp_application_crypto::AppCrypto; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; use sp_consensus::{Error as ConsensusError, SelectChain}; use sp_consensus_babe::{ diff --git a/client/consensus/babe/src/authorship.rs b/client/consensus/babe/src/authorship.rs index c4b43b0d074b9..3ff4c393ffd67 100644 --- a/client/consensus/babe/src/authorship.rs +++ b/client/consensus/babe/src/authorship.rs @@ -22,7 +22,7 @@ use super::Epoch; use codec::Encode; use sc_consensus_epochs::Epoch as EpochT; use schnorrkel::{keys::PublicKey, vrf::VRFInOut}; -use sp_application_crypto::AppKey; +use sp_application_crypto::AppCrypto; use sp_consensus_babe::{ digests::{PreDigest, PrimaryPreDigest, SecondaryPlainPreDigest, SecondaryVRFPreDigest}, make_transcript, make_transcript_data, AuthorityId, BabeAuthorityWeight, Slot, BABE_VRF_PREFIX, diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index e2c2793b11c9d..a59870ced0693 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -108,7 +108,7 @@ use sc_consensus_slots::{ }; use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_TRACE}; use sp_api::{ApiExt, ProvideRuntimeApi}; -use sp_application_crypto::AppKey; +use sp_application_crypto::AppCrypto; use sp_block_builder::BlockBuilder as BlockBuilderApi; use sp_blockchain::{ Backend as _, BlockStatus, Error as ClientError, ForkBackend, HeaderBackend, HeaderMetadata, @@ -117,7 +117,7 @@ use sp_blockchain::{ use sp_consensus::{BlockOrigin, Environment, Error as ConsensusError, Proposer, SelectChain}; use sp_consensus_babe::inherents::BabeInherentData; use sp_consensus_slots::Slot; -use sp_core::{crypto::ByteArray, ExecutionContext}; +use sp_core::ExecutionContext; use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider}; use sp_keystore::KeystorePtr; use sp_runtime::{ @@ -274,7 +274,7 @@ pub enum Error { MultipleConfigChangeDigests, /// Could not extract timestamp and slot #[error("Could not extract timestamp and slot: {0}")] - Extraction(sp_consensus::Error), + Extraction(ConsensusError), /// Could not fetch epoch #[error("Could not fetch epoch at {0:?}")] FetchEpoch(B::Hash), @@ -471,7 +471,7 @@ pub fn start_babe( max_block_proposal_slot_portion, telemetry, }: BabeParams, -) -> Result, sp_consensus::Error> +) -> Result, ConsensusError> where B: BlockT, C: ProvideRuntimeApi @@ -739,7 +739,7 @@ where type SyncOracle = SO; type JustificationSyncLink = L; type CreateProposer = - Pin> + Send + 'static>>; + Pin> + Send + 'static>>; type Proposer = E::Proposer; type BlockImport = I; type AuxData = ViableEpochDescriptor, Epoch>; @@ -762,7 +762,7 @@ where slot, ) .map_err(|e| ConsensusError::ChainLookup(e.to_string()))? - .ok_or(sp_consensus::Error::InvalidAuthoritiesSet) + .ok_or(ConsensusError::InvalidAuthoritiesSet) } fn authorities_len(&self, epoch_descriptor: &Self::AuxData) -> Option { @@ -827,28 +827,21 @@ where (_, public): Self::Claim, epoch_descriptor: Self::AuxData, ) -> Result< - sc_consensus::BlockImportParams>::Transaction>, - sp_consensus::Error, + BlockImportParams>::Transaction>, + ConsensusError, > { - // sign the pre-sealed hash of the block and then - // add it to a digest item. - let public_type_pair = public.clone().into(); - let public = public.to_raw_vec(); let signature = self .keystore - .sign_with(::ID, &public_type_pair, header_hash.as_ref()) - .map_err(|e| sp_consensus::Error::CannotSign(public.clone(), e.to_string()))? + .sr25519_sign(::ID, public.as_ref(), header_hash.as_ref()) + .map_err(|e| ConsensusError::CannotSign(format!("{}. Key: {:?}", e, public)))? .ok_or_else(|| { - sp_consensus::Error::CannotSign( - public.clone(), - "Could not find key in keystore.".into(), - ) + ConsensusError::CannotSign(format!( + "Could not find key in keystore. Key: {:?}", + public + )) })?; - let signature: AuthoritySignature = signature - .clone() - .try_into() - .map_err(|_| sp_consensus::Error::InvalidSignature(signature, public))?; - let digest_item = ::babe_seal(signature); + + let digest_item = ::babe_seal(signature.into()); let mut import_block = BlockImportParams::new(BlockOrigin::Own, header); import_block.post_digests.push(digest_item); @@ -891,11 +884,7 @@ where } fn proposer(&mut self, block: &B::Header) -> Self::CreateProposer { - Box::pin( - self.env - .init(block) - .map_err(|e| sp_consensus::Error::ClientImport(format!("{:?}", e))), - ) + Box::pin(self.env.init(block).map_err(|e| ConsensusError::ClientImport(e.to_string()))) } fn telemetry(&self) -> Option { @@ -1182,7 +1171,7 @@ where .create_inherent_data_providers .create_inherent_data_providers(parent_hash, ()) .await - .map_err(|e| Error::::Client(sp_consensus::Error::from(e).into()))?; + .map_err(|e| Error::::Client(ConsensusError::from(e).into()))?; let slot_now = create_inherent_data_providers.slot(); diff --git a/client/consensus/grandpa/src/lib.rs b/client/consensus/grandpa/src/lib.rs index cf98e17920d5d..90cb8a51fa6f4 100644 --- a/client/consensus/grandpa/src/lib.rs +++ b/client/consensus/grandpa/src/lib.rs @@ -72,7 +72,7 @@ use sc_network::types::ProtocolName; use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_INFO}; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver}; use sp_api::ProvideRuntimeApi; -use sp_application_crypto::AppKey; +use sp_application_crypto::AppCrypto; use sp_blockchain::{Error as ClientError, HeaderBackend, HeaderMetadata, Result as ClientResult}; use sp_consensus::SelectChain; use sp_consensus_grandpa::{ diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index f1d817ab7d8cf..e4147340793a4 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -150,7 +150,7 @@ pub trait SimpleSlotWorker { body: Vec, storage_changes: StorageChanges<>::Transaction, B>, public: Self::Claim, - epoch: Self::AuxData, + aux_data: Self::AuxData, ) -> Result< sc_consensus::BlockImportParams>::Transaction>, sp_consensus::Error, diff --git a/client/keystore/src/local.rs b/client/keystore/src/local.rs index a4af7811721ce..abdf97bb22aad 100644 --- a/client/keystore/src/local.rs +++ b/client/keystore/src/local.rs @@ -18,13 +18,10 @@ //! Local keystore implementation use parking_lot::RwLock; -use sp_application_crypto::{ecdsa, ed25519, sr25519, AppKey, AppPair, IsWrappedBy}; +use sp_application_crypto::{AppCrypto, AppPair, IsWrappedBy}; use sp_core::{ - crypto::{ - ByteArray, CryptoTypePublicPair, ExposeSecret, KeyTypeId, Pair as PairT, SecretString, - }, - sr25519::{Pair as Sr25519Pair, Public as Sr25519Public}, - Encode, + crypto::{ByteArray, ExposeSecret, KeyTypeId, Pair as CorePair, SecretString}, + ecdsa, ed25519, sr25519, }; use sp_keystore::{ vrf::{make_transcript, VRFSignature, VRFTranscriptData}, @@ -62,67 +59,13 @@ impl LocalKeystore { /// `Err(_)` when something failed. pub fn key_pair( &self, - public: &::Public, + public: &::Public, ) -> Result> { self.0.read().key_pair::(public) } } impl Keystore for LocalKeystore { - fn keys(&self, id: KeyTypeId) -> std::result::Result, TraitError> { - let raw_keys = self.0.read().raw_public_keys(id)?; - Ok(raw_keys.into_iter().fold(Vec::new(), |mut v, k| { - v.push(CryptoTypePublicPair(sr25519::CRYPTO_ID, k.clone())); - v.push(CryptoTypePublicPair(ed25519::CRYPTO_ID, k.clone())); - v.push(CryptoTypePublicPair(ecdsa::CRYPTO_ID, k)); - v - })) - } - - fn sign_with( - &self, - id: KeyTypeId, - key: &CryptoTypePublicPair, - msg: &[u8], - ) -> std::result::Result>, TraitError> { - match key.0 { - ed25519::CRYPTO_ID => { - let pub_key = ed25519::Public::from_slice(key.1.as_slice()).map_err(|()| { - TraitError::Other("Corrupted public key - Invalid size".into()) - })?; - let key_pair = self - .0 - .read() - .key_pair_by_type::(&pub_key, id) - .map_err(TraitError::from)?; - key_pair.map(|k| k.sign(msg).encode()).map(Ok).transpose() - }, - sr25519::CRYPTO_ID => { - let pub_key = sr25519::Public::from_slice(key.1.as_slice()).map_err(|()| { - TraitError::Other("Corrupted public key - Invalid size".into()) - })?; - let key_pair = self - .0 - .read() - .key_pair_by_type::(&pub_key, id) - .map_err(TraitError::from)?; - key_pair.map(|k| k.sign(msg).encode()).map(Ok).transpose() - }, - ecdsa::CRYPTO_ID => { - let pub_key = ecdsa::Public::from_slice(key.1.as_slice()).map_err(|()| { - TraitError::Other("Corrupted public key - Invalid size".into()) - })?; - let key_pair = self - .0 - .read() - .key_pair_by_type::(&pub_key, id) - .map_err(TraitError::from)?; - key_pair.map(|k| k.sign(msg).encode()).map(Ok).transpose() - }, - _ => Err(TraitError::KeyNotSupported(id)), - } - } - fn sr25519_public_keys(&self, key_type: KeyTypeId) -> Vec { self.0 .read() @@ -140,19 +83,49 @@ impl Keystore for LocalKeystore { /// If the `[seed]` is `Some` then the key will be ephemeral and stored in memory. fn sr25519_generate_new( &self, - id: KeyTypeId, + key_type: KeyTypeId, seed: Option<&str>, ) -> std::result::Result { let pair = match seed { - Some(seed) => - self.0.write().insert_ephemeral_from_seed_by_type::(seed, id), - None => self.0.write().generate_by_type::(id), + Some(seed) => self + .0 + .write() + .insert_ephemeral_from_seed_by_type::(seed, key_type), + None => self.0.write().generate_by_type::(key_type), } .map_err(|e| -> TraitError { e.into() })?; Ok(pair.public()) } + fn sr25519_sign( + &self, + key_type: KeyTypeId, + public: &sr25519::Public, + msg: &[u8], + ) -> std::result::Result, TraitError> { + let res = self + .0 + .read() + .key_pair_by_type::(public, key_type)? + .map(|pair| pair.sign(msg)); + Ok(res) + } + + fn sr25519_vrf_sign( + &self, + key_type: KeyTypeId, + public: &sr25519::Public, + transcript_data: VRFTranscriptData, + ) -> std::result::Result, TraitError> { + let res = self.0.read().key_pair_by_type::(public, key_type)?.map(|pair| { + let transcript = make_transcript(transcript_data); + let (inout, proof, _) = pair.as_ref().vrf_sign(transcript); + VRFSignature { output: inout.to_output(), proof } + }); + Ok(res) + } + fn ed25519_public_keys(&self, key_type: KeyTypeId) -> Vec { self.0 .read() @@ -170,19 +143,35 @@ impl Keystore for LocalKeystore { /// If the `[seed]` is `Some` then the key will be ephemeral and stored in memory. fn ed25519_generate_new( &self, - id: KeyTypeId, + key_type: KeyTypeId, seed: Option<&str>, ) -> std::result::Result { let pair = match seed { - Some(seed) => - self.0.write().insert_ephemeral_from_seed_by_type::(seed, id), - None => self.0.write().generate_by_type::(id), + Some(seed) => self + .0 + .write() + .insert_ephemeral_from_seed_by_type::(seed, key_type), + None => self.0.write().generate_by_type::(key_type), } .map_err(|e| -> TraitError { e.into() })?; Ok(pair.public()) } + fn ed25519_sign( + &self, + key_type: KeyTypeId, + public: &ed25519::Public, + msg: &[u8], + ) -> std::result::Result, TraitError> { + let res = self + .0 + .read() + .key_pair_by_type::(public, key_type)? + .map(|pair| pair.sign(msg)); + Ok(res) + } + fn ecdsa_public_keys(&self, key_type: KeyTypeId) -> Vec { self.0 .read() @@ -200,19 +189,47 @@ impl Keystore for LocalKeystore { /// If the `[seed]` is `Some` then the key will be ephemeral and stored in memory. fn ecdsa_generate_new( &self, - id: KeyTypeId, + key_type: KeyTypeId, seed: Option<&str>, ) -> std::result::Result { let pair = match seed { Some(seed) => - self.0.write().insert_ephemeral_from_seed_by_type::(seed, id), - None => self.0.write().generate_by_type::(id), + self.0.write().insert_ephemeral_from_seed_by_type::(seed, key_type), + None => self.0.write().generate_by_type::(key_type), } .map_err(|e| -> TraitError { e.into() })?; Ok(pair.public()) } + fn ecdsa_sign( + &self, + key_type: KeyTypeId, + public: &ecdsa::Public, + msg: &[u8], + ) -> std::result::Result, TraitError> { + let res = self + .0 + .read() + .key_pair_by_type::(public, key_type)? + .map(|pair| pair.sign(msg)); + Ok(res) + } + + fn ecdsa_sign_prehashed( + &self, + key_type: KeyTypeId, + public: &ecdsa::Public, + msg: &[u8; 32], + ) -> std::result::Result, TraitError> { + let res = self + .0 + .read() + .key_pair_by_type::(public, key_type)? + .map(|pair| pair.sign_prehashed(msg)); + Ok(res) + } + fn insert( &self, key_type: KeyTypeId, @@ -222,39 +239,15 @@ impl Keystore for LocalKeystore { self.0.write().insert(key_type, suri, public).map_err(|_| ()) } + fn keys(&self, key_type: KeyTypeId) -> std::result::Result>, TraitError> { + self.0.read().raw_public_keys(key_type).map_err(|e| e.into()) + } + fn has_keys(&self, public_keys: &[(Vec, KeyTypeId)]) -> bool { public_keys .iter() .all(|(p, t)| self.0.read().key_phrase_by_type(p, *t).ok().flatten().is_some()) } - - fn sr25519_vrf_sign( - &self, - key_type: KeyTypeId, - public: &Sr25519Public, - transcript_data: VRFTranscriptData, - ) -> std::result::Result, TraitError> { - let transcript = make_transcript(transcript_data); - let pair = self.0.read().key_pair_by_type::(public, key_type)?; - - if let Some(pair) = pair { - let (inout, proof, _) = pair.as_ref().vrf_sign(transcript); - Ok(Some(VRFSignature { output: inout.to_output(), proof })) - } else { - Ok(None) - } - } - - fn ecdsa_sign_prehashed( - &self, - id: KeyTypeId, - public: &ecdsa::Public, - msg: &[u8; 32], - ) -> std::result::Result, TraitError> { - let pair = self.0.read().key_pair_by_type::(public, id)?; - - pair.map(|k| k.sign_prehashed(msg)).map(Ok).transpose() - } } impl Into for LocalKeystore { @@ -305,7 +298,12 @@ impl KeystoreInner { /// Insert the given public/private key pair with the given key type. /// /// Does not place it into the file system store. - fn insert_ephemeral_pair(&mut self, pair: &Pair, seed: &str, key_type: KeyTypeId) { + fn insert_ephemeral_pair( + &mut self, + pair: &Pair, + seed: &str, + key_type: KeyTypeId, + ) { let key = (key_type, pair.public().to_raw_vec()); self.additional.insert(key, seed.into()); } @@ -325,7 +323,7 @@ impl KeystoreInner { /// /// Places it into the file system store, if a path is configured. Otherwise insert /// it into the memory cache only. - fn generate_by_type(&mut self, key_type: KeyTypeId) -> Result { + fn generate_by_type(&mut self, key_type: KeyTypeId) -> Result { let (pair, phrase, _) = Pair::generate_with_phrase(self.password()); if let Some(path) = self.key_file_path(pair.public().as_slice(), key_type) { Self::write_to_file(path, &phrase)?; @@ -354,7 +352,7 @@ impl KeystoreInner { /// Create a new key from seed. /// /// Does not place it into the file system store. - fn insert_ephemeral_from_seed_by_type( + fn insert_ephemeral_from_seed_by_type( &mut self, seed: &str, key_type: KeyTypeId, @@ -386,7 +384,7 @@ impl KeystoreInner { } /// Get a key pair for the given public key and key type. - fn key_pair_by_type( + fn key_pair_by_type( &self, public: &Pair::Public, key_type: KeyTypeId, @@ -418,12 +416,12 @@ impl KeystoreInner { } /// Returns a list of raw public keys filtered by `KeyTypeId` - fn raw_public_keys(&self, id: KeyTypeId) -> Result>> { + fn raw_public_keys(&self, key_type: KeyTypeId) -> Result>> { let mut public_keys: Vec> = self .additional .keys() .into_iter() - .filter_map(|k| if k.0 == id { Some(k.1.clone()) } else { None }) + .filter_map(|k| if k.0 == key_type { Some(k.1.clone()) } else { None }) .collect(); if let Some(path) = &self.path { @@ -435,7 +433,7 @@ impl KeystoreInner { if let Some(name) = path.file_name().and_then(|n| n.to_str()) { match array_bytes::hex2bytes(name) { Ok(ref hex) if hex.len() > 4 => { - if hex[0..4] != id.0 { + if hex[0..4] != key_type.0 { continue } let public = hex[4..].to_vec(); @@ -456,7 +454,7 @@ impl KeystoreInner { /// when something failed. pub fn key_pair( &self, - public: &::Public, + public: &::Public, ) -> Result> { self.key_pair_by_type::(IsWrappedBy::from_ref(public), Pair::ID) .map(|v| v.map(Into::into)) diff --git a/client/rpc/src/author/tests.rs b/client/rpc/src/author/tests.rs index 75b6390c83cc7..fbbd1a92fdaa7 100644 --- a/client/rpc/src/author/tests.rs +++ b/client/rpc/src/author/tests.rs @@ -31,8 +31,8 @@ use sc_transaction_pool_api::TransactionStatus; use sp_core::{ blake2_256, bytes::to_hex, - crypto::{ByteArray, CryptoTypePublicPair, Pair}, - ed25519, sr25519, + crypto::{ByteArray, Pair}, + ed25519, testing::{ED25519, SR25519}, H256, }; @@ -227,9 +227,7 @@ async fn author_should_insert_key() { api.call::<_, ()>("author_insertKey", params).await.unwrap(); let pubkeys = setup.keystore.keys(ED25519).unwrap(); - assert!( - pubkeys.contains(&CryptoTypePublicPair(ed25519::CRYPTO_ID, keypair.public().to_raw_vec())) - ); + assert!(pubkeys.contains(&keypair.public().to_raw_vec())); } #[tokio::test] @@ -242,10 +240,8 @@ async fn author_should_rotate_keys() { SessionKeys::decode(&mut &new_pubkeys[..]).expect("SessionKeys decode successfully"); let ed25519_pubkeys = setup.keystore.keys(ED25519).unwrap(); let sr25519_pubkeys = setup.keystore.keys(SR25519).unwrap(); - assert!(ed25519_pubkeys - .contains(&CryptoTypePublicPair(ed25519::CRYPTO_ID, session_keys.ed25519.to_raw_vec()))); - assert!(sr25519_pubkeys - .contains(&CryptoTypePublicPair(sr25519::CRYPTO_ID, session_keys.sr25519.to_raw_vec()))); + assert!(ed25519_pubkeys.contains(&session_keys.ed25519.to_raw_vec())); + assert!(sr25519_pubkeys.contains(&session_keys.sr25519.to_raw_vec())); } #[tokio::test] diff --git a/primitives/application-crypto/src/lib.rs b/primitives/application-crypto/src/lib.rs index 0685477ddff8d..bf738813333be 100644 --- a/primitives/application-crypto/src/lib.rs +++ b/primitives/application-crypto/src/lib.rs @@ -27,10 +27,7 @@ pub use sp_core::crypto::{DeriveError, DeriveJunction, Pair, SecretStringError, #[doc(hidden)] pub use sp_core::{ self, - crypto::{ - ByteArray, CryptoType, CryptoTypePublicPair, Derive, IsWrappedBy, Public, UncheckedFrom, - Wraps, - }, + crypto::{ByteArray, CryptoType, Derive, IsWrappedBy, Public, UncheckedFrom, Wraps}, RuntimeDebug, }; @@ -170,8 +167,7 @@ macro_rules! app_crypto_pair { } } - impl $crate::AppKey for Pair { - type UntypedGeneric = $pair; + impl $crate::AppCrypto for Pair { type Public = Public; type Pair = Pair; type Signature = Signature; @@ -238,8 +234,7 @@ macro_rules! app_crypto_public_full_crypto { type Pair = Pair; } - impl $crate::AppKey for Public { - type UntypedGeneric = $public; + impl $crate::AppCrypto for Public { type Public = Public; type Pair = Pair; type Signature = Signature; @@ -272,8 +267,7 @@ macro_rules! app_crypto_public_not_full_crypto { impl $crate::CryptoType for Public {} - impl $crate::AppKey for Public { - type UntypedGeneric = $public; + impl $crate::AppCrypto for Public { type Public = Public; type Signature = Signature; const ID: $crate::KeyTypeId = $key_type; @@ -306,11 +300,8 @@ macro_rules! app_crypto_public_common { impl $crate::ByteArray for Public { const LEN: usize = <$public>::LEN; } - impl $crate::Public for Public { - fn to_public_crypto_pair(&self) -> $crate::CryptoTypePublicPair { - $crate::CryptoTypePublicPair($crypto_type, $crate::ByteArray::to_raw_vec(self)) - } - } + + impl $crate::Public for Public {} impl $crate::AppPublic for Public { type Generic = $public; @@ -350,18 +341,6 @@ macro_rules! app_crypto_public_common { } } - impl From for $crate::CryptoTypePublicPair { - fn from(key: Public) -> Self { - (&key).into() - } - } - - impl From<&Public> for $crate::CryptoTypePublicPair { - fn from(key: &Public) -> Self { - $crate::CryptoTypePublicPair($crypto_type, $crate::ByteArray::to_raw_vec(key)) - } - } - impl<'a> TryFrom<&'a [u8]> for Public { type Error = (); @@ -450,8 +429,7 @@ macro_rules! app_crypto_signature_full_crypto { type Pair = Pair; } - impl $crate::AppKey for Signature { - type UntypedGeneric = $sig; + impl $crate::AppCrypto for Signature { type Public = Public; type Pair = Pair; type Signature = Signature; @@ -482,8 +460,7 @@ macro_rules! app_crypto_signature_not_full_crypto { impl $crate::CryptoType for Signature {} - impl $crate::AppKey for Signature { - type UntypedGeneric = $sig; + impl $crate::AppCrypto for Signature { type Public = Public; type Signature = Signature; const ID: $crate::KeyTypeId = $key_type; diff --git a/primitives/application-crypto/src/traits.rs b/primitives/application-crypto/src/traits.rs index e3586ccecd0d8..f672efb8a890a 100644 --- a/primitives/application-crypto/src/traits.rs +++ b/primitives/application-crypto/src/traits.rs @@ -23,24 +23,22 @@ use sp_core::crypto::{CryptoType, CryptoTypeId, IsWrappedBy, KeyTypeId, Public}; use sp_std::{fmt::Debug, vec::Vec}; /// An application-specific key. -pub trait AppKey: 'static + Send + Sync + Sized + CryptoType + Clone { - /// The corresponding type as a generic crypto type. - type UntypedGeneric: IsWrappedBy; +pub trait AppCrypto: 'static + Send + Sync + Sized + CryptoType + Clone { + /// Identifier for application-specific key type. + const ID: KeyTypeId; + + /// Identifier of the crypto type of this application-specific key type. + const CRYPTO_ID: CryptoTypeId; /// The corresponding public key type in this application scheme. type Public: AppPublic; - /// The corresponding key pair type in this application scheme. - #[cfg(feature = "full_crypto")] - type Pair: AppPair; - /// The corresponding signature type in this application scheme. type Signature: AppSignature; - /// An identifier for this application-specific key type. - const ID: KeyTypeId; - /// The identifier of the crypto type of this application-specific key type. - const CRYPTO_ID: CryptoTypeId; + /// The corresponding key pair type in this application scheme. + #[cfg(feature = "full_crypto")] + type Pair: AppPair; } /// Type which implements Hash in std, not when no-std (std variant). @@ -63,7 +61,7 @@ impl MaybeDebugHash for T {} /// A application's public key. pub trait AppPublic: - AppKey + Public + Ord + PartialOrd + Eq + PartialEq + Debug + MaybeHash + codec::Codec + AppCrypto + Public + Ord + PartialOrd + Eq + PartialEq + Debug + MaybeHash + codec::Codec { /// The wrapped type which is just a plain instance of `Public`. type Generic: IsWrappedBy @@ -79,14 +77,15 @@ pub trait AppPublic: /// A application's key pair. #[cfg(feature = "full_crypto")] -pub trait AppPair: AppKey + Pair::Public> { +pub trait AppPair: AppCrypto + Pair::Public> { /// The wrapped type which is just a plain instance of `Pair`. type Generic: IsWrappedBy - + Pair::Public as AppPublic>::Generic>; + + Pair::Public as AppPublic>::Generic> + + Pair::Signature as AppSignature>::Generic>; } /// A application's signature. -pub trait AppSignature: AppKey + Eq + PartialEq + Debug + MaybeHash { +pub trait AppSignature: AppCrypto + Eq + PartialEq + Debug + MaybeHash { /// The wrapped type which is just a plain instance of `Signature`. type Generic: IsWrappedBy + Eq + PartialEq + Debug + MaybeHash; } diff --git a/primitives/application-crypto/test/src/ecdsa.rs b/primitives/application-crypto/test/src/ecdsa.rs index fe9e17a65b1a7..99ca6f4c4adf2 100644 --- a/primitives/application-crypto/test/src/ecdsa.rs +++ b/primitives/application-crypto/test/src/ecdsa.rs @@ -17,8 +17,11 @@ //! Integration tests for ecdsa use sp_api::ProvideRuntimeApi; -use sp_application_crypto::ecdsa::{AppPair, AppPublic}; -use sp_core::{crypto::Pair, testing::ECDSA}; +use sp_application_crypto::ecdsa::AppPair; +use sp_core::{ + crypto::{ByteArray, Pair}, + testing::ECDSA, +}; use sp_keystore::{testing::MemoryKeystore, Keystore}; use std::sync::Arc; use substrate_test_runtime_client::{ @@ -35,6 +38,6 @@ fn ecdsa_works_in_runtime() { .expect("Tests `ecdsa` crypto."); let supported_keys = keystore.keys(ECDSA).unwrap(); - assert!(supported_keys.contains(&public.clone().into())); - assert!(AppPair::verify(&signature, "ecdsa", &AppPublic::from(public))); + assert!(supported_keys.contains(&public.to_raw_vec())); + assert!(AppPair::verify(&signature, "ecdsa", &public)); } diff --git a/primitives/application-crypto/test/src/ed25519.rs b/primitives/application-crypto/test/src/ed25519.rs index 5687bd013970a..f4553f95bf1f8 100644 --- a/primitives/application-crypto/test/src/ed25519.rs +++ b/primitives/application-crypto/test/src/ed25519.rs @@ -18,8 +18,11 @@ //! Integration tests for ed25519 use sp_api::ProvideRuntimeApi; -use sp_application_crypto::ed25519::{AppPair, AppPublic}; -use sp_core::{crypto::Pair, testing::ED25519}; +use sp_application_crypto::ed25519::AppPair; +use sp_core::{ + crypto::{ByteArray, Pair}, + testing::ED25519, +}; use sp_keystore::{testing::MemoryKeystore, Keystore}; use std::sync::Arc; use substrate_test_runtime_client::{ @@ -36,6 +39,6 @@ fn ed25519_works_in_runtime() { .expect("Tests `ed25519` crypto."); let supported_keys = keystore.keys(ED25519).unwrap(); - assert!(supported_keys.contains(&public.clone().into())); - assert!(AppPair::verify(&signature, "ed25519", &AppPublic::from(public))); + assert!(supported_keys.contains(&public.to_raw_vec())); + assert!(AppPair::verify(&signature, "ed25519", &public)); } diff --git a/primitives/application-crypto/test/src/sr25519.rs b/primitives/application-crypto/test/src/sr25519.rs index 92886b80cbfb3..736521d7d9f3a 100644 --- a/primitives/application-crypto/test/src/sr25519.rs +++ b/primitives/application-crypto/test/src/sr25519.rs @@ -18,8 +18,11 @@ //! Integration tests for sr25519 use sp_api::ProvideRuntimeApi; -use sp_application_crypto::sr25519::{AppPair, AppPublic}; -use sp_core::{crypto::Pair, testing::SR25519}; +use sp_application_crypto::sr25519::AppPair; +use sp_core::{ + crypto::{ByteArray, Pair}, + testing::SR25519, +}; use sp_keystore::{testing::MemoryKeystore, Keystore}; use std::sync::Arc; use substrate_test_runtime_client::{ @@ -36,6 +39,6 @@ fn sr25519_works_in_runtime() { .expect("Tests `sr25519` crypto."); let supported_keys = keystore.keys(SR25519).unwrap(); - assert!(supported_keys.contains(&public.clone().into())); - assert!(AppPair::verify(&signature, "sr25519", &AppPublic::from(public))); + assert!(supported_keys.contains(&public.to_raw_vec())); + assert!(AppPair::verify(&signature, "sr25519", &public)); } diff --git a/primitives/consensus/common/src/error.rs b/primitives/consensus/common/src/error.rs index e881259da11e4..fb8d0447fe3d6 100644 --- a/primitives/consensus/common/src/error.rs +++ b/primitives/consensus/common/src/error.rs @@ -48,8 +48,8 @@ pub enum Error { #[error("Chain lookup failed: {0}")] ChainLookup(String), /// Signing failed. - #[error("Failed to sign using key: {0:?}. Reason: {1}")] - CannotSign(Vec, String), + #[error("Failed to sign: {0}")] + CannotSign(String), /// Some other error. #[error(transparent)] Other(#[from] Box), diff --git a/primitives/consensus/grandpa/src/lib.rs b/primitives/consensus/grandpa/src/lib.rs index 7f5857e4ba26a..728ce3092888b 100644 --- a/primitives/consensus/grandpa/src/lib.rs +++ b/primitives/consensus/grandpa/src/lib.rs @@ -451,12 +451,11 @@ where H: Encode, N: Encode, { - use sp_application_crypto::AppKey; - use sp_core::crypto::Public; + use sp_application_crypto::AppCrypto; let encoded = localized_payload(round, set_id, &message); let signature = keystore - .sign_with(AuthorityId::ID, &public.to_public_crypto_pair(), &encoded[..]) + .ed25519_sign(AuthorityId::ID, public.as_ref(), &encoded[..]) .ok() .flatten()? .try_into() diff --git a/primitives/core/src/crypto.rs b/primitives/core/src/crypto.rs index 80e65b342cbd7..2e60ac2370a16 100644 --- a/primitives/core/src/crypto.rs +++ b/primitives/core/src/crypto.rs @@ -19,8 +19,6 @@ //! Cryptographic utilities. // end::description[] -#[cfg(feature = "std")] -use crate::hexdisplay::HexDisplay; use crate::{ed25519, sr25519}; #[cfg(feature = "std")] use base58::{FromBase58, ToBase58}; @@ -487,10 +485,7 @@ pub trait ByteArray: AsRef<[u8]> + AsMut<[u8]> + for<'a> TryFrom<&'a [u8], Error } /// Trait suitable for typical cryptographic PKI key public type. -pub trait Public: ByteArray + Derive + CryptoType + PartialEq + Eq + Clone + Send + Sync { - /// Return `CryptoTypePublicPair` from public key. - fn to_public_crypto_pair(&self) -> CryptoTypePublicPair; -} +pub trait Public: ByteArray + Derive + CryptoType + PartialEq + Eq + Clone + Send + Sync {} /// An opaque 32-byte cryptographic identifier. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, TypeInfo)] @@ -689,11 +684,7 @@ mod dummy { b"" } } - impl Public for Dummy { - fn to_public_crypto_pair(&self) -> CryptoTypePublicPair { - CryptoTypePublicPair(CryptoTypeId(*b"dumm"), ::to_raw_vec(self)) - } - } + impl Public for Dummy {} impl Pair for Dummy { type Public = Dummy; @@ -1118,24 +1109,6 @@ impl<'a> TryFrom<&'a str> for KeyTypeId { #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct CryptoTypeId(pub [u8; 4]); -/// A type alias of CryptoTypeId & a public key -#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Encode, Decode)] -#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] -pub struct CryptoTypePublicPair(pub CryptoTypeId, pub Vec); - -#[cfg(feature = "std")] -impl sp_std::fmt::Display for CryptoTypePublicPair { - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { - let id = match str::from_utf8(&(self.0).0[..]) { - Ok(id) => id.to_string(), - Err(_) => { - format!("{:#?}", self.0) - }, - }; - write!(f, "{}-{}", id, HexDisplay::from(&self.1)) - } -} - /// Known key types; this also functions as a global registry of key types for projects wishing to /// avoid collisions with each other. /// @@ -1223,11 +1196,7 @@ mod tests { vec![] } } - impl Public for TestPublic { - fn to_public_crypto_pair(&self) -> CryptoTypePublicPair { - CryptoTypePublicPair(CryptoTypeId(*b"dumm"), self.to_raw_vec()) - } - } + impl Public for TestPublic {} impl Pair for TestPair { type Public = TestPublic; type Seed = [u8; 8]; diff --git a/primitives/core/src/ecdsa.rs b/primitives/core/src/ecdsa.rs index e63b283d26ee3..8dc4a55130fd6 100644 --- a/primitives/core/src/ecdsa.rs +++ b/primitives/core/src/ecdsa.rs @@ -24,8 +24,7 @@ use sp_runtime_interface::pass_by::PassByInner; #[cfg(feature = "std")] use crate::crypto::Ss58Codec; use crate::crypto::{ - ByteArray, CryptoType, CryptoTypeId, CryptoTypePublicPair, Derive, Public as TraitPublic, - UncheckedFrom, + ByteArray, CryptoType, CryptoTypeId, Derive, Public as TraitPublic, UncheckedFrom, }; #[cfg(feature = "full_crypto")] use crate::{ @@ -103,23 +102,7 @@ impl ByteArray for Public { const LEN: usize = 33; } -impl TraitPublic for Public { - fn to_public_crypto_pair(&self) -> CryptoTypePublicPair { - CryptoTypePublicPair(CRYPTO_ID, self.to_raw_vec()) - } -} - -impl From for CryptoTypePublicPair { - fn from(key: Public) -> Self { - (&key).into() - } -} - -impl From<&Public> for CryptoTypePublicPair { - fn from(key: &Public) -> Self { - CryptoTypePublicPair(CRYPTO_ID, key.to_raw_vec()) - } -} +impl TraitPublic for Public {} impl Derive for Public {} diff --git a/primitives/core/src/ed25519.rs b/primitives/core/src/ed25519.rs index 503c127a9e06b..884d29dc122e9 100644 --- a/primitives/core/src/ed25519.rs +++ b/primitives/core/src/ed25519.rs @@ -31,9 +31,7 @@ use scale_info::TypeInfo; #[cfg(feature = "std")] use crate::crypto::Ss58Codec; -use crate::crypto::{ - CryptoType, CryptoTypeId, CryptoTypePublicPair, Derive, Public as TraitPublic, UncheckedFrom, -}; +use crate::crypto::{CryptoType, CryptoTypeId, Derive, Public as TraitPublic, UncheckedFrom}; #[cfg(feature = "full_crypto")] use crate::crypto::{DeriveError, DeriveJunction, Pair as TraitPair, SecretStringError}; #[cfg(feature = "full_crypto")] @@ -355,26 +353,10 @@ impl ByteArray for Public { const LEN: usize = 32; } -impl TraitPublic for Public { - fn to_public_crypto_pair(&self) -> CryptoTypePublicPair { - CryptoTypePublicPair(CRYPTO_ID, self.to_raw_vec()) - } -} +impl TraitPublic for Public {} impl Derive for Public {} -impl From for CryptoTypePublicPair { - fn from(key: Public) -> Self { - (&key).into() - } -} - -impl From<&Public> for CryptoTypePublicPair { - fn from(key: &Public) -> Self { - CryptoTypePublicPair(CRYPTO_ID, key.to_raw_vec()) - } -} - /// Derive a single hard junction. #[cfg(feature = "full_crypto")] fn derive_hard_junction(secret_seed: &Seed, cc: &[u8; 32]) -> Seed { diff --git a/primitives/core/src/sr25519.rs b/primitives/core/src/sr25519.rs index 8dbcca9e2673e..d7c1c79c3f42b 100644 --- a/primitives/core/src/sr25519.rs +++ b/primitives/core/src/sr25519.rs @@ -34,10 +34,7 @@ use schnorrkel::{ use sp_std::vec::Vec; use crate::{ - crypto::{ - ByteArray, CryptoType, CryptoTypeId, CryptoTypePublicPair, Derive, Public as TraitPublic, - UncheckedFrom, - }, + crypto::{ByteArray, CryptoType, CryptoTypeId, Derive, Public as TraitPublic, UncheckedFrom}, hash::{H256, H512}, }; use codec::{Decode, Encode, MaxEncodedLen}; @@ -386,23 +383,7 @@ impl ByteArray for Public { const LEN: usize = 32; } -impl TraitPublic for Public { - fn to_public_crypto_pair(&self) -> CryptoTypePublicPair { - CryptoTypePublicPair(CRYPTO_ID, self.to_raw_vec()) - } -} - -impl From for CryptoTypePublicPair { - fn from(key: Public) -> Self { - (&key).into() - } -} - -impl From<&Public> for CryptoTypePublicPair { - fn from(key: &Public) -> Self { - CryptoTypePublicPair(CRYPTO_ID, key.to_raw_vec()) - } -} +impl TraitPublic for Public {} #[cfg(feature = "std")] impl From for Pair { diff --git a/primitives/io/src/lib.rs b/primitives/io/src/lib.rs index 709e1fa642f80..306ac8e60c529 100644 --- a/primitives/io/src/lib.rs +++ b/primitives/io/src/lib.rs @@ -762,10 +762,9 @@ pub trait Crypto { ) -> Option { self.extension::() .expect("No `keystore` associated for the current context!") - .sign_with(id, &pub_key.into(), msg) + .ed25519_sign(id, pub_key, msg) .ok() .flatten() - .and_then(|sig| ed25519::Signature::from_slice(&sig)) } /// Verify `ed25519` signature. @@ -902,10 +901,9 @@ pub trait Crypto { ) -> Option { self.extension::() .expect("No `keystore` associated for the current context!") - .sign_with(id, &pub_key.into(), msg) + .sr25519_sign(id, pub_key, msg) .ok() .flatten() - .and_then(|sig| sr25519::Signature::from_slice(&sig)) } /// Verify an `sr25519` signature. @@ -949,10 +947,9 @@ pub trait Crypto { ) -> Option { self.extension::() .expect("No `keystore` associated for the current context!") - .sign_with(id, &pub_key.into(), msg) + .ecdsa_sign(id, pub_key, msg) .ok() .flatten() - .and_then(|sig| ecdsa::Signature::from_slice(&sig)) } /// Sign the given a pre-hashed `msg` with the `ecdsa` key that corresponds to the given public diff --git a/primitives/keystore/src/lib.rs b/primitives/keystore/src/lib.rs index d1cbe227ed551..577969cdfecd8 100644 --- a/primitives/keystore/src/lib.rs +++ b/primitives/keystore/src/lib.rs @@ -21,7 +21,7 @@ pub mod vrf; use crate::vrf::{VRFSignature, VRFTranscriptData}; use sp_core::{ - crypto::{CryptoTypePublicPair, KeyTypeId}, + crypto::{ByteArray, CryptoTypeId, KeyTypeId}, ecdsa, ed25519, sr25519, }; use std::sync::Arc; @@ -45,109 +45,174 @@ pub enum Error { /// Something that generates, stores and provides access to secret keys. pub trait Keystore: Send + Sync { - /// Returns all sr25519 public keys for the given key type. - fn sr25519_public_keys(&self, id: KeyTypeId) -> Vec; + /// Returns all the sr25519 public keys for the given key type. + fn sr25519_public_keys(&self, key_type: KeyTypeId) -> Vec; /// Generate a new sr25519 key pair for the given key type and an optional seed. /// - /// If the given seed is `Some(_)`, the key pair will only be stored in memory. - /// - /// Returns the public key of the generated key pair. + /// Returns an `sr25519::Public` key of the generated key pair or an `Err` if + /// something failed during key generation. fn sr25519_generate_new( &self, - id: KeyTypeId, + key_type: KeyTypeId, seed: Option<&str>, ) -> Result; + /// Generate an sr25519 signature for a given message. + /// + /// Receives [`KeyTypeId`] and an [`sr25519::Public`] key to be able to map + /// them to a private key that exists in the keystore. + /// + /// Returns an [`sr25519::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 sr25519_sign( + &self, + key_type: KeyTypeId, + public: &sr25519::Public, + msg: &[u8], + ) -> Result, Error>; + + /// Generate an sr25519 VRF signature for a given transcript data. + /// + /// Receives [`KeyTypeId`] and an [`sr25519::Public`] key to be able to map + /// them to a private key that exists in the keystore. + /// + /// Returns a result containing the signature data. + /// Namely, VRFOutput and VRFProof which are returned inside the `VRFSignature` + /// container struct. + /// Returns `None` if the given `key_type` and `public` combination doesn't + /// exist in the keystore or an `Err` when something failed. + fn sr25519_vrf_sign( + &self, + key_type: KeyTypeId, + public: &sr25519::Public, + transcript_data: VRFTranscriptData, + ) -> Result, Error>; + /// Returns all ed25519 public keys for the given key type. - fn ed25519_public_keys(&self, id: KeyTypeId) -> Vec; + fn ed25519_public_keys(&self, key_type: KeyTypeId) -> Vec; /// Generate a new ed25519 key pair for the given key type and an optional seed. /// - /// If the given seed is `Some(_)`, the key pair will only be stored in memory. - /// - /// Returns the public key of the generated key pair. + /// Returns an `ed25519::Public` key of the generated key pair or an `Err` if + /// something failed during key generation. fn ed25519_generate_new( &self, - id: KeyTypeId, + key_type: KeyTypeId, seed: Option<&str>, ) -> Result; + /// Generate an ed25519 signature for a given message. + /// + /// Receives [`KeyTypeId`] and an [`ed25519::Public`] key to be able to map + /// them to a private key that exists in the keystore. + /// + /// Returns an [`ed25519::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 ed25519_sign( + &self, + key_type: KeyTypeId, + public: &ed25519::Public, + msg: &[u8], + ) -> Result, Error>; + /// Returns all ecdsa public keys for the given key type. - fn ecdsa_public_keys(&self, id: KeyTypeId) -> Vec; + fn ecdsa_public_keys(&self, key_type: KeyTypeId) -> Vec; /// Generate a new ecdsa key pair for the given key type and an optional seed. /// - /// If the given seed is `Some(_)`, the key pair will only be stored in memory. + /// Returns an `ecdsa::Public` key of the generated key pair or an `Err` if + /// something failed during key generation. + fn ecdsa_generate_new( + &self, + key_type: KeyTypeId, + seed: Option<&str>, + ) -> Result; + + /// Generate an ecdsa signature for a given message. + /// + /// Receives [`KeyTypeId`] and an [`ecdsa::Public`] key to be able to map + /// them to a private key that exists in the keystore. + /// + /// Returns an [`ecdsa::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 ecdsa_sign( + &self, + key_type: KeyTypeId, + public: &ecdsa::Public, + msg: &[u8], + ) -> Result, Error>; + + /// Generate an ecdsa signature for a given pre-hashed message. + /// + /// Receives [`KeyTypeId`] and an [`ecdsa::Public`] key to be able to map + /// them to a private key that exists in the keystore. /// - /// Returns the public key of the generated key pair. - fn ecdsa_generate_new(&self, id: KeyTypeId, seed: Option<&str>) - -> Result; + /// Returns an [`ecdsa::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 ecdsa_sign_prehashed( + &self, + key_type: KeyTypeId, + public: &ecdsa::Public, + msg: &[u8; 32], + ) -> Result, Error>; /// Insert a new secret key. fn insert(&self, key_type: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()>; - /// List all supported keys + /// List all supported keys of a given type. /// - /// Returns a set of public keys the signer supports. - fn keys(&self, id: KeyTypeId) -> Result, Error>; + /// Returns a set of public keys the signer supports in raw format. + fn keys(&self, key_type: KeyTypeId) -> Result>, Error>; /// Checks if the private keys for the given public key and key type combinations exist. /// /// Returns `true` iff all private keys could be found. fn has_keys(&self, public_keys: &[(Vec, KeyTypeId)]) -> bool; - /// Sign with key + /// Convenience method to sign a message using the given key type and a raw public key + /// for secret lookup. /// - /// Signs a message with the private key that matches - /// the public key passed. + /// The message is signed using the cryptographic primitive specified by `crypto_id`. + /// + /// Schemes supported by the default trait implementation: sr25519, ed25519 and ecdsa. + /// 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 /// exist or an error when something failed. fn sign_with( &self, id: KeyTypeId, - key: &CryptoTypePublicPair, + crypto_id: CryptoTypeId, + public: &[u8], msg: &[u8], - ) -> Result>, Error>; - - /// Generate VRF signature for given transcript data. - /// - /// Receives KeyTypeId and Public key to be able to map - /// them to a private key that exists in the keystore which - /// is, in turn, used for signing the provided transcript. - /// - /// Returns a result containing the signature data. - /// Namely, VRFOutput and VRFProof which are returned - /// inside the `VRFSignature` container struct. - /// - /// This function will return `None` if the given `key_type` and `public` combination - /// doesn't exist in the keystore or an `Err` when something failed. - fn sr25519_vrf_sign( - &self, - key_type: KeyTypeId, - public: &sr25519::Public, - transcript_data: VRFTranscriptData, - ) -> Result, Error>; - - /// Generate an ECDSA signature for a given pre-hashed message. - /// - /// Receives [`KeyTypeId`] and an [`ecdsa::Public`] key to be able to map - /// them to a private key that exists in the keystore. This private key is, - /// in turn, used for signing the provided pre-hashed message. - /// - /// The `msg` argument provided should be a hashed message for which an - /// ECDSA signature should be generated. - /// - /// Returns an [`ecdsa::Signature`] or `None` in case the given `id` and - /// `public` combination doesn't exist in the keystore. An `Err` will be - /// returned if generating the signature itself failed. - fn ecdsa_sign_prehashed( - &self, - id: KeyTypeId, - public: &ecdsa::Public, - msg: &[u8; 32], - ) -> Result, Error>; + ) -> Result>, Error> { + use codec::Encode; + + let signature = match crypto_id { + sr25519::CRYPTO_ID => { + let public = sr25519::Public::from_slice(public) + .map_err(|_| Error::ValidationError("Invalid public key format".into()))?; + self.sr25519_sign(id, &public, msg)?.map(|s| s.encode()) + }, + ed25519::CRYPTO_ID => { + let public = ed25519::Public::from_slice(public) + .map_err(|_| Error::ValidationError("Invalid public key format".into()))?; + self.ed25519_sign(id, &public, msg)?.map(|s| s.encode()) + }, + 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()) + }, + _ => return Err(Error::KeyNotSupported(id)), + }; + Ok(signature) + } } /// A shared pointer to a keystore implementation. diff --git a/primitives/keystore/src/testing.rs b/primitives/keystore/src/testing.rs index 73b560d563a17..de034c65889ff 100644 --- a/primitives/keystore/src/testing.rs +++ b/primitives/keystore/src/testing.rs @@ -18,7 +18,7 @@ //! Types that should only be used for testing! use sp_core::{ - crypto::{ByteArray, CryptoTypePublicPair, KeyTypeId, Pair}, + crypto::{ByteArray, KeyTypeId, Pair}, ecdsa, ed25519, sr25519, }; @@ -42,51 +42,44 @@ impl MemoryKeystore { Self::default() } - fn sr25519_key_pair(&self, id: KeyTypeId, pub_key: &sr25519::Public) -> Option { - self.keys.read().get(&id).and_then(|inner| { - inner.get(pub_key.as_slice()).map(|s| { + fn sr25519_key_pair( + &self, + key_type: KeyTypeId, + public: &sr25519::Public, + ) -> Option { + self.keys.read().get(&key_type).and_then(|inner| { + inner.get(public.as_slice()).map(|s| { sr25519::Pair::from_string(s, None).expect("`sr25519` seed slice is valid") }) }) } - fn ed25519_key_pair(&self, id: KeyTypeId, pub_key: &ed25519::Public) -> Option { - self.keys.read().get(&id).and_then(|inner| { - inner.get(pub_key.as_slice()).map(|s| { + fn ed25519_key_pair( + &self, + key_type: KeyTypeId, + public: &ed25519::Public, + ) -> Option { + self.keys.read().get(&key_type).and_then(|inner| { + inner.get(public.as_slice()).map(|s| { ed25519::Pair::from_string(s, None).expect("`ed25519` seed slice is valid") }) }) } - fn ecdsa_key_pair(&self, id: KeyTypeId, pub_key: &ecdsa::Public) -> Option { - self.keys.read().get(&id).and_then(|inner| { + fn ecdsa_key_pair(&self, key_type: KeyTypeId, public: &ecdsa::Public) -> Option { + self.keys.read().get(&key_type).and_then(|inner| { inner - .get(pub_key.as_slice()) + .get(public.as_slice()) .map(|s| ecdsa::Pair::from_string(s, None).expect("`ecdsa` seed slice is valid")) }) } } impl Keystore for MemoryKeystore { - fn keys(&self, id: KeyTypeId) -> Result, Error> { - self.keys - .read() - .get(&id) - .map(|map| { - Ok(map.keys().fold(Vec::new(), |mut v, k| { - v.push(CryptoTypePublicPair(sr25519::CRYPTO_ID, k.clone())); - v.push(CryptoTypePublicPair(ed25519::CRYPTO_ID, k.clone())); - v.push(CryptoTypePublicPair(ecdsa::CRYPTO_ID, k.clone())); - v - })) - }) - .unwrap_or_else(|| Ok(vec![])) - } - - fn sr25519_public_keys(&self, id: KeyTypeId) -> Vec { + fn sr25519_public_keys(&self, key_type: KeyTypeId) -> Vec { self.keys .read() - .get(&id) + .get(&key_type) .map(|keys| { keys.values() .map(|s| { @@ -100,7 +93,7 @@ impl Keystore for MemoryKeystore { fn sr25519_generate_new( &self, - id: KeyTypeId, + key_type: KeyTypeId, seed: Option<&str>, ) -> Result { match seed { @@ -110,7 +103,7 @@ impl Keystore for MemoryKeystore { })?; self.keys .write() - .entry(id) + .entry(key_type) .or_default() .insert(pair.public().to_raw_vec(), seed.into()); Ok(pair.public()) @@ -119,7 +112,7 @@ impl Keystore for MemoryKeystore { let (pair, phrase, _) = sr25519::Pair::generate_with_phrase(None); self.keys .write() - .entry(id) + .entry(key_type) .or_default() .insert(pair.public().to_raw_vec(), phrase); Ok(pair.public()) @@ -127,10 +120,33 @@ impl Keystore for MemoryKeystore { } } - fn ed25519_public_keys(&self, id: KeyTypeId) -> Vec { + fn sr25519_sign( + &self, + key_type: KeyTypeId, + public: &sr25519::Public, + msg: &[u8], + ) -> Result, Error> { + Ok(self.sr25519_key_pair(key_type, public).map(|pair| pair.sign(msg))) + } + + fn sr25519_vrf_sign( + &self, + key_type: KeyTypeId, + public: &sr25519::Public, + transcript_data: VRFTranscriptData, + ) -> Result, Error> { + let transcript = make_transcript(transcript_data); + let pair = + if let Some(k) = self.sr25519_key_pair(key_type, public) { k } else { return Ok(None) }; + + let (inout, proof, _) = pair.as_ref().vrf_sign(transcript); + Ok(Some(VRFSignature { output: inout.to_output(), proof })) + } + + fn ed25519_public_keys(&self, key_type: KeyTypeId) -> Vec { self.keys .read() - .get(&id) + .get(&key_type) .map(|keys| { keys.values() .map(|s| { @@ -144,7 +160,7 @@ impl Keystore for MemoryKeystore { fn ed25519_generate_new( &self, - id: KeyTypeId, + key_type: KeyTypeId, seed: Option<&str>, ) -> Result { match seed { @@ -154,7 +170,7 @@ impl Keystore for MemoryKeystore { })?; self.keys .write() - .entry(id) + .entry(key_type) .or_default() .insert(pair.public().to_raw_vec(), seed.into()); Ok(pair.public()) @@ -163,7 +179,7 @@ impl Keystore for MemoryKeystore { let (pair, phrase, _) = ed25519::Pair::generate_with_phrase(None); self.keys .write() - .entry(id) + .entry(key_type) .or_default() .insert(pair.public().to_raw_vec(), phrase); Ok(pair.public()) @@ -171,10 +187,19 @@ impl Keystore for MemoryKeystore { } } - fn ecdsa_public_keys(&self, id: KeyTypeId) -> Vec { + fn ed25519_sign( + &self, + key_type: KeyTypeId, + public: &ed25519::Public, + msg: &[u8], + ) -> Result, Error> { + Ok(self.ed25519_key_pair(key_type, public).map(|pair| pair.sign(msg))) + } + + fn ecdsa_public_keys(&self, key_type: KeyTypeId) -> Vec { self.keys .read() - .get(&id) + .get(&key_type) .map(|keys| { keys.values() .map(|s| { @@ -188,7 +213,7 @@ impl Keystore for MemoryKeystore { fn ecdsa_generate_new( &self, - id: KeyTypeId, + key_type: KeyTypeId, seed: Option<&str>, ) -> Result { match seed { @@ -197,7 +222,7 @@ impl Keystore for MemoryKeystore { .map_err(|_| Error::ValidationError("Generates an `ecdsa` pair.".to_owned()))?; self.keys .write() - .entry(id) + .entry(key_type) .or_default() .insert(pair.public().to_raw_vec(), seed.into()); Ok(pair.public()) @@ -206,7 +231,7 @@ impl Keystore for MemoryKeystore { let (pair, phrase, _) = ecdsa::Pair::generate_with_phrase(None); self.keys .write() - .entry(id) + .entry(key_type) .or_default() .insert(pair.public().to_raw_vec(), phrase); Ok(pair.public()) @@ -214,75 +239,49 @@ impl Keystore for MemoryKeystore { } } - fn insert(&self, id: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()> { + fn ecdsa_sign( + &self, + key_type: KeyTypeId, + public: &ecdsa::Public, + msg: &[u8], + ) -> Result, Error> { + Ok(self.ecdsa_key_pair(key_type, public).map(|pair| pair.sign(msg))) + } + + fn ecdsa_sign_prehashed( + &self, + key_type: KeyTypeId, + public: &ecdsa::Public, + msg: &[u8; 32], + ) -> Result, Error> { + let pair = self.ecdsa_key_pair(key_type, public); + pair.map(|pair| pair.sign_prehashed(msg)).map(Ok).transpose() + } + + fn insert(&self, key_type: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()> { self.keys .write() - .entry(id) + .entry(key_type) .or_default() .insert(public.to_owned(), suri.to_string()); Ok(()) } + fn keys(&self, key_type: KeyTypeId) -> Result>, Error> { + let keys = self + .keys + .read() + .get(&key_type) + .map(|map| map.keys().cloned().collect()) + .unwrap_or_default(); + Ok(keys) + } + fn has_keys(&self, public_keys: &[(Vec, KeyTypeId)]) -> bool { public_keys .iter() .all(|(k, t)| self.keys.read().get(t).and_then(|s| s.get(k)).is_some()) } - - fn sign_with( - &self, - id: KeyTypeId, - key: &CryptoTypePublicPair, - msg: &[u8], - ) -> Result>, Error> { - use codec::Encode; - - match key.0 { - ed25519::CRYPTO_ID => { - let key_pair = self - .ed25519_key_pair(id, &ed25519::Public::from_slice(key.1.as_slice()).unwrap()); - - key_pair.map(|k| k.sign(msg).encode()).map(Ok).transpose() - }, - sr25519::CRYPTO_ID => { - let key_pair = self - .sr25519_key_pair(id, &sr25519::Public::from_slice(key.1.as_slice()).unwrap()); - - key_pair.map(|k| k.sign(msg).encode()).map(Ok).transpose() - }, - ecdsa::CRYPTO_ID => { - let key_pair = - self.ecdsa_key_pair(id, &ecdsa::Public::from_slice(key.1.as_slice()).unwrap()); - - key_pair.map(|k| k.sign(msg).encode()).map(Ok).transpose() - }, - _ => Err(Error::KeyNotSupported(id)), - } - } - - fn sr25519_vrf_sign( - &self, - key_type: KeyTypeId, - public: &sr25519::Public, - transcript_data: VRFTranscriptData, - ) -> Result, Error> { - let transcript = make_transcript(transcript_data); - let pair = - if let Some(k) = self.sr25519_key_pair(key_type, public) { k } else { return Ok(None) }; - - let (inout, proof, _) = pair.as_ref().vrf_sign(transcript); - Ok(Some(VRFSignature { output: inout.to_output(), proof })) - } - - fn ecdsa_sign_prehashed( - &self, - id: KeyTypeId, - public: &ecdsa::Public, - msg: &[u8; 32], - ) -> Result, Error> { - let pair = self.ecdsa_key_pair(id, public); - pair.map(|k| k.sign_prehashed(msg)).map(Ok).transpose() - } } impl Into for MemoryKeystore { @@ -306,7 +305,7 @@ mod tests { let public = store.ed25519_generate_new(ED25519, None).expect("Generates key"); - let public_keys = store.keys(ED25519).unwrap(); + let public_keys = store.ed25519_public_keys(ED25519); assert!(public_keys.contains(&public.into())); } @@ -322,7 +321,7 @@ mod tests { .insert(SR25519, secret_uri, key_pair.public().as_ref()) .expect("Inserts unknown key"); - let public_keys = store.keys(SR25519).unwrap(); + let public_keys = store.sr25519_public_keys(SR25519); assert!(public_keys.contains(&key_pair.public().into())); } diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 4bba6f6bc1283..95f977077e704 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -30,7 +30,7 @@ use crate::{ use impl_trait_for_tuples::impl_for_tuples; #[cfg(feature = "std")] use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use sp_application_crypto::AppKey; +use sp_application_crypto::AppCrypto; pub use sp_arithmetic::traits::{ checked_pow, ensure_pow, AtLeast32Bit, AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedShl, CheckedShr, CheckedSub, Ensure, EnsureAdd, EnsureAddAssign, EnsureDiv, @@ -148,10 +148,10 @@ pub trait AppVerify { } impl< - S: Verify::Public as sp_application_crypto::AppPublic>::Generic> + S: Verify::Public as sp_application_crypto::AppPublic>::Generic> + From, T: sp_application_crypto::Wraps - + sp_application_crypto::AppKey + + sp_application_crypto::AppCrypto + sp_application_crypto::AppSignature + AsRef + AsMut @@ -159,16 +159,18 @@ impl< > AppVerify for T where ::Signer: IdentifyAccount::Signer>, - <::Public as sp_application_crypto::AppPublic>::Generic: IdentifyAccount< - AccountId = <::Public as sp_application_crypto::AppPublic>::Generic, + <::Public as sp_application_crypto::AppPublic>::Generic: IdentifyAccount< + AccountId = <::Public as sp_application_crypto::AppPublic>::Generic, >, { - type AccountId = ::Public; - fn verify>(&self, msg: L, signer: &::Public) -> bool { + type AccountId = ::Public; + fn verify>(&self, msg: L, signer: &::Public) -> bool { use sp_application_crypto::IsWrappedBy; let inner: &S = self.as_ref(); let inner_pubkey = - <::Public as sp_application_crypto::AppPublic>::Generic::from_ref(signer); + <::Public as sp_application_crypto::AppPublic>::Generic::from_ref( + signer, + ); Verify::verify(inner, msg, inner_pubkey) } } From 656b139c24b660c9b3edd39e2418a0dd4a075cbd Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Fri, 24 Mar 2023 14:48:37 +0000 Subject: [PATCH 66/80] Use sensible maths for `from_rational` (#13660) * Use sensible maths for from_rational * Fixes * Fixes * More fixes * Remove debugging * Add fuzzer tests Signed-off-by: Oliver Tale-Yazdi * Prevent panics Signed-off-by: Oliver Tale-Yazdi * docs Signed-off-by: Oliver Tale-Yazdi * Clean up old code Signed-off-by: Oliver Tale-Yazdi * Test all rounding modes of from_rational Signed-off-by: Oliver Tale-Yazdi * Clean up code Signed-off-by: Oliver Tale-Yazdi * Revert "Prevent panics" This reverts commit 7e88ac76138a1b590e68b68318505b69efe1e1f6. * fix imports Signed-off-by: Oliver Tale-Yazdi * cleanup Signed-off-by: Oliver Tale-Yazdi * Fuzz test multiply_rational Signed-off-by: Oliver Tale-Yazdi * Fix import Signed-off-by: Oliver Tale-Yazdi * fmt Signed-off-by: Oliver Tale-Yazdi * Return None in multiply_rational on zero div Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi Co-authored-by: Oliver Tale-Yazdi --- Cargo.lock | 42 ++++++- frame/staking/src/tests.rs | 8 +- primitives/arithmetic/fuzzer/Cargo.toml | 11 +- .../src/multiply_by_rational_with_rounding.rs | 99 +++++++++------ .../fuzzer/src/per_thing_from_rational.rs | 105 ++++++++++++++++ .../fuzzer/src/per_thing_mult_fraction.rs | 69 +++++++++++ .../fuzzer/src/per_thing_rational.rs | 116 ------------------ primitives/arithmetic/src/helpers_128bit.rs | 4 +- primitives/arithmetic/src/lib.rs | 2 +- primitives/arithmetic/src/per_things.rs | 89 ++++---------- primitives/arithmetic/src/rational.rs | 48 ++++++++ primitives/arithmetic/src/traits.rs | 6 +- 12 files changed, 372 insertions(+), 227 deletions(-) create mode 100644 primitives/arithmetic/fuzzer/src/per_thing_from_rational.rs create mode 100644 primitives/arithmetic/fuzzer/src/per_thing_mult_fraction.rs delete mode 100644 primitives/arithmetic/fuzzer/src/per_thing_rational.rs diff --git a/Cargo.lock b/Cargo.lock index a645ecec60d86..33bca4005483c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -220,9 +220,9 @@ dependencies = [ [[package]] name = "arbitrary" -version = "1.2.3" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e90af4de65aa7b293ef2d09daff88501eb254f58edde2e1ac02c82d873eadad" +checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" [[package]] name = "arc-swap" @@ -2224,6 +2224,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fraction" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3027ae1df8d41b4bed2241c8fdad4acc1e7af60c8e17743534b545e77182d678" +dependencies = [ + "lazy_static", + "num", +] + [[package]] name = "fragile" version = "2.0.0" @@ -5286,6 +5296,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "num" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.3" @@ -5326,6 +5350,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-rational" version = "0.4.1" @@ -10143,8 +10178,11 @@ dependencies = [ name = "sp-arithmetic-fuzzer" version = "2.0.0" dependencies = [ + "arbitrary", + "fraction", "honggfuzz", "num-bigint", + "num-traits", "primitive-types", "sp-arithmetic", ] diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 36cafcc1854db..d97eb3ef89cab 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -5461,7 +5461,7 @@ fn proportional_ledger_slash_works() { ledger.active = unit; ledger.total = unit * 4 + value; // When - assert_eq!(ledger.slash(slash, 0, 0), slash - 5); + assert_eq!(ledger.slash(slash, 0, 0), slash); // Then // The amount slashed out of `unit` let affected_balance = value + unit * 4; @@ -5477,12 +5477,12 @@ fn proportional_ledger_slash_works() { value - value_slash }; assert_eq!(ledger.active, unit_slashed); - assert_eq!(ledger.unlocking, vec![c(5, value_slashed)]); - assert_eq!(ledger.total, value_slashed); + assert_eq!(ledger.unlocking, vec![c(5, value_slashed), c(7, 32)]); + assert_eq!(ledger.total, value_slashed + 32); assert_eq!(LedgerSlashPerEra::get().0, 0); assert_eq!( LedgerSlashPerEra::get().1, - BTreeMap::from([(4, 0), (5, value_slashed), (6, 0), (7, 0)]) + BTreeMap::from([(4, 0), (5, value_slashed), (6, 0), (7, 32)]) ); } diff --git a/primitives/arithmetic/fuzzer/Cargo.toml b/primitives/arithmetic/fuzzer/Cargo.toml index 7be800a2e966c..99dbdf7487320 100644 --- a/primitives/arithmetic/fuzzer/Cargo.toml +++ b/primitives/arithmetic/fuzzer/Cargo.toml @@ -14,8 +14,11 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] +arbitrary = "1.3.0" +fraction = "0.13.1" honggfuzz = "0.5.49" num-bigint = "0.4.3" +num-traits = "0.2.15" primitive-types = "0.12.0" sp-arithmetic = { version = "6.0.0", path = ".." } @@ -28,8 +31,12 @@ name = "normalize" path = "src/normalize.rs" [[bin]] -name = "per_thing_rational" -path = "src/per_thing_rational.rs" +name = "per_thing_from_rational" +path = "src/per_thing_from_rational.rs" + +[[bin]] +name = "per_thing_mult_fraction" +path = "src/per_thing_mult_fraction.rs" [[bin]] name = "multiply_by_rational_with_rounding" diff --git a/primitives/arithmetic/fuzzer/src/multiply_by_rational_with_rounding.rs b/primitives/arithmetic/fuzzer/src/multiply_by_rational_with_rounding.rs index 13c9d022be6bd..e9a3208a738ef 100644 --- a/primitives/arithmetic/fuzzer/src/multiply_by_rational_with_rounding.rs +++ b/primitives/arithmetic/fuzzer/src/multiply_by_rational_with_rounding.rs @@ -29,52 +29,79 @@ //! More information about `honggfuzz` can be found //! [here](https://docs.rs/honggfuzz/). +use fraction::prelude::BigFraction as Fraction; use honggfuzz::fuzz; -use sp_arithmetic::{helpers_128bit::multiply_by_rational_with_rounding, traits::Zero, Rounding}; +use sp_arithmetic::{MultiplyRational, Rounding, Rounding::*}; +/// Tries to demonstrate that `multiply_by_rational_with_rounding` is incorrect. fn main() { loop { - fuzz!(|data: ([u8; 16], [u8; 16], [u8; 16])| { - let (a_bytes, b_bytes, c_bytes) = data; - let (a, b, c) = ( - u128::from_be_bytes(a_bytes), - u128::from_be_bytes(b_bytes), - u128::from_be_bytes(c_bytes), - ); + fuzz!(|data: (u128, u128, u128, ArbitraryRounding)| { + let (f, n, d, r) = (data.0, data.1, data.2, data.3 .0); - println!("++ Equation: {} * {} / {}", a, b, c); - - // The point of this fuzzing is to make sure that `multiply_by_rational_with_rounding` - // is 100% accurate as long as the value fits in a u128. - if let Some(result) = multiply_by_rational_with_rounding(a, b, c, Rounding::Down) { - let truth = mul_div(a, b, c); - - if result != truth && result != truth + 1 { - println!("++ Expected {}", truth); - println!("+++++++ Got {}", result); - panic!(); - } - } + check::(f as u8, n as u8, d as u8, r); + check::(f as u16, n as u16, d as u16, r); + check::(f as u32, n as u32, d as u32, r); + check::(f as u64, n as u64, d as u64, r); + check::(f, n, d, r); }) } } -fn mul_div(a: u128, b: u128, c: u128) -> u128 { - use primitive_types::U256; - if a.is_zero() { - return Zero::zero() - } - let c = c.max(1); +fn check(f: N, n: N, d: N, r: Rounding) +where + N: MultiplyRational + Into + Copy + core::fmt::Debug, +{ + let Some(got) = f.multiply_rational(n, d, r) else { + return; + }; + + let (ae, be, ce) = + (Fraction::from(f.into()), Fraction::from(n.into()), Fraction::from(d.into())); + let want = round(ae * be / ce, r); - // e for extended - let ae: U256 = a.into(); - let be: U256 = b.into(); - let ce: U256 = c.into(); + assert_eq!( + Fraction::from(got.into()), + want, + "{:?} * {:?} / {:?} = {:?} != {:?}", + f, + n, + d, + got, + want + ); +} + +/// Round a `Fraction` according to the given mode. +fn round(f: Fraction, r: Rounding) -> Fraction { + match r { + Up => f.ceil(), + NearestPrefUp => + if f.fract() < Fraction::from(0.5) { + f.floor() + } else { + f.ceil() + }, + Down => f.floor(), + NearestPrefDown => + if f.fract() > Fraction::from(0.5) { + f.ceil() + } else { + f.floor() + }, + } +} - let r = ae * be / ce; - if r > u128::MAX.into() { - a - } else { - r.as_u128() +/// An [`arbitrary::Arbitrary`] [`Rounding`] mode. +struct ArbitraryRounding(Rounding); +impl arbitrary::Arbitrary<'_> for ArbitraryRounding { + fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { + Ok(Self(match u.int_in_range(0..=3).unwrap() { + 0 => Up, + 1 => NearestPrefUp, + 2 => Down, + 3 => NearestPrefDown, + _ => unreachable!(), + })) } } diff --git a/primitives/arithmetic/fuzzer/src/per_thing_from_rational.rs b/primitives/arithmetic/fuzzer/src/per_thing_from_rational.rs new file mode 100644 index 0000000000000..93af4df9e8e55 --- /dev/null +++ b/primitives/arithmetic/fuzzer/src/per_thing_from_rational.rs @@ -0,0 +1,105 @@ +// 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. + +//! # Running +//! Running this fuzzer can be done with `cargo hfuzz run per_thing_from_rational`. `honggfuzz` CLI +//! options can be used by setting `HFUZZ_RUN_ARGS`, such as `-n 4` to use 4 threads. +//! +//! # Debugging a panic +//! Once a panic is found, it can be debugged with +//! `cargo hfuzz run-debug per_thing_from_rational hfuzz_workspace/per_thing_from_rational/*.fuzz`. + +use fraction::prelude::BigFraction as Fraction; +use honggfuzz::fuzz; +use sp_arithmetic::{ + traits::SaturatedConversion, PerThing, Perbill, Percent, Perquintill, Rounding::*, *, +}; + +/// Tries to demonstrate that `from_rational` is incorrect for any rounding modes. +/// +/// NOTE: This `Fraction` library is really slow. Using f128/f256 does not work for the large +/// numbers. But an optimization could be done do use either floats or Fraction depending on the +/// size of the inputs. +fn main() { + loop { + fuzz!(|data: (u128, u128, ArbitraryRounding)| { + let (n, d, r) = (data.0.min(data.1), data.0.max(data.1).max(1), data.2); + + check::(n, d, r.0); + check::(n, d, r.0); + check::(n, d, r.0); + check::(n, d, r.0); + check::(n, d, r.0); + }) + } +} + +/// Assert that the parts of `from_rational` are correct for the given rounding mode. +fn check(a: u128, b: u128, r: Rounding) +where + Per::Inner: Into, +{ + let approx_ratio = Per::from_rational_with_rounding(a, b, r).unwrap(); + let approx_parts = Fraction::from(approx_ratio.deconstruct().saturated_into::()); + + let perfect_ratio = if a == 0 && b == 0 { + Fraction::from(1) + } else { + Fraction::from(a) / Fraction::from(b.max(1)) + }; + let perfect_parts = round(perfect_ratio * Fraction::from(Per::ACCURACY.into()), r); + + assert_eq!( + approx_parts, perfect_parts, + "approx_parts: {}, perfect_parts: {}, a: {}, b: {}", + approx_parts, perfect_parts, a, b + ); +} + +/// Round a `Fraction` according to the given mode. +fn round(f: Fraction, r: Rounding) -> Fraction { + match r { + Up => f.ceil(), + NearestPrefUp => + if f.fract() < Fraction::from(0.5) { + f.floor() + } else { + f.ceil() + }, + Down => f.floor(), + NearestPrefDown => + if f.fract() > Fraction::from(0.5) { + f.ceil() + } else { + f.floor() + }, + } +} + +/// An [`arbitrary::Arbitrary`] [`Rounding`] mode. +struct ArbitraryRounding(Rounding); +impl arbitrary::Arbitrary<'_> for ArbitraryRounding { + fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { + Ok(Self(match u.int_in_range(0..=3).unwrap() { + 0 => Up, + 1 => NearestPrefUp, + 2 => Down, + 3 => NearestPrefDown, + _ => unreachable!(), + })) + } +} diff --git a/primitives/arithmetic/fuzzer/src/per_thing_mult_fraction.rs b/primitives/arithmetic/fuzzer/src/per_thing_mult_fraction.rs new file mode 100644 index 0000000000000..9cfe28a7800b0 --- /dev/null +++ b/primitives/arithmetic/fuzzer/src/per_thing_mult_fraction.rs @@ -0,0 +1,69 @@ +// 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. + +//! # Running +//! Running this fuzzer can be done with `cargo hfuzz run per_thing_mult_fraction`. `honggfuzz` CLI +//! options can be used by setting `HFUZZ_RUN_ARGS`, such as `-n 4` to use 4 threads. +//! +//! # Debugging a panic +//! Once a panic is found, it can be debugged with +//! `cargo hfuzz run-debug per_thing_mult_fraction hfuzz_workspace/per_thing_mult_fraction/*.fuzz`. + +use honggfuzz::fuzz; +use sp_arithmetic::{PerThing, Perbill, Percent, Perquintill, *}; + +/// Tries to disprove `(n / d) * d <= n` for any `PerThing`s. +fn main() { + loop { + fuzz!(|data: (u128, u128)| { + let (n, d) = (data.0.min(data.1), data.0.max(data.1).max(1)); + + check_mul::(n, d); + check_mul::(n, d); + check_mul::(n, d); + check_mul::(n, d); + + check_reciprocal_mul::(n, d); + check_reciprocal_mul::(n, d); + check_reciprocal_mul::(n, d); + check_reciprocal_mul::(n, d); + }) + } +} + +/// Checks that `(n / d) * d <= n`. +fn check_mul(n: u128, d: u128) +where + P: PerThing + core::ops::Mul, +{ + let q = P::from_rational_with_rounding(n, d, Rounding::Down).unwrap(); + assert!(q * d <= n, "{:?} * {:?} <= {:?}", q, d, n); +} + +/// Checks that `n / (n / d) >= d`. +fn check_reciprocal_mul(n: u128, d: u128) +where + P: PerThing + core::ops::Mul, +{ + let q = P::from_rational_with_rounding(n, d, Rounding::Down).unwrap(); + if q.is_zero() { + return + } + + let r = q.saturating_reciprocal_mul_floor(n); + assert!(r >= d, "{} / ({} / {}) != {} but {}", n, n, d, d, r); +} diff --git a/primitives/arithmetic/fuzzer/src/per_thing_rational.rs b/primitives/arithmetic/fuzzer/src/per_thing_rational.rs deleted file mode 100644 index c9c5146565cc7..0000000000000 --- a/primitives/arithmetic/fuzzer/src/per_thing_rational.rs +++ /dev/null @@ -1,116 +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. - -//! # Running -//! Running this fuzzer can be done with `cargo hfuzz run per_thing_rational`. `honggfuzz` CLI -//! options can be used by setting `HFUZZ_RUN_ARGS`, such as `-n 4` to use 4 threads. -//! -//! # Debugging a panic -//! Once a panic is found, it can be debugged with -//! `cargo hfuzz run-debug per_thing_rational hfuzz_workspace/per_thing_rational/*.fuzz`. - -use honggfuzz::fuzz; -use sp_arithmetic::{traits::SaturatedConversion, PerThing, PerU16, Perbill, Percent, Perquintill}; - -fn main() { - loop { - fuzz!(|data: ((u16, u16), (u32, u32), (u64, u64))| { - let (u16_pair, u32_pair, u64_pair) = data; - - // peru16 - let (smaller, bigger) = (u16_pair.0.min(u16_pair.1), u16_pair.0.max(u16_pair.1)); - let ratio = PerU16::from_rational(smaller, bigger); - assert_per_thing_equal_error( - ratio, - PerU16::from_float(smaller as f64 / bigger.max(1) as f64), - 1, - ); - let (smaller, bigger) = (u32_pair.0.min(u32_pair.1), u32_pair.0.max(u32_pair.1)); - let ratio = PerU16::from_rational(smaller, bigger); - assert_per_thing_equal_error( - ratio, - PerU16::from_float(smaller as f64 / bigger.max(1) as f64), - 1, - ); - let (smaller, bigger) = (u64_pair.0.min(u64_pair.1), u64_pair.0.max(u64_pair.1)); - let ratio = PerU16::from_rational(smaller, bigger); - assert_per_thing_equal_error( - ratio, - PerU16::from_float(smaller as f64 / bigger.max(1) as f64), - 1, - ); - - // percent - let (smaller, bigger) = (u16_pair.0.min(u16_pair.1), u16_pair.0.max(u16_pair.1)); - let ratio = Percent::from_rational(smaller, bigger); - assert_per_thing_equal_error( - ratio, - Percent::from_float(smaller as f64 / bigger.max(1) as f64), - 1, - ); - - let (smaller, bigger) = (u32_pair.0.min(u32_pair.1), u32_pair.0.max(u32_pair.1)); - let ratio = Percent::from_rational(smaller, bigger); - assert_per_thing_equal_error( - ratio, - Percent::from_float(smaller as f64 / bigger.max(1) as f64), - 1, - ); - - let (smaller, bigger) = (u64_pair.0.min(u64_pair.1), u64_pair.0.max(u64_pair.1)); - let ratio = Percent::from_rational(smaller, bigger); - assert_per_thing_equal_error( - ratio, - Percent::from_float(smaller as f64 / bigger.max(1) as f64), - 1, - ); - - // perbill - let (smaller, bigger) = (u32_pair.0.min(u32_pair.1), u32_pair.0.max(u32_pair.1)); - let ratio = Perbill::from_rational(smaller, bigger); - assert_per_thing_equal_error( - ratio, - Perbill::from_float(smaller as f64 / bigger.max(1) as f64), - 100, - ); - - let (smaller, bigger) = (u64_pair.0.min(u64_pair.1), u64_pair.0.max(u64_pair.1)); - let ratio = Perbill::from_rational(smaller, bigger); - assert_per_thing_equal_error( - ratio, - Perbill::from_float(smaller as f64 / bigger.max(1) as f64), - 100, - ); - - // perquintillion - let (smaller, bigger) = (u64_pair.0.min(u64_pair.1), u64_pair.0.max(u64_pair.1)); - let ratio = Perquintill::from_rational(smaller, bigger); - assert_per_thing_equal_error( - ratio, - Perquintill::from_float(smaller as f64 / bigger.max(1) as f64), - 1000, - ); - }) - } -} - -fn assert_per_thing_equal_error(a: P, b: P, err: u128) { - let a_abs = a.deconstruct().saturated_into::(); - let b_abs = b.deconstruct().saturated_into::(); - let diff = a_abs.max(b_abs) - a_abs.min(b_abs); - assert!(diff <= err, "{:?} !~ {:?}", a, b); -} diff --git a/primitives/arithmetic/src/helpers_128bit.rs b/primitives/arithmetic/src/helpers_128bit.rs index 56432d15a7260..9b9c74ba55774 100644 --- a/primitives/arithmetic/src/helpers_128bit.rs +++ b/primitives/arithmetic/src/helpers_128bit.rs @@ -182,8 +182,8 @@ mod double128 { } } -/// Returns `a * b / c` and `(a * b) % c` (wrapping to 128 bits) or `None` in the case of -/// overflow and c = 0. +/// Returns `a * b / c` (wrapping to 128 bits) or `None` in the case of +/// overflow. pub const fn multiply_by_rational_with_rounding( a: u128, b: u128, diff --git a/primitives/arithmetic/src/lib.rs b/primitives/arithmetic/src/lib.rs index 581206b6d4460..e7ba08a532909 100644 --- a/primitives/arithmetic/src/lib.rs +++ b/primitives/arithmetic/src/lib.rs @@ -45,7 +45,7 @@ pub use per_things::{ InnerOf, MultiplyArg, PerThing, PerU16, Perbill, Percent, Permill, Perquintill, RationalArg, ReciprocalArg, Rounding, SignedRounding, UpperOf, }; -pub use rational::{Rational128, RationalInfinite}; +pub use rational::{MultiplyRational, Rational128, RationalInfinite}; use sp_std::{cmp::Ordering, fmt::Debug, prelude::*}; use traits::{BaseArithmetic, One, SaturatedConversion, Unsigned, Zero}; diff --git a/primitives/arithmetic/src/per_things.rs b/primitives/arithmetic/src/per_things.rs index 068bdb4e17b0d..c4cb5196602ea 100644 --- a/primitives/arithmetic/src/per_things.rs +++ b/primitives/arithmetic/src/per_things.rs @@ -26,7 +26,7 @@ use codec::{CompactAs, Encode}; use num_traits::{Pow, SaturatingAdd, SaturatingSub}; use sp_std::{ fmt, ops, - ops::{Add, AddAssign, Div, Rem, Sub}, + ops::{Add, Sub}, prelude::*, }; @@ -46,6 +46,7 @@ pub trait RationalArg: + Unsigned + Zero + One + + crate::MultiplyRational { } @@ -58,7 +59,8 @@ impl< + ops::AddAssign + Unsigned + Zero - + One, + + One + + crate::MultiplyRational, > RationalArg for T { } @@ -105,7 +107,7 @@ pub trait PerThing: + Pow { /// The data type used to build this per-thingy. - type Inner: BaseArithmetic + Unsigned + Copy + Into + fmt::Debug; + type Inner: BaseArithmetic + Unsigned + Copy + Into + fmt::Debug + crate::MultiplyRational; /// A data type larger than `Self::Inner`, used to avoid overflow in some computations. /// It must be able to compute `ACCURACY^2`. @@ -115,7 +117,8 @@ pub trait PerThing: + TryInto + UniqueSaturatedInto + Unsigned - + fmt::Debug; + + fmt::Debug + + crate::MultiplyRational; /// The accuracy of this type. const ACCURACY: Self::Inner; @@ -538,39 +541,6 @@ where rem_mul_div_inner.into() } -/// Just a simple generic integer divide with custom rounding. -fn div_rounded(n: N, d: N, r: Rounding) -> N -where - N: Clone - + Eq - + Ord - + Zero - + One - + AddAssign - + Add - + Rem - + Div, -{ - let mut o = n.clone() / d.clone(); - use Rounding::*; - let two = || N::one() + N::one(); - if match r { - Up => !((n % d).is_zero()), - NearestPrefDown => { - let rem = n % d.clone(); - rem > d / two() - }, - NearestPrefUp => { - let rem = n % d.clone(); - rem >= d.clone() / two() + d % two() - }, - Down => false, - } { - o += N::one() - } - o -} - macro_rules! implement_per_thing { ( $name:ident, @@ -687,7 +657,8 @@ macro_rules! implement_per_thing { + ops::AddAssign + Unsigned + Zero - + One, + + One + + $crate::MultiplyRational, Self::Inner: Into { // q cannot be zero. @@ -695,30 +666,8 @@ macro_rules! implement_per_thing { // p should not be bigger than q. if p > q { return Err(()) } - let factor = div_rounded::(q.clone(), $max.into(), Rounding::Up).max(One::one()); - - // q cannot overflow: (q / (q/$max)) < $max. p < q hence p also cannot overflow. - let q_reduce: $type = div_rounded(q, factor.clone(), r) - .try_into() - .map_err(|_| "Failed to convert") - .expect( - "`q / ceil(q/$max) < $max`; macro prevents any type being created that \ - does not satisfy this; qed" - ); - let p_reduce: $type = div_rounded(p, factor, r) - .try_into() - .map_err(|_| "Failed to convert") - .expect( - "`p / ceil(p/$max) < $max`; macro prevents any type being created that \ - does not satisfy this; qed" - ); - - // `p_reduced` and `q_reduced` are within `Self::Inner`. Multiplication by another - // `$max` will always fit in `$upper_type`. This is guaranteed by the macro tests. - let n = p_reduce as $upper_type * <$upper_type>::from($max); - let d = q_reduce as $upper_type; - let part = div_rounded(n, d, r); - Ok($name(part as Self::Inner)) + let max: N = $max.into(); + max.multiply_rational(p, q, r).ok_or(())?.try_into().map(|x| $name(x)).map_err(|_| ()) } } @@ -1862,6 +1811,22 @@ fn from_rational_with_rounding_works_in_extreme_case() { } } +#[test] +fn from_rational_with_rounding_breakage() { + let n = 372633774963620730670986667244911905u128; + let d = 512593663333074177468745541591173060u128; + let q = Perquintill::from_rational_with_rounding(n, d, Rounding::Down).unwrap(); + assert!(q * d <= n); +} + +#[test] +fn from_rational_with_rounding_breakage_2() { + let n = 36893488147419103230u128; + let d = 36893488147419103630u128; + let q = Perquintill::from_rational_with_rounding(n, d, Rounding::Up).unwrap(); + assert!(q * d >= n); +} + implement_per_thing!(Percent, test_per_cent, [u32, u64, u128], 100u8, u8, u16, "_Percent_",); implement_per_thing_with_perthousand!( PerU16, diff --git a/primitives/arithmetic/src/rational.rs b/primitives/arithmetic/src/rational.rs index 0fcb7d4d9462a..ebd89c615a38b 100644 --- a/primitives/arithmetic/src/rational.rs +++ b/primitives/arithmetic/src/rational.rs @@ -284,6 +284,54 @@ impl PartialEq for Rational128 { } } +pub trait MultiplyRational: Sized { + fn multiply_rational(self, n: Self, d: Self, r: Rounding) -> Option; +} + +macro_rules! impl_rrm { + ($ulow:ty, $uhi:ty) => { + impl MultiplyRational for $ulow { + fn multiply_rational(self, n: Self, d: Self, r: Rounding) -> Option { + if d.is_zero() { + return None + } + + let sn = (self as $uhi) * (n as $uhi); + let mut result = sn / (d as $uhi); + let remainder = (sn % (d as $uhi)) as $ulow; + if match r { + Rounding::Up => remainder > 0, + // cannot be `(d + 1) / 2` since `d` might be `max_value` and overflow. + Rounding::NearestPrefUp => remainder >= d / 2 + d % 2, + Rounding::NearestPrefDown => remainder > d / 2, + Rounding::Down => false, + } { + result = match result.checked_add(1) { + Some(v) => v, + None => return None, + }; + } + if result > (<$ulow>::max_value() as $uhi) { + None + } else { + Some(result as $ulow) + } + } + } + }; +} + +impl_rrm!(u8, u16); +impl_rrm!(u16, u32); +impl_rrm!(u32, u64); +impl_rrm!(u64, u128); + +impl MultiplyRational for u128 { + fn multiply_rational(self, n: Self, d: Self, r: Rounding) -> Option { + crate::helpers_128bit::multiply_by_rational_with_rounding(self, n, d, r) + } +} + #[cfg(test)] mod tests { use super::{helpers_128bit::*, *}; diff --git a/primitives/arithmetic/src/traits.rs b/primitives/arithmetic/src/traits.rs index 33b4e376aaf9d..061b11b3e9c72 100644 --- a/primitives/arithmetic/src/traits.rs +++ b/primitives/arithmetic/src/traits.rs @@ -32,6 +32,8 @@ use sp_std::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, Shr, Sub, SubAssign, }; +use crate::MultiplyRational; + /// A meta trait for arithmetic type operations, regardless of any limitation on size. pub trait BaseArithmetic: From @@ -186,9 +188,9 @@ pub trait AtLeast32Bit: BaseArithmetic + From + From {} impl + From> AtLeast32Bit for T {} /// A meta trait for arithmetic. Same as [`AtLeast32Bit `], but also bounded to be unsigned. -pub trait AtLeast32BitUnsigned: AtLeast32Bit + Unsigned {} +pub trait AtLeast32BitUnsigned: AtLeast32Bit + Unsigned + MultiplyRational {} -impl AtLeast32BitUnsigned for T {} +impl AtLeast32BitUnsigned for T {} /// Just like `From` except that if the source value is too big to fit into the destination type /// then it'll saturate the destination. From ad66dd2ff1c6c97d9d5d25a0dc7d3a44342c9a3a Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 24 Mar 2023 16:09:34 +0100 Subject: [PATCH 67/80] try-runtime: run migration checks per default (#13684) * try-runtime: run migration checks per default The current behaviour of having to explicetly specify --checks seems to cause confusion. Therefore bringing back the old behaviour of running the pre- and post-upgrade checks per default. Signed-off-by: Oliver Tale-Yazdi * Fix docs Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi --- .../try-runtime/cli/src/commands/on_runtime_upgrade.rs | 4 ++-- utils/frame/try-runtime/cli/src/lib.rs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs b/utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs index c8582ea4d2a60..948ff9c030ea9 100644 --- a/utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs +++ b/utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs @@ -40,8 +40,8 @@ pub struct OnRuntimeUpgradeCmd { /// Performing any checks will potentially invalidate the measured PoV/Weight. // NOTE: The clap attributes make it backwards compatible with the previous `--checks` flag. #[clap(long, - default_value = "None", - default_missing_value = "All", + default_value = "pre-and-post", + default_missing_value = "all", num_args = 0..=1, require_equals = true, verbatim_doc_comment)] diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index 0a521d1215562..bc9fd99d3e628 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -134,10 +134,10 @@ //! //! ```ignore //! -//! #[cfg(feature = try-runtime)] +//! #[cfg(feature = "try-runtime")] //! fn pre_upgrade() -> Result, &'static str> {} //! -//! #[cfg(feature = try-runtime)] +//! #[cfg(feature = "try-runtime")] //! fn post_upgrade(state: Vec) -> Result<(), &'static str> {} //! ``` //! @@ -152,9 +152,9 @@ //! //! Similarly, each pallet can expose a function in `#[pallet::hooks]` section as follows: //! -//! ``` -//! #[cfg(feature = try-runtime)] -//! fn try_state(_) -> Result<(), &'static str> {} +//! ```ignore +//! #[cfg(feature = "try-runtime")] +//! fn try_state(_: BlockNumber) -> Result<(), &'static str> {} //! ``` //! //! which is called on numerous code paths in the try-runtime tool. These checks should ensure that From 770d23709a7e004ae8f5fff1598bb4cf72928b43 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Fri, 24 Mar 2023 17:48:21 +0000 Subject: [PATCH 68/80] Make ED of zero (kind of) work (#13655) * Minimum of 1 for ED * Avoid need for ED to be minimum one * Docs * Ban ED of zero unless feature enabled * use integrity_test * Docs * Cleanup * Update frame/balances/Cargo.toml Co-authored-by: Oliver Tale-Yazdi * Update frame/balances/src/lib.rs Co-authored-by: Oliver Tale-Yazdi * Update frame/balances/src/lib.rs Co-authored-by: Oliver Tale-Yazdi * Ensure dodgy code is disabled by default * zero_ed -> insecure_zero_ed --------- Co-authored-by: Oliver Tale-Yazdi Co-authored-by: parity-processbot <> --- frame/balances/Cargo.toml | 2 + frame/balances/src/lib.rs | 55 +++++++++++++++++++--- frame/balances/src/tests/currency_tests.rs | 15 +++++- frame/balances/src/tests/mod.rs | 2 +- frame/vesting/src/mock.rs | 2 +- 5 files changed, 65 insertions(+), 11 deletions(-) diff --git a/frame/balances/Cargo.toml b/frame/balances/Cargo.toml index 15ef136aa3800..9646a934df00e 100644 --- a/frame/balances/Cargo.toml +++ b/frame/balances/Cargo.toml @@ -39,5 +39,7 @@ std = [ "sp-runtime/std", "sp-std/std", ] +# Enable support for setting the existential deposit to zero. +insecure_zero_ed = [] runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] try-runtime = ["frame-support/try-runtime"] diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index ca8e86ef2f64a..460f2be37ff2d 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -151,6 +151,10 @@ //! ## Assumptions //! //! * Total issued balanced of all accounts should be less than `Config::Balance::max_value()`. +//! * Existential Deposit is set to a value greater than zero. +//! +//! Note, you may find the Balances pallet still functions with an ED of zero in some circumstances, +//! however this is not a configuration which is generally supported, nor will it be. #![cfg_attr(not(feature = "std"), no_std)] mod benchmarking; @@ -231,7 +235,14 @@ pub mod pallet { /// Handler for the unbalanced reduction when removing a dust account. type DustRemoval: OnUnbalanced>; - /// The minimum amount required to keep an account open. + /// The minimum amount required to keep an account open. MUST BE GREATER THAN ZERO! + /// + /// If you *really* need it to be zero, you can enable the feature `insecure_zero_ed` for + /// this pallet. However, you do so at your own risk: this will open up a major DoS vector. + /// In case you have multiple sources of provider references, you may also get unexpected + /// behaviour if you set this to zero. + /// + /// Bottom line: Do yourself a favour and make it at least one! #[pallet::constant] type ExistentialDeposit: Get; @@ -445,6 +456,7 @@ pub mod pallet { impl, I: 'static> GenesisBuild for GenesisConfig { fn build(&self) { let total = self.balances.iter().fold(Zero::zero(), |acc: T::Balance, &(_, n)| acc + n); + >::put(total); for (_, balance) in &self.balances { @@ -492,6 +504,17 @@ pub mod pallet { } } + #[pallet::hooks] + impl, I: 'static> Hooks for Pallet { + #[cfg(not(feature = "insecure_zero_ed"))] + fn integrity_test() { + assert!( + !>::ExistentialDeposit::get().is_zero(), + "The existential deposit must be greater than zero!" + ); + } + } + #[pallet::call] impl, I: 'static> Pallet { /// Transfer some liquid free balance to another account. @@ -533,7 +556,7 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { ensure_root(origin)?; let who = T::Lookup::lookup(who)?; - let existential_deposit = T::ExistentialDeposit::get(); + let existential_deposit = Self::ed(); let wipeout = new_free < existential_deposit; let new_free = if wipeout { Zero::zero() } else { new_free }; @@ -716,7 +739,7 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { ensure_root(origin)?; let who = T::Lookup::lookup(who)?; - let existential_deposit = T::ExistentialDeposit::get(); + let existential_deposit = Self::ed(); let wipeout = new_free < existential_deposit; let new_free = if wipeout { Zero::zero() } else { new_free }; @@ -742,6 +765,9 @@ pub mod pallet { } impl, I: 'static> Pallet { + fn ed() -> T::Balance { + T::ExistentialDeposit::get() + } /// Ensure the account `who` is using the new logic. /// /// Returns `true` if the account did get upgraded, `false` if it didn't need upgrading. @@ -756,7 +782,7 @@ pub mod pallet { // Gah!! We have a non-zero reserve balance but no provider refs :( // This shouldn't practically happen, but we need a failsafe anyway: let's give // them enough for an ED. - a.free = a.free.min(T::ExistentialDeposit::get()); + a.free = a.free.min(Self::ed()); system::Pallet::::inc_providers(who); } let _ = system::Pallet::::inc_consumers(who).defensive(); @@ -864,6 +890,20 @@ pub mod pallet { Self::try_mutate_account(who, |a, _| -> Result { Ok(f(a)) }) } + /// Returns `true` when `who` has some providers or `insecure_zero_ed` feature is disnabled. + /// Returns `false` otherwise. + #[cfg(not(feature = "insecure_zero_ed"))] + fn have_providers_or_no_zero_ed(_: &T::AccountId) -> bool { + true + } + + /// Returns `true` when `who` has some providers or `insecure_zero_ed` feature is disnabled. + /// Returns `false` otherwise. + #[cfg(feature = "insecure_zero_ed")] + fn have_providers_or_no_zero_ed(who: &T::AccountId) -> bool { + frame_system::Pallet::::providers(who) > 0 + } + /// Mutate an account to some new value, or delete it entirely with `None`. Will enforce /// `ExistentialDeposit` law, annulling the account as needed. This will do nothing if the /// result of `f` is an `Err`. @@ -885,13 +925,14 @@ pub mod pallet { let result = T::AccountStore::try_mutate_exists(who, |maybe_account| { let is_new = maybe_account.is_none(); let mut account = maybe_account.take().unwrap_or_default(); - let did_provide = account.free >= T::ExistentialDeposit::get(); + let did_provide = + account.free >= Self::ed() && Self::have_providers_or_no_zero_ed(who); let did_consume = !is_new && (!account.reserved.is_zero() || !account.frozen.is_zero()); let result = f(&mut account, is_new)?; - let does_provide = account.free >= T::ExistentialDeposit::get(); + let does_provide = account.free >= Self::ed(); let does_consume = !account.reserved.is_zero() || !account.frozen.is_zero(); if !did_provide && does_provide { @@ -930,7 +971,7 @@ pub mod pallet { // // We should never be dropping if reserved is non-zero. Reserved being non-zero // should imply that we have a consumer ref, so this is economically safe. - let ed = T::ExistentialDeposit::get(); + let ed = Self::ed(); let maybe_dust = if account.free < ed && account.reserved.is_zero() { if account.free.is_zero() { None diff --git a/frame/balances/src/tests/currency_tests.rs b/frame/balances/src/tests/currency_tests.rs index b0a38f4ac4ed7..f74e6bb8c4993 100644 --- a/frame/balances/src/tests/currency_tests.rs +++ b/frame/balances/src/tests/currency_tests.rs @@ -23,7 +23,8 @@ use frame_support::traits::{ BalanceStatus::{Free, Reserved}, Currency, ExistenceRequirement::{self, AllowDeath}, - LockIdentifier, LockableCurrency, NamedReservableCurrency, ReservableCurrency, WithdrawReasons, + Hooks, LockIdentifier, LockableCurrency, NamedReservableCurrency, ReservableCurrency, + WithdrawReasons, }; const ID_1: LockIdentifier = *b"1 "; @@ -974,7 +975,7 @@ fn slash_reserved_on_non_existant_works() { fn operations_on_dead_account_should_not_change_state() { // These functions all use `mutate_account` which may introduce a storage change when // the account never existed to begin with, and shouldn't exist in the end. - ExtBuilder::default().existential_deposit(0).build_and_execute_with(|| { + ExtBuilder::default().existential_deposit(1).build_and_execute_with(|| { assert!(!frame_system::Account::::contains_key(&1337)); // Unreserve @@ -993,6 +994,16 @@ fn operations_on_dead_account_should_not_change_state() { }); } +#[test] +#[should_panic = "The existential deposit must be greater than zero!"] +fn zero_ed_is_prohibited() { + // These functions all use `mutate_account` which may introduce a storage change when + // the account never existed to begin with, and shouldn't exist in the end. + ExtBuilder::default().existential_deposit(0).build_and_execute_with(|| { + Balances::integrity_test(); + }); +} + #[test] fn named_reserve_should_work() { ExtBuilder::default().build_and_execute_with(|| { diff --git a/frame/balances/src/tests/mod.rs b/frame/balances/src/tests/mod.rs index c4a8a631cad20..68e7e82035b0e 100644 --- a/frame/balances/src/tests/mod.rs +++ b/frame/balances/src/tests/mod.rs @@ -87,7 +87,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max( frame_support::weights::Weight::from_parts(1024, u64::MAX), ); - pub static ExistentialDeposit: u64 = 0; + pub static ExistentialDeposit: u64 = 1; } impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index be6afd4a60ec8..1adb36b730b1a 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -89,7 +89,7 @@ parameter_types! { pub const MinVestedTransfer: u64 = 256 * 2; pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); - pub static ExistentialDeposit: u64 = 0; + pub static ExistentialDeposit: u64 = 1; } impl Config for Test { type BlockNumberToBalance = Identity; From d0449fd4219cb3c77e46a9916c7996a1136ca63e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 24 Mar 2023 18:50:16 +0100 Subject: [PATCH 69/80] try-runtime: Use configured wasm execution method (#13694) * try-runtime: Use configured wasm execution method * Fix compilation --- client/cli/src/arg_enums.rs | 4 ++-- utils/frame/try-runtime/cli/src/lib.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/cli/src/arg_enums.rs b/client/cli/src/arg_enums.rs index c3399a89680d1..7e2498cec4b7f 100644 --- a/client/cli/src/arg_enums.rs +++ b/client/cli/src/arg_enums.rs @@ -74,12 +74,12 @@ impl std::fmt::Display for WasmExecutionMethod { /// into an execution method which can be used internally. pub fn execution_method_from_cli( execution_method: WasmExecutionMethod, - _instantiation_strategy: WasmtimeInstantiationStrategy, + instantiation_strategy: WasmtimeInstantiationStrategy, ) -> sc_service::config::WasmExecutionMethod { match execution_method { WasmExecutionMethod::Interpreted => sc_service::config::WasmExecutionMethod::Interpreted, WasmExecutionMethod::Compiled => sc_service::config::WasmExecutionMethod::Compiled { - instantiation_strategy: match _instantiation_strategy { + instantiation_strategy: match instantiation_strategy { WasmtimeInstantiationStrategy::PoolingCopyOnWrite => sc_service::config::WasmtimeInstantiationStrategy::PoolingCopyOnWrite, WasmtimeInstantiationStrategy::RecreateInstanceCopyOnWrite => diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index bc9fd99d3e628..e1873f6a04abd 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -133,7 +133,6 @@ //! given the right flag: //! //! ```ignore -//! //! #[cfg(feature = "try-runtime")] //! fn pre_upgrade() -> Result, &'static str> {} //! @@ -365,8 +364,9 @@ use remote_externalities::{ TestExternalities, }; use sc_cli::{ - CliConfiguration, RuntimeVersion, WasmExecutionMethod, WasmtimeInstantiationStrategy, - DEFAULT_WASMTIME_INSTANTIATION_STRATEGY, DEFAULT_WASM_EXECUTION_METHOD, + execution_method_from_cli, CliConfiguration, RuntimeVersion, WasmExecutionMethod, + WasmtimeInstantiationStrategy, DEFAULT_WASMTIME_INSTANTIATION_STRATEGY, + DEFAULT_WASM_EXECUTION_METHOD, }; use sc_executor::{sp_wasm_interface::HostFunctions, WasmExecutor}; use sp_api::HashT; @@ -831,7 +831,7 @@ pub(crate) fn build_executor(shared: &SharedParams) -> WasmExe let runtime_cache_size = 2; WasmExecutor::new( - sc_executor::WasmExecutionMethod::Interpreted, + execution_method_from_cli(shared.wasm_method, shared.wasmtime_instantiation_strategy), heap_pages, max_runtime_instances, None, From e87f7acc4191274a2889f1b9adb59260e038b0a8 Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Fri, 24 Mar 2023 22:00:48 +0100 Subject: [PATCH 70/80] bump timestamp script to v0.2 (#13710) --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6cf06273650f7..c4d88ebde75f2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -313,7 +313,7 @@ include: rules: - if: $PIPELINE != "automatic-crate-publishing" - project: parity/infrastructure/ci_cd/shared - ref: v0.1 + ref: v0.2 file: /common/timestamp.yml #### stage: notify From a3df63ef370adb7f806aa6ffa876eb17672b7ca8 Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Fri, 24 Mar 2023 23:54:32 +0100 Subject: [PATCH 71/80] Fix docs (#13709) --- primitives/application-crypto/src/traits.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/primitives/application-crypto/src/traits.rs b/primitives/application-crypto/src/traits.rs index f672efb8a890a..b3bcd0ce2b701 100644 --- a/primitives/application-crypto/src/traits.rs +++ b/primitives/application-crypto/src/traits.rs @@ -22,7 +22,14 @@ use codec::Codec; use sp_core::crypto::{CryptoType, CryptoTypeId, IsWrappedBy, KeyTypeId, Public}; use sp_std::{fmt::Debug, vec::Vec}; -/// An application-specific key. +/// An application-specific cryptographic object. +/// +/// Combines all the core types and constants that are defined by a particular +/// cryptographic scheme when it is used in a specific application domain. +/// +/// Typically, the implementers of this trait are its associated types themselves. +/// This provides a convenient way to access generic information about the scheme +/// given any of the associated types. pub trait AppCrypto: 'static + Send + Sync + Sized + CryptoType + Clone { /// Identifier for application-specific key type. const ID: KeyTypeId; From 5766265306d104b4a5d7cf1082bcae78986dfff0 Mon Sep 17 00:00:00 2001 From: Aaro Altonen <48052676+altonen@users.noreply.github.com> Date: Sat, 25 Mar 2023 01:47:28 +0200 Subject: [PATCH 72/80] Get the correct number of connected peers in `SyncState` (#13700) `Protocol` is not a reliable source for the information of connected peers because it doesn't have real-time information of the actual connectivity state because it's not resposible for accepting/rejecting connections and gets that information with delay from `SyncinEngine`. --- client/informant/src/display.rs | 2 +- client/network/common/src/sync.rs | 2 ++ client/network/sync/src/engine.rs | 4 +++- client/network/sync/src/lib.rs | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/client/informant/src/display.rs b/client/informant/src/display.rs index 46e7229273d79..2f101307229da 100644 --- a/client/informant/src/display.rs +++ b/client/informant/src/display.rs @@ -76,7 +76,7 @@ impl InformantDisplay { let best_number = info.chain.best_number; let best_hash = info.chain.best_hash; let finalized_number = info.chain.finalized_number; - let num_connected_peers = net_status.num_connected_peers; + let num_connected_peers = sync_status.num_connected_peers; let speed = speed::(best_number, self.last_number, self.last_update); let total_bytes_inbound = net_status.total_bytes_inbound; let total_bytes_outbound = net_status.total_bytes_outbound; diff --git a/client/network/common/src/sync.rs b/client/network/common/src/sync.rs index 130f354b70050..d02a81379aea0 100644 --- a/client/network/common/src/sync.rs +++ b/client/network/common/src/sync.rs @@ -94,6 +94,8 @@ pub struct SyncStatus { pub best_seen_block: Option>, /// Number of peers participating in syncing. pub num_peers: u32, + /// Number of peers known to `SyncingEngine` (both full and light). + pub num_connected_peers: u32, /// Number of blocks queued for import pub queued_blocks: u32, /// State sync status in progress, if any. diff --git a/client/network/sync/src/engine.rs b/client/network/sync/src/engine.rs index a9c9afc3c6f4c..b4c1a2ed05bb0 100644 --- a/client/network/sync/src/engine.rs +++ b/client/network/sync/src/engine.rs @@ -711,7 +711,9 @@ where ToServiceCommand::NewBestBlockImported(hash, number) => self.new_best_block_imported(hash, number), ToServiceCommand::Status(tx) => { - let _ = tx.send(self.chain_sync.status()); + let mut status = self.chain_sync.status(); + status.num_connected_peers = self.peers.len() as u32; + let _ = tx.send(status); }, ToServiceCommand::NumActivePeers(tx) => { let _ = tx.send(self.chain_sync.num_active_peers()); diff --git a/client/network/sync/src/lib.rs b/client/network/sync/src/lib.rs index 45d14ffa7bb37..28959e7f9c886 100644 --- a/client/network/sync/src/lib.rs +++ b/client/network/sync/src/lib.rs @@ -523,6 +523,7 @@ where state: sync_state, best_seen_block, num_peers: self.peers.len() as u32, + num_connected_peers: 0u32, queued_blocks: self.queue_blocks.len() as u32, state_sync: self.state_sync.as_ref().map(|s| s.progress()), warp_sync: warp_sync_progress, From ea7238237da06731ff2c4280d71f00c0b361e74c Mon Sep 17 00:00:00 2001 From: Harald Heckmann Date: Sat, 25 Mar 2023 00:53:18 +0100 Subject: [PATCH 73/80] Emit event when changing total locked value in pallet-balances (#12287) * Emit Locked/Unlocked events * Implement lock event tests * Adhere to style guide * Use saturating math Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Fix typo * Emit event on change locks and add tests * Adjust event docstring --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: parity-processbot <> --- frame/balances/src/lib.rs | 16 +++++++ frame/balances/src/tests/currency_tests.rs | 55 ++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 460f2be37ff2d..d4be806982dfe 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -330,6 +330,10 @@ pub mod pallet { Issued { amount: T::Balance }, /// Total issuance was decreased by `amount`, creating a debt to be balanced. Rescinded { amount: T::Balance }, + /// Some balance was locked. + Locked { who: T::AccountId, amount: T::Balance }, + /// Some balance was unlocked. + Unlocked { who: T::AccountId, amount: T::Balance }, } #[pallet::error] @@ -1016,9 +1020,12 @@ pub mod pallet { ); } let freezes = Freezes::::get(who); + let mut prev_frozen = Zero::zero(); + let mut after_frozen = Zero::zero(); // TODO: Revisit this assumption. We no manipulate consumer/provider refs. // No way this can fail since we do not alter the existential balances. let res = Self::mutate_account(who, |b| { + prev_frozen = b.frozen; b.frozen = Zero::zero(); for l in locks.iter() { b.frozen = b.frozen.max(l.amount); @@ -1026,6 +1033,7 @@ pub mod pallet { for l in freezes.iter() { b.frozen = b.frozen.max(l.amount); } + after_frozen = b.frozen; }); debug_assert!(res.is_ok()); if let Ok((_, maybe_dust)) = res { @@ -1053,6 +1061,14 @@ pub mod pallet { ); } } + + if prev_frozen > after_frozen { + let amount = prev_frozen.saturating_sub(after_frozen); + Self::deposit_event(Event::Unlocked { who: who.clone(), amount }); + } else if after_frozen > prev_frozen { + let amount = after_frozen.saturating_sub(prev_frozen); + Self::deposit_event(Event::Locked { who: who.clone(), amount }); + } } /// Update the account entry for `who`, given the locks. diff --git a/frame/balances/src/tests/currency_tests.rs b/frame/balances/src/tests/currency_tests.rs index f74e6bb8c4993..034c92f65689b 100644 --- a/frame/balances/src/tests/currency_tests.rs +++ b/frame/balances/src/tests/currency_tests.rs @@ -754,6 +754,61 @@ fn emit_events_with_reserve_and_unreserve() { }); } +#[test] +fn emit_events_with_changing_locks() { + ExtBuilder::default().build_and_execute_with(|| { + let _ = Balances::deposit_creating(&1, 100); + System::reset_events(); + + // Locks = [] --> [10] + Balances::set_lock(*b"LOCK_000", &1, 10, WithdrawReasons::TRANSFER); + assert_eq!(events(), [RuntimeEvent::Balances(crate::Event::Locked { who: 1, amount: 10 })]); + + // Locks = [10] --> [15] + Balances::set_lock(*b"LOCK_000", &1, 15, WithdrawReasons::TRANSFER); + assert_eq!(events(), [RuntimeEvent::Balances(crate::Event::Locked { who: 1, amount: 5 })]); + + // Locks = [15] --> [15, 20] + Balances::set_lock(*b"LOCK_001", &1, 20, WithdrawReasons::TRANSACTION_PAYMENT); + assert_eq!(events(), [RuntimeEvent::Balances(crate::Event::Locked { who: 1, amount: 5 })]); + + // Locks = [15, 20] --> [17, 20] + Balances::set_lock(*b"LOCK_000", &1, 17, WithdrawReasons::TRANSACTION_PAYMENT); + for event in events() { + match event { + RuntimeEvent::Balances(crate::Event::Locked { .. }) => { + assert!(false, "unexpected lock event") + }, + RuntimeEvent::Balances(crate::Event::Unlocked { .. }) => { + assert!(false, "unexpected unlock event") + }, + _ => continue, + } + } + + // Locks = [17, 20] --> [17, 15] + Balances::set_lock(*b"LOCK_001", &1, 15, WithdrawReasons::TRANSFER); + assert_eq!( + events(), + [RuntimeEvent::Balances(crate::Event::Unlocked { who: 1, amount: 3 })] + ); + + // Locks = [17, 15] --> [15] + Balances::remove_lock(*b"LOCK_000", &1); + assert_eq!( + events(), + [RuntimeEvent::Balances(crate::Event::Unlocked { who: 1, amount: 2 })] + ); + + // Locks = [15] --> [] + Balances::remove_lock(*b"LOCK_001", &1); + assert_eq!( + events(), + [RuntimeEvent::Balances(crate::Event::Unlocked { who: 1, amount: 15 })] + ); + }); +} + #[test] fn emit_events_with_existential_deposit() { ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { From 78c99dadc961a46aaa90c231a209f0855a97e8ca Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Sat, 25 Mar 2023 16:59:31 +0100 Subject: [PATCH 74/80] Fix failing offences bench test (#13712) Signed-off-by: Oliver Tale-Yazdi --- frame/offences/benchmarking/src/lib.rs | 11 ++++++++++- frame/offences/benchmarking/src/mock.rs | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index 0efbdcd48ecf3..894a725b5ce2f 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -335,6 +335,12 @@ benchmarks! { let balance_slash = |id| core::iter::once( ::RuntimeEvent::from(pallet_balances::Event::::Slashed{ who: id, amount: slash_amount.into() }) ); + let balance_locked = |id| core::iter::once( + ::RuntimeEvent::from(pallet_balances::Event::::Locked{ who: id, amount: slash_amount.into() }) + ); + let balance_unlocked = |id| core::iter::once( + ::RuntimeEvent::from(pallet_balances::Event::::Unlocked{ who: id, amount: slash_amount.into() }) + ); let chill = |id| core::iter::once( ::RuntimeEvent::from(StakingEvent::::Chilled{ stash: id }) ); @@ -349,12 +355,15 @@ benchmarks! { let slash_events = raw_offenders.into_iter() .flat_map(|offender| { let nom_slashes = offender.nominator_stashes.into_iter().flat_map(|nom| { - balance_slash(nom.clone()).map(Into::into).chain(slash(nom).map(Into::into)).map(Box::new) + balance_slash(nom.clone()).map(Into::into) + .chain(balance_unlocked(nom.clone()).map(Into::into)) + .chain(slash(nom).map(Into::into)).map(Box::new) }); let events = chill(offender.stash.clone()).map(Into::into).map(Box::new) .chain(slash_report(offender.stash.clone()).map(Into::into).map(Box::new)) .chain(balance_slash(offender.stash.clone()).map(Into::into).map(Box::new)) + .chain(balance_unlocked(offender.stash.clone()).map(Into::into).map(Box::new)) .chain(slash(offender.stash).map(Into::into).map(Box::new)) .chain(nom_slashes) .collect::>(); diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 058361e9f77e8..668d88e0bf3d0 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -65,7 +65,7 @@ impl frame_system::Config for Test { } impl pallet_balances::Config for Test { - type MaxLocks = (); + type MaxLocks = ConstU32<128>; type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; From aeefc8bda0c0eecc67ca2d5ad24665ff27191968 Mon Sep 17 00:00:00 2001 From: yjh Date: Mon, 27 Mar 2023 06:07:17 +0800 Subject: [PATCH 75/80] chore(sc-cli): improve runner and signals (#13688) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(sc-cli): improve runner and signals * Update client/cli/src/runner.rs * fmt --------- Co-authored-by: Bastian Köcher --- client/cli/src/lib.rs | 2 + client/cli/src/runner.rs | 101 +++++--------------------------------- client/cli/src/signals.rs | 92 ++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+), 89 deletions(-) create mode 100644 client/cli/src/signals.rs diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index e73321ecce5b3..5d451bbed6562 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -31,6 +31,7 @@ mod config; mod error; mod params; mod runner; +mod signals; pub use arg_enums::*; pub use clap; @@ -41,6 +42,7 @@ pub use params::*; pub use runner::*; pub use sc_service::{ChainSpec, Role}; pub use sc_tracing::logging::LoggerBuilder; +pub use signals::Signals; pub use sp_version::RuntimeVersion; /// Substrate client CLI diff --git a/client/cli/src/runner.rs b/client/cli/src/runner.rs index 3d216aef4a75c..a8b75f2665aea 100644 --- a/client/cli/src/runner.rs +++ b/client/cli/src/runner.rs @@ -16,80 +16,15 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::{error::Error as CliError, Result, SubstrateCli}; +use crate::{error::Error as CliError, Result, Signals, SubstrateCli}; use chrono::prelude::*; -use futures::{ - future::{self, BoxFuture, FutureExt}, - pin_mut, select, Future, -}; +use futures::{future::FutureExt, Future}; use log::info; use sc_service::{Configuration, Error as ServiceError, TaskManager}; use sc_utils::metrics::{TOKIO_THREADS_ALIVE, TOKIO_THREADS_TOTAL}; use std::{marker::PhantomData, time::Duration}; -/// Abstraction over OS signals to handle the shutdown of the node smoothly. -/// -/// On `unix` this represents `SigInt` and `SigTerm`. -pub struct Signals(BoxFuture<'static, ()>); - -impl Signals { - /// Capture the relevant signals to handle shutdown of the node smoothly. - /// - /// Needs to be called in a Tokio context to have access to the tokio reactor. - #[cfg(target_family = "unix")] - pub fn capture() -> std::result::Result { - use tokio::signal::unix::{signal, SignalKind}; - - let mut stream_int = signal(SignalKind::interrupt()).map_err(ServiceError::Io)?; - let mut stream_term = signal(SignalKind::terminate()).map_err(ServiceError::Io)?; - - Ok(Signals( - async move { - future::select(stream_int.recv().boxed(), stream_term.recv().boxed()).await; - } - .boxed(), - )) - } - - /// Capture the relevant signals to handle shutdown of the node smoothly. - /// - /// Needs to be called in a Tokio context to have access to the tokio reactor. - #[cfg(not(unix))] - pub fn capture() -> std::result::Result { - use tokio::signal::ctrl_c; - - Ok(Signals( - async move { - let _ = ctrl_c().await; - } - .boxed(), - )) - } - - /// A dummy signal that never returns. - pub fn dummy() -> Self { - Self(future::pending().boxed()) - } -} - -async fn main(func: F, signals: impl Future) -> std::result::Result<(), E> -where - F: Future> + future::FusedFuture, - E: std::error::Error + Send + Sync + 'static, -{ - let signals = signals.fuse(); - - pin_mut!(func, signals); - - select! { - _ = signals => {}, - res = func => res?, - } - - Ok(()) -} - -/// Build a tokio runtime with all features +/// Build a tokio runtime with all features. pub fn build_runtime() -> std::result::Result { tokio::runtime::Builder::new_multi_thread() .on_thread_start(|| { @@ -103,25 +38,6 @@ pub fn build_runtime() -> std::result::Result( - tokio_runtime: tokio::runtime::Runtime, - future: F, - task_manager: TaskManager, - signals: impl Future, -) -> std::result::Result<(), E> -where - F: Future> + future::Future, - E: std::error::Error + Send + Sync + 'static + From, -{ - let f = future.fuse(); - pin_mut!(f); - - tokio_runtime.block_on(main(f, signals))?; - drop(task_manager); - - Ok(()) -} - /// A Substrate CLI runtime that can be used to run a node or a command pub struct Runner { config: Configuration, @@ -171,7 +87,10 @@ impl Runner { self.print_node_infos(); let mut task_manager = self.tokio_runtime.block_on(initialize(self.config))?; - let res = self.tokio_runtime.block_on(main(task_manager.future().fuse(), self.signals.0)); + + let res = self + .tokio_runtime + .block_on(self.signals.run_until_signal(task_manager.future().fuse())); // We need to drop the task manager here to inform all tasks that they should shut down. // // This is important to be done before we instruct the tokio runtime to shutdown. Otherwise @@ -234,7 +153,11 @@ impl Runner { E: std::error::Error + Send + Sync + 'static + From + From, { let (future, task_manager) = runner(self.config)?; - run_until_exit::<_, E>(self.tokio_runtime, future, task_manager, self.signals.0) + self.tokio_runtime.block_on(self.signals.run_until_signal(future.fuse()))?; + // Drop the task manager before dropping the rest, to ensure that all futures were informed + // about the shut down. + drop(task_manager); + Ok(()) } /// Get an immutable reference to the node Configuration diff --git a/client/cli/src/signals.rs b/client/cli/src/signals.rs new file mode 100644 index 0000000000000..4b6a6f957a766 --- /dev/null +++ b/client/cli/src/signals.rs @@ -0,0 +1,92 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use futures::{ + future::{self, BoxFuture, FutureExt}, + pin_mut, select, Future, +}; + +use sc_service::Error as ServiceError; + +/// Abstraction over OS signals to handle the shutdown of the node smoothly. +/// +/// On `unix` this represents `SigInt` and `SigTerm`. +pub struct Signals(BoxFuture<'static, ()>); + +impl Signals { + /// Return the signals future. + pub fn future(self) -> BoxFuture<'static, ()> { + self.0 + } + + /// Capture the relevant signals to handle shutdown of the node smoothly. + /// + /// Needs to be called in a Tokio context to have access to the tokio reactor. + #[cfg(target_family = "unix")] + pub fn capture() -> std::result::Result { + use tokio::signal::unix::{signal, SignalKind}; + + let mut stream_int = signal(SignalKind::interrupt()).map_err(ServiceError::Io)?; + let mut stream_term = signal(SignalKind::terminate()).map_err(ServiceError::Io)?; + + Ok(Signals( + async move { + future::select(stream_int.recv().boxed(), stream_term.recv().boxed()).await; + } + .boxed(), + )) + } + + /// Capture the relevant signals to handle shutdown of the node smoothly. + /// + /// Needs to be called in a Tokio context to have access to the tokio reactor. + #[cfg(not(unix))] + pub fn capture() -> Result { + use tokio::signal::ctrl_c; + + Ok(Signals( + async move { + let _ = ctrl_c().await; + } + .boxed(), + )) + } + + /// A dummy signal that never returns. + pub fn dummy() -> Self { + Self(future::pending().boxed()) + } + + /// Run a future task until receive a signal. + pub async fn run_until_signal(self, func: F) -> Result<(), E> + where + F: Future> + future::FusedFuture, + E: std::error::Error + Send + Sync + 'static, + { + let signals = self.future().fuse(); + + pin_mut!(func, signals); + + select! { + _ = signals => {}, + res = func => res?, + } + + Ok(()) + } +} From 83c81985521b9f956890539d8b62371c40093c60 Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Mon, 27 Mar 2023 07:23:53 +0200 Subject: [PATCH 76/80] add a new ci job to fuzz sp-arithmetic (#13673) as requested in https://github.com/paritytech/ci_cd/issues/761 --- scripts/ci/gitlab/pipeline/test.yml | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index 7c5f43c291ea7..b5c37d243f1b3 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -432,3 +432,39 @@ cargo-check-each-crate-macos: - time cargo check --workspace --locked tags: - osx + +cargo-hfuzz: + stage: test + extends: + - .docker-env + - .test-refs + - .pipeline-stopper-artifacts + variables: + # max 10s per iteration, 60s per file + HFUZZ_RUN_ARGS: > + --exit_upon_crash + --exit_code_upon_crash 1 + --timeout 10 + --run_time 60 + artifacts: + name: "hfuzz-$CI_COMMIT_SHORT_SHA" + expire_in: 7 days + when: on_failure + paths: + - primitives/arithmetic/fuzzer/hfuzz_workspace/ + script: + # use git version of honggfuzz-rs until v0.5.56 is out, we need a few recent changes: + # https://github.com/rust-fuzz/honggfuzz-rs/pull/75 to avoid breakage on debian + # https://github.com/rust-fuzz/honggfuzz-rs/pull/81 fix to the above pr + # https://github.com/rust-fuzz/honggfuzz-rs/pull/82 fix for handling rusty-cachier's absolute CARGO_TARGET_DIR + - | + cat >>Cargo.toml < Date: Mon, 27 Mar 2023 09:50:31 +0200 Subject: [PATCH 77/80] sc-slots: Forward block size limit (#13716) --- client/consensus/slots/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index e4147340793a4..5057e7858a0bc 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -217,7 +217,7 @@ pub trait SimpleSlotWorker { inherent_data, sp_runtime::generic::Digest { logs }, proposing_remaining_duration.mul_f32(0.98), - None, + slot_info.block_size_limit, ) .map_err(|e| sp_consensus::Error::ClientImport(e.to_string())); From bede15d5085fd5741e2522f85f36a7ec45cd9554 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Mon, 27 Mar 2023 14:04:24 +0200 Subject: [PATCH 78/80] FRAME: Fix the Referenda confirming alarm (#13704) * Fix the Referenda confirming alarm * Add minimal regression test This fails on bf395c8308c481a9774373e0b0b14bd7a2e4b8d2 since the downwards rounding voids the curve delay. Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi Co-authored-by: Oliver Tale-Yazdi --- frame/referenda/src/lib.rs | 2 +- frame/referenda/src/tests.rs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index f699850062267..b96cf5a76733d 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -1206,7 +1206,7 @@ impl, I: 'static> Pallet { let until_approval = track.min_approval.delay(approval); let until_support = track.min_support.delay(support); let offset = until_support.max(until_approval); - deciding.since.saturating_add(offset * track.decision_period) + deciding.since.saturating_add(offset.mul_ceil(track.decision_period)) }) } diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index f728350c37e6f..0a1561d001a7d 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -286,6 +286,24 @@ fn alarm_interval_works() { }); } +#[test] +fn decision_time_is_correct() { + new_test_ext().execute_with(|| { + let decision_time = |since: u64| { + Pallet::::decision_time( + &DecidingStatus { since: since.into(), confirming: None }, + &Tally { ayes: 100, nays: 5 }, + TestTracksInfo::tracks()[0].0, + &TestTracksInfo::tracks()[0].1, + ) + }; + + for i in 0u64..=100 { + assert!(decision_time(i) > i, "The decision time should be delayed by the curve"); + } + }); +} + #[test] fn auto_timeout_should_happen_with_nothing_but_submit() { new_test_ext().execute_with(|| { From 8f0414c761486eb6cea2a091ebdb3d3efbdebb9b Mon Sep 17 00:00:00 2001 From: Aaron Bassett Date: Mon, 27 Mar 2023 16:03:04 +0200 Subject: [PATCH 79/80] Update pallet licenses to Apache-2.0 (#13467) --- frame/fast-unstake/Cargo.toml | 2 +- frame/scheduler/README.md | 2 +- frame/transaction-storage/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/fast-unstake/Cargo.toml b/frame/fast-unstake/Cargo.toml index 36b4c3a5ec1cb..8e4df2f2b9eb5 100644 --- a/frame/fast-unstake/Cargo.toml +++ b/frame/fast-unstake/Cargo.toml @@ -3,7 +3,7 @@ name = "pallet-fast-unstake" version = "4.0.0-dev" authors = ["Parity Technologies "] edition = "2021" -license = "Unlicense" +license = "Apache-2.0" homepage = "https://substrate.io" repository = "https://github.com/paritytech/substrate/" description = "FRAME fast unstake pallet" diff --git a/frame/scheduler/README.md b/frame/scheduler/README.md index 9a209031d7402..bdd2c2226c88e 100644 --- a/frame/scheduler/README.md +++ b/frame/scheduler/README.md @@ -31,4 +31,4 @@ then those filter will not be used when dispatching the schedule call. `Vec` parameter that can be used for identification. * `cancel_named` - the named complement to the cancel function. -License: Unlicense +License: Apache 2.0 diff --git a/frame/transaction-storage/Cargo.toml b/frame/transaction-storage/Cargo.toml index 527ff4f240169..c23be8194d87f 100644 --- a/frame/transaction-storage/Cargo.toml +++ b/frame/transaction-storage/Cargo.toml @@ -3,7 +3,7 @@ name = "pallet-transaction-storage" version = "4.0.0-dev" authors = ["Parity Technologies "] edition = "2021" -license = "Unlicense" +license = "Apache-2.0" homepage = "https://substrate.io" repository = "https://github.com/paritytech/substrate/" description = "Storage chain pallet" From 46bdb43422007619c4efa4b03e32ad7b2f9b282e Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 27 Mar 2023 16:02:03 +0100 Subject: [PATCH 80/80] Reward pool migration fix (#13715) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * reward pool migration fix * comment * remove generic * rm max * foramtting * Add note to V4 migration Signed-off-by: Oliver Tale-Yazdi * Add more asserts to the V5 migration Signed-off-by: Oliver Tale-Yazdi * Make compile Signed-off-by: Oliver Tale-Yazdi * Update frame/nomination-pools/src/migration.rs Co-authored-by: Gonçalo Pestana * Make V4 migration re-usable Otherwise it wont chain together with the V5. Signed-off-by: Oliver Tale-Yazdi * Add MigrateV3ToV5 wrapper Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi Co-authored-by: Oliver Tale-Yazdi Co-authored-by: Gonçalo Pestana --- frame/nomination-pools/src/lib.rs | 2 +- frame/nomination-pools/src/migration.rs | 162 +++++++++++++++++++++++- 2 files changed, 161 insertions(+), 3 deletions(-) diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index e73d4b4173ecf..cfde05ffeeabe 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -1496,7 +1496,7 @@ pub mod pallet { use sp_runtime::Perbill; /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(5); #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] diff --git a/frame/nomination-pools/src/migration.rs b/frame/nomination-pools/src/migration.rs index f6f166d7f5de2..45d6424119900 100644 --- a/frame/nomination-pools/src/migration.rs +++ b/frame/nomination-pools/src/migration.rs @@ -478,9 +478,22 @@ pub mod v4 { } } + /// Migrates from `v3` directly to `v5` to avoid the broken `v4` migration. + #[allow(deprecated)] + pub type MigrateV3ToV5 = (v4::MigrateToV4, v5::MigrateToV5); + + /// # Warning + /// + /// To avoid mangled storage please use `MigrateV3ToV5` instead. + /// See: github.com/paritytech/substrate/pull/13715 + /// /// This migration adds a `commission` field to every `BondedPoolInner`, if /// any. + #[deprecated( + note = "To avoid mangled storage please use `MigrateV3ToV5` instead. See: github.com/paritytech/substrate/pull/13715" + )] pub struct MigrateToV4(sp_std::marker::PhantomData<(T, U)>); + #[allow(deprecated)] impl> OnRuntimeUpgrade for MigrateToV4 { fn on_runtime_upgrade() -> Weight { let current = Pallet::::current_storage_version(); @@ -493,7 +506,8 @@ pub mod v4 { onchain ); - if current == 4 && onchain == 3 { + if onchain == 3 { + log!(warn, "Please run MigrateToV5 immediately after this migration. See github.com/paritytech/substrate/pull/13715"); let initial_global_max_commission = U::get(); GlobalMaxCommission::::set(Some(initial_global_max_commission)); log!( @@ -508,7 +522,7 @@ pub mod v4 { Some(old_value.migrate_to_v4()) }); - current.put::>(); + StorageVersion::new(4).put::>(); log!(info, "Upgraded {} pools, storage to version {:?}", translated, current); // reads: translated + onchain version. @@ -548,3 +562,147 @@ pub mod v4 { } } } + +pub mod v5 { + use super::*; + + #[derive(Decode)] + pub struct OldRewardPool { + last_recorded_reward_counter: T::RewardCounter, + last_recorded_total_payouts: BalanceOf, + total_rewards_claimed: BalanceOf, + } + + impl OldRewardPool { + fn migrate_to_v5(self) -> RewardPool { + RewardPool { + last_recorded_reward_counter: self.last_recorded_reward_counter, + last_recorded_total_payouts: self.last_recorded_total_payouts, + total_rewards_claimed: self.total_rewards_claimed, + total_commission_pending: Zero::zero(), + total_commission_claimed: Zero::zero(), + } + } + } + + /// This migration adds `total_commission_pending` and `total_commission_claimed` field to every + /// `RewardPool`, if any. + pub struct MigrateToV5(sp_std::marker::PhantomData); + impl OnRuntimeUpgrade for MigrateToV5 { + fn on_runtime_upgrade() -> Weight { + let current = Pallet::::current_storage_version(); + let onchain = Pallet::::on_chain_storage_version(); + + log!( + info, + "Running migration with current storage version {:?} / onchain {:?}", + current, + onchain + ); + + if current == 5 && onchain == 4 { + let mut translated = 0u64; + RewardPools::::translate::, _>(|_id, old_value| { + translated.saturating_inc(); + Some(old_value.migrate_to_v5()) + }); + + current.put::>(); + log!(info, "Upgraded {} pools, storage to version {:?}", translated, current); + + // reads: translated + onchain version. + // writes: translated + current.put. + T::DbWeight::get().reads_writes(translated + 1, translated + 1) + } else { + log!(info, "Migration did not execute. This probably should be removed"); + T::DbWeight::get().reads(1) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + ensure!( + Pallet::::current_storage_version() > Pallet::::on_chain_storage_version(), + "the on_chain version is equal or more than the current one" + ); + + let rpool_keys = RewardPools::::iter_keys().count(); + let rpool_values = RewardPools::::iter_values().count(); + if rpool_keys != rpool_values { + log!(info, "🔥 There are {} undecodable RewardPools in storage. This migration will try to correct them. keys: {}, values: {}", rpool_keys.saturating_sub(rpool_values), rpool_keys, rpool_values); + } + + ensure!( + PoolMembers::::iter_keys().count() == PoolMembers::::iter_values().count(), + "There are undecodable PoolMembers in storage. This migration will not fix that." + ); + ensure!( + BondedPools::::iter_keys().count() == BondedPools::::iter_values().count(), + "There are undecodable BondedPools in storage. This migration will not fix that." + ); + ensure!( + SubPoolsStorage::::iter_keys().count() == + SubPoolsStorage::::iter_values().count(), + "There are undecodable SubPools in storage. This migration will not fix that." + ); + ensure!( + Metadata::::iter_keys().count() == Metadata::::iter_values().count(), + "There are undecodable Metadata in storage. This migration will not fix that." + ); + + Ok((rpool_values as u64).encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(data: Vec) -> Result<(), &'static str> { + let old_rpool_values: u64 = Decode::decode(&mut &data[..]).unwrap(); + let rpool_keys = RewardPools::::iter_keys().count() as u64; + let rpool_values = RewardPools::::iter_values().count() as u64; + ensure!( + rpool_keys == rpool_values, + "There are STILL undecodable RewardPools - migration failed" + ); + + if old_rpool_values != rpool_values { + log!( + info, + "🎉 Fixed {} undecodable RewardPools.", + rpool_values.saturating_sub(old_rpool_values) + ); + } + + // ensure all RewardPools items now contain `total_commission_pending` and + // `total_commission_claimed` field. + ensure!( + RewardPools::::iter().all(|(_, reward_pool)| reward_pool + .total_commission_pending + .is_zero() && reward_pool + .total_commission_claimed + .is_zero()), + "a commission value has been incorrectly set" + ); + ensure!(Pallet::::on_chain_storage_version() == 5, "wrong storage version"); + + // These should not have been touched - just in case. + ensure!( + PoolMembers::::iter_keys().count() == PoolMembers::::iter_values().count(), + "There are undecodable PoolMembers in storage." + ); + ensure!( + BondedPools::::iter_keys().count() == BondedPools::::iter_values().count(), + "There are undecodable BondedPools in storage." + ); + ensure!( + SubPoolsStorage::::iter_keys().count() == + SubPoolsStorage::::iter_values().count(), + "There are undecodable SubPools in storage." + ); + ensure!( + Metadata::::iter_keys().count() == Metadata::::iter_values().count(), + "There are undecodable Metadata in storage." + ); + + Ok(()) + } + } +}