git.delta.rocks / unique-network / refs/commits / 90ad566cc7e8

difftreelog

Merge pull request #1008 from UniqueNetwork/fix/update-benchmarks-to-v2

Yaroslav Bolyukin2023-10-12parents: #900be63 #4275a8f.patch.diff
in: master
Update benchmarks to v2

31 files changed

modifiedCargo.lockdiffbeforeafterboth
6536 "sp-runtime",6536 "sp-runtime",
6537 "sp-session",6537 "sp-session",
6538 "sp-std",6538 "sp-std",
6539 "sp-storage",
6539 "sp-transaction-pool",6540 "sp-transaction-pool",
6540 "sp-version",6541 "sp-version",
6541 "staging-xcm",6542 "staging-xcm",
10144 "sp-runtime",10145 "sp-runtime",
10145 "sp-session",10146 "sp-session",
10146 "sp-std",10147 "sp-std",
10148 "sp-storage",
10147 "sp-transaction-pool",10149 "sp-transaction-pool",
10148 "sp-version",10150 "sp-version",
10149 "staging-xcm",10151 "staging-xcm",
14896 "sp-runtime",14898 "sp-runtime",
14897 "sp-session",14899 "sp-session",
14898 "sp-std",14900 "sp-std",
14901 "sp-storage",
14899 "sp-transaction-pool",14902 "sp-transaction-pool",
14900 "sp-version",14903 "sp-version",
14901 "staging-xcm",14904 "staging-xcm",
modifiedCargo.tomldiffbeforeafterboth
170sp-staking = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }170sp-staking = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
171sp-state-machine = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }171sp-state-machine = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
172sp-std = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }172sp-std = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
173sp-storage = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
173sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }174sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
174sp-tracing = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }175sp-tracing = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
175sp-transaction-pool = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }176sp-transaction-pool = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
modifiedMakefilediffbeforeafterboth
8888
89evm_stubs: UniqueFungible UniqueNFT UniqueRefungible UniqueRefungibleToken ContractHelpers CollectionHelpers89evm_stubs: UniqueFungible UniqueNFT UniqueRefungible UniqueRefungibleToken ContractHelpers CollectionHelpers
9090
91# TODO: Create benchmarking profile, make it a proper dependency
91.PHONY: _bench92.PHONY: benchmarking-node
92_bench:93benchmarking-node:
93 cargo run --profile production --features runtime-benchmarks,$(RUNTIME) -- \94 cargo build --profile production --features runtime-benchmarks
94 benchmark pallet --pallet pallet-$(if $(PALLET),$(PALLET),$(error Must set PALLET)) \95
95 --wasm-execution compiled --extrinsic '*' \96define _bench =
96 $(if $(TEMPLATE),$(TEMPLATE),--template=.maintain/frame-weight-template.hbs) --steps=50 --repeat=80 --heap-pages=4096 \97.PHONY: bench-$(1)
97 --output=$(if $(OUTPUT),$(OUTPUT),./pallets/$(if $(PALLET_DIR),$(PALLET_DIR),$(PALLET))/src/weights.rs)98bench-$(1): benchmarking-node
9899 ./target/production/unique-collator \
99.PHONY: bench-evm-migration100 benchmark pallet --pallet pallet-$(1) \
100bench-evm-migration:101 --wasm-execution compiled --extrinsic '*' \
101 make _bench PALLET=evm-migration102 $(if $(4),$(4),--template=.maintain/frame-weight-template.hbs) --steps=50 --repeat=80 --heap-pages=4096 \
102103 --output=$$(if $(3),$(3),./pallets/$(if $(2),$(2),$(1))/src/weights.rs)
103.PHONY: bench-configuration104endef
104bench-configuration:105
105 make _bench PALLET=configuration106# _bench,pallet,(pallet_dir|),(output|),(extra|)
106107$(eval $(call _bench,evm-migration))
107.PHONY: bench-common108$(eval $(call _bench,configuration))
108bench-common:109$(eval $(call _bench,common))
109 make _bench PALLET=common110$(eval $(call _bench,unique))
110111$(eval $(call _bench,fungible))
111.PHONY: bench-unique112$(eval $(call _bench,refungible))
112bench-unique:113$(eval $(call _bench,nonfungible))
113 make _bench PALLET=unique114$(eval $(call _bench,structure))
114115$(eval $(call _bench,foreign-assets))
115.PHONY: bench-fungible116$(eval $(call _bench,collator-selection))
116bench-fungible:117$(eval $(call _bench,identity))
117 make _bench PALLET=fungible118$(eval $(call _bench,app-promotion))
118119$(eval $(call _bench,maintenance))
119.PHONY: bench-refungible120$(eval $(call _bench,xcm,,./runtime/common/weights/xcm.rs,"--template=.maintain/external-weights/template.hbs"))
120bench-refungible:
121 make _bench PALLET=refungible
122
123.PHONY: bench-nonfungible
124bench-nonfungible:
125 make _bench PALLET=nonfungible
126
127.PHONY: bench-structure
128bench-structure:
129 make _bench PALLET=structure
130
131.PHONY: bench-foreign-assets
132bench-foreign-assets:
133 make _bench PALLET=foreign-assets
134
135.PHONY: bench-collator-selection
136bench-collator-selection:
137 make _bench PALLET=collator-selection
138
139.PHONY: bench-identity
140bench-identity:
141 make _bench PALLET=identity
142
143.PHONY: bench-app-promotion
144bench-app-promotion:
145 make _bench PALLET=app-promotion
146
147.PHONY: bench-maintenance
148bench-maintenance:
149 make _bench PALLET=maintenance
150
151.PHONY: bench-xcm
152bench-xcm:
153 make _bench PALLET=xcm OUTPUT=./runtime/common/weights/xcm.rs TEMPLATE="--template=.maintain/external-weight-template.hbs"
154121
155.PHONY: bench122.PHONY: bench
156bench: bench-app-promotion bench-common bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-configuration bench-foreign-assets bench-maintenance bench-xcm bench-collator-selection bench-identity123bench: bench-app-promotion bench-common bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-configuration bench-foreign-assets bench-maintenance bench-xcm bench-collator-selection bench-identity
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
238 vesting: VestingConfig { vesting: vec![] },238 vesting: VestingConfig { vesting: vec![] },
239 parachain_info: ParachainInfoConfig {239 parachain_info: ParachainInfoConfig {
240 parachain_id: $id.into(),240 parachain_id: $id.into(),
241 Default::default()241 ..Default::default()
242 },242 },
243 aura: AuraConfig {243 aura: AuraConfig {
244 authorities: $initial_invulnerables244 authorities: $initial_invulnerables
modifiednode/cli/src/command.rsdiffbeforeafterboth
42use sp_runtime::traits::AccountIdConversion;42use sp_runtime::traits::AccountIdConversion;
43use up_common::types::opaque::RuntimeId;43use up_common::types::opaque::RuntimeId;
4444
45#[cfg(feature = "runtime-benchmarks")]
46use crate::chain_spec::default_runtime;
47#[cfg(feature = "runtime-benchmarks")]
48use crate::service::DefaultRuntimeExecutor;
49#[cfg(feature = "quartz-runtime")]45#[cfg(feature = "quartz-runtime")]
50use crate::service::QuartzRuntimeExecutor;46use crate::service::QuartzRuntimeExecutor;
51#[cfg(feature = "unique-runtime")]47#[cfg(feature = "unique-runtime")]
355 #[cfg(feature = "runtime-benchmarks")]351 #[cfg(feature = "runtime-benchmarks")]
356 Some(Subcommand::Benchmark(cmd)) => {352 Some(Subcommand::Benchmark(cmd)) => {
357 use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};353 use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
354 use polkadot_cli::Block;
355 use sp_io::SubstrateHostFunctions;
356
358 let runner = cli.create_runner(cmd)?;357 let runner = cli.create_runner(cmd)?;
359 // Switch on the concrete benchmark sub-command-358 // Switch on the concrete benchmark sub-command-
360 match cmd {359 match cmd {
361 BenchmarkCmd::Pallet(cmd) => {360 BenchmarkCmd::Pallet(cmd) => {
362 runner.sync_run(|config| cmd.run::<Block, DefaultRuntimeExecutor>(config))361 runner.sync_run(|config| cmd.run::<Block, SubstrateHostFunctions>(config))
363 }362 }
364 BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {363 BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
365 let partials = new_partial::<364 let partials = new_partial::<
365 opal_runtime::Runtime,
366 default_runtime::RuntimeApi,366 opal_runtime::RuntimeApi,
367 DefaultRuntimeExecutor,367 OpalRuntimeExecutor,
368 _,368 _,
369 >(&config, crate::service::parachain_build_import_queue)?;369 >(
370 &config,
371 crate::service::parachain_build_import_queue::<opal_runtime::Runtime, _, _>,
372 )?;
370 cmd.run(partials.client)373 cmd.run(partials.client)
371 }),374 }),
372 BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {375 BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
373 let partials = new_partial::<376 let partials = new_partial::<
377 opal_runtime::Runtime,
374 default_runtime::RuntimeApi,378 opal_runtime::RuntimeApi,
375 DefaultRuntimeExecutor,379 OpalRuntimeExecutor,
376 _,380 _,
377 >(&config, crate::service::parachain_build_import_queue)?;381 >(
382 &config,
383 crate::service::parachain_build_import_queue::<opal_runtime::Runtime, _, _>,
384 )?;
378 let db = partials.backend.expose_db();385 let db = partials.backend.expose_db();
379 let storage = partials.backend.expose_storage();386 let storage = partials.backend.expose_storage();
392 Some(Subcommand::TryRuntime(cmd)) => {399 Some(Subcommand::TryRuntime(cmd)) => {
393 use std::{future::Future, pin::Pin};400 use std::{future::Future, pin::Pin};
394401
402 use polkadot_cli::Block;
395 use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};403 use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
396 use try_runtime_cli::block_building_info::timestamp_with_aura_info;404 use try_runtime_cli::block_building_info::timestamp_with_aura_info;
397405
modifiednode/cli/src/rpc.rsdiffbeforeafterboth
67}67}
6868
69/// Instantiate all Full RPC extensions.69/// Instantiate all Full RPC extensions.
70pub fn create_full<C, P, SC, R, A, B>(70pub fn create_full<C, P, SC, R, B>(
71 io: &mut RpcModule<()>,71 io: &mut RpcModule<()>,
72 deps: FullDeps<C, P, SC>,72 deps: FullDeps<C, P, SC>,
73) -> Result<(), Box<dyn std::error::Error + Send + Sync>>73) -> Result<(), Box<dyn std::error::Error + Send + Sync>>
244 EthFilter::new(244 EthFilter::new(
245 client.clone(),245 client.clone(),
246 eth_backend,246 eth_backend,
247 graph.clone(),247 graph,
248 filter_pool,248 filter_pool,
249 500_usize, // max stored filters249 500_usize, // max stored filters
250 max_past_logs,250 max_past_logs,
modifiednode/cli/src/service.rsdiffbeforeafterboth
93/// Opal native executor instance.93/// Opal native executor instance.
94pub struct OpalRuntimeExecutor;94pub struct OpalRuntimeExecutor;
95
96#[cfg(all(feature = "unique-runtime", feature = "runtime-benchmarks"))]
97pub type DefaultRuntimeExecutor = UniqueRuntimeExecutor;
98
99#[cfg(all(
100 not(feature = "unique-runtime"),
101 feature = "quartz-runtime",
102 feature = "runtime-benchmarks"
103))]
104pub type DefaultRuntimeExecutor = QuartzRuntimeExecutor;
105
106#[cfg(all(
107 not(feature = "unique-runtime"),
108 not(feature = "quartz-runtime"),
109 feature = "runtime-benchmarks"
110))]
111pub type DefaultRuntimeExecutor = OpalRuntimeExecutor;
11295
113#[cfg(feature = "unique-runtime")]96#[cfg(feature = "unique-runtime")]
114impl NativeExecutionDispatch for UniqueRuntimeExecutor {97impl NativeExecutionDispatch for UniqueRuntimeExecutor {
515 select_chain,498 select_chain,
516 };499 };
517500
518 create_full::<_, _, _, Runtime, RuntimeApi, _>(&mut rpc_handle, full_deps)?;501 create_full::<_, _, _, Runtime, _>(&mut rpc_handle, full_deps)?;
519502
520 let eth_deps = EthDeps {503 let eth_deps = EthDeps {
521 client,504 client,
564 config: parachain_config,547 config: parachain_config,
565 keystore: params.keystore_container.keystore(),548 keystore: params.keystore_container.keystore(),
566 backend: backend.clone(),549 backend: backend.clone(),
567 network: network.clone(),550 network,
568 sync_service: sync_service.clone(),551 sync_service: sync_service.clone(),
569 system_rpc_tx,552 system_rpc_tx,
570 telemetry: telemetry.as_mut(),553 telemetry: telemetry.as_mut(),
617 if validator {600 if validator {
618 start_consensus(601 start_consensus(
619 client.clone(),602 client.clone(),
603 transaction_pool,
604 StartConsensusParameters {
620 backend.clone(),605 backend: backend.clone(),
621 prometheus_registry.as_ref(),606 prometheus_registry: prometheus_registry.as_ref(),
622 telemetry.as_ref().map(|t| t.handle()),607 telemetry: telemetry.as_ref().map(|t| t.handle()),
623 &task_manager,608 task_manager: &task_manager,
624 relay_chain_interface.clone(),609 relay_chain_interface: relay_chain_interface.clone(),
625 transaction_pool,
626 sync_service.clone(),610 sync_oracle: sync_service,
627 params.keystore_container.keystore(),611 keystore: params.keystore_container.keystore(),
628 overseer_handle,612 overseer_handle,
629 relay_chain_slot_duration,613 relay_chain_slot_duration,
630 para_id,614 para_id,
631 collator_key.expect("cli args do not allow this"),615 collator_key: collator_key.expect("cli args do not allow this"),
632 announce_block,616 announce_block,
617 },
633 )?;618 )?;
634 }619 }
635620
687 .map_err(Into::into)672 .map_err(Into::into)
688}673}
689674
690pub fn start_consensus<ExecutorDispatch, RuntimeApi, Runtime>(675pub struct StartConsensusParameters<'a> {
691 client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
692 backend: Arc<FullBackend>,676 backend: Arc<FullBackend>,
693 prometheus_registry: Option<&Registry>,677 prometheus_registry: Option<&'a Registry>,
694 telemetry: Option<TelemetryHandle>,678 telemetry: Option<TelemetryHandle>,
695 task_manager: &TaskManager,679 task_manager: &'a TaskManager,
696 relay_chain_interface: Arc<dyn RelayChainInterface>,680 relay_chain_interface: Arc<dyn RelayChainInterface>,
697 transaction_pool: Arc<
698 sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
699 >,
700 sync_oracle: Arc<SyncingService<Block>>,681 sync_oracle: Arc<SyncingService<Block>>,
701 keystore: KeystorePtr,682 keystore: KeystorePtr,
702 overseer_handle: OverseerHandle,683 overseer_handle: OverseerHandle,
703 relay_chain_slot_duration: Duration,684 relay_chain_slot_duration: Duration,
704 para_id: ParaId,685 para_id: ParaId,
705 collator_key: CollatorPair,686 collator_key: CollatorPair,
706 announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,687 announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
688}
689
690pub fn start_consensus<ExecutorDispatch, RuntimeApi, Runtime>(
691 client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
692 transaction_pool: Arc<
693 sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
694 >,
695 parameters: StartConsensusParameters<'_>,
707) -> Result<(), sc_service::Error>696) -> Result<(), sc_service::Error>
708where697where
709 ExecutorDispatch: NativeExecutionDispatch + 'static,698 ExecutorDispatch: NativeExecutionDispatch + 'static,
710 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>699 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
714 RuntimeApi::RuntimeApi: RuntimeApiDep<Runtime> + 'static,703 RuntimeApi::RuntimeApi: RuntimeApiDep<Runtime> + 'static,
715 Runtime: RuntimeInstance,704 Runtime: RuntimeInstance,
716{705{
706 let StartConsensusParameters {
707 backend,
708 prometheus_registry,
709 telemetry,
710 task_manager,
711 relay_chain_interface,
712 sync_oracle,
713 keystore,
714 overseer_handle,
715 relay_chain_slot_duration,
716 para_id,
717 collator_key,
718 announce_block,
719 } = parameters;
717 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;720 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
718721
719 let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(722 let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
720 task_manager.spawn_handle(),723 task_manager.spawn_handle(),
721 client.clone(),724 client.clone(),
722 transaction_pool,725 transaction_pool,
723 prometheus_registry,726 prometheus_registry,
724 telemetry.clone(),727 telemetry,
725 );728 );
726 let proposer = Proposer::new(proposer_factory);729 let proposer = Proposer::new(proposer_factory);
727730
1060 select_chain,1063 select_chain,
1061 };1064 };
10621065
1063 create_full::<_, _, _, Runtime, RuntimeApi, _>(&mut rpc_module, full_deps)?;1066 create_full::<_, _, _, Runtime, _>(&mut rpc_module, full_deps)?;
10641067
1065 let eth_deps = EthDeps {1068 let eth_deps = EthDeps {
1066 client,1069 client,
modifiedpallets/app-promotion/src/benchmarking.rsdiffbeforeafterboth
1616
17#![cfg(feature = "runtime-benchmarks")]17#![cfg(feature = "runtime-benchmarks")]
1818
19use frame_benchmarking::{account, benchmarks};19use frame_benchmarking::v2::*;
20use frame_support::traits::{fungible::Unbalanced, OnInitialize};20use frame_support::traits::{
21 fungible::{Inspect, Mutate, Unbalanced},
22 OnInitialize,
23};
21use frame_system::RawOrigin;24use frame_system::{pallet_prelude::*, RawOrigin};
25use pallet_evm::account::CrossAccountId;
22use pallet_evm_migration::Pallet as EvmMigrationPallet;26use pallet_evm_migration::Pallet as EvmMigrationPallet;
23use pallet_unique::benchmarking::create_nft_collection;27use pallet_unique::benchmarking::create_nft_collection;
24use sp_runtime::traits::Bounded;28use sp_core::{Get, H160};
29use sp_runtime::{
30 traits::{BlockNumberProvider, Bounded},
31 Perbill,
32};
33use sp_std::{iter::Sum, vec, vec::Vec};
2534
26use super::*;35use super::{BalanceOf, Call, Config, Pallet, Staked, PENDING_LIMIT_PER_BLOCK};
27use crate::Pallet as PromototionPallet;36use crate::{pallet, Pallet as PromototionPallet};
2837
29const SEED: u32 = 0;38const SEED: u32 = 0;
3039
49 Ok(pallet_admin)58 Ok(pallet_admin)
50}59}
5160
52benchmarks! {61#[benchmarks(
53 where_clause{
54 where T: Config + pallet_unique::Config + pallet_evm_migration::Config ,62 where T: Config + pallet_unique::Config + pallet_evm_migration::Config ,
55 BlockNumberFor<T>: From<u32> + Into<u32>,63 BlockNumberFor<T>: From<u32> + Into<u32>,
56 BalanceOf<T>: Sum + From<u128>64 BalanceOf<T>: Sum + From<u128>
65)]
66mod benchmarks {
57 }67 use super::*;
5868
59 on_initialize {69 #[benchmark]
60 let b in 0..PENDING_LIMIT_PER_BLOCK;70 fn on_initialize(b: Linear<0, PENDING_LIMIT_PER_BLOCK>) -> Result<(), BenchmarkError> {
61 set_admin::<T>()?;71 set_admin::<T>()?;
6272
63 (0..b).try_for_each(|index| {73 (0..b).try_for_each(|index| {
64 let staker = account::<T::AccountId>("staker", index, SEED);74 let staker = account::<T::AccountId>("staker", index, SEED);
65 <T as Config>::Currency::write_balance(&staker, Into::<BalanceOf<T>>::into(10_000u128) * T::Nominal::get())?;75 <T as Config>::Currency::write_balance(
76 &staker,
77 Into::<BalanceOf<T>>::into(10_000u128) * T::Nominal::get(),
78 )?;
66 PromototionPallet::<T>::stake(RawOrigin::Signed(staker.clone()).into(), Into::<BalanceOf<T>>::into(100u128) * T::Nominal::get())?;79 PromototionPallet::<T>::stake(
80 RawOrigin::Signed(staker.clone()).into(),
81 Into::<BalanceOf<T>>::into(100u128) * T::Nominal::get(),
82 )?;
67 PromototionPallet::<T>::unstake_all(RawOrigin::Signed(staker).into())?;83 PromototionPallet::<T>::unstake_all(RawOrigin::Signed(staker).into())?;
68 Result::<(), sp_runtime::DispatchError>::Ok(())84 Result::<(), sp_runtime::DispatchError>::Ok(())
69 })?;85 })?;
70 let block_number = <frame_system::Pallet<T>>::current_block_number() + T::PendingInterval::get();86 let block_number =
71 }: {PromototionPallet::<T>::on_initialize(block_number)}87 <frame_system::Pallet<T>>::current_block_number() + T::PendingInterval::get();
7288
73 set_admin_address {89 #[block]
90 {
91 PromototionPallet::<T>::on_initialize(block_number);
92 }
93
94 Ok(())
95 }
96
97 #[benchmark]
98 fn set_admin_address() -> Result<(), BenchmarkError> {
74 let pallet_admin = account::<T::AccountId>("admin", 0, SEED);99 let pallet_admin = account::<T::AccountId>("admin", 0, SEED);
75 let _ = <T as Config>::Currency::set_balance(&pallet_admin, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());100 let _ = <T as Config>::Currency::set_balance(
101 &pallet_admin,
102 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
76 } : _(RawOrigin::Root, T::CrossAccountId::from_sub(pallet_admin))103 );
77104
78 payout_stakers{105 #[extrinsic_call]
79 let b in 1..100;106 _(RawOrigin::Root, T::CrossAccountId::from_sub(pallet_admin));
80107
108 Ok(())
109 }
110
111 #[benchmark]
112 fn payout_stakers(b: Linear<1, 100>) -> Result<(), BenchmarkError> {
81 let pallet_admin = account::<T::AccountId>("admin", 1, SEED);113 let pallet_admin = account::<T::AccountId>("admin", 1, SEED);
82 let share = Perbill::from_rational(1u32, 20);114 PromototionPallet::<T>::set_admin_address(
83 PromototionPallet::<T>::set_admin_address(RawOrigin::Root.into(), T::CrossAccountId::from_sub(pallet_admin.clone()))?;115 RawOrigin::Root.into(),
116 T::CrossAccountId::from_sub(pallet_admin.clone()),
117 )?;
84 <T as Config>::Currency::write_balance(&pallet_admin, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value())?;118 <T as Config>::Currency::write_balance(
119 &pallet_admin,
120 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
121 )?;
85 <T as Config>::Currency::write_balance(&<T as pallet::Config>::TreasuryAccountId::get(), Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value())?;122 <T as Config>::Currency::write_balance(
123 &<T as pallet::Config>::TreasuryAccountId::get(),
124 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
125 )?;
86126
87 let stakers: Vec<T::AccountId> = (0..b).map(|index| account("staker", index, SEED)).collect();127 let stakers: Vec<T::AccountId> =
128 (0..b).map(|index| account("staker", index, SEED)).collect();
88 stakers.iter().try_for_each(|staker| {129 stakers.iter().try_for_each(|staker| {
89 <T as Config>::Currency::write_balance(staker, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value())?;130 <T as Config>::Currency::write_balance(
131 staker,
132 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
133 )?;
90 Result::<(), sp_runtime::DispatchError>::Ok(())134 Result::<(), sp_runtime::DispatchError>::Ok(())
91 })?;135 })?;
92 (1..11).try_for_each(|i| {136 (1..11).try_for_each(|i| {
93 <frame_system::Pallet<T>>::set_block_number(i.into());137 <frame_system::Pallet<T>>::set_block_number(i.into());
94 T::RelayBlockNumberProvider::set_block_number((2*i).into());138 T::RelayBlockNumberProvider::set_block_number((2 * i).into());
95 assert_eq!(<frame_system::Pallet<T>>::block_number(), i.into());139 assert_eq!(<frame_system::Pallet<T>>::block_number(), i.into());
96 assert_eq!(T::RelayBlockNumberProvider::current_block_number(), (2*i).into());140 assert_eq!(
141 T::RelayBlockNumberProvider::current_block_number(),
142 (2 * i).into()
143 );
97 stakers.iter()144 stakers
145 .iter()
98 .map(|staker| {146 .map(|staker| {
99 PromototionPallet::<T>::stake(RawOrigin::Signed(staker.clone()).into(), Into::<BalanceOf<T>>::into(100u128) * T::Nominal::get())147 PromototionPallet::<T>::stake(
148 RawOrigin::Signed(staker.clone()).into(),
149 Into::<BalanceOf<T>>::into(100u128) * T::Nominal::get(),
150 )
100 }).collect::<Result<Vec<_>, _>>()?;151 })
152 .collect::<Result<Vec<_>, _>>()?;
101153
102 Result::<(), sp_runtime::DispatchError>::Ok(())154 Result::<(), sp_runtime::DispatchError>::Ok(())
103 })?;155 })?;
107159
108 <frame_system::Pallet<T>>::set_block_number(15_000.into());160 <frame_system::Pallet<T>>::set_block_number(15_000.into());
109 T::RelayBlockNumberProvider::set_block_number(30_000.into());161 T::RelayBlockNumberProvider::set_block_number(30_000.into());
110 } : _(RawOrigin::Signed(pallet_admin.clone()), Some(b as u8))
111162
112 stake {163 #[extrinsic_call]
164 _(RawOrigin::Signed(pallet_admin), Some(b as u8));
165
166 Ok(())
167 }
168
169 #[benchmark]
170 fn stake() -> Result<(), BenchmarkError> {
113 let caller = account::<T::AccountId>("caller", 0, SEED);171 let caller = account::<T::AccountId>("caller", 0, SEED);
114 let share = Perbill::from_rational(1u32, 10);172 let share = Perbill::from_rational(1u32, 10);
115 let _ = <T as Config>::Currency::write_balance(&caller, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());
116 } : _(RawOrigin::Signed(caller.clone()), share * <T as Config>::Currency::total_balance(&caller))
117173
118 unstake_all {174 let _ = <T as Config>::Currency::write_balance(
175 &caller,
176 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
177 );
178
179 #[extrinsic_call]
180 _(
181 RawOrigin::Signed(caller),
182 share * <T as Config>::Currency::total_balance(&caller),
183 );
184
185 Ok(())
186 }
187
188 #[benchmark]
189 fn unstake_all() -> Result<(), BenchmarkError> {
119 let caller = account::<T::AccountId>("caller", 0, SEED);190 let caller = account::<T::AccountId>("caller", 0, SEED);
120 let share = Perbill::from_rational(1u32, 20);191 let share = Perbill::from_rational(1u32, 20);
121 let _ = <T as Config>::Currency::write_balance(&caller, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());192 let _ = <T as Config>::Currency::write_balance(
193 &caller,
194 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
195 );
122 (1..11).map(|i| {196 (1..11)
197 .map(|i| {
123 // used to change block number198 // used to change block number
124 <frame_system::Pallet<T>>::set_block_number(i.into());199 <frame_system::Pallet<T>>::set_block_number(i.into());
125 T::RelayBlockNumberProvider::set_block_number((2*i).into());200 T::RelayBlockNumberProvider::set_block_number((2 * i).into());
126 assert_eq!(<frame_system::Pallet<T>>::block_number(), i.into());201 assert_eq!(<frame_system::Pallet<T>>::block_number(), i.into());
127 assert_eq!(T::RelayBlockNumberProvider::current_block_number(), (2*i).into());202 assert_eq!(
203 T::RelayBlockNumberProvider::current_block_number(),
204 (2 * i).into()
205 );
128 PromototionPallet::<T>::stake(RawOrigin::Signed(caller.clone()).into(), share * <T as Config>::Currency::total_balance(&caller))206 PromototionPallet::<T>::stake(
207 RawOrigin::Signed(caller.clone()).into(),
208 share * <T as Config>::Currency::total_balance(&caller),
209 )
129 }).collect::<Result<Vec<_>, _>>()?;210 })
211 .collect::<Result<Vec<_>, _>>()?;
130212
131 } : _(RawOrigin::Signed(caller.clone()))213 #[extrinsic_call]
214 _(RawOrigin::Signed(caller));
132215
133 unstake_partial {216 Ok(())
217 }
218
219 #[benchmark]
220 fn unstake_partial() -> Result<(), BenchmarkError> {
134 let caller = account::<T::AccountId>("caller", 0, SEED);221 let caller = account::<T::AccountId>("caller", 0, SEED);
135 let share = Perbill::from_rational(1u32, 20);222 let _ = <T as Config>::Currency::write_balance(
136 let _ = <T as Config>::Currency::write_balance(&caller, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());223 &caller,
224 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
225 );
137 (1..11).map(|i| {226 (1..11)
227 .map(|i| {
138 // used to change block number228 // used to change block number
139 <frame_system::Pallet<T>>::set_block_number(i.into());229 <frame_system::Pallet<T>>::set_block_number(i.into());
140 T::RelayBlockNumberProvider::set_block_number((2*i).into());230 T::RelayBlockNumberProvider::set_block_number((2 * i).into());
141 assert_eq!(<frame_system::Pallet<T>>::block_number(), i.into());231 assert_eq!(<frame_system::Pallet<T>>::block_number(), i.into());
142 assert_eq!(T::RelayBlockNumberProvider::current_block_number(), (2*i).into());232 assert_eq!(
233 T::RelayBlockNumberProvider::current_block_number(),
234 (2 * i).into()
235 );
143 PromototionPallet::<T>::stake(RawOrigin::Signed(caller.clone()).into(), Into::<BalanceOf<T>>::into(100u128) * T::Nominal::get())236 PromototionPallet::<T>::stake(
237 RawOrigin::Signed(caller.clone()).into(),
238 Into::<BalanceOf<T>>::into(100u128) * T::Nominal::get(),
239 )
144 }).collect::<Result<Vec<_>, _>>()?;240 })
241 .collect::<Result<Vec<_>, _>>()?;
145242
146 } : _(RawOrigin::Signed(caller.clone()), Into::<BalanceOf<T>>::into(1000u128) * T::Nominal::get())243 #[extrinsic_call]
244 _(
245 RawOrigin::Signed(caller),
246 Into::<BalanceOf<T>>::into(1000u128) * T::Nominal::get(),
247 );
147248
148 sponsor_collection {249 Ok(())
250 }
251
252 #[benchmark]
253 fn sponsor_collection() -> Result<(), BenchmarkError> {
149 let pallet_admin = account::<T::AccountId>("admin", 0, SEED);254 let pallet_admin = account::<T::AccountId>("admin", 0, SEED);
150 PromototionPallet::<T>::set_admin_address(RawOrigin::Root.into(), T::CrossAccountId::from_sub(pallet_admin.clone()))?;255 PromototionPallet::<T>::set_admin_address(
256 RawOrigin::Root.into(),
257 T::CrossAccountId::from_sub(pallet_admin.clone()),
258 )?;
151 let _ = <T as Config>::Currency::write_balance(&pallet_admin, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());259 let _ = <T as Config>::Currency::write_balance(
260 &pallet_admin,
261 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
262 );
152 let caller: T::AccountId = account("caller", 0, SEED);263 let caller: T::AccountId = account("caller", 0, SEED);
153 let _ = <T as Config>::Currency::write_balance(&caller, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());264 let _ = <T as Config>::Currency::write_balance(
265 &caller,
266 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
267 );
154 let collection = create_nft_collection::<T>(caller)?;268 let collection = create_nft_collection::<T>(caller)?;
155 } : _(RawOrigin::Signed(pallet_admin.clone()), collection)
156269
157 stop_sponsoring_collection {270 #[extrinsic_call]
271 _(RawOrigin::Signed(pallet_admin), collection);
272
273 Ok(())
274 }
275
276 #[benchmark]
277 fn stop_sponsoring_collection() -> Result<(), BenchmarkError> {
158 let pallet_admin = account::<T::AccountId>("admin", 0, SEED);278 let pallet_admin = account::<T::AccountId>("admin", 0, SEED);
159 PromototionPallet::<T>::set_admin_address(RawOrigin::Root.into(), T::CrossAccountId::from_sub(pallet_admin.clone()))?;279 PromototionPallet::<T>::set_admin_address(
280 RawOrigin::Root.into(),
281 T::CrossAccountId::from_sub(pallet_admin.clone()),
282 )?;
160 let _ = <T as Config>::Currency::write_balance(&pallet_admin, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());283 let _ = <T as Config>::Currency::write_balance(
284 &pallet_admin,
285 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
286 );
161 let caller: T::AccountId = account("caller", 0, SEED);287 let caller: T::AccountId = account("caller", 0, SEED);
162 let _ = <T as Config>::Currency::write_balance(&caller, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());288 let _ = <T as Config>::Currency::write_balance(
289 &caller,
290 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
291 );
163 let collection = create_nft_collection::<T>(caller)?;292 let collection = create_nft_collection::<T>(caller)?;
164 PromototionPallet::<T>::sponsor_collection(RawOrigin::Signed(pallet_admin.clone()).into(), collection)?;293 PromototionPallet::<T>::sponsor_collection(
294 RawOrigin::Signed(pallet_admin.clone()).into(),
295 collection,
165 } : _(RawOrigin::Signed(pallet_admin.clone()), collection)296 )?;
166297
167 sponsor_contract {298 #[extrinsic_call]
299 _(RawOrigin::Signed(pallet_admin), collection);
300
301 Ok(())
302 }
303
304 #[benchmark]
305 fn sponsor_contract() -> Result<(), BenchmarkError> {
168 let pallet_admin = account::<T::AccountId>("admin", 0, SEED);306 let pallet_admin = account::<T::AccountId>("admin", 0, SEED);
169 PromototionPallet::<T>::set_admin_address(RawOrigin::Root.into(), T::CrossAccountId::from_sub(pallet_admin.clone()))?;307 PromototionPallet::<T>::set_admin_address(
308 RawOrigin::Root.into(),
309 T::CrossAccountId::from_sub(pallet_admin.clone()),
310 )?;
170311
171 let _ = <T as Config>::Currency::write_balance(&pallet_admin, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());312 let _ = <T as Config>::Currency::write_balance(
313 &pallet_admin,
314 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
315 );
172 let address = H160::from_low_u64_be(SEED as u64);316 let address = H160::from_low_u64_be(SEED as u64);
173 let data: Vec<u8> = (0..20).collect();317 let data: Vec<u8> = (0..20).collect();
174 <EvmMigrationPallet<T>>::begin(RawOrigin::Root.into(), address)?;318 <EvmMigrationPallet<T>>::begin(RawOrigin::Root.into(), address)?;
175 <EvmMigrationPallet<T>>::finish(RawOrigin::Root.into(), address, data)?;319 <EvmMigrationPallet<T>>::finish(RawOrigin::Root.into(), address, data)?;
176 } : _(RawOrigin::Signed(pallet_admin.clone()), address)
177320
178 stop_sponsoring_contract {321 #[extrinsic_call]
322 _(RawOrigin::Signed(pallet_admin), address);
323
324 Ok(())
325 }
326
327 #[benchmark]
328 fn stop_sponsoring_contract() -> Result<(), BenchmarkError> {
179 let pallet_admin = account::<T::AccountId>("admin", 0, SEED);329 let pallet_admin = account::<T::AccountId>("admin", 0, SEED);
180 PromototionPallet::<T>::set_admin_address(RawOrigin::Root.into(), T::CrossAccountId::from_sub(pallet_admin.clone()))?;330 PromototionPallet::<T>::set_admin_address(
331 RawOrigin::Root.into(),
332 T::CrossAccountId::from_sub(pallet_admin.clone()),
333 )?;
181334
182 let _ = <T as Config>::Currency::write_balance(&pallet_admin, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());335 let _ = <T as Config>::Currency::write_balance(
336 &pallet_admin,
337 Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value(),
338 );
183 let address = H160::from_low_u64_be(SEED as u64);339 let address = H160::from_low_u64_be(SEED as u64);
184 let data: Vec<u8> = (0..20).collect();340 let data: Vec<u8> = (0..20).collect();
185 <EvmMigrationPallet<T>>::begin(RawOrigin::Root.into(), address)?;341 <EvmMigrationPallet<T>>::begin(RawOrigin::Root.into(), address)?;
186 <EvmMigrationPallet<T>>::finish(RawOrigin::Root.into(), address, data)?;342 <EvmMigrationPallet<T>>::finish(RawOrigin::Root.into(), address, data)?;
187 PromototionPallet::<T>::sponsor_contract(RawOrigin::Signed(pallet_admin.clone()).into(), address)?;343 PromototionPallet::<T>::sponsor_contract(
344 RawOrigin::Signed(pallet_admin.clone()).into(),
345 address,
346 )?;
347
188 } : _(RawOrigin::Signed(pallet_admin.clone()), address)348 #[extrinsic_call]
349 _(RawOrigin::Signed(pallet_admin), address);
350
351 Ok(())
352 }
189}353}
190354
modifiedpallets/app-promotion/src/weights.rsdiffbeforeafterboth
3//! Autogenerated weights for pallet_app_promotion3//! Autogenerated weights for pallet_app_promotion
4//!4//!
5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
6//! DATE: 2023-09-26, STEPS: `50`, REPEAT: `400`, LOW RANGE: `[]`, HIGH RANGE: `[]`6//! DATE: 2023-10-12, STEPS: `50`, REPEAT: `80`, LOW RANGE: `[]`, HIGH RANGE: `[]`
7//! WORST CASE MAP SIZE: `1000000`7//! WORST CASE MAP SIZE: `1000000`
8//! HOSTNAME: `bench-host`, CPU: `Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz`8//! HOSTNAME: `ubuntu-11`, CPU: `QEMU Virtual CPU version 2.5+`
9//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 10249//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
1010
11// Executed Command:11// Executed Command:
12// target/production/unique-collator12// target/production/unique-collator
20// *20// *
21// --template=.maintain/frame-weight-template.hbs21// --template=.maintain/frame-weight-template.hbs
22// --steps=5022// --steps=50
23// --repeat=40023// --repeat=80
24// --heap-pages=409624// --heap-pages=4096
25// --output=./pallets/app-promotion/src/weights.rs25// --output=./pallets/app-promotion/src/weights.rs
2626
48/// Weights for pallet_app_promotion using the Substrate node and recommended hardware.48/// Weights for pallet_app_promotion using the Substrate node and recommended hardware.
49pub struct SubstrateWeight<T>(PhantomData<T>);49pub struct SubstrateWeight<T>(PhantomData<T>);
50impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {50impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
51 /// Storage: Maintenance Enabled (r:1 w:0)51 /// Storage: `Maintenance::Enabled` (r:1 w:0)
52 /// Proof: Maintenance Enabled (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen)52 /// Proof: `Maintenance::Enabled` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`)
53 /// Storage: AppPromotion PendingUnstake (r:1 w:1)53 /// Storage: `AppPromotion::PendingUnstake` (r:1 w:1)
54 /// Proof: AppPromotion PendingUnstake (max_values: None, max_size: Some(157), added: 2632, mode: MaxEncodedLen)54 /// Proof: `AppPromotion::PendingUnstake` (`max_values`: None, `max_size`: Some(157), added: 2632, mode: `MaxEncodedLen`)
55 /// Storage: Balances Freezes (r:3 w:3)55 /// Storage: `Balances::Freezes` (r:3 w:3)
56 /// Proof: Balances Freezes (max_values: None, max_size: Some(369), added: 2844, mode: MaxEncodedLen)56 /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(369), added: 2844, mode: `MaxEncodedLen`)
57 /// Storage: System Account (r:3 w:3)57 /// Storage: `System::Account` (r:3 w:3)
58 /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)58 /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
59 /// Storage: Balances Locks (r:3 w:0)59 /// Storage: `Balances::Locks` (r:3 w:0)
60 /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)60 /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
61 /// The range of component `b` is `[0, 3]`.61 /// The range of component `b` is `[0, 3]`.
62 fn on_initialize(b: u32, ) -> Weight {62 fn on_initialize(b: u32, ) -> Weight {
63 // Proof Size summary in bytes:63 // Proof Size summary in bytes:
64 // Measured: `222 + b * (285 ±0)`64 // Measured: `222 + b * (285 ±0)`
65 // Estimated: `3622 + b * (3774 ±0)`65 // Estimated: `3622 + b * (3774 ±0)`
66 // Minimum execution time: 4_107_000 picoseconds.66 // Minimum execution time: 6_031_000 picoseconds.
67 Weight::from_parts(4_751_973, 3622)67 Weight::from_parts(6_880_848, 3622)
68 // Standard Error: 4_66868 // Standard Error: 18_753
69 .saturating_add(Weight::from_parts(10_570_330, 0).saturating_mul(b.into()))69 .saturating_add(Weight::from_parts(22_907_186, 0).saturating_mul(b.into()))
70 .saturating_add(T::DbWeight::get().reads(2_u64))70 .saturating_add(T::DbWeight::get().reads(2_u64))
71 .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(b.into())))71 .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(b.into())))
72 .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(b.into())))72 .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(b.into())))
73 .saturating_add(Weight::from_parts(0, 3774).saturating_mul(b.into()))73 .saturating_add(Weight::from_parts(0, 3774).saturating_mul(b.into()))
74 }74 }
75 /// Storage: AppPromotion Admin (r:0 w:1)75 /// Storage: `AppPromotion::Admin` (r:0 w:1)
76 /// Proof: AppPromotion Admin (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)76 /// Proof: `AppPromotion::Admin` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
77 fn set_admin_address() -> Weight {77 fn set_admin_address() -> Weight {
78 // Proof Size summary in bytes:78 // Proof Size summary in bytes:
79 // Measured: `0`79 // Measured: `0`
80 // Estimated: `0`80 // Estimated: `0`
81 // Minimum execution time: 3_459_000 picoseconds.81 // Minimum execution time: 7_565_000 picoseconds.
82 Weight::from_parts(3_627_000, 0)82 Weight::from_parts(7_795_000, 0)
83 .saturating_add(T::DbWeight::get().writes(1_u64))83 .saturating_add(T::DbWeight::get().writes(1_u64))
84 }84 }
85 /// Storage: AppPromotion Admin (r:1 w:0)85 /// Storage: `AppPromotion::Admin` (r:1 w:0)
86 /// Proof: AppPromotion Admin (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)86 /// Proof: `AppPromotion::Admin` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
87 /// Storage: Configuration AppPromomotionConfigurationOverride (r:1 w:0)87 /// Storage: `Configuration::AppPromomotionConfigurationOverride` (r:1 w:0)
88 /// Proof: Configuration AppPromomotionConfigurationOverride (max_values: Some(1), max_size: Some(17), added: 512, mode: MaxEncodedLen)88 /// Proof: `Configuration::AppPromomotionConfigurationOverride` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`)
89 /// Storage: ParachainSystem ValidationData (r:1 w:0)89 /// Storage: `ParachainSystem::ValidationData` (r:1 w:0)
90 /// Proof Skipped: ParachainSystem ValidationData (max_values: Some(1), max_size: None, mode: Measured)90 /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
91 /// Storage: AppPromotion PreviousCalculatedRecord (r:1 w:1)91 /// Storage: `AppPromotion::PreviousCalculatedRecord` (r:1 w:1)
92 /// Proof: AppPromotion PreviousCalculatedRecord (max_values: Some(1), max_size: Some(36), added: 531, mode: MaxEncodedLen)92 /// Proof: `AppPromotion::PreviousCalculatedRecord` (`max_values`: Some(1), `max_size`: Some(36), added: 531, mode: `MaxEncodedLen`)
93 /// Storage: AppPromotion Staked (r:1001 w:1000)93 /// Storage: `AppPromotion::Staked` (r:1001 w:1000)
94 /// Proof: AppPromotion Staked (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)94 /// Proof: `AppPromotion::Staked` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`)
95 /// Storage: System Account (r:101 w:101)95 /// Storage: `System::Account` (r:101 w:101)
96 /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)96 /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
97 /// Storage: Balances Freezes (r:100 w:100)97 /// Storage: `Balances::Freezes` (r:100 w:100)
98 /// Proof: Balances Freezes (max_values: None, max_size: Some(369), added: 2844, mode: MaxEncodedLen)98 /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(369), added: 2844, mode: `MaxEncodedLen`)
99 /// Storage: Balances Locks (r:100 w:0)99 /// Storage: `Balances::Locks` (r:100 w:0)
100 /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)100 /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
101 /// Storage: AppPromotion TotalStaked (r:1 w:1)101 /// Storage: `AppPromotion::TotalStaked` (r:1 w:1)
102 /// Proof: AppPromotion TotalStaked (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)102 /// Proof: `AppPromotion::TotalStaked` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
103 /// The range of component `b` is `[1, 100]`.103 /// The range of component `b` is `[1, 100]`.
104 fn payout_stakers(b: u32, ) -> Weight {104 fn payout_stakers(b: u32, ) -> Weight {
105 // Proof Size summary in bytes:105 // Proof Size summary in bytes:
106 // Measured: `564 + b * (641 ±0)`106 // Measured: `564 + b * (641 ±0)`
107 // Estimated: `3593 + b * (25550 ±0)`107 // Estimated: `3593 + b * (25550 ±0)`
108 // Minimum execution time: 73_245_000 picoseconds.108 // Minimum execution time: 146_577_000 picoseconds.
109 Weight::from_parts(74_196_000, 3593)109 Weight::from_parts(147_970_000, 3593)
110 // Standard Error: 8_231110 // Standard Error: 59_065
111 .saturating_add(Weight::from_parts(49_090_053, 0).saturating_mul(b.into()))111 .saturating_add(Weight::from_parts(115_527_092, 0).saturating_mul(b.into()))
112 .saturating_add(T::DbWeight::get().reads(7_u64))112 .saturating_add(T::DbWeight::get().reads(7_u64))
113 .saturating_add(T::DbWeight::get().reads((13_u64).saturating_mul(b.into())))113 .saturating_add(T::DbWeight::get().reads((13_u64).saturating_mul(b.into())))
114 .saturating_add(T::DbWeight::get().writes(3_u64))114 .saturating_add(T::DbWeight::get().writes(3_u64))
115 .saturating_add(T::DbWeight::get().writes((12_u64).saturating_mul(b.into())))115 .saturating_add(T::DbWeight::get().writes((12_u64).saturating_mul(b.into())))
116 .saturating_add(Weight::from_parts(0, 25550).saturating_mul(b.into()))116 .saturating_add(Weight::from_parts(0, 25550).saturating_mul(b.into()))
117 }117 }
118 /// Storage: AppPromotion StakesPerAccount (r:1 w:1)118 /// Storage: `AppPromotion::StakesPerAccount` (r:1 w:1)
119 /// Proof: AppPromotion StakesPerAccount (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)119 /// Proof: `AppPromotion::StakesPerAccount` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
120 /// Storage: Configuration AppPromomotionConfigurationOverride (r:1 w:0)120 /// Storage: `Configuration::AppPromomotionConfigurationOverride` (r:1 w:0)
121 /// Proof: Configuration AppPromomotionConfigurationOverride (max_values: Some(1), max_size: Some(17), added: 512, mode: MaxEncodedLen)121 /// Proof: `Configuration::AppPromomotionConfigurationOverride` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`)
122 /// Storage: System Account (r:1 w:1)122 /// Storage: `System::Account` (r:1 w:1)
123 /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)123 /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
124 /// Storage: Balances Freezes (r:1 w:1)124 /// Storage: `Balances::Freezes` (r:1 w:1)
125 /// Proof: Balances Freezes (max_values: None, max_size: Some(369), added: 2844, mode: MaxEncodedLen)125 /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(369), added: 2844, mode: `MaxEncodedLen`)
126 /// Storage: Balances Locks (r:1 w:0)126 /// Storage: `Balances::Locks` (r:1 w:0)
127 /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)127 /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
128 /// Storage: ParachainSystem ValidationData (r:1 w:0)128 /// Storage: `ParachainSystem::ValidationData` (r:1 w:0)
129 /// Proof Skipped: ParachainSystem ValidationData (max_values: Some(1), max_size: None, mode: Measured)129 /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
130 /// Storage: AppPromotion Staked (r:1 w:1)130 /// Storage: `AppPromotion::Staked` (r:1 w:1)
131 /// Proof: AppPromotion Staked (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)131 /// Proof: `AppPromotion::Staked` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`)
132 /// Storage: AppPromotion TotalStaked (r:1 w:1)132 /// Storage: `AppPromotion::TotalStaked` (r:1 w:1)
133 /// Proof: AppPromotion TotalStaked (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)133 /// Proof: `AppPromotion::TotalStaked` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
134 fn stake() -> Weight {134 fn stake() -> Weight {
135 // Proof Size summary in bytes:135 // Proof Size summary in bytes:
136 // Measured: `389`136 // Measured: `389`
137 // Estimated: `4764`137 // Estimated: `4764`
138 // Minimum execution time: 21_088_000 picoseconds.138 // Minimum execution time: 46_889_000 picoseconds.
139 Weight::from_parts(21_639_000, 4764)139 Weight::from_parts(47_549_000, 4764)
140 .saturating_add(T::DbWeight::get().reads(8_u64))140 .saturating_add(T::DbWeight::get().reads(8_u64))
141 .saturating_add(T::DbWeight::get().writes(5_u64))141 .saturating_add(T::DbWeight::get().writes(5_u64))
142 }142 }
143 /// Storage: Configuration AppPromomotionConfigurationOverride (r:1 w:0)143 /// Storage: `Configuration::AppPromomotionConfigurationOverride` (r:1 w:0)
144 /// Proof: Configuration AppPromomotionConfigurationOverride (max_values: Some(1), max_size: Some(17), added: 512, mode: MaxEncodedLen)144 /// Proof: `Configuration::AppPromomotionConfigurationOverride` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`)
145 /// Storage: AppPromotion PendingUnstake (r:1 w:1)145 /// Storage: `AppPromotion::PendingUnstake` (r:1 w:1)
146 /// Proof: AppPromotion PendingUnstake (max_values: None, max_size: Some(157), added: 2632, mode: MaxEncodedLen)146 /// Proof: `AppPromotion::PendingUnstake` (`max_values`: None, `max_size`: Some(157), added: 2632, mode: `MaxEncodedLen`)
147 /// Storage: AppPromotion Staked (r:11 w:10)147 /// Storage: `AppPromotion::Staked` (r:11 w:10)
148 /// Proof: AppPromotion Staked (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)148 /// Proof: `AppPromotion::Staked` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`)
149 /// Storage: AppPromotion TotalStaked (r:1 w:1)149 /// Storage: `AppPromotion::TotalStaked` (r:1 w:1)
150 /// Proof: AppPromotion TotalStaked (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)150 /// Proof: `AppPromotion::TotalStaked` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
151 /// Storage: AppPromotion StakesPerAccount (r:0 w:1)151 /// Storage: `AppPromotion::StakesPerAccount` (r:0 w:1)
152 /// Proof: AppPromotion StakesPerAccount (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)152 /// Proof: `AppPromotion::StakesPerAccount` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
153 fn unstake_all() -> Weight {153 fn unstake_all() -> Weight {
154 // Proof Size summary in bytes:154 // Proof Size summary in bytes:
155 // Measured: `829`155 // Measured: `829`
156 // Estimated: `29095`156 // Estimated: `29095`
157 // Minimum execution time: 42_086_000 picoseconds.157 // Minimum execution time: 63_069_000 picoseconds.
158 Weight::from_parts(43_149_000, 29095)158 Weight::from_parts(64_522_000, 29095)
159 .saturating_add(T::DbWeight::get().reads(14_u64))159 .saturating_add(T::DbWeight::get().reads(14_u64))
160 .saturating_add(T::DbWeight::get().writes(13_u64))160 .saturating_add(T::DbWeight::get().writes(13_u64))
161 }161 }
162 /// Storage: Configuration AppPromomotionConfigurationOverride (r:1 w:0)162 /// Storage: `Configuration::AppPromomotionConfigurationOverride` (r:1 w:0)
163 /// Proof: Configuration AppPromomotionConfigurationOverride (max_values: Some(1), max_size: Some(17), added: 512, mode: MaxEncodedLen)163 /// Proof: `Configuration::AppPromomotionConfigurationOverride` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`)
164 /// Storage: AppPromotion PendingUnstake (r:1 w:1)164 /// Storage: `AppPromotion::PendingUnstake` (r:1 w:1)
165 /// Proof: AppPromotion PendingUnstake (max_values: None, max_size: Some(157), added: 2632, mode: MaxEncodedLen)165 /// Proof: `AppPromotion::PendingUnstake` (`max_values`: None, `max_size`: Some(157), added: 2632, mode: `MaxEncodedLen`)
166 /// Storage: AppPromotion Staked (r:11 w:10)166 /// Storage: `AppPromotion::Staked` (r:11 w:10)
167 /// Proof: AppPromotion Staked (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)167 /// Proof: `AppPromotion::Staked` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`)
168 /// Storage: AppPromotion TotalStaked (r:1 w:1)168 /// Storage: `AppPromotion::TotalStaked` (r:1 w:1)
169 /// Proof: AppPromotion TotalStaked (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)169 /// Proof: `AppPromotion::TotalStaked` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
170 /// Storage: AppPromotion StakesPerAccount (r:1 w:1)170 /// Storage: `AppPromotion::StakesPerAccount` (r:1 w:1)
171 /// Proof: AppPromotion StakesPerAccount (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)171 /// Proof: `AppPromotion::StakesPerAccount` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
172 fn unstake_partial() -> Weight {172 fn unstake_partial() -> Weight {
173 // Proof Size summary in bytes:173 // Proof Size summary in bytes:
174 // Measured: `829`174 // Measured: `829`
175 // Estimated: `29095`175 // Estimated: `29095`
176 // Minimum execution time: 46_458_000 picoseconds.176 // Minimum execution time: 84_649_000 picoseconds.
177 Weight::from_parts(47_333_000, 29095)177 Weight::from_parts(86_173_000, 29095)
178 .saturating_add(T::DbWeight::get().reads(15_u64))178 .saturating_add(T::DbWeight::get().reads(15_u64))
179 .saturating_add(T::DbWeight::get().writes(13_u64))179 .saturating_add(T::DbWeight::get().writes(13_u64))
180 }180 }
181 /// Storage: AppPromotion Admin (r:1 w:0)181 /// Storage: `AppPromotion::Admin` (r:1 w:0)
182 /// Proof: AppPromotion Admin (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)182 /// Proof: `AppPromotion::Admin` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
183 /// Storage: Common CollectionById (r:1 w:1)183 /// Storage: `Common::CollectionById` (r:1 w:1)
184 /// Proof: Common CollectionById (max_values: None, max_size: Some(860), added: 3335, mode: MaxEncodedLen)184 /// Proof: `Common::CollectionById` (`max_values`: None, `max_size`: Some(860), added: 3335, mode: `MaxEncodedLen`)
185 fn sponsor_collection() -> Weight {185 fn sponsor_collection() -> Weight {
186 // Proof Size summary in bytes:186 // Proof Size summary in bytes:
187 // Measured: `1060`187 // Measured: `1060`
188 // Estimated: `4325`188 // Estimated: `4325`
189 // Minimum execution time: 12_827_000 picoseconds.189 // Minimum execution time: 24_396_000 picoseconds.
190 Weight::from_parts(13_610_000, 4325)190 Weight::from_parts(24_917_000, 4325)
191 .saturating_add(T::DbWeight::get().reads(2_u64))191 .saturating_add(T::DbWeight::get().reads(2_u64))
192 .saturating_add(T::DbWeight::get().writes(1_u64))192 .saturating_add(T::DbWeight::get().writes(1_u64))
193 }193 }
194 /// Storage: AppPromotion Admin (r:1 w:0)194 /// Storage: `AppPromotion::Admin` (r:1 w:0)
195 /// Proof: AppPromotion Admin (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)195 /// Proof: `AppPromotion::Admin` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
196 /// Storage: Common CollectionById (r:1 w:1)196 /// Storage: `Common::CollectionById` (r:1 w:1)
197 /// Proof: Common CollectionById (max_values: None, max_size: Some(860), added: 3335, mode: MaxEncodedLen)197 /// Proof: `Common::CollectionById` (`max_values`: None, `max_size`: Some(860), added: 3335, mode: `MaxEncodedLen`)
198 fn stop_sponsoring_collection() -> Weight {198 fn stop_sponsoring_collection() -> Weight {
199 // Proof Size summary in bytes:199 // Proof Size summary in bytes:
200 // Measured: `1092`200 // Measured: `1092`
201 // Estimated: `4325`201 // Estimated: `4325`
202 // Minimum execution time: 11_899_000 picoseconds.202 // Minimum execution time: 22_412_000 picoseconds.
203 Weight::from_parts(12_303_000, 4325)203 Weight::from_parts(23_033_000, 4325)
204 .saturating_add(T::DbWeight::get().reads(2_u64))204 .saturating_add(T::DbWeight::get().reads(2_u64))
205 .saturating_add(T::DbWeight::get().writes(1_u64))205 .saturating_add(T::DbWeight::get().writes(1_u64))
206 }206 }
207 /// Storage: AppPromotion Admin (r:1 w:0)207 /// Storage: `AppPromotion::Admin` (r:1 w:0)
208 /// Proof: AppPromotion Admin (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)208 /// Proof: `AppPromotion::Admin` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
209 /// Storage: EvmContractHelpers Sponsoring (r:0 w:1)209 /// Storage: `EvmContractHelpers::Sponsoring` (r:0 w:1)
210 /// Proof: EvmContractHelpers Sponsoring (max_values: None, max_size: Some(62), added: 2537, mode: MaxEncodedLen)210 /// Proof: `EvmContractHelpers::Sponsoring` (`max_values`: None, `max_size`: Some(62), added: 2537, mode: `MaxEncodedLen`)
211 fn sponsor_contract() -> Weight {211 fn sponsor_contract() -> Weight {
212 // Proof Size summary in bytes:212 // Proof Size summary in bytes:
213 // Measured: `198`213 // Measured: `198`
214 // Estimated: `1517`214 // Estimated: `1517`
215 // Minimum execution time: 10_226_000 picoseconds.215 // Minimum execution time: 21_621_000 picoseconds.
216 Weight::from_parts(10_549_000, 1517)216 Weight::from_parts(22_041_000, 1517)
217 .saturating_add(T::DbWeight::get().reads(1_u64))217 .saturating_add(T::DbWeight::get().reads(1_u64))
218 .saturating_add(T::DbWeight::get().writes(1_u64))218 .saturating_add(T::DbWeight::get().writes(1_u64))
219 }219 }
220 /// Storage: AppPromotion Admin (r:1 w:0)220 /// Storage: `AppPromotion::Admin` (r:1 w:0)
221 /// Proof: AppPromotion Admin (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)221 /// Proof: `AppPromotion::Admin` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
222 /// Storage: EvmContractHelpers Sponsoring (r:1 w:1)222 /// Storage: `EvmContractHelpers::Sponsoring` (r:1 w:1)
223 /// Proof: EvmContractHelpers Sponsoring (max_values: None, max_size: Some(62), added: 2537, mode: MaxEncodedLen)223 /// Proof: `EvmContractHelpers::Sponsoring` (`max_values`: None, `max_size`: Some(62), added: 2537, mode: `MaxEncodedLen`)
224 fn stop_sponsoring_contract() -> Weight {224 fn stop_sponsoring_contract() -> Weight {
225 // Proof Size summary in bytes:225 // Proof Size summary in bytes:
226 // Measured: `396`226 // Measured: `396`
227 // Estimated: `3527`227 // Estimated: `3527`
228 // Minimum execution time: 10_528_000 picoseconds.228 // Minimum execution time: 19_186_000 picoseconds.
229 Weight::from_parts(10_842_000, 3527)229 Weight::from_parts(19_616_000, 3527)
230 .saturating_add(T::DbWeight::get().reads(2_u64))230 .saturating_add(T::DbWeight::get().reads(2_u64))
231 .saturating_add(T::DbWeight::get().writes(1_u64))231 .saturating_add(T::DbWeight::get().writes(1_u64))
232 }232 }
233}233}
234234
235// For backwards compatibility and tests235// For backwards compatibility and tests
236impl WeightInfo for () {236impl WeightInfo for () {
237 /// Storage: Maintenance Enabled (r:1 w:0)237 /// Storage: `Maintenance::Enabled` (r:1 w:0)
238 /// Proof: Maintenance Enabled (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen)238 /// Proof: `Maintenance::Enabled` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`)
239 /// Storage: AppPromotion PendingUnstake (r:1 w:1)239 /// Storage: `AppPromotion::PendingUnstake` (r:1 w:1)
240 /// Proof: AppPromotion PendingUnstake (max_values: None, max_size: Some(157), added: 2632, mode: MaxEncodedLen)240 /// Proof: `AppPromotion::PendingUnstake` (`max_values`: None, `max_size`: Some(157), added: 2632, mode: `MaxEncodedLen`)
241 /// Storage: Balances Freezes (r:3 w:3)241 /// Storage: `Balances::Freezes` (r:3 w:3)
242 /// Proof: Balances Freezes (max_values: None, max_size: Some(369), added: 2844, mode: MaxEncodedLen)242 /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(369), added: 2844, mode: `MaxEncodedLen`)
243 /// Storage: System Account (r:3 w:3)243 /// Storage: `System::Account` (r:3 w:3)
244 /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)244 /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
245 /// Storage: Balances Locks (r:3 w:0)245 /// Storage: `Balances::Locks` (r:3 w:0)
246 /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)246 /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
247 /// The range of component `b` is `[0, 3]`.247 /// The range of component `b` is `[0, 3]`.
248 fn on_initialize(b: u32, ) -> Weight {248 fn on_initialize(b: u32, ) -> Weight {
249 // Proof Size summary in bytes:249 // Proof Size summary in bytes:
250 // Measured: `222 + b * (285 ±0)`250 // Measured: `222 + b * (285 ±0)`
251 // Estimated: `3622 + b * (3774 ±0)`251 // Estimated: `3622 + b * (3774 ±0)`
252 // Minimum execution time: 4_107_000 picoseconds.252 // Minimum execution time: 6_031_000 picoseconds.
253 Weight::from_parts(4_751_973, 3622)253 Weight::from_parts(6_880_848, 3622)
254 // Standard Error: 4_668254 // Standard Error: 18_753
255 .saturating_add(Weight::from_parts(10_570_330, 0).saturating_mul(b.into()))255 .saturating_add(Weight::from_parts(22_907_186, 0).saturating_mul(b.into()))
256 .saturating_add(RocksDbWeight::get().reads(2_u64))256 .saturating_add(RocksDbWeight::get().reads(2_u64))
257 .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(b.into())))257 .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(b.into())))
258 .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(b.into())))258 .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(b.into())))
259 .saturating_add(Weight::from_parts(0, 3774).saturating_mul(b.into()))259 .saturating_add(Weight::from_parts(0, 3774).saturating_mul(b.into()))
260 }260 }
261 /// Storage: AppPromotion Admin (r:0 w:1)261 /// Storage: `AppPromotion::Admin` (r:0 w:1)
262 /// Proof: AppPromotion Admin (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)262 /// Proof: `AppPromotion::Admin` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
263 fn set_admin_address() -> Weight {263 fn set_admin_address() -> Weight {
264 // Proof Size summary in bytes:264 // Proof Size summary in bytes:
265 // Measured: `0`265 // Measured: `0`
266 // Estimated: `0`266 // Estimated: `0`
267 // Minimum execution time: 3_459_000 picoseconds.267 // Minimum execution time: 7_565_000 picoseconds.
268 Weight::from_parts(3_627_000, 0)268 Weight::from_parts(7_795_000, 0)
269 .saturating_add(RocksDbWeight::get().writes(1_u64))269 .saturating_add(RocksDbWeight::get().writes(1_u64))
270 }270 }
271 /// Storage: AppPromotion Admin (r:1 w:0)271 /// Storage: `AppPromotion::Admin` (r:1 w:0)
272 /// Proof: AppPromotion Admin (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)272 /// Proof: `AppPromotion::Admin` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
273 /// Storage: Configuration AppPromomotionConfigurationOverride (r:1 w:0)273 /// Storage: `Configuration::AppPromomotionConfigurationOverride` (r:1 w:0)
274 /// Proof: Configuration AppPromomotionConfigurationOverride (max_values: Some(1), max_size: Some(17), added: 512, mode: MaxEncodedLen)274 /// Proof: `Configuration::AppPromomotionConfigurationOverride` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`)
275 /// Storage: ParachainSystem ValidationData (r:1 w:0)275 /// Storage: `ParachainSystem::ValidationData` (r:1 w:0)
276 /// Proof Skipped: ParachainSystem ValidationData (max_values: Some(1), max_size: None, mode: Measured)276 /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
277 /// Storage: AppPromotion PreviousCalculatedRecord (r:1 w:1)277 /// Storage: `AppPromotion::PreviousCalculatedRecord` (r:1 w:1)
278 /// Proof: AppPromotion PreviousCalculatedRecord (max_values: Some(1), max_size: Some(36), added: 531, mode: MaxEncodedLen)278 /// Proof: `AppPromotion::PreviousCalculatedRecord` (`max_values`: Some(1), `max_size`: Some(36), added: 531, mode: `MaxEncodedLen`)
279 /// Storage: AppPromotion Staked (r:1001 w:1000)279 /// Storage: `AppPromotion::Staked` (r:1001 w:1000)
280 /// Proof: AppPromotion Staked (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)280 /// Proof: `AppPromotion::Staked` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`)
281 /// Storage: System Account (r:101 w:101)281 /// Storage: `System::Account` (r:101 w:101)
282 /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)282 /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
283 /// Storage: Balances Freezes (r:100 w:100)283 /// Storage: `Balances::Freezes` (r:100 w:100)
284 /// Proof: Balances Freezes (max_values: None, max_size: Some(369), added: 2844, mode: MaxEncodedLen)284 /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(369), added: 2844, mode: `MaxEncodedLen`)
285 /// Storage: Balances Locks (r:100 w:0)285 /// Storage: `Balances::Locks` (r:100 w:0)
286 /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)286 /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
287 /// Storage: AppPromotion TotalStaked (r:1 w:1)287 /// Storage: `AppPromotion::TotalStaked` (r:1 w:1)
288 /// Proof: AppPromotion TotalStaked (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)288 /// Proof: `AppPromotion::TotalStaked` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
289 /// The range of component `b` is `[1, 100]`.289 /// The range of component `b` is `[1, 100]`.
290 fn payout_stakers(b: u32, ) -> Weight {290 fn payout_stakers(b: u32, ) -> Weight {
291 // Proof Size summary in bytes:291 // Proof Size summary in bytes:
292 // Measured: `564 + b * (641 ±0)`292 // Measured: `564 + b * (641 ±0)`
293 // Estimated: `3593 + b * (25550 ±0)`293 // Estimated: `3593 + b * (25550 ±0)`
294 // Minimum execution time: 73_245_000 picoseconds.294 // Minimum execution time: 146_577_000 picoseconds.
295 Weight::from_parts(74_196_000, 3593)295 Weight::from_parts(147_970_000, 3593)
296 // Standard Error: 8_231296 // Standard Error: 59_065
297 .saturating_add(Weight::from_parts(49_090_053, 0).saturating_mul(b.into()))297 .saturating_add(Weight::from_parts(115_527_092, 0).saturating_mul(b.into()))
298 .saturating_add(RocksDbWeight::get().reads(7_u64))298 .saturating_add(RocksDbWeight::get().reads(7_u64))
299 .saturating_add(RocksDbWeight::get().reads((13_u64).saturating_mul(b.into())))299 .saturating_add(RocksDbWeight::get().reads((13_u64).saturating_mul(b.into())))
300 .saturating_add(RocksDbWeight::get().writes(3_u64))300 .saturating_add(RocksDbWeight::get().writes(3_u64))
301 .saturating_add(RocksDbWeight::get().writes((12_u64).saturating_mul(b.into())))301 .saturating_add(RocksDbWeight::get().writes((12_u64).saturating_mul(b.into())))
302 .saturating_add(Weight::from_parts(0, 25550).saturating_mul(b.into()))302 .saturating_add(Weight::from_parts(0, 25550).saturating_mul(b.into()))
303 }303 }
304 /// Storage: AppPromotion StakesPerAccount (r:1 w:1)304 /// Storage: `AppPromotion::StakesPerAccount` (r:1 w:1)
305 /// Proof: AppPromotion StakesPerAccount (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)305 /// Proof: `AppPromotion::StakesPerAccount` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
306 /// Storage: Configuration AppPromomotionConfigurationOverride (r:1 w:0)306 /// Storage: `Configuration::AppPromomotionConfigurationOverride` (r:1 w:0)
307 /// Proof: Configuration AppPromomotionConfigurationOverride (max_values: Some(1), max_size: Some(17), added: 512, mode: MaxEncodedLen)307 /// Proof: `Configuration::AppPromomotionConfigurationOverride` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`)
308 /// Storage: System Account (r:1 w:1)308 /// Storage: `System::Account` (r:1 w:1)
309 /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)309 /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
310 /// Storage: Balances Freezes (r:1 w:1)310 /// Storage: `Balances::Freezes` (r:1 w:1)
311 /// Proof: Balances Freezes (max_values: None, max_size: Some(369), added: 2844, mode: MaxEncodedLen)311 /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(369), added: 2844, mode: `MaxEncodedLen`)
312 /// Storage: Balances Locks (r:1 w:0)312 /// Storage: `Balances::Locks` (r:1 w:0)
313 /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)313 /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
314 /// Storage: ParachainSystem ValidationData (r:1 w:0)314 /// Storage: `ParachainSystem::ValidationData` (r:1 w:0)
315 /// Proof Skipped: ParachainSystem ValidationData (max_values: Some(1), max_size: None, mode: Measured)315 /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
316 /// Storage: AppPromotion Staked (r:1 w:1)316 /// Storage: `AppPromotion::Staked` (r:1 w:1)
317 /// Proof: AppPromotion Staked (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)317 /// Proof: `AppPromotion::Staked` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`)
318 /// Storage: AppPromotion TotalStaked (r:1 w:1)318 /// Storage: `AppPromotion::TotalStaked` (r:1 w:1)
319 /// Proof: AppPromotion TotalStaked (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)319 /// Proof: `AppPromotion::TotalStaked` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
320 fn stake() -> Weight {320 fn stake() -> Weight {
321 // Proof Size summary in bytes:321 // Proof Size summary in bytes:
322 // Measured: `389`322 // Measured: `389`
323 // Estimated: `4764`323 // Estimated: `4764`
324 // Minimum execution time: 21_088_000 picoseconds.324 // Minimum execution time: 46_889_000 picoseconds.
325 Weight::from_parts(21_639_000, 4764)325 Weight::from_parts(47_549_000, 4764)
326 .saturating_add(RocksDbWeight::get().reads(8_u64))326 .saturating_add(RocksDbWeight::get().reads(8_u64))
327 .saturating_add(RocksDbWeight::get().writes(5_u64))327 .saturating_add(RocksDbWeight::get().writes(5_u64))
328 }328 }
329 /// Storage: Configuration AppPromomotionConfigurationOverride (r:1 w:0)329 /// Storage: `Configuration::AppPromomotionConfigurationOverride` (r:1 w:0)
330 /// Proof: Configuration AppPromomotionConfigurationOverride (max_values: Some(1), max_size: Some(17), added: 512, mode: MaxEncodedLen)330 /// Proof: `Configuration::AppPromomotionConfigurationOverride` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`)
331 /// Storage: AppPromotion PendingUnstake (r:1 w:1)331 /// Storage: `AppPromotion::PendingUnstake` (r:1 w:1)
332 /// Proof: AppPromotion PendingUnstake (max_values: None, max_size: Some(157), added: 2632, mode: MaxEncodedLen)332 /// Proof: `AppPromotion::PendingUnstake` (`max_values`: None, `max_size`: Some(157), added: 2632, mode: `MaxEncodedLen`)
333 /// Storage: AppPromotion Staked (r:11 w:10)333 /// Storage: `AppPromotion::Staked` (r:11 w:10)
334 /// Proof: AppPromotion Staked (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)334 /// Proof: `AppPromotion::Staked` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`)
335 /// Storage: AppPromotion TotalStaked (r:1 w:1)335 /// Storage: `AppPromotion::TotalStaked` (r:1 w:1)
336 /// Proof: AppPromotion TotalStaked (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)336 /// Proof: `AppPromotion::TotalStaked` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
337 /// Storage: AppPromotion StakesPerAccount (r:0 w:1)337 /// Storage: `AppPromotion::StakesPerAccount` (r:0 w:1)
338 /// Proof: AppPromotion StakesPerAccount (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)338 /// Proof: `AppPromotion::StakesPerAccount` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
339 fn unstake_all() -> Weight {339 fn unstake_all() -> Weight {
340 // Proof Size summary in bytes:340 // Proof Size summary in bytes:
341 // Measured: `829`341 // Measured: `829`
342 // Estimated: `29095`342 // Estimated: `29095`
343 // Minimum execution time: 42_086_000 picoseconds.343 // Minimum execution time: 63_069_000 picoseconds.
344 Weight::from_parts(43_149_000, 29095)344 Weight::from_parts(64_522_000, 29095)
345 .saturating_add(RocksDbWeight::get().reads(14_u64))345 .saturating_add(RocksDbWeight::get().reads(14_u64))
346 .saturating_add(RocksDbWeight::get().writes(13_u64))346 .saturating_add(RocksDbWeight::get().writes(13_u64))
347 }347 }
348 /// Storage: Configuration AppPromomotionConfigurationOverride (r:1 w:0)348 /// Storage: `Configuration::AppPromomotionConfigurationOverride` (r:1 w:0)
349 /// Proof: Configuration AppPromomotionConfigurationOverride (max_values: Some(1), max_size: Some(17), added: 512, mode: MaxEncodedLen)349 /// Proof: `Configuration::AppPromomotionConfigurationOverride` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`)
350 /// Storage: AppPromotion PendingUnstake (r:1 w:1)350 /// Storage: `AppPromotion::PendingUnstake` (r:1 w:1)
351 /// Proof: AppPromotion PendingUnstake (max_values: None, max_size: Some(157), added: 2632, mode: MaxEncodedLen)351 /// Proof: `AppPromotion::PendingUnstake` (`max_values`: None, `max_size`: Some(157), added: 2632, mode: `MaxEncodedLen`)
352 /// Storage: AppPromotion Staked (r:11 w:10)352 /// Storage: `AppPromotion::Staked` (r:11 w:10)
353 /// Proof: AppPromotion Staked (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)353 /// Proof: `AppPromotion::Staked` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`)
354 /// Storage: AppPromotion TotalStaked (r:1 w:1)354 /// Storage: `AppPromotion::TotalStaked` (r:1 w:1)
355 /// Proof: AppPromotion TotalStaked (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)355 /// Proof: `AppPromotion::TotalStaked` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
356 /// Storage: AppPromotion StakesPerAccount (r:1 w:1)356 /// Storage: `AppPromotion::StakesPerAccount` (r:1 w:1)
357 /// Proof: AppPromotion StakesPerAccount (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)357 /// Proof: `AppPromotion::StakesPerAccount` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
358 fn unstake_partial() -> Weight {358 fn unstake_partial() -> Weight {
359 // Proof Size summary in bytes:359 // Proof Size summary in bytes:
360 // Measured: `829`360 // Measured: `829`
361 // Estimated: `29095`361 // Estimated: `29095`
362 // Minimum execution time: 46_458_000 picoseconds.362 // Minimum execution time: 84_649_000 picoseconds.
363 Weight::from_parts(47_333_000, 29095)363 Weight::from_parts(86_173_000, 29095)
364 .saturating_add(RocksDbWeight::get().reads(15_u64))364 .saturating_add(RocksDbWeight::get().reads(15_u64))
365 .saturating_add(RocksDbWeight::get().writes(13_u64))365 .saturating_add(RocksDbWeight::get().writes(13_u64))
366 }366 }
367 /// Storage: AppPromotion Admin (r:1 w:0)367 /// Storage: `AppPromotion::Admin` (r:1 w:0)
368 /// Proof: AppPromotion Admin (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)368 /// Proof: `AppPromotion::Admin` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
369 /// Storage: Common CollectionById (r:1 w:1)369 /// Storage: `Common::CollectionById` (r:1 w:1)
370 /// Proof: Common CollectionById (max_values: None, max_size: Some(860), added: 3335, mode: MaxEncodedLen)370 /// Proof: `Common::CollectionById` (`max_values`: None, `max_size`: Some(860), added: 3335, mode: `MaxEncodedLen`)
371 fn sponsor_collection() -> Weight {371 fn sponsor_collection() -> Weight {
372 // Proof Size summary in bytes:372 // Proof Size summary in bytes:
373 // Measured: `1060`373 // Measured: `1060`
374 // Estimated: `4325`374 // Estimated: `4325`
375 // Minimum execution time: 12_827_000 picoseconds.375 // Minimum execution time: 24_396_000 picoseconds.
376 Weight::from_parts(13_610_000, 4325)376 Weight::from_parts(24_917_000, 4325)
377 .saturating_add(RocksDbWeight::get().reads(2_u64))377 .saturating_add(RocksDbWeight::get().reads(2_u64))
378 .saturating_add(RocksDbWeight::get().writes(1_u64))378 .saturating_add(RocksDbWeight::get().writes(1_u64))
379 }379 }
380 /// Storage: AppPromotion Admin (r:1 w:0)380 /// Storage: `AppPromotion::Admin` (r:1 w:0)
381 /// Proof: AppPromotion Admin (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)381 /// Proof: `AppPromotion::Admin` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
382 /// Storage: Common CollectionById (r:1 w:1)382 /// Storage: `Common::CollectionById` (r:1 w:1)
383 /// Proof: Common CollectionById (max_values: None, max_size: Some(860), added: 3335, mode: MaxEncodedLen)383 /// Proof: `Common::CollectionById` (`max_values`: None, `max_size`: Some(860), added: 3335, mode: `MaxEncodedLen`)
384 fn stop_sponsoring_collection() -> Weight {384 fn stop_sponsoring_collection() -> Weight {
385 // Proof Size summary in bytes:385 // Proof Size summary in bytes:
386 // Measured: `1092`386 // Measured: `1092`
387 // Estimated: `4325`387 // Estimated: `4325`
388 // Minimum execution time: 11_899_000 picoseconds.388 // Minimum execution time: 22_412_000 picoseconds.
389 Weight::from_parts(12_303_000, 4325)389 Weight::from_parts(23_033_000, 4325)
390 .saturating_add(RocksDbWeight::get().reads(2_u64))390 .saturating_add(RocksDbWeight::get().reads(2_u64))
391 .saturating_add(RocksDbWeight::get().writes(1_u64))391 .saturating_add(RocksDbWeight::get().writes(1_u64))
392 }392 }
393 /// Storage: AppPromotion Admin (r:1 w:0)393 /// Storage: `AppPromotion::Admin` (r:1 w:0)
394 /// Proof: AppPromotion Admin (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)394 /// Proof: `AppPromotion::Admin` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
395 /// Storage: EvmContractHelpers Sponsoring (r:0 w:1)395 /// Storage: `EvmContractHelpers::Sponsoring` (r:0 w:1)
396 /// Proof: EvmContractHelpers Sponsoring (max_values: None, max_size: Some(62), added: 2537, mode: MaxEncodedLen)396 /// Proof: `EvmContractHelpers::Sponsoring` (`max_values`: None, `max_size`: Some(62), added: 2537, mode: `MaxEncodedLen`)
397 fn sponsor_contract() -> Weight {397 fn sponsor_contract() -> Weight {
398 // Proof Size summary in bytes:398 // Proof Size summary in bytes:
399 // Measured: `198`399 // Measured: `198`
400 // Estimated: `1517`400 // Estimated: `1517`
401 // Minimum execution time: 10_226_000 picoseconds.401 // Minimum execution time: 21_621_000 picoseconds.
402 Weight::from_parts(10_549_000, 1517)402 Weight::from_parts(22_041_000, 1517)
403 .saturating_add(RocksDbWeight::get().reads(1_u64))403 .saturating_add(RocksDbWeight::get().reads(1_u64))
404 .saturating_add(RocksDbWeight::get().writes(1_u64))404 .saturating_add(RocksDbWeight::get().writes(1_u64))
405 }405 }
406 /// Storage: AppPromotion Admin (r:1 w:0)406 /// Storage: `AppPromotion::Admin` (r:1 w:0)
407 /// Proof: AppPromotion Admin (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)407 /// Proof: `AppPromotion::Admin` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
408 /// Storage: EvmContractHelpers Sponsoring (r:1 w:1)408 /// Storage: `EvmContractHelpers::Sponsoring` (r:1 w:1)
409 /// Proof: EvmContractHelpers Sponsoring (max_values: None, max_size: Some(62), added: 2537, mode: MaxEncodedLen)409 /// Proof: `EvmContractHelpers::Sponsoring` (`max_values`: None, `max_size`: Some(62), added: 2537, mode: `MaxEncodedLen`)
410 fn stop_sponsoring_contract() -> Weight {410 fn stop_sponsoring_contract() -> Weight {
411 // Proof Size summary in bytes:411 // Proof Size summary in bytes:
412 // Measured: `396`412 // Measured: `396`
413 // Estimated: `3527`413 // Estimated: `3527`
414 // Minimum execution time: 10_528_000 picoseconds.414 // Minimum execution time: 19_186_000 picoseconds.
415 Weight::from_parts(10_842_000, 3527)415 Weight::from_parts(19_616_000, 3527)
416 .saturating_add(RocksDbWeight::get().reads(2_u64))416 .saturating_add(RocksDbWeight::get().reads(2_u64))
417 .saturating_add(RocksDbWeight::get().writes(1_u64))417 .saturating_add(RocksDbWeight::get().writes(1_u64))
418 }418 }
modifiedpallets/collator-selection/Cargo.tomldiffbeforeafterboth
14[dependencies]14[dependencies]
15log = { workspace = true }15log = { workspace = true }
16parity-scale-codec = { workspace = true }16parity-scale-codec = { workspace = true }
17rand = { version = "0.8.5", default-features = false }17rand = { version = "0.8.5", default-features = false, features = ["std_rng"] }
18scale-info = { workspace = true }18scale-info = { workspace = true }
19serde = { workspace = true }19serde = { workspace = true }
2020
modifiedpallets/collator-selection/src/benchmarking.rsdiffbeforeafterboth
3232
33//! Benchmarking setup for pallet-collator-selection33//! Benchmarking setup for pallet-collator-selection
3434
35use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller};35use frame_benchmarking::v2::{
36 account, benchmarks, impl_benchmark_test_suite, whitelisted_caller, BenchmarkError,
37};
36use frame_support::{38use frame_support::{
37 assert_ok,39 assert_ok,
159/// Our benchmarking environment already has invulnerables registered.161/// Our benchmarking environment already has invulnerables registered.
160const INITIAL_INVULNERABLES: u32 = 2;162const INITIAL_INVULNERABLES: u32 = 2;
161163
162benchmarks! {164#[benchmarks(where T: Config + pallet_authorship::Config + session::Config)]
163 where_clause { where165mod benchmarks {
164 T: Config + pallet_authorship::Config + session::Config166 use super::*;
165 }167 const MAX_COLLATORS: u32 = 10;
168 const MAX_INVULNERABLES: u32 = MAX_COLLATORS - INITIAL_INVULNERABLES;
166169
167 // todo:collator this and all the following do not work for some reason, going all the way up to 10 in length170 // todo:collator this and all the following do not work for some reason, going all the way up to 10 in length
168 // Both invulnerables and candidates count together against MaxCollators.171 // Both invulnerables and candidates count together against MaxCollators.
169 // Maybe try putting it in braces? 1 .. (T::MaxCollators::get() - 2)172 // Maybe try putting it in braces? 1 .. (T::MaxCollators::get() - 2)
173 #[benchmark]
170 add_invulnerable {174 fn add_invulnerable<T>(b: Linear<2, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
171 let b in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES - 1;175 let b = b - 1;
172 register_validators::<T>(b);176 register_validators::<T>(b);
173 register_invulnerables::<T>(b);177 register_invulnerables::<T>(b);
174178
175 // log::info!("{} {}", <Invulnerables<T>>::get().len(), b);179 // log::info!("{} {}", <Invulnerables<T>>::get().len(), b);
176180
177 let new_invulnerable: T::AccountId = whitelisted_caller();181 let new_invulnerable: T::AccountId = whitelisted_caller();
178 let bond: BalanceOf<T> = balance_unit::<T>() * 2u32.into();182 let bond: BalanceOf<T> = balance_unit::<T>() * 2u32.into();
179 <T as Config>::Currency::set_balance(&new_invulnerable, bond);183 <T as Config>::Currency::set_balance(&new_invulnerable, bond);
180184
181 <session::Pallet<T>>::set_keys(185 <session::Pallet<T>>::set_keys(
182 RawOrigin::Signed(new_invulnerable.clone()).into(),
183 keys::<T>(b + 1),
184 Vec::new()
185 ).unwrap();186 RawOrigin::Signed(new_invulnerable.clone()).into(),
187 keys::<T>(b + 1),
188 Vec::new(),
189 )
190 .unwrap();
186191
187 let root_origin = T::UpdateOrigin::try_successful_origin().unwrap();192 let root_origin = T::UpdateOrigin::try_successful_origin().unwrap();
193
194 #[block]
188 }: {195 {
189 assert_ok!(196 assert_ok!(<CollatorSelection<T>>::add_invulnerable(
190 <CollatorSelection<T>>::add_invulnerable(root_origin, new_invulnerable.clone())197 root_origin,
198 new_invulnerable.clone()
191 );199 ));
192 }200 }
193 verify {201
194 assert_last_event::<T>(Event::InvulnerableAdded{invulnerable: new_invulnerable}.into());202 assert_last_event::<T>(
195 }203 Event::InvulnerableAdded {
196204 invulnerable: new_invulnerable,
205 }
206 .into(),
207 );
208
209 Ok(())
210 }
211
212 #[benchmark]
197 remove_invulnerable {213 fn remove_invulnerable(b: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
198 let b in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES - 1;
199 register_validators::<T>(b);214 register_validators::<T>(b);
200 register_invulnerables::<T>(b);215 register_invulnerables::<T>(b);
201216
202 let root_origin = T::UpdateOrigin::try_successful_origin().unwrap();217 let root_origin = T::UpdateOrigin::try_successful_origin().unwrap();
203 let leaving = <Invulnerables<T>>::get().last().unwrap().clone();218 let leaving = <Invulnerables<T>>::get().last().unwrap().clone();
204 whitelist!(leaving);219 whitelist!(leaving);
220
221 #[block]
205 }: {222 {
206 assert_ok!(223 assert_ok!(<CollatorSelection<T>>::remove_invulnerable(
207 <CollatorSelection<T>>::remove_invulnerable(root_origin, leaving.clone())224 root_origin,
225 leaving.clone()
208 );226 ));
209 }227 }
210 verify {228
211 assert_last_event::<T>(Event::InvulnerableRemoved{invulnerable: leaving}.into());229 assert_last_event::<T>(
212 }230 Event::InvulnerableRemoved {
213231 invulnerable: leaving,
232 }
233 .into(),
234 );
235
236 Ok(())
237 }
238
239 #[benchmark]
214 get_license {240 fn get_license(c: Linear<1, MAX_COLLATORS>) -> Result<(), BenchmarkError> {
215 let c in 1 .. T::MaxCollators::get() - 1;
216
217 register_validators::<T>(c);241 register_validators::<T>(c);
218 get_licenses::<T>(c);242 get_licenses::<T>(c);
219243
220 let caller: T::AccountId = whitelisted_caller();244 let caller: T::AccountId = whitelisted_caller();
221 let bond: BalanceOf<T> = balance_unit::<T>() * 2u32.into();245 let bond: BalanceOf<T> = balance_unit::<T>() * 2u32.into();
222 T::Currency::set_balance(&caller, bond);246 T::Currency::set_balance(&caller, bond);
223247
224 <session::Pallet<T>>::set_keys(248 <session::Pallet<T>>::set_keys(
225 RawOrigin::Signed(caller.clone()).into(),249 RawOrigin::Signed(caller.clone()).into(),
226 keys::<T>(c + 1),250 keys::<T>(c + 1),
227 Vec::new()251 Vec::new(),
228 ).unwrap();252 )
229253 .unwrap();
254
255 #[extrinsic_call]
230 }: _(RawOrigin::Signed(caller.clone()))256 _(RawOrigin::Signed(caller.clone()));
231 verify {257
232 assert_last_event::<T>(Event::LicenseObtained{account_id: caller, deposit: bond / 2u32.into()}.into());258 assert_last_event::<T>(
233 }259 Event::LicenseObtained {
260 account_id: caller,
261 deposit: bond / 2u32.into(),
262 }
263 .into(),
264 );
265
266 Ok(())
267 }
234268
235 // worst case is when we have all the max-candidate slots filled except one, and we fill that269 // worst case is when we have all the max-candidate slots filled except one, and we fill that
236 // one.270 // one.
271 #[benchmark]
237 onboard {272 fn onboard(c: Linear<2, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
238 let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES - 1;273 let c = c - 1;
239
240 register_validators::<T>(c);274 register_validators::<T>(c);
241 register_candidates::<T>(c);275 register_candidates::<T>(c);
242276
243 let caller: T::AccountId = whitelisted_caller();277 let caller: T::AccountId = whitelisted_caller();
244 let bond: BalanceOf<T> = balance_unit::<T>() * 2u32.into();278 let bond: BalanceOf<T> = balance_unit::<T>() * 2u32.into();
245 T::Currency::set_balance(&caller, bond);279 T::Currency::set_balance(&caller, bond);
246280
247 let origin = RawOrigin::Signed(caller.clone());281 let origin = RawOrigin::Signed(caller.clone());
248282
249 <session::Pallet<T>>::set_keys(283 <session::Pallet<T>>::set_keys(origin.clone().into(), keys::<T>(c + 1), Vec::new())
250 origin.clone().into(),
251 keys::<T>(c + 1),
252 Vec::new()
253 ).unwrap();284 .unwrap();
254285
255 assert_ok!(286 assert_ok!(<CollatorSelection<T>>::get_license(origin.clone().into()));
256 <CollatorSelection<T>>::get_license(origin.clone().into())287
257 );288 #[extrinsic_call]
289 _(origin);
290
291 assert_last_event::<T>(Event::CandidateAdded { account_id: caller }.into());
292
293 Ok(())
258 }: _(origin)294 }
259 verify {
260 assert_last_event::<T>(Event::CandidateAdded{account_id: caller}.into());
261 }
262295
263 // worst case is the last candidate leaving.296 // worst case is the last candidate leaving.
297 #[benchmark]
264 offboard {298 fn offboard(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
265 let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;
266
267 register_validators::<T>(c);299 register_validators::<T>(c);
268 register_candidates::<T>(c);300 register_candidates::<T>(c);
269301
270 let leaving = <Candidates<T>>::get().last().unwrap().clone();302 let leaving = <Candidates<T>>::get().last().unwrap().clone();
271 whitelist!(leaving);303 whitelist!(leaving);
304
305 #[extrinsic_call]
272 }: _(RawOrigin::Signed(leaving.clone()))306 _(RawOrigin::Signed(leaving.clone()));
273 verify {307
274 assert_last_event::<T>(Event::CandidateRemoved{account_id: leaving}.into());308 assert_last_event::<T>(
275 }309 Event::CandidateRemoved {
310 account_id: leaving,
311 }
312 .into(),
313 );
314
315 Ok(())
316 }
276317
277 // worst case is the last candidate leaving.318 // worst case is the last candidate leaving.
319 #[benchmark]
278 release_license {320 fn release_license(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
279 let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;
280 let bond = balance_unit::<T>();321 let bond = balance_unit::<T>();
281322
282 register_validators::<T>(c);323 register_validators::<T>(c);
283 register_candidates::<T>(c);324 register_candidates::<T>(c);
284325
285 let leaving = <Candidates<T>>::get().last().unwrap().clone();326 let leaving = <Candidates<T>>::get().last().unwrap().clone();
286 whitelist!(leaving);327 whitelist!(leaving);
328
329 #[extrinsic_call]
287 }: _(RawOrigin::Signed(leaving.clone()))330 _(RawOrigin::Signed(leaving.clone()));
288 verify {331
289 assert_last_event::<T>(Event::LicenseReleased{account_id: leaving, deposit_returned: bond}.into());332 assert_last_event::<T>(
290 }333 Event::LicenseReleased {
334 account_id: leaving,
335 deposit_returned: bond,
336 }
337 .into(),
338 );
339
340 Ok(())
341 }
291342
292 // worst case is the last candidate leaving.343 // worst case is the last candidate leaving.
344 #[benchmark]
293 force_release_license {345 fn force_release_license(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
294 let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;
295 let bond = balance_unit::<T>();346 let bond = balance_unit::<T>();
296347
297 register_validators::<T>(c);348 register_validators::<T>(c);
298 register_candidates::<T>(c);349 register_candidates::<T>(c);
299350
300 let leaving = <Candidates<T>>::get().last().unwrap().clone();351 let leaving = <Candidates<T>>::get().last().unwrap().clone();
301 whitelist!(leaving);352 whitelist!(leaving);
302 let origin = T::UpdateOrigin::try_successful_origin().unwrap();353 let origin = T::UpdateOrigin::try_successful_origin().unwrap();
354
355 #[block]
303 }: {356 {
304 assert_ok!(357 assert_ok!(<CollatorSelection<T>>::force_release_license(
305 <CollatorSelection<T>>::force_release_license(origin, leaving.clone())358 origin,
359 leaving.clone()
306 );360 ));
307 }361 }
308 verify {362
309 assert_last_event::<T>(Event::LicenseReleased{account_id: leaving, deposit_returned: bond}.into());363 assert_last_event::<T>(
310 }364 Event::LicenseReleased {
365 account_id: leaving,
366 deposit_returned: bond,
367 }
368 .into(),
369 );
370
371 Ok(())
372 }
311373
312 // worst case is paying a non-existing candidate account.374 // worst case is paying a non-existing candidate account.
375 #[benchmark]
313 note_author {376 fn note_author() -> Result<(), BenchmarkError> {
314 T::Currency::set_balance(377 T::Currency::set_balance(
315 &<CollatorSelection<T>>::account_id(),378 &<CollatorSelection<T>>::account_id(),
316 balance_unit::<T>() * 4u32.into(),379 balance_unit::<T>() * 4u32.into(),
317 );380 );
318 let author = account("author", 0, SEED);381 let author = account("author", 0, SEED);
319 let new_block: BlockNumberFor<T>= 10u32.into();382 let new_block: BlockNumberFor<T> = 10u32.into();
320383
321 frame_system::Pallet::<T>::set_block_number(new_block);384 frame_system::Pallet::<T>::set_block_number(new_block);
322 assert!(T::Currency::balance(&author) == 0u32.into());385 assert!(T::Currency::balance(&author) == 0u32.into());
386
387 #[block]
323 }: {388 {
324 <CollatorSelection<T> as EventHandler<_, _>>::note_author(author.clone())389 <CollatorSelection<T> as EventHandler<_, _>>::note_author(author.clone());
325 } verify {390 }
391
326 assert!(T::Currency::balance(&author) > 0u32.into());392 assert!(T::Currency::balance(&author) > 0u32.into());
327 assert_eq!(frame_system::Pallet::<T>::block_number(), new_block);393 assert_eq!(frame_system::Pallet::<T>::block_number(), new_block);
328 }394
395 Ok(())
396 }
329397
330 // worst case for new session.398 // worst case for new session.
399 #[benchmark]
331 new_session {400 fn new_session(
332 let r in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;401 r: Linear<1, MAX_INVULNERABLES>,
333 let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;402 c: Linear<1, MAX_INVULNERABLES>,
334403 ) -> Result<(), BenchmarkError> {
335 frame_system::Pallet::<T>::set_block_number(0u32.into());404 frame_system::Pallet::<T>::set_block_number(0u32.into());
336405
337 register_validators::<T>(c);406 register_validators::<T>(c);
338 register_candidates::<T>(c);407 register_candidates::<T>(c);
339408
340 let new_block: BlockNumberFor<T>= 1800u32.into();409 let new_block: BlockNumberFor<T> = 1800u32.into();
341 let zero_block: BlockNumberFor<T> = 0u32.into();410 let zero_block: BlockNumberFor<T> = 0u32.into();
342 let candidates = <Candidates<T>>::get();411 let candidates = <Candidates<T>>::get();
343412
344 let non_removals = c.saturating_sub(r);413 let non_removals = c.saturating_sub(r);
345414
346 for i in 0..c {415 for i in 0..c {
347 <LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), zero_block);416 <LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), zero_block);
348 }417 }
349418
350 if non_removals > 0 {419 if non_removals > 0 {
351 for i in 0..non_removals {420 for i in 0..non_removals {
352 <LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), new_block);421 <LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), new_block);
353 }422 }
354 } else {423 } else {
355 for i in 0..c {424 for i in 0..c {
356 <LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), new_block);425 <LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), new_block);
357 }426 }
358 }427 }
359428
360 let pre_length = <Candidates<T>>::get().len();429 let pre_length = <Candidates<T>>::get().len();
361430
362 frame_system::Pallet::<T>::set_block_number(new_block);431 frame_system::Pallet::<T>::set_block_number(new_block);
363432
364 assert!(<Candidates<T>>::get().len() == c as usize);433 assert!(<Candidates<T>>::get().len() == c as usize);
434
435 #[block]
365 }: {436 {
366 <CollatorSelection<T> as SessionManager<_>>::new_session(0)437 <CollatorSelection<T> as SessionManager<_>>::new_session(0);
367 } verify {438 }
439
368 if c > r {440 if c > r {
369 assert!(<Candidates<T>>::get().len() < pre_length);441 assert!(<Candidates<T>>::get().len() < pre_length);
370 } else {442 } else {
371 assert!(<Candidates<T>>::get().len() == pre_length);443 assert!(<Candidates<T>>::get().len() == pre_length);
372 }444 }
373 }445
374}446 Ok(())
375447 }
376impl_benchmark_test_suite!(448
377 CollatorSelection,449 impl_benchmark_test_suite!(
378 crate::mock::new_test_ext(),450 CollatorSelection,
379 crate::mock::Test,451 crate::mock::new_test_ext(),
380);452 crate::mock::Test,
453 );
454}
381455
modifiedpallets/common/src/benchmarking.rsdiffbeforeafterboth
1818
19use core::convert::TryInto;19use core::convert::TryInto;
2020
21use frame_benchmarking::{account, benchmarks};21use frame_benchmarking::{account, v2::*};
22use frame_support::{22use frame_support::{
23 pallet_prelude::ConstU32,23 pallet_prelude::ConstU32,
24 traits::{fungible::Balanced, tokens::Precision, Get, Imbalance},24 traits::{fungible::Balanced, tokens::Precision, Get, Imbalance},
25 BoundedVec,25 BoundedVec,
26};26};
27use pallet_evm::account::CrossAccountId;27use pallet_evm::account::CrossAccountId;
28use sp_runtime::{traits::Zero, DispatchError};28use sp_runtime::{traits::Zero, DispatchError};
29use sp_std::vec::Vec;29use sp_std::{vec, vec::Vec};
30use up_data_structs::{30use up_data_structs::{
31 AccessMode, CollectionId, CollectionMode, CollectionPermissions, CreateCollectionData,31 AccessMode, CollectionId, CollectionMode, CollectionPermissions, CreateCollectionData,
32 NestingPermissions, PropertiesPermissionMap, Property, PropertyKey, PropertyValue,32 NestingPermissions, PropertiesPermissionMap, Property, PropertyKey, PropertyValue,
178 () => {}178 () => {}
179}179}
180180
181#[benchmarks]
181benchmarks! {182mod benchmarks {
183 use super::*;
184
185 #[benchmark]
182 set_collection_properties {186 fn set_collection_properties(
183 let b in 0..MAX_PROPERTIES_PER_ITEM;187 b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
188 ) -> Result<(), BenchmarkError> {
184 bench_init!{189 bench_init! {
185 owner: sub; collection: collection(owner);190 owner: sub; collection: collection(owner);
186 owner: cross_from_sub;191 owner: cross_from_sub;
187 };192 };
188 let props = (0..b).map(|p| Property {193 let props = (0..b)
194 .map(|p| Property {
189 key: property_key(p as usize),195 key: property_key(p as usize),
190 value: property_value(),196 value: property_value(),
191 }).collect::<Vec<_>>();197 })
198 .collect::<Vec<_>>();
199
200 #[block]
192 }: {<Pallet<T>>::set_collection_properties(&collection, &owner, props.into_iter())?}201 {
193202 <Pallet<T>>::set_collection_properties(&collection, &owner, props.into_iter())?;
203 }
204
205 Ok(())
206 }
207
208 #[benchmark]
194 delete_collection_properties {209 fn delete_collection_properties(
195 let b in 0..MAX_PROPERTIES_PER_ITEM;210 b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
211 ) -> Result<(), BenchmarkError> {
196 bench_init!{212 bench_init! {
197 owner: sub; collection: collection(owner);213 owner: sub; collection: collection(owner);
198 owner: cross_from_sub;214 owner: cross_from_sub;
199 };215 };
200 let props = (0..b).map(|p| Property {216 let props = (0..b)
217 .map(|p| Property {
201 key: property_key(p as usize),218 key: property_key(p as usize),
202 value: property_value(),219 value: property_value(),
203 }).collect::<Vec<_>>();220 })
221 .collect::<Vec<_>>();
204 <Pallet<T>>::set_collection_properties(&collection, &owner, props.into_iter())?;222 <Pallet<T>>::set_collection_properties(&collection, &owner, props.into_iter())?;
205 let to_delete = (0..b).map(|p| property_key(p as usize)).collect::<Vec<_>>();223 let to_delete = (0..b).map(|p| property_key(p as usize)).collect::<Vec<_>>();
224
225 #[block]
206 }: {<Pallet<T>>::delete_collection_properties(&collection, &owner, to_delete.into_iter())?}226 {
207227 <Pallet<T>>::delete_collection_properties(&collection, &owner, to_delete.into_iter())?;
228 }
229
230 Ok(())
231 }
232
233 #[benchmark]
208 check_accesslist{234 fn check_accesslist() -> Result<(), BenchmarkError> {
209 bench_init!{235 bench_init! {
210 owner: sub; collection: collection(owner);236 owner: sub; collection: collection(owner);
211 sender: cross_from_sub(owner);237 sender: cross_from_sub(owner);
212 };238 };
213239
214 let mut collection_handle = <CollectionHandle<T>>::try_get(collection.id)?;240 let mut collection_handle = <CollectionHandle<T>>::try_get(collection.id)?;
215 <Pallet<T>>::update_permissions(241 <Pallet<T>>::update_permissions(
216 &sender,242 &sender,
217 &mut collection_handle,243 &mut collection_handle,
218 CollectionPermissions { access: Some(AccessMode::AllowList), ..Default::default() }244 CollectionPermissions {
245 access: Some(AccessMode::AllowList),
246 ..Default::default()
247 },
219 )?;248 )?;
220249
221 <Pallet<T>>::toggle_allowlist(250 <Pallet<T>>::toggle_allowlist(&collection, &sender, &sender, true)?;
222 &collection,
223 &sender,
224 &sender,
225 true,
226 )?;
227251
228 assert_eq!(collection_handle.permissions.access(), AccessMode::AllowList);252 assert_eq!(
229253 collection_handle.permissions.access(),
254 AccessMode::AllowList
255 );
256
257 #[block]
258 {
259 collection_handle.check_allowlist(&sender)?;
260 }
261
262 Ok(())
230 }: {collection_handle.check_allowlist(&sender)?;}263 }
231264
265 #[benchmark]
232 init_token_properties_common {266 fn init_token_properties_common() -> Result<(), BenchmarkError> {
233 bench_init!{267 bench_init! {
234 owner: sub; collection: collection(owner);268 owner: sub; collection: collection(owner);
235 sender: sub;269 sender: sub;
236 sender: cross_from_sub(sender);270 sender: cross_from_sub(sender);
237 };271 };
272
273 #[block]
238 }: {load_is_admin_and_property_permissions(&collection, &sender);}274 {
275 load_is_admin_and_property_permissions(&collection, &sender);
276 }
277
278 Ok(())
279 }
239}280}
240281
modifiedpallets/configuration/src/benchmarking.rsdiffbeforeafterboth
1616
17//! Benchmarking setup for pallet-configuration17//! Benchmarking setup for pallet-configuration
1818
19use frame_benchmarking::benchmarks;19use frame_benchmarking::v2::*;
20use frame_support::assert_ok;20use frame_support::assert_ok;
21use frame_system::{pallet_prelude::*, EventRecord, RawOrigin};21use frame_system::{pallet_prelude::*, EventRecord, RawOrigin};
22use sp_std::vec;
2223
23use super::*;24use super::*;
2425
30 assert_eq!(event, &system_event);31 assert_eq!(event, &system_event);
31}32}
3233
33benchmarks! {34#[benchmarks(
34 where_clause { where35 where
35 T: Config,36 T: Config,
36 T::Balance: From<u32>37 T::Balance: From<u32>
37 }38)]
3839mod benchmarks {
40 use super::*;
41
42 #[benchmark]
39 set_weight_to_fee_coefficient_override {43 fn set_weight_to_fee_coefficient_override() -> Result<(), BenchmarkError> {
40 let coeff: u64 = 999;44 let coeff: u64 = 999;
45
46 #[block]
41 }: {47 {
42 assert_ok!(48 assert_ok!(<Pallet<T>>::set_weight_to_fee_coefficient_override(
43 <Pallet<T>>::set_weight_to_fee_coefficient_override(RawOrigin::Root.into(), Some(coeff))49 RawOrigin::Root.into(),
50 Some(coeff)
44 );51 ));
45 }52 }
4653
54 Ok(())
55 }
56
57 #[benchmark]
47 set_min_gas_price_override {58 fn set_min_gas_price_override() -> Result<(), BenchmarkError> {
48 let coeff: u64 = 999;59 let coeff: u64 = 999;
60
61 #[block]
49 }: {62 {
50 assert_ok!(63 assert_ok!(<Pallet<T>>::set_min_gas_price_override(
51 <Pallet<T>>::set_min_gas_price_override(RawOrigin::Root.into(), Some(coeff))64 RawOrigin::Root.into(),
65 Some(coeff)
52 );66 ));
53 }67 }
5468
69 Ok(())
70 }
71
72 #[benchmark]
55 set_app_promotion_configuration_override {73 fn set_app_promotion_configuration_override() -> Result<(), BenchmarkError> {
56 let configuration: AppPromotionConfiguration<BlockNumberFor<T>> = Default::default();74 let configuration: AppPromotionConfiguration<BlockNumberFor<T>> = Default::default();
75
76 #[block]
57 }: {77 {
58 assert_ok!(78 assert_ok!(<Pallet<T>>::set_app_promotion_configuration_override(
59 <Pallet<T>>::set_app_promotion_configuration_override(RawOrigin::Root.into(), configuration)79 RawOrigin::Root.into(),
80 configuration
60 );81 ));
61 }82 }
6283
84 Ok(())
85 }
86
87 #[benchmark]
63 set_collator_selection_desired_collators {88 fn set_collator_selection_desired_collators() -> Result<(), BenchmarkError> {
64 let max: u32 = 999;89 let max: u32 = 999;
90
91 #[block]
65 }: {92 {
66 assert_ok!(93 assert_ok!(<Pallet<T>>::set_collator_selection_desired_collators(
67 <Pallet<T>>::set_collator_selection_desired_collators(RawOrigin::Root.into(), Some(max))94 RawOrigin::Root.into(),
95 Some(max)
68 );96 ));
69 }97 }
70 verify {98
71 assert_last_event::<T>(Event::NewDesiredCollators{desired_collators: Some(max)}.into());99 assert_last_event::<T>(
72 }100 Event::NewDesiredCollators {
73101 desired_collators: Some(max),
102 }
103 .into(),
104 );
105
106 Ok(())
107 }
108
109 #[benchmark]
74 set_collator_selection_license_bond {110 fn set_collator_selection_license_bond() -> Result<(), BenchmarkError> {
75 let bond_cost: Option<T::Balance> = Some(1000u32.into());111 let bond_cost: Option<T::Balance> = Some(1000u32.into());
112
113 #[block]
76 }: {114 {
77 assert_ok!(115 assert_ok!(<Pallet<T>>::set_collator_selection_license_bond(
78 <Pallet<T>>::set_collator_selection_license_bond(RawOrigin::Root.into(), bond_cost)116 RawOrigin::Root.into(),
117 bond_cost
79 );118 ));
80 }119 }
81 verify {120
82 assert_last_event::<T>(Event::NewCollatorLicenseBond{bond_cost}.into());121 assert_last_event::<T>(Event::NewCollatorLicenseBond { bond_cost }.into());
83 }122
84123 Ok(())
124 }
125
126 #[benchmark]
85 set_collator_selection_kick_threshold {127 fn set_collator_selection_kick_threshold() -> Result<(), BenchmarkError> {
86 let threshold: Option<BlockNumberFor<T>> = Some(900u32.into());128 let threshold: Option<BlockNumberFor<T>> = Some(900u32.into());
129
130 #[block]
87 }: {131 {
88 assert_ok!(132 assert_ok!(<Pallet<T>>::set_collator_selection_kick_threshold(
89 <Pallet<T>>::set_collator_selection_kick_threshold(RawOrigin::Root.into(), threshold)133 RawOrigin::Root.into(),
134 threshold
90 );135 ));
91 }136 }
92 verify {137
93 assert_last_event::<T>(Event::NewCollatorKickThreshold{length_in_blocks: threshold}.into());138 assert_last_event::<T>(
94 }139 Event::NewCollatorKickThreshold {
95}140 length_in_blocks: threshold,
141 }
142 .into(),
143 );
144
145 Ok(())
146 }
147}
96148
modifiedpallets/evm-migration/src/benchmarking.rsdiffbeforeafterboth
1616
17#![allow(missing_docs)]17#![allow(missing_docs)]
1818
19use frame_benchmarking::benchmarks;19use frame_benchmarking::v2::*;
20use frame_system::RawOrigin;20use frame_system::RawOrigin;
21use sp_core::{H160, H256};21use sp_core::{H160, H256};
22use sp_std::{vec, vec::Vec};22use sp_std::{vec, vec::Vec};
2323
24use super::{Call, Config, Pallet};24use super::{Call, Config, Pallet};
2525
26benchmarks! {26#[benchmarks(
27 where_clause { where <T as Config>::RuntimeEvent: parity_scale_codec::Encode }27 where <T as Config>::RuntimeEvent: parity_scale_codec::Encode
2828)]
29mod benchmarks {
30 use super::*;
31
32 #[benchmark]
29 begin {33 fn begin() -> Result<(), BenchmarkError> {
34 #[extrinsic_call]
30 }: _(RawOrigin::Root, H160::default())35 _(RawOrigin::Root, H160::default());
3136
37 Ok(())
38 }
39
40 #[benchmark]
32 set_data {41 fn set_data(b: Linear<0, 80>) -> Result<(), BenchmarkError> {
33 let b in 0..80;
34 let address = H160::from_low_u64_be(b as u64);42 let address = H160::from_low_u64_be(b as u64);
35 let mut data = Vec::new();43 let mut data = Vec::new();
36 for i in 0..b {44 for i in 0..b {
39 H256::from_low_u64_be(i as u64),47 H256::from_low_u64_be(i as u64),
40 ));48 ));
41 }49 }
42 <Pallet<T>>::begin(RawOrigin::Root.into(), address)?;50 <Pallet<T>>::begin(RawOrigin::Root.into(), address)?;
51
52 #[extrinsic_call]
43 }: _(RawOrigin::Root, address, data)53 _(RawOrigin::Root, address, data);
4454
55 Ok(())
56 }
57
58 #[benchmark]
45 finish {59 fn finish(b: Linear<0, 80>) -> Result<(), BenchmarkError> {
46 let b in 0..80;
47 let address = H160::from_low_u64_be(b as u64);60 let address = H160::from_low_u64_be(b as u64);
48 let data: Vec<u8> = (0..b as u8).collect();61 let data: Vec<u8> = (0..b as u8).collect();
49 <Pallet<T>>::begin(RawOrigin::Root.into(), address)?;62 <Pallet<T>>::begin(RawOrigin::Root.into(), address)?;
63
64 #[extrinsic_call]
50 }: _(RawOrigin::Root, address, data)65 _(RawOrigin::Root, address, data);
5166
67 Ok(())
68 }
69
70 #[benchmark]
52 insert_eth_logs {71 fn insert_eth_logs(b: Linear<0, 200>) -> Result<(), BenchmarkError> {
53 let b in 0..200;
54 let logs = (0..b).map(|_| ethereum::Log {72 let logs = (0..b)
73 .map(|_| ethereum::Log {
55 address: H160([b as u8; 20]),74 address: H160([b as u8; 20]),
56 data: vec![b as u8; 128],75 data: vec![b as u8; 128],
57 topics: vec![H256([b as u8; 32]); 6],76 topics: vec![H256([b as u8; 32]); 6],
58 }).collect::<Vec<_>>();77 })
78 .collect::<Vec<_>>();
79
80 #[extrinsic_call]
59 }: _(RawOrigin::Root, logs)81 _(RawOrigin::Root, logs);
6082
83 Ok(())
84 }
85
86 #[benchmark]
61 insert_events {87 fn insert_events(b: Linear<0, 200>) -> Result<(), BenchmarkError> {
62 let b in 0..200;
63 use parity_scale_codec::Encode;88 use parity_scale_codec::Encode;
64 let logs = (0..b).map(|_| <T as Config>::RuntimeEvent::from(crate::Event::<T>::TestEvent).encode()).collect::<Vec<_>>();89 let logs = (0..b)
90 .map(|_| <T as Config>::RuntimeEvent::from(crate::Event::<T>::TestEvent).encode())
91 .collect::<Vec<_>>();
92
93 #[extrinsic_call]
65 }: _(RawOrigin::Root, logs)94 _(RawOrigin::Root, logs);
66}95
96 Ok(())
97 }
98}
6799
modifiedpallets/foreign-assets/src/benchmarking.rsdiffbeforeafterboth
1616
17#![allow(missing_docs)]17#![allow(missing_docs)]
1818
19use frame_benchmarking::{account, benchmarks};19use frame_benchmarking::{account, v2::*};
20use frame_support::traits::Currency;20use frame_support::traits::Currency;
21use frame_system::RawOrigin;21use frame_system::RawOrigin;
22use sp_std::{boxed::Box, vec::Vec};22use sp_std::{boxed::Box, vec, vec::Vec};
23use staging_xcm::{opaque::latest::Junction::Parachain, v3::Junctions::X1, VersionedMultiLocation};23use staging_xcm::{opaque::latest::Junction::Parachain, v3::Junctions::X1, VersionedMultiLocation};
2424
25use super::{Call, Config, Pallet};25use super::{Call, Config, Pallet};
31 .unwrap()31 .unwrap()
32}32}
3333
34#[benchmarks]
34benchmarks! {35mod benchmarks {
36 use super::*;
37
38 #[benchmark]
35 register_foreign_asset {39 fn register_foreign_asset() -> Result<(), BenchmarkError> {
36 let owner: T::AccountId = account("user", 0, 1);40 let owner: T::AccountId = account("user", 0, 1);
37 let location: VersionedMultiLocation = VersionedMultiLocation::from(X1(Parachain(1000)));41 let location: VersionedMultiLocation = VersionedMultiLocation::from(X1(Parachain(1000)));
38 let metadata: AssetMetadata<<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance> = AssetMetadata{42 let metadata: AssetMetadata<
43 <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance,
44 > = AssetMetadata {
39 name: bounded(b"name"),45 name: bounded(b"name"),
40 symbol: bounded(b"symbol"),46 symbol: bounded(b"symbol"),
41 decimals: 18,47 decimals: 18,
42 minimal_balance: 1u32.into()48 minimal_balance: 1u32.into(),
43 };49 };
44 let mut balance: <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance =50 let mut balance: <<T as Config>::Currency as Currency<
51 <T as frame_system::Config>::AccountId,
45 4_000_000_000u32.into();52 >>::Balance = 4_000_000_000u32.into();
46 balance = balance * balance;53 balance = balance * balance;
47 <T as Config>::Currency::make_free_balance_be(&owner,54 <T as Config>::Currency::make_free_balance_be(&owner, balance);
48 balance);55
56 #[extrinsic_call]
57 _(
58 RawOrigin::Root,
59 owner,
60 Box::new(location),
61 Box::new(metadata),
62 );
63
64 Ok(())
49 }: _(RawOrigin::Root, owner, Box::new(location), Box::new(metadata))65 }
5066
67 #[benchmark]
51 update_foreign_asset {68 fn update_foreign_asset() -> Result<(), BenchmarkError> {
52 let owner: T::AccountId = account("user", 0, 1);69 let owner: T::AccountId = account("user", 0, 1);
53 let location: VersionedMultiLocation = VersionedMultiLocation::from(X1(Parachain(2000)));70 let location: VersionedMultiLocation = VersionedMultiLocation::from(X1(Parachain(2000)));
54 let metadata: AssetMetadata<<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance> = AssetMetadata{71 let metadata: AssetMetadata<
72 <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance,
73 > = AssetMetadata {
55 name: bounded(b"name"),74 name: bounded(b"name"),
56 symbol: bounded(b"symbol"),75 symbol: bounded(b"symbol"),
57 decimals: 18,76 decimals: 18,
58 minimal_balance: 1u32.into()77 minimal_balance: 1u32.into(),
59 };78 };
60 let metadata2: AssetMetadata<<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance> = AssetMetadata{79 let metadata2: AssetMetadata<
80 <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance,
81 > = AssetMetadata {
61 name: bounded(b"name2"),82 name: bounded(b"name2"),
62 symbol: bounded(b"symbol2"),83 symbol: bounded(b"symbol2"),
63 decimals: 18,84 decimals: 18,
64 minimal_balance: 1u32.into()85 minimal_balance: 1u32.into(),
65 };86 };
66 let mut balance: <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance =87 let mut balance: <<T as Config>::Currency as Currency<
88 <T as frame_system::Config>::AccountId,
67 4_000_000_000u32.into();89 >>::Balance = 4_000_000_000u32.into();
68 balance = balance * balance;90 balance = balance * balance;
69 <T as Config>::Currency::make_free_balance_be(&owner, balance);91 <T as Config>::Currency::make_free_balance_be(&owner, balance);
70 Pallet::<T>::register_foreign_asset(RawOrigin::Root.into(), owner, Box::new(location.clone()), Box::new(metadata))?;92 Pallet::<T>::register_foreign_asset(
93 RawOrigin::Root.into(),
94 owner,
95 Box::new(location.clone()),
96 Box::new(metadata),
97 )?;
98
99 #[extrinsic_call]
100 _(RawOrigin::Root, 0, Box::new(location), Box::new(metadata2));
101
102 Ok(())
71 }: _(RawOrigin::Root, 0, Box::new(location), Box::new(metadata2))103 }
72}104}
73105
modifiedpallets/fungible/src/benchmarking.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17use frame_benchmarking::{account, benchmarks};17use frame_benchmarking::{account, v2::*};
18use pallet_common::{bench_init, benchmarking::create_collection_raw};18use pallet_common::{bench_init, benchmarking::create_collection_raw};
19use sp_std::prelude::*;19use sp_std::prelude::*;
20use up_data_structs::{budget::Unlimited, CollectionMode, MAX_ITEMS_PER_BATCH};20use up_data_structs::{budget::Unlimited, CollectionMode, MAX_ITEMS_PER_BATCH};
35 )35 )
36}36}
3737
38#[benchmarks]
38benchmarks! {39mod benchmarks {
40 use super::*;
41
42 #[benchmark]
39 create_item {43 fn create_item() -> Result<(), BenchmarkError> {
40 bench_init!{44 bench_init! {
41 owner: sub; collection: collection(owner);45 owner: sub; collection: collection(owner);
42 sender: cross_from_sub(owner); to: cross_sub;46 sender: cross_from_sub(owner); to: cross_sub;
43 };47 };
48
49 #[block]
44 }: {<Pallet<T>>::create_item(&collection, &sender, (to, 200), &Unlimited)?}50 {
4551 <Pallet<T>>::create_item(&collection, &sender, (to, 200), &Unlimited)?;
52 }
53
54 Ok(())
55 }
56
57 #[benchmark]
46 create_multiple_items_ex {58 fn create_multiple_items_ex(b: Linear<0, MAX_ITEMS_PER_BATCH>) -> Result<(), BenchmarkError> {
47 let b in 0..MAX_ITEMS_PER_BATCH;
48 bench_init!{59 bench_init! {
49 owner: sub; collection: collection(owner);60 owner: sub; collection: collection(owner);
50 sender: cross_from_sub(owner);61 sender: cross_from_sub(owner);
51 };62 };
52 let data = (0..b).map(|i| {63 let data = (0..b)
64 .map(|i| {
53 bench_init!(to: cross_sub(i););65 bench_init!(to: cross_sub(i););
54 (to, 200)66 (to, 200)
55 }).collect::<BTreeMap<_, _>>();67 })
68 .collect::<BTreeMap<_, _>>();
69
70 #[block]
56 }: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}71 {
5772 <Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?;
73 }
74
75 Ok(())
76 }
77
78 #[benchmark]
58 burn_item {79 fn burn_item() -> Result<(), BenchmarkError> {
59 bench_init!{80 bench_init! {
60 owner: sub; collection: collection(owner);81 owner: sub; collection: collection(owner);
61 owner: cross_from_sub; burner: cross_sub;82 owner: cross_from_sub; burner: cross_sub;
62 };83 };
63 <Pallet<T>>::create_item(&collection, &owner, (burner.clone(), 200), &Unlimited)?;84 <Pallet<T>>::create_item(&collection, &owner, (burner.clone(), 200), &Unlimited)?;
85
86 #[block]
87 {
88 <Pallet<T>>::burn(&collection, &burner, 100)?;
89 }
90
91 Ok(())
64 }: {<Pallet<T>>::burn(&collection, &burner, 100)?}92 }
6593
94 #[benchmark]
66 transfer_raw {95 fn transfer_raw() -> Result<(), BenchmarkError> {
67 bench_init!{96 bench_init! {
68 owner: sub; collection: collection(owner);97 owner: sub; collection: collection(owner);
69 owner: cross_from_sub; sender: cross_sub; to: cross_sub;98 owner: cross_from_sub; sender: cross_sub; to: cross_sub;
70 };99 };
71 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;100 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
101
102 #[block]
72 }: {<Pallet<T>>::transfer(&collection, &sender, &to, 200, &Unlimited)?}103 {
73104 <Pallet<T>>::transfer(&collection, &sender, &to, 200, &Unlimited)?;
105 }
106
107 Ok(())
108 }
109
110 #[benchmark]
74 approve {111 fn approve() -> Result<(), BenchmarkError> {
75 bench_init!{112 bench_init! {
76 owner: sub; collection: collection(owner);113 owner: sub; collection: collection(owner);
77 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;114 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
78 };115 };
79 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;116 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
117
118 #[block]
80 }: {<Pallet<T>>::set_allowance(&collection, &sender, &spender, 100)?}119 {
81120 <Pallet<T>>::set_allowance(&collection, &sender, &spender, 100)?;
121 }
122
123 Ok(())
124 }
125
126 #[benchmark]
82 approve_from {127 fn approve_from() -> Result<(), BenchmarkError> {
83 bench_init!{128 bench_init! {
84 owner: sub; collection: collection(owner);129 owner: sub; collection: collection(owner);
85 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;130 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
86131
87 };132 };
88 let owner_eth = T::CrossAccountId::from_eth(*sender.as_eth());133 let owner_eth = T::CrossAccountId::from_eth(*sender.as_eth());
89 <Pallet<T>>::create_item(&collection, &owner, (owner_eth.clone(), 200), &Unlimited)?;134 <Pallet<T>>::create_item(&collection, &owner, (owner_eth.clone(), 200), &Unlimited)?;
135
136 #[block]
137 {
138 <Pallet<T>>::set_allowance_from(&collection, &sender, &owner_eth, &spender, 100)?;
139 }
140
141 Ok(())
90 }: {<Pallet<T>>::set_allowance_from(&collection, &sender, &owner_eth, &spender, 100)?}142 }
91143
144 #[benchmark]
92 check_allowed_raw {145 fn check_allowed_raw() -> Result<(), BenchmarkError> {
93 bench_init!{146 bench_init! {
94 owner: sub; collection: collection(owner);147 owner: sub; collection: collection(owner);
95 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;148 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
96 };149 };
97 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;150 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
98 <Pallet<T>>::set_allowance(&collection, &sender, &spender, 200)?;151 <Pallet<T>>::set_allowance(&collection, &sender, &spender, 200)?;
152
153 #[block]
154 {
155 <Pallet<T>>::check_allowed(&collection, &spender, &sender, 200, &Unlimited)?;
156 }
157
158 Ok(())
99 }: {<Pallet<T>>::check_allowed(&collection, &spender, &sender, 200, &Unlimited)?;}159 }
100160
161 #[benchmark]
101 set_allowance_unchecked_raw {162 fn set_allowance_unchecked_raw() -> Result<(), BenchmarkError> {
102 bench_init!{163 bench_init! {
103 owner: sub; collection: collection(owner);164 owner: sub; collection: collection(owner);
104 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;165 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
105 };166 };
106 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;167 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
168
169 #[block]
107 }: {<Pallet<T>>::set_allowance_unchecked(&collection, &sender, &spender, 200);}170 {
108171 <Pallet<T>>::set_allowance_unchecked(&collection, &sender, &spender, 200);
172 }
173
174 Ok(())
175 }
176
177 #[benchmark]
109 burn_from {178 fn burn_from() -> Result<(), BenchmarkError> {
110 bench_init!{179 bench_init! {
111 owner: sub; collection: collection(owner);180 owner: sub; collection: collection(owner);
112 owner: cross_from_sub; sender: cross_sub; burner: cross_sub;181 owner: cross_from_sub; sender: cross_sub; burner: cross_sub;
113 };182 };
114 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;183 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
115 <Pallet<T>>::set_allowance(&collection, &sender, &burner, 200)?;184 <Pallet<T>>::set_allowance(&collection, &sender, &burner, 200)?;
185
186 #[block]
187 {
188 <Pallet<T>>::burn_from(&collection, &burner, &sender, 100, &Unlimited)?
189 }
190
191 Ok(())
116 }: {<Pallet<T>>::burn_from(&collection, &burner, &sender, 100, &Unlimited)?}192 }
117}193}
118194
modifiedpallets/identity/src/benchmarking.rsdiffbeforeafterboth
37#![cfg(feature = "runtime-benchmarks")]37#![cfg(feature = "runtime-benchmarks")]
38#![allow(clippy::no_effect)]38#![allow(clippy::no_effect)]
3939
40use frame_benchmarking::{account, benchmarks, whitelisted_caller};40use frame_benchmarking::v2::*;
41use frame_support::{41use frame_support::{assert_ok, ensure, traits::EnsureOrigin};
42 assert_ok, ensure,
43 traits::{EnsureOrigin, Get},
44};
45use frame_system::RawOrigin;42use frame_system::RawOrigin;
46use sp_runtime::traits::Bounded;43use sp_runtime::traits::Bounded;
4744
145 200u32.into()142 200u32.into()
146}143}
147144
148benchmarks! {145#[benchmarks]
146mod benchmarks {
149 add_registrar {147 use super::*;
148
150 let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;149 const MAX_REGISTRARS: u32 = 20;
150 const MAX_ADDITIONAL_FIELDS: u32 = 100;
151 const MAX_SUB_ACCOUNTS: u32 = 100;
152
153 #[benchmark]
154 fn add_registrar(r: Linear<2, MAX_REGISTRARS>) -> Result<(), BenchmarkError> {
155 let r = r - 1;
156 add_registrars::<T>(r)?;
151 ensure!(Registrars::<T>::get().len() as u32 == r, "Registrars not set up correctly.");157 ensure!(
158 Registrars::<T>::get().len() as u32 == r,
159 "Registrars not set up correctly."
160 );
152 let origin = T::RegistrarOrigin::try_successful_origin().unwrap();161 let origin = T::RegistrarOrigin::try_successful_origin().unwrap();
153 let account = T::Lookup::unlookup(account("registrar", r + 1, SEED));162 let account = T::Lookup::unlookup(account("registrar", r + 1, SEED));
163
154 }: _<T::RuntimeOrigin>(origin, account)164 #[extrinsic_call]
155 verify {165 _(origin as T::RuntimeOrigin, account);
166
156 ensure!(Registrars::<T>::get().len() as u32 == r + 1, "Registrars not added.");167 ensure!(
168 Registrars::<T>::get().len() as u32 == r + 1,
169 "Registrars not added."
170 );
171
172 Ok(())
157 }173 }
158174
159 set_identity {175 #[benchmark]
176 fn set_identity(
160 let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;177 x: Linear<0, MAX_ADDITIONAL_FIELDS>,
178 r: Linear<1, MAX_REGISTRARS>,
179 ) -> Result<(), BenchmarkError> {
161 let x in 0 .. T::MaxAdditionalFields::get();180 add_registrars::<T>(r)?;
162 let caller = {181 let caller = {
163 // The target user182 // The target user
164 let caller: T::AccountId = whitelisted_caller();183 let caller: T::AccountId = whitelisted_caller();
165 let caller_lookup = T::Lookup::unlookup(caller.clone());184 let caller_lookup = T::Lookup::unlookup(caller.clone());
166 let caller_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(caller.clone()).into();185 let caller_origin: <T as frame_system::Config>::RuntimeOrigin =
186 RawOrigin::Signed(caller.clone()).into();
167 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());187 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
168188
169 // Add an initial identity189 // Add an initial identity
173 // User requests judgement from all the registrars, and they approve193 // User requests judgement from all the registrars, and they approve
174 for i in 0..r {194 for i in 0..r {
175 let registrar: T::AccountId = account("registrar", i, SEED);195 let registrar: T::AccountId = account("registrar", i, SEED);
176 let registrar_lookup = T::Lookup::unlookup(registrar.clone());196 let balance_to_use = balance_unit::<T>() * 10u32.into();
177 let balance_to_use = balance_unit::<T>() * 10u32.into();
178 let _ = T::Currency::make_free_balance_be(&registrar, balance_to_use);197 let _ = T::Currency::make_free_balance_be(&registrar, balance_to_use);
179198
180 Identity::<T>::request_judgement(caller_origin.clone(), i, 10u32.into())?;199 Identity::<T>::request_judgement(caller_origin.clone(), i, 10u32.into())?;
188 }207 }
189 caller208 caller
190 };209 };
210
191 }: _(RawOrigin::Signed(caller.clone()), Box::new(create_identity_info::<T>(x)))211 #[extrinsic_call]
192 verify {212 _(
213 RawOrigin::Signed(caller.clone()),
214 Box::new(create_identity_info::<T>(x)),
215 );
216
193 assert_last_event::<T>(Event::<T>::IdentitySet { who: caller }.into());217 assert_last_event::<T>(Event::<T>::IdentitySet { who: caller }.into());
218
219 Ok(())
194 }220 }
195221
196 // We need to split `set_subs` into two benchmarks to accurately isolate the potential222 // We need to split `set_subs` into two benchmarks to accurately isolate the potential
197 // writes caused by new or old sub accounts. The actual weight should simply be223 // writes caused by new or old sub accounts. The actual weight should simply be
198 // the sum of these two weights.224 // the sum of these two weights.
199 set_subs_new {225 #[benchmark]
226 fn set_subs_new(s: Linear<0, MAX_SUB_ACCOUNTS>) -> Result<(), BenchmarkError> {
200 let caller: T::AccountId = whitelisted_caller();227 let caller: T::AccountId = whitelisted_caller();
201 // Create a new subs vec with s sub accounts228 // Create a new subs vec with s sub accounts
202 let s in 0 .. T::MaxSubAccounts::get() => ();
203 let subs = create_sub_accounts::<T>(&caller, s)?;229 let subs = create_sub_accounts::<T>(&caller, s)?;
204 ensure!(SubsOf::<T>::get(&caller).1.len() == 0, "Caller already has subs");230 ensure!(
231 SubsOf::<T>::get(&caller).1.len() == 0,
232 "Caller already has subs"
233 );
234
205 }: set_subs(RawOrigin::Signed(caller.clone()), subs)235 #[extrinsic_call]
206 verify {236 set_subs(RawOrigin::Signed(caller.clone()), subs);
237
207 ensure!(SubsOf::<T>::get(&caller).1.len() as u32 == s, "Subs not added");238 ensure!(
239 SubsOf::<T>::get(&caller).1.len() as u32 == s,
240 "Subs not added"
241 );
242
243 Ok(())
208 }244 }
209245
210 set_subs_old {246 #[benchmark]
247 fn set_subs_old(p: Linear<0, MAX_SUB_ACCOUNTS>) -> Result<(), BenchmarkError> {
211 let caller: T::AccountId = whitelisted_caller();248 let caller: T::AccountId = whitelisted_caller();
212 // Give them p many previous sub accounts.249 // Give them p many previous sub accounts.
213 let p in 0 .. T::MaxSubAccounts::get() => {250 let _ = add_sub_accounts::<T>(&caller, p)?;
214 let _ = add_sub_accounts::<T>(&caller, p)?;
215 };
216 // Remove all subs.251 // Remove all subs.
217 let subs = create_sub_accounts::<T>(&caller, 0)?;252 let subs = create_sub_accounts::<T>(&caller, 0)?;
218 ensure!(253 ensure!(
219 SubsOf::<T>::get(&caller).1.len() as u32 == p,254 SubsOf::<T>::get(&caller).1.len() as u32 == p,
220 "Caller does have subs",255 "Caller does have subs",
221 );256 );
257
222 }: set_subs(RawOrigin::Signed(caller.clone()), subs)258 #[extrinsic_call]
223 verify {259 set_subs(RawOrigin::Signed(caller.clone()), subs);
260
224 ensure!(SubsOf::<T>::get(&caller).1.len() == 0, "Subs not removed");261 ensure!(SubsOf::<T>::get(&caller).1.len() == 0, "Subs not removed");
262
263 Ok(())
225 }264 }
226265
227 clear_identity {266 #[benchmark]
267 fn clear_identity(
268 r: Linear<1, MAX_REGISTRARS>,
269 s: Linear<0, MAX_SUB_ACCOUNTS>,
270 x: Linear<0, MAX_ADDITIONAL_FIELDS>,
271 ) -> Result<(), BenchmarkError> {
228 let caller: T::AccountId = whitelisted_caller();272 let caller: T::AccountId = whitelisted_caller();
229 let caller_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller.clone()));
230 let caller_lookup = <T::Lookup as StaticLookup>::unlookup(caller.clone());273 let caller_lookup = <T::Lookup as StaticLookup>::unlookup(caller.clone());
231 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());274 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
232275
233 let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;276 add_registrars::<T>(r)?;
277
234 let s in 0 .. T::MaxSubAccounts::get() => {278 {
235 // Give them s many sub accounts279 // Give them s many sub accounts
236 let caller: T::AccountId = whitelisted_caller();280 let caller: T::AccountId = whitelisted_caller();
237 let _ = add_sub_accounts::<T>(&caller, s)?;281 let _ = add_sub_accounts::<T>(&caller, s)?;
238 };282 }
239 let x in 0 .. T::MaxAdditionalFields::get();
240283
241 // Create their main identity with x additional fields284 // Create their main identity with x additional fields
242 let info = create_identity_info::<T>(x);285 let info = create_identity_info::<T>(x);
243 let caller: T::AccountId = whitelisted_caller();286 let caller: T::AccountId = whitelisted_caller();
244 let caller_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller.clone()));287 let caller_origin =
288 <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller.clone()));
245 Identity::<T>::set_identity(caller_origin.clone(), Box::new(info.clone()))?;289 Identity::<T>::set_identity(caller_origin.clone(), Box::new(info.clone()))?;
246290
247 // User requests judgement from all the registrars, and they approve291 // User requests judgement from all the registrars, and they approve
248 for i in 0..r {292 for i in 0..r {
249 let registrar: T::AccountId = account("registrar", i, SEED);293 let registrar: T::AccountId = account("registrar", i, SEED);
250 let balance_to_use = balance_unit::<T>() * 10u32.into();294 let balance_to_use = balance_unit::<T>() * 10u32.into();
251 let _ = T::Currency::make_free_balance_be(&registrar, balance_to_use);295 let _ = T::Currency::make_free_balance_be(&registrar, balance_to_use);
252296
253 Identity::<T>::request_judgement(caller_origin.clone(), i, 10u32.into())?;297 Identity::<T>::request_judgement(caller_origin.clone(), i, 10u32.into())?;
259 T::Hashing::hash_of(&info),303 T::Hashing::hash_of(&info),
260 )?;304 )?;
261 }305 }
262 ensure!(IdentityOf::<T>::contains_key(&caller), "Identity does not exist.");306 ensure!(
307 IdentityOf::<T>::contains_key(&caller),
308 "Identity does not exist."
309 );
310
263 }: _(RawOrigin::Signed(caller.clone()))311 #[extrinsic_call]
264 verify {312 _(RawOrigin::Signed(caller.clone()));
313
265 ensure!(!IdentityOf::<T>::contains_key(&caller), "Identity not cleared.");314 ensure!(
315 !IdentityOf::<T>::contains_key(&caller),
316 "Identity not cleared."
317 );
318
319 Ok(())
266 }320 }
267321
268 request_judgement {322 #[benchmark]
323 fn request_judgement(
324 r: Linear<1, MAX_REGISTRARS>,
325 x: Linear<0, MAX_ADDITIONAL_FIELDS>,
326 ) -> Result<(), BenchmarkError> {
269 let caller: T::AccountId = whitelisted_caller();327 let caller: T::AccountId = whitelisted_caller();
270 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());328 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
271329
272 let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;330 add_registrars::<T>(r)?;
331
273 let x in 0 .. T::MaxAdditionalFields::get() => {332 {
274 // Create their main identity with x additional fields333 // Create their main identity with x additional fields
275 let info = create_identity_info::<T>(x);334 let info = create_identity_info::<T>(x);
276 let caller: T::AccountId = whitelisted_caller();335 let caller: T::AccountId = whitelisted_caller();
277 let caller_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller));336 let caller_origin =
337 <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller));
278 Identity::<T>::set_identity(caller_origin, Box::new(info))?;338 Identity::<T>::set_identity(caller_origin, Box::new(info))?;
279 };339 }
340
280 }: _(RawOrigin::Signed(caller.clone()), r - 1, 10u32.into())341 #[extrinsic_call]
281 verify {342 _(RawOrigin::Signed(caller.clone()), r - 1, 10u32.into());
343
282 assert_last_event::<T>(Event::<T>::JudgementRequested { who: caller, registrar_index: r-1 }.into());344 assert_last_event::<T>(
345 Event::<T>::JudgementRequested {
346 who: caller,
347 registrar_index: r - 1,
348 }
349 .into(),
350 );
351
352 Ok(())
283 }353 }
284354
285 cancel_request {355 #[benchmark]
356 fn cancel_request(
357 r: Linear<1, MAX_REGISTRARS>,
358 x: Linear<0, MAX_ADDITIONAL_FIELDS>,
359 ) -> Result<(), BenchmarkError> {
286 let caller: T::AccountId = whitelisted_caller();360 let caller: T::AccountId = whitelisted_caller();
287 let caller_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller.clone()));361 let caller_origin =
362 <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller.clone()));
288 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());363 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
289364
290 let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;365 add_registrars::<T>(r)?;
366
291 let x in 0 .. T::MaxAdditionalFields::get() => {367 {
292 // Create their main identity with x additional fields368 // Create their main identity with x additional fields
293 let info = create_identity_info::<T>(x);369 let info = create_identity_info::<T>(x);
294 let caller: T::AccountId = whitelisted_caller();370 let caller: T::AccountId = whitelisted_caller();
295 let caller_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller));371 let caller_origin =
372 <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller));
296 Identity::<T>::set_identity(caller_origin, Box::new(info))?;373 Identity::<T>::set_identity(caller_origin, Box::new(info))?;
297 };374 }
298375
299 Identity::<T>::request_judgement(caller_origin, r - 1, 10u32.into())?;376 Identity::<T>::request_judgement(caller_origin, r - 1, 10u32.into())?;
377
300 }: _(RawOrigin::Signed(caller.clone()), r - 1)378 #[extrinsic_call]
301 verify {379 _(RawOrigin::Signed(caller.clone()), r - 1);
380
302 assert_last_event::<T>(Event::<T>::JudgementUnrequested { who: caller, registrar_index: r-1 }.into());381 assert_last_event::<T>(
382 Event::<T>::JudgementUnrequested {
383 who: caller,
384 registrar_index: r - 1,
385 }
386 .into(),
387 );
388
389 Ok(())
303 }390 }
304391
305 set_fee {392 #[benchmark]
393 fn set_fee(r: Linear<2, MAX_REGISTRARS>) -> Result<(), BenchmarkError> {
394 let r = r - 1;
306 let caller: T::AccountId = whitelisted_caller();395 let caller: T::AccountId = whitelisted_caller();
307 let caller_lookup = T::Lookup::unlookup(caller.clone());396 let caller_lookup = T::Lookup::unlookup(caller.clone());
308397
309 let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;398 add_registrars::<T>(r)?;
310399
311 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();400 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();
312 Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;401 Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;
313 let registrars = Registrars::<T>::get();402 let registrars = Registrars::<T>::get();
314 ensure!(registrars[r as usize].as_ref().unwrap().fee == 0u32.into(), "Fee already set.");403 ensure!(
404 registrars[r as usize].as_ref().unwrap().fee == 0u32.into(),
405 "Fee already set."
406 );
407
315 }: _(RawOrigin::Signed(caller), r, 100u32.into())408 #[extrinsic_call]
316 verify {409 _(RawOrigin::Signed(caller), r, 100u32.into());
410
317 let registrars = Registrars::<T>::get();411 let registrars = Registrars::<T>::get();
318 ensure!(registrars[r as usize].as_ref().unwrap().fee == 100u32.into(), "Fee not changed.");412 ensure!(
413 registrars[r as usize].as_ref().unwrap().fee == 100u32.into(),
414 "Fee not changed."
415 );
416
417 Ok(())
319 }418 }
320419
321 set_account_id {420 #[benchmark]
421 fn set_account_id(r: Linear<2, MAX_REGISTRARS>) -> Result<(), BenchmarkError> {
422 let r = r - 1;
322 let caller: T::AccountId = whitelisted_caller();423 let caller: T::AccountId = whitelisted_caller();
323 let caller_lookup = T::Lookup::unlookup(caller.clone());424 let caller_lookup = T::Lookup::unlookup(caller.clone());
324 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());425 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
325426
326 let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;427 add_registrars::<T>(r)?;
327428
328 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();429 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();
329 Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;430 Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;
330 let registrars = Registrars::<T>::get();431 let registrars = Registrars::<T>::get();
331 ensure!(registrars[r as usize].as_ref().unwrap().account == caller, "id not set.");432 ensure!(
433 registrars[r as usize].as_ref().unwrap().account == caller,
434 "id not set."
435 );
332 let new_account = T::Lookup::unlookup(account("new", 0, SEED));436 let new_account = T::Lookup::unlookup(account("new", 0, SEED));
437
333 }: _(RawOrigin::Signed(caller), r, new_account)438 #[extrinsic_call]
334 verify {439 _(RawOrigin::Signed(caller), r, new_account);
440
335 let registrars = Registrars::<T>::get();441 let registrars = Registrars::<T>::get();
336 ensure!(registrars[r as usize].as_ref().unwrap().account == account("new", 0, SEED), "id not changed.");442 ensure!(
443 registrars[r as usize].as_ref().unwrap().account == account("new", 0, SEED),
444 "id not changed."
445 );
446
447 Ok(())
337 }448 }
338449
339 set_fields {450 #[benchmark]
451 fn set_fields(r: Linear<2, MAX_REGISTRARS>) -> Result<(), BenchmarkError> {
452 let r = r - 1;
340 let caller: T::AccountId = whitelisted_caller();453 let caller: T::AccountId = whitelisted_caller();
341 let caller_lookup = T::Lookup::unlookup(caller.clone());454 let caller_lookup = T::Lookup::unlookup(caller.clone());
342 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());455 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
343456
344 let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;457 add_registrars::<T>(r)?;
345458
346 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();459 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();
347 Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;460 Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;
348 let fields = IdentityFields(461 let fields = IdentityFields(
349 IdentityField::Display | IdentityField::Legal | IdentityField::Web | IdentityField::Riot462 IdentityField::Display
463 | IdentityField::Legal
464 | IdentityField::Web
465 | IdentityField::Riot
350 | IdentityField::Email | IdentityField::PgpFingerprint | IdentityField::Image | IdentityField::Twitter466 | IdentityField::Email
467 | IdentityField::PgpFingerprint
468 | IdentityField::Image
469 | IdentityField::Twitter,
351 );470 );
352 let registrars = Registrars::<T>::get();471 let registrars = Registrars::<T>::get();
353 ensure!(registrars[r as usize].as_ref().unwrap().fields == Default::default(), "fields already set.");472 ensure!(
473 registrars[r as usize].as_ref().unwrap().fields == Default::default(),
474 "fields already set."
475 );
476
354 }: _(RawOrigin::Signed(caller), r, fields)477 #[extrinsic_call]
355 verify {478 _(RawOrigin::Signed(caller), r, fields);
479
356 let registrars = Registrars::<T>::get();480 let registrars = Registrars::<T>::get();
357 ensure!(registrars[r as usize].as_ref().unwrap().fields != Default::default(), "fields not set.");481 ensure!(
482 registrars[r as usize].as_ref().unwrap().fields != Default::default(),
483 "fields not set."
484 );
485
486 Ok(())
358 }487 }
359488
360 provide_judgement {489 #[benchmark]
490 fn provide_judgement(
491 r: Linear<2, MAX_REGISTRARS>,
492 x: Linear<0, MAX_ADDITIONAL_FIELDS>,
493 ) -> Result<(), BenchmarkError> {
494 let r = r - 1;
361 // The user495 // The user
362 let user: T::AccountId = account("user", r, SEED);496 let user: T::AccountId = account("user", r, SEED);
363 let user_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(user.clone()));497 let user_origin =
498 <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(user.clone()));
364 let user_lookup = <T::Lookup as StaticLookup>::unlookup(user.clone());499 let user_lookup = <T::Lookup as StaticLookup>::unlookup(user.clone());
365 let _ = T::Currency::make_free_balance_be(&user, BalanceOf::<T>::max_value());500 let _ = T::Currency::make_free_balance_be(&user, BalanceOf::<T>::max_value());
366501
367 let caller: T::AccountId = whitelisted_caller();502 let caller: T::AccountId = whitelisted_caller();
368 let caller_lookup = T::Lookup::unlookup(caller.clone());503 let caller_lookup = T::Lookup::unlookup(caller.clone());
369 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());504 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
370505
371 let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;506 add_registrars::<T>(r)?;
372 let x in 0 .. T::MaxAdditionalFields::get();
373507
374 let info = create_identity_info::<T>(x);508 let info = create_identity_info::<T>(x);
375 let info_hash = T::Hashing::hash_of(&info);509 let info_hash = T::Hashing::hash_of(&info);
378 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();512 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();
379 Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;513 Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;
380 Identity::<T>::request_judgement(user_origin, r, 10u32.into())?;514 Identity::<T>::request_judgement(user_origin, r, 10u32.into())?;
515
381 }: _(RawOrigin::Signed(caller), r, user_lookup, Judgement::Reasonable, info_hash)516 #[extrinsic_call]
517 _(
518 RawOrigin::Signed(caller),
519 r,
520 user_lookup,
521 Judgement::Reasonable,
522 info_hash,
382 verify {523 );
524
383 assert_last_event::<T>(Event::<T>::JudgementGiven { target: user, registrar_index: r }.into())525 assert_last_event::<T>(
526 Event::<T>::JudgementGiven {
527 target: user,
528 registrar_index: r,
529 }
530 .into(),
531 );
532
533 Ok(())
384 }534 }
385535
386 kill_identity {536 #[benchmark]
537 fn kill_identity(
387 let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;538 r: Linear<1, MAX_REGISTRARS>,
388 let s in 0 .. T::MaxSubAccounts::get();539 s: Linear<0, MAX_SUB_ACCOUNTS>,
389 let x in 0 .. T::MaxAdditionalFields::get();540 x: Linear<0, MAX_ADDITIONAL_FIELDS>,
541 ) -> Result<(), BenchmarkError> {
542 add_registrars::<T>(r)?;
390543
391 let target: T::AccountId = account("target", 0, SEED);544 let target: T::AccountId = account("target", 0, SEED);
392 let target_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(target.clone()).into();545 let target_origin: <T as frame_system::Config>::RuntimeOrigin =
546 RawOrigin::Signed(target.clone()).into();
393 let target_lookup = T::Lookup::unlookup(target.clone());547 let target_lookup = T::Lookup::unlookup(target.clone());
394 let _ = T::Currency::make_free_balance_be(&target, BalanceOf::<T>::max_value());548 let _ = T::Currency::make_free_balance_be(&target, BalanceOf::<T>::max_value());
395549
400 // User requests judgement from all the registrars, and they approve554 // User requests judgement from all the registrars, and they approve
401 for i in 0..r {555 for i in 0..r {
402 let registrar: T::AccountId = account("registrar", i, SEED);556 let registrar: T::AccountId = account("registrar", i, SEED);
403 let balance_to_use = balance_unit::<T>() * 10u32.into();557 let balance_to_use = balance_unit::<T>() * 10u32.into();
404 let _ = T::Currency::make_free_balance_be(&registrar, balance_to_use);558 let _ = T::Currency::make_free_balance_be(&registrar, balance_to_use);
405559
406 Identity::<T>::request_judgement(target_origin.clone(), i, 10u32.into())?;560 Identity::<T>::request_judgement(target_origin.clone(), i, 10u32.into())?;
414 }568 }
415 ensure!(IdentityOf::<T>::contains_key(&target), "Identity not set");569 ensure!(IdentityOf::<T>::contains_key(&target), "Identity not set");
416 let origin = T::ForceOrigin::try_successful_origin().unwrap();570 let origin = T::ForceOrigin::try_successful_origin().unwrap();
571
417 }: _<T::RuntimeOrigin>(origin, target_lookup)572 #[extrinsic_call]
418 verify {573 _(origin as T::RuntimeOrigin, target_lookup);
574
419 ensure!(!IdentityOf::<T>::contains_key(&target), "Identity not removed");575 ensure!(
576 !IdentityOf::<T>::contains_key(&target),
577 "Identity not removed"
578 );
579
580 Ok(())
420 }581 }
421582
422 force_insert_identities {583 #[benchmark]
584 fn force_insert_identities(
423 let x in 0 .. T::MaxAdditionalFields::get();585 x: Linear<0, MAX_ADDITIONAL_FIELDS>,
424 let n in 0..600;586 n: Linear<0, 600>,
587 ) -> Result<(), BenchmarkError> {
425 use frame_benchmarking::account;588 use frame_benchmarking::account;
426 let identities = (0..n).map(|i| (589 let identities = (0..n)
590 .map(|i| {
591 (
427 account("caller", i, SEED),592 account("caller", i, SEED),
428 Registration::<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields> {593 Registration::<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields> {
429 judgements: Default::default(),594 judgements: Default::default(),
430 deposit: Default::default(),595 deposit: Default::default(),
431 info: create_identity_info::<T>(x),596 info: create_identity_info::<T>(x),
432 },597 },
433 )).collect::<Vec<_>>();598 )
599 })
600 .collect::<Vec<_>>();
434 let origin = T::ForceOrigin::try_successful_origin().unwrap();601 let origin = T::ForceOrigin::try_successful_origin().unwrap();
435 }: _<T::RuntimeOrigin>(origin, identities)
436602
437 force_remove_identities {603 #[extrinsic_call]
438 let x in 0 .. T::MaxAdditionalFields::get();604 _(origin as T::RuntimeOrigin, identities);
605
439 let n in 0..600;606 Ok(())
607 }
608
609 #[benchmark]
610 fn force_remove_identities(
611 x: Linear<0, MAX_ADDITIONAL_FIELDS>,
612 n: Linear<0, 600>,
613 ) -> Result<(), BenchmarkError> {
440 use frame_benchmarking::account;614 use frame_benchmarking::account;
441 let origin = T::ForceOrigin::try_successful_origin().unwrap();615 let origin = T::ForceOrigin::try_successful_origin().unwrap();
442 let identities = (0..n).map(|i| (616 let identities = (0..n)
617 .map(|i| {
618 (
443 account("caller", i, SEED),619 account("caller", i, SEED),
444 Registration::<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields> {620 Registration::<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields> {
445 judgements: Default::default(),621 judgements: Default::default(),
446 deposit: Default::default(),622 deposit: Default::default(),
447 info: create_identity_info::<T>(x),623 info: create_identity_info::<T>(x),
448 },624 },
449 )).collect::<Vec<_>>();625 )
626 })
627 .collect::<Vec<_>>();
450 assert_ok!(628 assert_ok!(Identity::<T>::force_insert_identities(
451 Identity::<T>::force_insert_identities(origin.clone(), identities.clone()),629 origin.clone(),
630 identities.clone()
452 );631 ),);
453 let identities = identities.into_iter().map(|(acc, _)| acc).collect::<Vec<_>>();632 let identities = identities
454 }: _<T::RuntimeOrigin>(origin, identities)633 .into_iter()
634 .map(|(acc, _)| acc)
635 .collect::<Vec<_>>();
455636
456 force_set_subs {637 #[extrinsic_call]
457 let s in 0 .. T::MaxSubAccounts::get();638 _(origin as T::RuntimeOrigin, identities);
639
458 let n in 0..600;640 Ok(())
641 }
642
643 #[benchmark]
644 fn force_set_subs(
645 s: Linear<0, MAX_SUB_ACCOUNTS>,
646 n: Linear<0, 600>,
647 ) -> Result<(), BenchmarkError> {
459 use frame_benchmarking::account;648 use frame_benchmarking::account;
460 let identities = (0..n).map(|i| {649 let identities = (0..n)
650 .map(|i| {
461 let caller: T::AccountId = account("caller", i, SEED);651 let caller: T::AccountId = account("caller", i, SEED);
462 (
463 caller.clone(),
464 (652 (
465 BalanceOf::<T>::max_value(),653 caller.clone(),
654 (
655 BalanceOf::<T>::max_value(),
466 create_sub_accounts::<T>(&caller, s).unwrap().try_into().unwrap(),656 create_sub_accounts::<T>(&caller, s)
657 .unwrap()
658 .try_into()
659 .unwrap(),
467 ),660 ),
468 )661 )
469 }).collect::<Vec<_>>();662 })
663 .collect::<Vec<_>>();
470 let origin = T::ForceOrigin::try_successful_origin().unwrap();664 let origin = T::ForceOrigin::try_successful_origin().unwrap();
471 }: _<T::RuntimeOrigin>(origin, identities)
472665
473 add_sub {666 #[extrinsic_call]
474 let s in 0 .. T::MaxSubAccounts::get() - 1;667 _(origin as T::RuntimeOrigin, identities);
475668
669 Ok(())
670 }
671
672 #[benchmark]
673 fn add_sub(s: Linear<1, MAX_SUB_ACCOUNTS>) -> Result<(), BenchmarkError> {
674 let s = s - 1;
476 let caller: T::AccountId = whitelisted_caller();675 let caller: T::AccountId = whitelisted_caller();
477 let _ = add_sub_accounts::<T>(&caller, s)?;676 let _ = add_sub_accounts::<T>(&caller, s)?;
478 let sub = account("new_sub", 0, SEED);677 let sub = account("new_sub", 0, SEED);
479 let data = Data::Raw(vec![0; 32].try_into().unwrap());678 let data = Data::Raw(vec![0; 32].try_into().unwrap());
480 ensure!(SubsOf::<T>::get(&caller).1.len() as u32 == s, "Subs not set.");679 ensure!(
680 SubsOf::<T>::get(&caller).1.len() as u32 == s,
681 "Subs not set."
682 );
683
481 }: _(RawOrigin::Signed(caller.clone()), T::Lookup::unlookup(sub), data)684 #[extrinsic_call]
685 _(
686 RawOrigin::Signed(caller.clone()),
687 T::Lookup::unlookup(sub),
688 data,
482 verify {689 );
690
483 ensure!(SubsOf::<T>::get(&caller).1.len() as u32 == s + 1, "Subs not added.");691 ensure!(
692 SubsOf::<T>::get(&caller).1.len() as u32 == s + 1,
693 "Subs not added."
694 );
695
696 Ok(())
484 }697 }
485698
486 rename_sub {699 #[benchmark]
487 let s in 1 .. T::MaxSubAccounts::get();700 fn rename_sub(s: Linear<1, MAX_SUB_ACCOUNTS>) -> Result<(), BenchmarkError> {
488
489 let caller: T::AccountId = whitelisted_caller();701 let caller: T::AccountId = whitelisted_caller();
490 let (sub, _) = add_sub_accounts::<T>(&caller, s)?.remove(0);702 let (sub, _) = add_sub_accounts::<T>(&caller, s)?.remove(0);
491 let data = Data::Raw(vec![1; 32].try_into().unwrap());703 let data = Data::Raw(vec![1; 32].try_into().unwrap());
492 ensure!(SuperOf::<T>::get(&sub).unwrap().1 != data, "data already set");704 ensure!(
705 SuperOf::<T>::get(&sub).unwrap().1 != data,
706 "data already set"
707 );
708
493 }: _(RawOrigin::Signed(caller), T::Lookup::unlookup(sub.clone()), data.clone())709 #[extrinsic_call]
494 verify {710 _(
711 RawOrigin::Signed(caller),
712 T::Lookup::unlookup(sub.clone()),
713 data.clone(),
714 );
715
495 ensure!(SuperOf::<T>::get(&sub).unwrap().1 == data, "data not set");716 ensure!(SuperOf::<T>::get(&sub).unwrap().1 == data, "data not set");
717
718 Ok(())
496 }719 }
497720
498 remove_sub {721 #[benchmark]
499 let s in 1 .. T::MaxSubAccounts::get();722 fn remove_sub(s: Linear<1, MAX_SUB_ACCOUNTS>) -> Result<(), BenchmarkError> {
500
501 let caller: T::AccountId = whitelisted_caller();723 let caller: T::AccountId = whitelisted_caller();
502 let (sub, _) = add_sub_accounts::<T>(&caller, s)?.remove(0);724 let (sub, _) = add_sub_accounts::<T>(&caller, s)?.remove(0);
503 ensure!(SuperOf::<T>::contains_key(&sub), "Sub doesn't exists");725 ensure!(SuperOf::<T>::contains_key(&sub), "Sub doesn't exists");
726
504 }: _(RawOrigin::Signed(caller), T::Lookup::unlookup(sub.clone()))727 #[extrinsic_call]
505 verify {728 _(RawOrigin::Signed(caller), T::Lookup::unlookup(sub.clone()));
729
506 ensure!(!SuperOf::<T>::contains_key(&sub), "Sub not removed");730 ensure!(!SuperOf::<T>::contains_key(&sub), "Sub not removed");
731
732 Ok(())
507 }733 }
508734
509 quit_sub {735 #[benchmark]
736 fn quit_sub(s: Linear<1, MAX_SUB_ACCOUNTS>) -> Result<(), BenchmarkError> {
510 let s in 0 .. T::MaxSubAccounts::get() - 1;737 let s = s - 1;
511
512 let caller: T::AccountId = whitelisted_caller();738 let caller: T::AccountId = whitelisted_caller();
513 let sup = account("super", 0, SEED);739 let sup = account("super", 0, SEED);
514 let _ = add_sub_accounts::<T>(&sup, s)?;740 let _ = add_sub_accounts::<T>(&sup, s)?;
515 let sup_origin = RawOrigin::Signed(sup).into();741 let sup_origin = RawOrigin::Signed(sup).into();
516 Identity::<T>::add_sub(sup_origin, T::Lookup::unlookup(caller.clone()), Data::Raw(vec![0; 32].try_into().unwrap()))?;742 Identity::<T>::add_sub(
743 sup_origin,
744 T::Lookup::unlookup(caller.clone()),
745 Data::Raw(vec![0; 32].try_into().unwrap()),
746 )?;
517 ensure!(SuperOf::<T>::contains_key(&caller), "Sub doesn't exists");747 ensure!(SuperOf::<T>::contains_key(&caller), "Sub doesn't exists");
748
518 }: _(RawOrigin::Signed(caller.clone()))749 #[extrinsic_call]
519 verify {750 _(RawOrigin::Signed(caller.clone()));
751
520 ensure!(!SuperOf::<T>::contains_key(&caller), "Sub not removed");752 ensure!(!SuperOf::<T>::contains_key(&caller), "Sub not removed");
753
754 Ok(())
521 }755 }
522756
523 impl_benchmark_test_suite!(Identity, crate::tests::new_test_ext(), crate::tests::Test);757 impl_benchmark_test_suite!(Identity, crate::tests::new_test_ext(), crate::tests::Test);
modifiedpallets/inflation/src/benchmarking.rsdiffbeforeafterboth
1616
17#![cfg(feature = "runtime-benchmarks")]17#![cfg(feature = "runtime-benchmarks")]
1818
19use frame_benchmarking::benchmarks;19use frame_benchmarking::v2::*;
20use frame_support::{pallet_prelude::*, traits::Hooks};20use frame_support::traits::Hooks;
21use sp_std::vec;
2122
22use super::*;23use super::*;
23use crate::Pallet as Inflation;24use crate::Pallet as Inflation;
2425
26#[benchmarks]
25benchmarks! {27mod benchmarks {
2628 use super::*;
29
30 #[benchmark]
27 on_initialize {31 fn on_initialize() -> Result<(), BenchmarkError> {
28 let block1: BlockNumberFor<T> = 1u32.into();32 let block1: BlockNumberFor<T> = 1u32.into();
29 let block2: BlockNumberFor<T> = 2u32.into();33 let block2: BlockNumberFor<T> = 2u32.into();
30 <Inflation<T> as Hooks>::on_initialize(block1); // Create Treasury account34 <Inflation<T> as Hooks<_>>::on_initialize(block1); // Create Treasury account
35
36 #[block]
37 {
31 }: { <Inflation<T> as Hooks>::on_initialize(block2); } // Benchmark deposit_into_existing path38 <Inflation<T> as Hooks<_>>::on_initialize(block2);
3239 // Benchmark deposit_into_existing path
40 }
41
42 Ok(())
43 }
33}44}
3445
modifiedpallets/maintenance/src/benchmarking.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17use frame_benchmarking::benchmarks;17use frame_benchmarking::v2::*;
18use frame_support::{ensure, pallet_prelude::Weight, traits::StorePreimage};18use frame_support::ensure;
19use frame_system::RawOrigin;19use frame_system::RawOrigin;
20use parity_scale_codec::Encode;20use sp_std::vec;
2121
22use super::*;22use super::*;
23use crate::{Config, Pallet as Maintenance};23use crate::{Config, Pallet as Maintenance};
2424
25#[benchmarks]
25benchmarks! {26mod benchmarks {
27 use super::*;
28
29 #[benchmark]
26 enable {30 fn enable() -> Result<(), BenchmarkError> {
31 #[extrinsic_call]
27 }: _(RawOrigin::Root)32 _(RawOrigin::Root);
28 verify {33
29 ensure!(<Enabled<T>>::get(), "didn't enable the MM");34 ensure!(<Enabled<T>>::get(), "didn't enable the MM");
30 }35
3136 Ok(())
37 }
38
39 #[benchmark]
32 disable {40 fn disable() -> Result<(), BenchmarkError> {
33 Maintenance::<T>::enable(RawOrigin::Root.into())?;41 Maintenance::<T>::enable(RawOrigin::Root.into())?;
42
43 #[extrinsic_call]
34 }: _(RawOrigin::Root)44 _(RawOrigin::Root);
35 verify {45
36 ensure!(!<Enabled<T>>::get(), "didn't disable the MM");46 ensure!(!<Enabled<T>>::get(), "didn't disable the MM");
37 }47
38
39 #[pov_mode = MaxEncodedLen {
40 // PoV size is deducted from weight_bound
41 Preimage::PreimageFor: Measured
42 }]
43 execute_preimage {
44 let call = <T as Config>::RuntimeCall::from(frame_system::Call::<T>::remark { remark: 1u32.encode() });48 Ok(())
45 let hash = T::Preimages::note(call.encode().into())?;49 }
46 }: _(RawOrigin::Root, hash, Weight::from_parts(100000000000, 100000000000))
47 verify {
48 }
49}50}
5051
modifiedpallets/maintenance/src/lib.rsdiffbeforeafterboth
32 traits::{EnsureOrigin, QueryPreimage, StorePreimage},32 traits::{EnsureOrigin, QueryPreimage, StorePreimage},
33 };33 };
34 use frame_system::pallet_prelude::*;34 use frame_system::pallet_prelude::*;
35 use sp_core::H256;
36 use sp_runtime::traits::Dispatchable;35 use sp_runtime::traits::Dispatchable;
3736
38 use crate::weights::WeightInfo;37 use crate::weights::WeightInfo;
104 Ok(())103 Ok(())
105 }104 }
106
107 /// Execute a runtime call stored as a preimage.
108 ///
109 /// `weight_bound` is the maximum weight that the caller is willing
110 /// to allow the extrinsic to be executed with.
111 #[pallet::call_index(2)]
112 #[pallet::weight(<T as Config>::WeightInfo::execute_preimage() + *weight_bound)]
113 pub fn execute_preimage(
114 origin: OriginFor<T>,
115 hash: H256,
116 weight_bound: Weight,
117 ) -> DispatchResultWithPostInfo {
118 use parity_scale_codec::Decode;
119
120 T::PreimageOrigin::ensure_origin(origin.clone())?;
121
122 let data = T::Preimages::fetch(&hash, None)?;
123 weight_bound.set_proof_size(
124 weight_bound
125 .proof_size()
126 .checked_sub(
127 data.len()
128 .try_into()
129 .map_err(|_| DispatchError::Corruption)?,
130 )
131 .ok_or(DispatchError::Exhausted)?,
132 );
133
134 let call = <T as Config>::RuntimeCall::decode(&mut &data[..])
135 .map_err(|_| DispatchError::Corruption)?;
136
137 ensure!(
138 call.get_dispatch_info().weight.all_lte(weight_bound),
139 DispatchError::Exhausted
140 );
141
142 match call.dispatch(origin) {
143 Ok(_) => Ok(Pays::No.into()),
144 Err(error_and_info) => Err(DispatchErrorWithPostInfo {
145 post_info: Pays::No.into(),
146 error: error_and_info.error,
147 }),
148 }
149 }
150 }105 }
151}106}
152107
modifiedpallets/maintenance/src/weights.rsdiffbeforeafterboth
35pub trait WeightInfo {35pub trait WeightInfo {
36 fn enable() -> Weight;36 fn enable() -> Weight;
37 fn disable() -> Weight;37 fn disable() -> Weight;
38 fn execute_preimage() -> Weight;
39}38}
4039
41/// Weights for pallet_maintenance using the Substrate node and recommended hardware.40/// Weights for pallet_maintenance using the Substrate node and recommended hardware.
61 Weight::from_parts(3_111_000, 0)60 Weight::from_parts(3_111_000, 0)
62 .saturating_add(T::DbWeight::get().writes(1_u64))61 .saturating_add(T::DbWeight::get().writes(1_u64))
63 }62 }
64 /// Storage: Preimage StatusFor (r:1 w:0)
65 /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
66 /// Storage: Preimage PreimageFor (r:1 w:0)
67 /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: Measured)
68 fn execute_preimage() -> Weight {
69 // Proof Size summary in bytes:
70 // Measured: `209`
71 // Estimated: `3674`
72 // Minimum execution time: 7_359_000 picoseconds.
73 Weight::from_parts(7_613_000, 3674)
74 .saturating_add(T::DbWeight::get().reads(2_u64))
75 }
76}63}
7764
78// For backwards compatibility and tests65// For backwards compatibility and tests
97 Weight::from_parts(3_111_000, 0)84 Weight::from_parts(3_111_000, 0)
98 .saturating_add(RocksDbWeight::get().writes(1_u64))85 .saturating_add(RocksDbWeight::get().writes(1_u64))
99 }86 }
100 /// Storage: Preimage StatusFor (r:1 w:0)
101 /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
102 /// Storage: Preimage PreimageFor (r:1 w:0)
103 /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: Measured)
104 fn execute_preimage() -> Weight {
105 // Proof Size summary in bytes:
106 // Measured: `209`
107 // Estimated: `3674`
108 // Minimum execution time: 7_359_000 picoseconds.
109 Weight::from_parts(7_613_000, 3674)
110 .saturating_add(RocksDbWeight::get().reads(2_u64))
111 }
112}87}
11388
11489
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17use frame_benchmarking::{account, benchmarks};17use frame_benchmarking::v2::{account, benchmarks, BenchmarkError};
18use pallet_common::{18use pallet_common::{
19 bench_init,19 bench_init,
20 benchmarking::{20 benchmarking::{create_collection_raw, property_key, property_value},
21 create_collection_raw, load_is_admin_and_property_permissions, property_key, property_value,
22 },
23 CommonCollectionOperations,21 CommonCollectionOperations,
24};22};
25use sp_std::prelude::*;23use sp_std::prelude::*;
64 )62 )
65}63}
6664
67benchmarks! {65#[benchmarks]
66mod benchmarks {
68 create_item {67 use super::*;
68
69 #[benchmark]
70 fn create_item() -> Result<(), BenchmarkError> {
69 bench_init!{71 bench_init! {
70 owner: sub; collection: collection(owner);72 owner: sub; collection: collection(owner);
71 sender: cross_from_sub(owner); to: cross_sub;73 sender: cross_from_sub(owner); to: cross_sub;
72 };74 };
73 }: {create_max_item(&collection, &sender, to.clone())?}
7475
75 create_multiple_items {76 #[block]
77 {
76 let b in 0..MAX_ITEMS_PER_BATCH;78 create_max_item(&collection, &sender, to)?;
79 }
80
81 Ok(())
82 }
83
84 #[benchmark]
85 fn create_multiple_items(b: Linear<0, MAX_ITEMS_PER_BATCH>) -> Result<(), BenchmarkError> {
77 bench_init!{86 bench_init! {
78 owner: sub; collection: collection(owner);87 owner: sub; collection: collection(owner);
79 sender: cross_from_sub(owner); to: cross_sub;88 sender: cross_from_sub(owner); to: cross_sub;
80 };89 };
81 let data = (0..b).map(|_| create_max_item_data::<T>(to.clone())).collect();90 let data = (0..b)
82 }: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}91 .map(|_| create_max_item_data::<T>(to.clone()))
92 .collect();
8393
84 create_multiple_items_ex {94 #[block]
95 {
85 let b in 0..MAX_ITEMS_PER_BATCH;96 <Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?;
97 }
98
99 Ok(())
100 }
101
102 #[benchmark]
103 fn create_multiple_items_ex(b: Linear<0, MAX_ITEMS_PER_BATCH>) -> Result<(), BenchmarkError> {
86 bench_init!{104 bench_init! {
87 owner: sub; collection: collection(owner);105 owner: sub; collection: collection(owner);
88 sender: cross_from_sub(owner);106 sender: cross_from_sub(owner);
89 };107 };
90 let data = (0..b).map(|i| {108 let data = (0..b)
109 .map(|i| {
91 bench_init!(to: cross_sub(i););110 bench_init!(to: cross_sub(i););
92 create_max_item_data::<T>(to)111 create_max_item_data::<T>(to)
93 }).collect();112 })
94 }: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}113 .collect();
95114
96 burn_item {115 #[block]
116 {
117 <Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?;
118 }
119
120 Ok(())
121 }
122
123 #[benchmark]
124 fn burn_item() -> Result<(), BenchmarkError> {
97 bench_init!{125 bench_init! {
98 owner: sub; collection: collection(owner);126 owner: sub; collection: collection(owner);
99 sender: cross_from_sub(owner); burner: cross_sub;127 sender: cross_from_sub(owner); burner: cross_sub;
100 };128 };
101 let item = create_max_item(&collection, &sender, burner.clone())?;129 let item = create_max_item(&collection, &sender, burner.clone())?;
102 }: {<Pallet<T>>::burn(&collection, &burner, item)?}
103130
104 burn_recursively_self_raw {131 #[block]
132 {
133 <Pallet<T>>::burn(&collection, &burner, item)?;
134 }
135
136 Ok(())
137 }
138
139 #[benchmark]
140 fn burn_recursively_self_raw() -> Result<(), BenchmarkError> {
105 bench_init!{141 bench_init! {
106 owner: sub; collection: collection(owner);142 owner: sub; collection: collection(owner);
107 sender: cross_from_sub(owner); burner: cross_sub;143 sender: cross_from_sub(owner); burner: cross_sub;
108 };144 };
109 let item = create_max_item(&collection, &sender, burner.clone())?;145 let item = create_max_item(&collection, &sender, burner.clone())?;
110 }: {<Pallet<T>>::burn_recursively(&collection, &burner, item, &Unlimited, &Unlimited)?}
111146
112 burn_recursively_breadth_plus_self_plus_self_per_each_raw {147 #[block]
148 {
113 let b in 0..200;149 <Pallet<T>>::burn_recursively(&collection, &burner, item, &Unlimited, &Unlimited)?;
150 }
151
152 Ok(())
153 }
154
155 #[benchmark]
156 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(
157 b: Linear<0, 200>,
114 bench_init!{158 ) -> Result<(), BenchmarkError> {
159 bench_init! {
115 owner: sub; collection: collection(owner);160 owner: sub; collection: collection(owner);
116 sender: cross_from_sub(owner); burner: cross_sub;161 sender: cross_from_sub(owner); burner: cross_sub;
117 };162 };
118 let item = create_max_item(&collection, &sender, burner.clone())?;163 let item = create_max_item(&collection, &sender, burner.clone())?;
119 for i in 0..b {164 for _ in 0..b {
120 create_max_item(&collection, &sender, T::CrossTokenAddressMapping::token_to_address(collection.id, item))?;165 create_max_item(
166 &collection,
167 &sender,
168 T::CrossTokenAddressMapping::token_to_address(collection.id, item),
169 )?;
121 }170 }
122 }: {<Pallet<T>>::burn_recursively(&collection, &burner, item, &Unlimited, &Unlimited)?}
123171
124 transfer_raw {172 #[block]
173 {
174 <Pallet<T>>::burn_recursively(&collection, &burner, item, &Unlimited, &Unlimited)?;
175 }
176
177 Ok(())
178 }
179
180 #[benchmark]
181 fn transfer_raw() -> Result<(), BenchmarkError> {
125 bench_init!{182 bench_init! {
126 owner: sub; collection: collection(owner);183 owner: sub; collection: collection(owner);
127 owner: cross_from_sub; sender: cross_sub; receiver: cross_sub;184 owner: cross_from_sub; sender: cross_sub; receiver: cross_sub;
128 };185 };
129 let item = create_max_item(&collection, &owner, sender.clone())?;186 let item = create_max_item(&collection, &owner, sender.clone())?;
130 }: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, &Unlimited)?}
131187
132 approve {188 #[block]
189 {
190 <Pallet<T>>::transfer(&collection, &sender, &receiver, item, &Unlimited)?;
191 }
192
193 Ok(())
194 }
195
196 #[benchmark]
197 fn approve() -> Result<(), BenchmarkError> {
133 bench_init!{198 bench_init! {
134 owner: sub; collection: collection(owner);199 owner: sub; collection: collection(owner);
135 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;200 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
136 };201 };
137 let item = create_max_item(&collection, &owner, sender.clone())?;202 let item = create_max_item(&collection, &owner, sender.clone())?;
138 }: {<Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?}
139203
140 approve_from {204 #[block]
205 {
206 <Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?;
207 }
208
209 Ok(())
210 }
211
212 #[benchmark]
213 fn approve_from() -> Result<(), BenchmarkError> {
141 bench_init!{214 bench_init! {
142 owner: sub; collection: collection(owner);215 owner: sub; collection: collection(owner);
143 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;216 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
144 };217 };
145 let owner_eth = T::CrossAccountId::from_eth(*sender.as_eth());218 let owner_eth = T::CrossAccountId::from_eth(*sender.as_eth());
146 let item = create_max_item(&collection, &owner, owner_eth.clone())?;219 let item = create_max_item(&collection, &owner, owner_eth.clone())?;
147 }: {<Pallet<T>>::set_allowance_from(&collection, &sender, &owner_eth, item, Some(&spender))?}
148220
149 check_allowed_raw {221 #[block]
222 {
223 <Pallet<T>>::set_allowance_from(
224 &collection,
225 &sender,
226 &owner_eth,
227 item,
228 Some(&spender),
229 )?;
230 }
231
232 Ok(())
233 }
234
235 #[benchmark]
236 fn check_allowed_raw() -> Result<(), BenchmarkError> {
150 bench_init!{237 bench_init! {
151 owner: sub; collection: collection(owner);238 owner: sub; collection: collection(owner);
152 owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;239 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
153 };240 };
154 let item = create_max_item(&collection, &owner, sender.clone())?;241 let item = create_max_item(&collection, &owner, sender.clone())?;
155 <Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?;242 <Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?;
156 }: {<Pallet<T>>::check_allowed(&collection, &spender, &sender, item, &Unlimited)?}
157243
158 burn_from {244 #[block]
245 {
246 <Pallet<T>>::check_allowed(&collection, &spender, &sender, item, &Unlimited)?;
247 }
248
249 Ok(())
250 }
251
252 #[benchmark]
253 fn burn_from() -> Result<(), BenchmarkError> {
159 bench_init!{254 bench_init! {
160 owner: sub; collection: collection(owner);255 owner: sub; collection: collection(owner);
161 owner: cross_from_sub; sender: cross_sub; burner: cross_sub;256 owner: cross_from_sub; sender: cross_sub; burner: cross_sub;
162 };257 };
163 let item = create_max_item(&collection, &owner, sender.clone())?;258 let item = create_max_item(&collection, &owner, sender.clone())?;
164 <Pallet<T>>::set_allowance(&collection, &sender, item, Some(&burner))?;259 <Pallet<T>>::set_allowance(&collection, &sender, item, Some(&burner))?;
165 }: {<Pallet<T>>::burn_from(&collection, &burner, &sender, item, &Unlimited)?}
166260
167 set_token_property_permissions {261 #[block]
262 {
168 let b in 0..MAX_PROPERTIES_PER_ITEM;263 <Pallet<T>>::burn_from(&collection, &burner, &sender, item, &Unlimited)?;
264 }
265
266 Ok(())
267 }
268
269 #[benchmark]
270 fn set_token_property_permissions(
271 b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
169 bench_init!{272 ) -> Result<(), BenchmarkError> {
273 bench_init! {
170 owner: sub; collection: collection(owner);274 owner: sub; collection: collection(owner);
171 owner: cross_from_sub;275 owner: cross_from_sub;
172 };276 };
173 let perms = (0..b).map(|k| PropertyKeyPermission {277 let perms = (0..b)
278 .map(|k| PropertyKeyPermission {
174 key: property_key(k as usize),279 key: property_key(k as usize),
175 permission: PropertyPermission {280 permission: PropertyPermission {
176 mutable: false,281 mutable: false,
177 collection_admin: false,282 collection_admin: false,
178 token_owner: false,283 token_owner: false,
179 },284 },
180 }).collect::<Vec<_>>();285 })
181 }: {<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?}286 .collect::<Vec<_>>();
182287
183 set_token_properties {288 #[block]
289 {
184 let b in 0..MAX_PROPERTIES_PER_ITEM;290 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
291 }
292
293 Ok(())
294 }
295
296 #[benchmark]
297 fn set_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
185 bench_init!{298 bench_init! {
186 owner: sub; collection: collection(owner);299 owner: sub; collection: collection(owner);
187 owner: cross_from_sub;300 owner: cross_from_sub;
188 };301 };
189 let perms = (0..b).map(|k| PropertyKeyPermission {302 let perms = (0..b)
303 .map(|k| PropertyKeyPermission {
190 key: property_key(k as usize),304 key: property_key(k as usize),
191 permission: PropertyPermission {305 permission: PropertyPermission {
192 mutable: false,306 mutable: false,
193 collection_admin: true,307 collection_admin: true,
194 token_owner: true,308 token_owner: true,
195 },309 },
196 }).collect::<Vec<_>>();310 })
311 .collect::<Vec<_>>();
197 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;312 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
198 let props = (0..b).map(|k| Property {313 let props = (0..b)
314 .map(|k| Property {
199 key: property_key(k as usize),315 key: property_key(k as usize),
200 value: property_value(),316 value: property_value(),
201 }).collect::<Vec<_>>();317 })
318 .collect::<Vec<_>>();
202 let item = create_max_item(&collection, &owner, owner.clone())?;319 let item = create_max_item(&collection, &owner, owner.clone())?;
203 }: {<Pallet<T>>::set_token_properties(&collection, &owner, item, props.into_iter(), &Unlimited)?}
204320
205 init_token_properties {321 #[block]
322 {
206 let b in 0..MAX_PROPERTIES_PER_ITEM;323 <Pallet<T>>::set_token_properties(
207 bench_init!{324 &collection,
208 owner: sub; collection: collection(owner);325 &owner,
326 item,
327 props.into_iter(),
209 owner: cross_from_sub;328 &Unlimited,
329 )?;
210 };330 }
211331
212 let perms = (0..b).map(|k| PropertyKeyPermission {332 Ok(())
213 key: property_key(k as usize),
214 permission: PropertyPermission {
215 mutable: false,
216 collection_admin: true,
217 token_owner: true,
218 },
219 }).collect::<Vec<_>>();
220 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;333 }
221 let props = (0..b).map(|k| Property {
222 key: property_key(k as usize),
223 value: property_value(),
224 }).collect::<Vec<_>>();
225 let item = create_max_item(&collection, &owner, owner.clone())?;
226334
227 let (is_collection_admin, property_permissions) = load_is_admin_and_property_permissions(&collection, &owner);335 // TODO:
336 #[benchmark]
337 fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
228 }: {338 // bench_init! {
229 let mut property_writer = pallet_common::collection_info_loaded_property_writer(339 // owner: sub; collection: collection(owner);
230 &collection,340 // owner: cross_from_sub;
231 is_collection_admin,341 // };
232 property_permissions,
233 );
234342
235 property_writer.write_token_properties(343 // let perms = (0..b)
344 // .map(|k| PropertyKeyPermission {
236 true,345 // key: property_key(k as usize),
346 // permission: PropertyPermission {
347 // mutable: false,
348 // collection_admin: true,
237 item,349 // token_owner: true,
350 // },
351 // })
352 // .collect::<Vec<_>>();
353 // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
354 #[block]
355 {}
356 // let props = (0..b)
357 // .map(|k| Property {
358 // key: property_key(k as usize),
359 // value: property_value(),
360 // })
361 // .collect::<Vec<_>>();
362 // let item = create_max_item(&collection, &owner, owner.clone())?;
363
238 props.into_iter(),364 // let (is_collection_admin, property_permissions) =
365 // load_is_admin_and_property_permissions(&collection, &owner);
366 // #[block]
367 // {
368 // let mut property_writer =
369 // pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
370
371 // property_writer.write_token_properties(
372 // item,
373 // props.into_iter(),
239 crate::erc::ERC721TokenEvent::TokenChanged {374 // crate::erc::ERC721TokenEvent::TokenChanged {
240 token_id: item.into(),375 // token_id: item.into(),
241 }376 // }
242 .to_log(T::ContractAddress::get()),377 // .to_log(T::ContractAddress::get()),
243 )?378 // )?;
379 // }
380
381 Ok(())
244 }382 }
245383
246 delete_token_properties {384 #[benchmark]
385 fn delete_token_properties(
247 let b in 0..MAX_PROPERTIES_PER_ITEM;386 b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
248 bench_init!{387 ) -> Result<(), BenchmarkError> {
388 bench_init! {
249 owner: sub; collection: collection(owner);389 owner: sub; collection: collection(owner);
250 owner: cross_from_sub;390 owner: cross_from_sub;
251 };391 };
252 let perms = (0..b).map(|k| PropertyKeyPermission {392 let perms = (0..b)
393 .map(|k| PropertyKeyPermission {
253 key: property_key(k as usize),394 key: property_key(k as usize),
254 permission: PropertyPermission {395 permission: PropertyPermission {
255 mutable: true,396 mutable: true,
256 collection_admin: true,397 collection_admin: true,
257 token_owner: true,398 token_owner: true,
258 },399 },
259 }).collect::<Vec<_>>();400 })
401 .collect::<Vec<_>>();
260 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;402 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
261 let props = (0..b).map(|k| Property {403 let props = (0..b)
404 .map(|k| Property {
262 key: property_key(k as usize),405 key: property_key(k as usize),
263 value: property_value(),406 value: property_value(),
264 }).collect::<Vec<_>>();407 })
408 .collect::<Vec<_>>();
265 let item = create_max_item(&collection, &owner, owner.clone())?;409 let item = create_max_item(&collection, &owner, owner.clone())?;
266 <Pallet<T>>::set_token_properties(&collection, &owner, item, props.into_iter(), &Unlimited)?;410 <Pallet<T>>::set_token_properties(
411 &collection,
412 &owner,
413 item,
414 props.into_iter(),
415 &Unlimited,
416 )?;
267 let to_delete = (0..b).map(|k| property_key(k as usize)).collect::<Vec<_>>();417 let to_delete = (0..b).map(|k| property_key(k as usize)).collect::<Vec<_>>();
268 }: {<Pallet<T>>::delete_token_properties(&collection, &owner, item, to_delete.into_iter(), &Unlimited)?}
269418
270 token_owner {419 #[block]
420 {
421 <Pallet<T>>::delete_token_properties(
422 &collection,
423 &owner,
424 item,
425 to_delete.into_iter(),
426 &Unlimited,
427 )?;
428 }
429
430 Ok(())
431 }
432
433 #[benchmark]
434 fn token_owner() -> Result<(), BenchmarkError> {
271 bench_init!{435 bench_init! {
272 owner: sub; collection: collection(owner);436 owner: sub; collection: collection(owner);
273 owner: cross_from_sub;437 owner: cross_from_sub;
274 };438 };
275 let item = create_max_item(&collection, &owner, owner.clone())?;439 let item = create_max_item(&collection, &owner, owner.clone())?;
276 }: {collection.token_owner(item).unwrap()}
277440
278 set_allowance_for_all {441 #[block]
442 {
443 collection.token_owner(item).unwrap();
444 }
445
446 Ok(())
447 }
448
449 #[benchmark]
450 fn set_allowance_for_all() -> Result<(), BenchmarkError> {
279 bench_init!{451 bench_init! {
280 owner: sub; collection: collection(owner); owner: cross_from_sub;452 owner: sub; collection: collection(owner); owner: cross_from_sub;
281 operator: cross_sub;453 operator: cross_sub;
282 };454 };
283 }: {<Pallet<T>>::set_allowance_for_all(&collection, &owner, &operator, true)?}
284455
285 allowance_for_all {456 #[block]
457 {
458 <Pallet<T>>::set_allowance_for_all(&collection, &owner, &operator, true)?;
459 }
460
461 Ok(())
462 }
463
464 #[benchmark]
465 fn allowance_for_all() -> Result<(), BenchmarkError> {
286 bench_init!{466 bench_init! {
287 owner: sub; collection: collection(owner); owner: cross_from_sub;467 owner: sub; collection: collection(owner); owner: cross_from_sub;
288 operator: cross_sub;468 operator: cross_sub;
289 };469 };
290 }: {<Pallet<T>>::allowance_for_all(&collection, &owner, &operator)}
291470
292 repair_item {471 #[block]
472 {
473 <Pallet<T>>::allowance_for_all(&collection, &owner, &operator);
474 }
475
476 Ok(())
477 }
478
479 #[benchmark]
480 fn repair_item() -> Result<(), BenchmarkError> {
293 bench_init!{481 bench_init! {
294 owner: sub; collection: collection(owner);482 owner: sub; collection: collection(owner);
295 owner: cross_from_sub;483 owner: cross_from_sub;
296 };484 };
297 let item = create_max_item(&collection, &owner, owner.clone())?;485 let item = create_max_item(&collection, &owner, owner.clone())?;
486
298 }: {<Pallet<T>>::repair_item(&collection, item)?}487 #[block]
488 {
489 <Pallet<T>>::repair_item(&collection, item)?;
490 }
491
492 Ok(())
493 }
299}494}
300495
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
1616
17use core::{convert::TryInto, iter::IntoIterator};17use core::{convert::TryInto, iter::IntoIterator};
1818
19use frame_benchmarking::{account, benchmarks};19use frame_benchmarking::v2::*;
20use pallet_common::{20use pallet_common::{
21 bench_init,21 bench_init,
22 benchmarking::{22 benchmarking::{
23 create_collection_raw, load_is_admin_and_property_permissions, property_key, property_value,23 create_collection_raw, /*load_is_admin_and_property_permissions,*/ property_key,
24 property_value,
24 },25 },
25};26};
26use sp_std::prelude::*;27use sp_std::prelude::*;
68 )69 )
69}70}
7071
71benchmarks! {72#[benchmarks]
73mod benchmarks {
72 create_item {74 use super::*;
75
76 #[benchmark]
77 fn create_item() -> Result<(), BenchmarkError> {
73 bench_init!{78 bench_init! {
74 owner: sub; collection: collection(owner);79 owner: sub; collection: collection(owner);
75 sender: cross_from_sub(owner); to: cross_sub;80 sender: cross_from_sub(owner); to: cross_sub;
76 };81 };
77 }: {create_max_item(&collection, &sender, [(to.clone(), 200)])?}
7882
79 create_multiple_items {83 #[block]
84 {
80 let b in 0..MAX_ITEMS_PER_BATCH;85 create_max_item(&collection, &sender, [(to, 200)])?;
86 }
87
88 Ok(())
89 }
90
91 #[benchmark]
92 fn create_multiple_items(b: Linear<0, MAX_ITEMS_PER_BATCH>) -> Result<(), BenchmarkError> {
81 bench_init!{93 bench_init! {
82 owner: sub; collection: collection(owner);94 owner: sub; collection: collection(owner);
83 sender: cross_from_sub(owner); to: cross_sub;95 sender: cross_from_sub(owner); to: cross_sub;
84 };96 };
85 let data = (0..b).map(|_| create_max_item_data::<T>([(to.clone(), 200)])).collect();97 let data = (0..b)
86 }: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}98 .map(|_| create_max_item_data::<T>([(to.clone(), 200)]))
99 .collect();
87100
88 create_multiple_items_ex_multiple_items {101 #[block]
102 {
89 let b in 0..MAX_ITEMS_PER_BATCH;103 <Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?;
104 }
105
106 Ok(())
107 }
108 #[benchmark]
109 fn create_multiple_items_ex_multiple_items(
110 b: Linear<0, MAX_ITEMS_PER_BATCH>,
90 bench_init!{111 ) -> Result<(), BenchmarkError> {
112 bench_init! {
91 owner: sub; collection: collection(owner);113 owner: sub; collection: collection(owner);
92 sender: cross_from_sub(owner);114 sender: cross_from_sub(owner);
93 };115 };
94 let data = (0..b).map(|t| {116 let data = (0..b)
117 .map(|t| {
95 bench_init!(to: cross_sub(t););118 bench_init!(to: cross_sub(t););
96 create_max_item_data::<T>([(to, 200)])119 create_max_item_data::<T>([(to, 200)])
97 }).collect();120 })
98 }: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}121 .collect();
99122
100 create_multiple_items_ex_multiple_owners {123 #[block]
124 {
101 let b in 0..MAX_ITEMS_PER_BATCH;125 <Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?;
126 }
127
128 Ok(())
129 }
130
131 #[benchmark]
132 fn create_multiple_items_ex_multiple_owners(
133 b: Linear<0, MAX_ITEMS_PER_BATCH>,
102 bench_init!{134 ) -> Result<(), BenchmarkError> {
135 bench_init! {
103 owner: sub; collection: collection(owner);136 owner: sub; collection: collection(owner);
104 sender: cross_from_sub(owner);137 sender: cross_from_sub(owner);
105 };138 };
106 let data = vec![create_max_item_data::<T>((0..b).map(|u| {139 let data = vec![create_max_item_data::<T>((0..b).map(|u| {
107 bench_init!(to: cross_sub(u););140 bench_init!(to: cross_sub(u););
108 (to, 200)141 (to, 200)
109 }))];142 }))];
110 }: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}
111143
144 #[block]
145 {
146 <Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?;
147 }
148
149 Ok(())
150 }
151
112 // Other user left, token data is kept152 // Other user left, token data is kept
113 burn_item_partial {153 #[benchmark]
154 fn burn_item_partial() -> Result<(), BenchmarkError> {
114 bench_init!{155 bench_init! {
115 owner: sub; collection: collection(owner);156 owner: sub; collection: collection(owner);
116 sender: cross_from_sub(owner); burner: cross_sub; another_owner: cross_sub;157 sender: cross_from_sub(owner); burner: cross_sub; another_owner: cross_sub;
117 };158 };
118 let item = create_max_item(&collection, &sender, [(burner.clone(), 200), (another_owner, 200)])?;159 let item = create_max_item(
160 &collection,
161 &sender,
162 [(burner.clone(), 200), (another_owner, 200)],
163 )?;
164
119 }: {<Pallet<T>>::burn(&collection, &burner, item, 200)?}165 #[block]
166 {
167 <Pallet<T>>::burn(&collection, &burner, item, 200)?;
168 }
169
170 Ok(())
171 }
172
120 // No users remaining, token is destroyed173 // No users remaining, token is destroyed
121 burn_item_fully {174 #[benchmark]
175 fn burn_item_fully() -> Result<(), BenchmarkError> {
122 bench_init!{176 bench_init! {
123 owner: sub; collection: collection(owner);177 owner: sub; collection: collection(owner);
124 sender: cross_from_sub(owner); burner: cross_sub; another_owner: cross_sub;178 sender: cross_from_sub(owner); burner: cross_sub;
125 };179 };
126 let item = create_max_item(&collection, &sender, [(burner.clone(), 200)])?;180 let item = create_max_item(&collection, &sender, [(burner.clone(), 200)])?;
127 }: {<Pallet<T>>::burn(&collection, &burner, item, 200)?}
128181
129 transfer_normal {182 #[block]
183 {
184 <Pallet<T>>::burn(&collection, &burner, item, 200)?;
185 }
186
187 Ok(())
188 }
189
190 #[benchmark]
191 fn transfer_normal() -> Result<(), BenchmarkError> {
130 bench_init!{192 bench_init! {
131 owner: sub; collection: collection(owner);193 owner: sub; collection: collection(owner);
132 sender: cross_from_sub(owner); receiver: cross_sub;194 sender: cross_from_sub(owner); receiver: cross_sub;
133 };195 };
134 let item = create_max_item(&collection, &sender, [(sender.clone(), 200), (receiver.clone(), 200)])?;196 let item = create_max_item(
197 &collection,
198 &sender,
199 [(sender.clone(), 200), (receiver.clone(), 200)],
200 )?;
201
135 }: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, 100, &Unlimited)?}202 #[block]
203 {
204 <Pallet<T>>::transfer(&collection, &sender, &receiver, item, 100, &Unlimited)?;
205 }
206
207 Ok(())
208 }
209
136 // Target account is created210 // Target account is created
137 transfer_creating {211 #[benchmark]
212 fn transfer_creating() -> Result<(), BenchmarkError> {
138 bench_init!{213 bench_init! {
139 owner: sub; collection: collection(owner);214 owner: sub; collection: collection(owner);
140 sender: cross_from_sub(owner); receiver: cross_sub;215 sender: cross_from_sub(owner); receiver: cross_sub;
141 };216 };
142 let item = create_max_item(&collection, &sender, [(sender.clone(), 200)])?;217 let item = create_max_item(&collection, &sender, [(sender.clone(), 200)])?;
218
143 }: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, 100, &Unlimited)?}219 #[block]
220 {
221 <Pallet<T>>::transfer(&collection, &sender, &receiver, item, 100, &Unlimited)?;
222 }
223
224 Ok(())
225 }
226
144 // Source account is destroyed227 // Source account is destroyed
145 transfer_removing {228 #[benchmark]
229 fn transfer_removing() -> Result<(), BenchmarkError> {
146 bench_init!{230 bench_init! {
147 owner: sub; collection: collection(owner);231 owner: sub; collection: collection(owner);
148 sender: cross_from_sub(owner); receiver: cross_sub;232 sender: cross_from_sub(owner); receiver: cross_sub;
149 };233 };
150 let item = create_max_item(&collection, &sender, [(sender.clone(), 200), (receiver.clone(), 200)])?;234 let item = create_max_item(
235 &collection,
236 &sender,
237 [(sender.clone(), 200), (receiver.clone(), 200)],
238 )?;
239
151 }: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, 200, &Unlimited)?}240 #[block]
241 {
242 <Pallet<T>>::transfer(&collection, &sender, &receiver, item, 200, &Unlimited)?;
243 }
244
245 Ok(())
246 }
247
152 // Source account destroyed, target created248 // Source account destroyed, target created
153 transfer_creating_removing {249 #[benchmark]
250 fn transfer_creating_removing() -> Result<(), BenchmarkError> {
154 bench_init!{251 bench_init! {
155 owner: sub; collection: collection(owner);252 owner: sub; collection: collection(owner);
156 sender: cross_from_sub(owner); receiver: cross_sub;253 sender: cross_from_sub(owner); receiver: cross_sub;
157 };254 };
158 let item = create_max_item(&collection, &sender, [(sender.clone(), 200)])?;255 let item = create_max_item(&collection, &sender, [(sender.clone(), 200)])?;
159 }: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, 200, &Unlimited)?}
160256
161 approve {257 #[block]
258 {
259 <Pallet<T>>::transfer(&collection, &sender, &receiver, item, 200, &Unlimited)?;
260 }
261
262 Ok(())
263 }
264
265 #[benchmark]
266 fn approve() -> Result<(), BenchmarkError> {
162 bench_init!{267 bench_init! {
163 owner: sub; collection: collection(owner);268 owner: sub; collection: collection(owner);
164 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;269 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
165 };270 };
166 let item = create_max_item(&collection, &owner, [(sender.clone(), 200)])?;271 let item = create_max_item(&collection, &owner, [(sender.clone(), 200)])?;
167 }: {<Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 100)?}
168272
169 approve_from {273 #[block]
274 {
275 <Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 100)?;
276 }
277
278 Ok(())
279 }
280
281 #[benchmark]
282 fn approve_from() -> Result<(), BenchmarkError> {
170 bench_init!{283 bench_init! {
171 owner: sub; collection: collection(owner);284 owner: sub; collection: collection(owner);
172 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;285 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
173 };286 };
174 let owner_eth = T::CrossAccountId::from_eth(*sender.as_eth());287 let owner_eth = T::CrossAccountId::from_eth(*sender.as_eth());
175 let item = create_max_item(&collection, &owner, [(owner_eth.clone(), 200)])?;288 let item = create_max_item(&collection, &owner, [(owner_eth.clone(), 200)])?;
176 }: {<Pallet<T>>::set_allowance_from(&collection, &sender, &owner_eth, &spender, item, 100)?}
177289
178 transfer_from_normal {290 #[block]
291 {
292 <Pallet<T>>::set_allowance_from(&collection, &sender, &owner_eth, &spender, item, 100)?;
293 }
294
295 Ok(())
296 }
297
298 #[benchmark]
299 fn transfer_from_normal() -> Result<(), BenchmarkError> {
179 bench_init!{300 bench_init! {
180 owner: sub; collection: collection(owner);301 owner: sub; collection: collection(owner);
181 owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;302 owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;
182 };303 };
183 let item = create_max_item(&collection, &owner, [(sender.clone(), 200), (receiver.clone(), 200)])?;304 let item = create_max_item(
305 &collection,
306 &owner,
307 [(sender.clone(), 200), (receiver.clone(), 200)],
308 )?;
184 <Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 100)?;309 <Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 100)?;
310
185 }: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, item, 100, &Unlimited)?}311 #[block]
312 {
313 <Pallet<T>>::transfer_from(
314 &collection,
315 &spender,
316 &sender,
317 &receiver,
318 item,
319 100,
320 &Unlimited,
321 )?;
322 }
323
324 Ok(())
325 }
326
186 // Target account is created327 // Target account is created
187 transfer_from_creating {328 #[benchmark]
329 fn transfer_from_creating() -> Result<(), BenchmarkError> {
188 bench_init!{330 bench_init! {
189 owner: sub; collection: collection(owner);331 owner: sub; collection: collection(owner);
190 owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;332 owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;
191 };333 };
192 let item = create_max_item(&collection, &owner, [(sender.clone(), 200)])?;334 let item = create_max_item(&collection, &owner, [(sender.clone(), 200)])?;
193 <Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 100)?;335 <Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 100)?;
336
194 }: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, item, 100, &Unlimited)?}337 #[block]
338 {
339 <Pallet<T>>::transfer_from(
340 &collection,
341 &spender,
342 &sender,
343 &receiver,
344 item,
345 100,
346 &Unlimited,
347 )?;
348 }
349
350 Ok(())
351 }
352
195 // Source account is destroyed353 // Source account is destroyed
196 transfer_from_removing {354 #[benchmark]
355 fn transfer_from_removing() -> Result<(), BenchmarkError> {
197 bench_init!{356 bench_init! {
198 owner: sub; collection: collection(owner);357 owner: sub; collection: collection(owner);
199 owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;358 owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;
200 };359 };
201 let item = create_max_item(&collection, &owner, [(sender.clone(), 200), (receiver.clone(), 200)])?;360 let item = create_max_item(
361 &collection,
362 &owner,
363 [(sender.clone(), 200), (receiver.clone(), 200)],
364 )?;
202 <Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 200)?;365 <Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 200)?;
366
203 }: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, item, 200, &Unlimited)?}367 #[block]
368 {
369 <Pallet<T>>::transfer_from(
370 &collection,
371 &spender,
372 &sender,
373 &receiver,
374 item,
375 200,
376 &Unlimited,
377 )?;
378 }
379
380 Ok(())
381 }
382
204 // Source account destroyed, target created383 // Source account destroyed, target created
205 transfer_from_creating_removing {384 #[benchmark]
385 fn transfer_from_creating_removing() -> Result<(), BenchmarkError> {
206 bench_init!{386 bench_init! {
207 owner: sub; collection: collection(owner);387 owner: sub; collection: collection(owner);
208 owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;388 owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;
209 };389 };
210 let item = create_max_item(&collection, &owner, [(sender.clone(), 200)])?;390 let item = create_max_item(&collection, &owner, [(sender.clone(), 200)])?;
211 <Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 200)?;391 <Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 200)?;
212 }: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, item, 200, &Unlimited)?}
213392
393 #[block]
394 {
395 <Pallet<T>>::transfer_from(
396 &collection,
397 &spender,
398 &sender,
399 &receiver,
400 item,
401 200,
402 &Unlimited,
403 )?;
404 }
405
406 Ok(())
407 }
408
214 // Both source account and token is destroyed409 // Both source account and token is destroyed
215 burn_from {410 #[benchmark]
411 fn burn_from() -> Result<(), BenchmarkError> {
216 bench_init!{412 bench_init! {
217 owner: sub; collection: collection(owner);413 owner: sub; collection: collection(owner);
218 owner: cross_from_sub; sender: cross_sub; burner: cross_sub;414 owner: cross_from_sub; sender: cross_sub; burner: cross_sub;
219 };415 };
220 let item = create_max_item(&collection, &owner, [(sender.clone(), 200)])?;416 let item = create_max_item(&collection, &owner, [(sender.clone(), 200)])?;
221 <Pallet<T>>::set_allowance(&collection, &sender, &burner, item, 200)?;417 <Pallet<T>>::set_allowance(&collection, &sender, &burner, item, 200)?;
222 }: {<Pallet<T>>::burn_from(&collection, &burner, &sender, item, 200, &Unlimited)?}
223418
224 set_token_property_permissions {419 #[block]
420 {
225 let b in 0..MAX_PROPERTIES_PER_ITEM;421 <Pallet<T>>::burn_from(&collection, &burner, &sender, item, 200, &Unlimited)?;
422 }
423
424 Ok(())
425 }
426
427 #[benchmark]
428 fn set_token_property_permissions(
429 b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
226 bench_init!{430 ) -> Result<(), BenchmarkError> {
431 bench_init! {
227 owner: sub; collection: collection(owner);432 owner: sub; collection: collection(owner);
228 owner: cross_from_sub;433 owner: cross_from_sub;
229 };434 };
230 let perms = (0..b).map(|k| PropertyKeyPermission {435 let perms = (0..b)
436 .map(|k| PropertyKeyPermission {
231 key: property_key(k as usize),437 key: property_key(k as usize),
232 permission: PropertyPermission {438 permission: PropertyPermission {
233 mutable: false,439 mutable: false,
234 collection_admin: false,440 collection_admin: false,
235 token_owner: false,441 token_owner: false,
236 },442 },
237 }).collect::<Vec<_>>();443 })
238 }: {<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?}444 .collect::<Vec<_>>();
239445
240 set_token_properties {446 #[block]
447 {
241 let b in 0..MAX_PROPERTIES_PER_ITEM;448 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
449 }
450
451 Ok(())
452 }
453
454 #[benchmark]
455 fn set_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
242 bench_init!{456 bench_init! {
243 owner: sub; collection: collection(owner);457 owner: sub; collection: collection(owner);
244 owner: cross_from_sub;458 owner: cross_from_sub;
245 };459 };
246 let perms = (0..b).map(|k| PropertyKeyPermission {460 let perms = (0..b)
461 .map(|k| PropertyKeyPermission {
247 key: property_key(k as usize),462 key: property_key(k as usize),
248 permission: PropertyPermission {463 permission: PropertyPermission {
249 mutable: false,464 mutable: false,
250 collection_admin: true,465 collection_admin: true,
251 token_owner: true,466 token_owner: true,
252 },467 },
253 }).collect::<Vec<_>>();468 })
469 .collect::<Vec<_>>();
254 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;470 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
255 let props = (0..b).map(|k| Property {471 let props = (0..b)
472 .map(|k| Property {
256 key: property_key(k as usize),473 key: property_key(k as usize),
257 value: property_value(),474 value: property_value(),
258 }).collect::<Vec<_>>();475 })
476 .collect::<Vec<_>>();
259 let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;477 let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
260 }: {<Pallet<T>>::set_token_properties(&collection, &owner, item, props.into_iter(), &Unlimited)?}
261478
262 init_token_properties {479 #[block]
480 {
263 let b in 0..MAX_PROPERTIES_PER_ITEM;481 <Pallet<T>>::set_token_properties(
264 bench_init!{482 &collection,
265 owner: sub; collection: collection(owner);483 &owner,
484 item,
485 props.into_iter(),
266 owner: cross_from_sub;486 &Unlimited,
487 )?;
267 };488 }
268489
269 let perms = (0..b).map(|k| PropertyKeyPermission {490 Ok(())
270 key: property_key(k as usize),
271 permission: PropertyPermission {
272 mutable: false,
273 collection_admin: true,
274 token_owner: true,
275 },
276 }).collect::<Vec<_>>();
277 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;491 }
278 let props = (0..b).map(|k| Property {
279 key: property_key(k as usize),
280 value: property_value(),
281 }).collect::<Vec<_>>();
282 let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
283492
284 let (is_collection_admin, property_permissions) = load_is_admin_and_property_permissions(&collection, &owner);493 // TODO:
494 #[benchmark]
495 fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
285 }: {496 // bench_init! {
286 let mut property_writer = pallet_common::collection_info_loaded_property_writer(497 // owner: sub; collection: collection(owner);
287 &collection,498 // owner: cross_from_sub;
288 is_collection_admin,499 // };
289 property_permissions,
290 );
291500
292 property_writer.write_token_properties(501 // let perms = (0..b)
502 // .map(|k| PropertyKeyPermission {
503 // key: property_key(k as usize),
504 // permission: PropertyPermission {
505 // mutable: false,
506 // collection_admin: true,
507 // token_owner: true,
508 // },
509 // })
510 // .collect::<Vec<_>>();
511 // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
512
513 #[block]
514 {}
515 // let props = (0..b).map(|k| Property {
516 // key: property_key(k as usize),
517 // value: property_value(),
518 // }).collect::<Vec<_>>();
519 // let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
520
521 // let (is_collection_admin, property_permissions) = load_is_admin_and_property_permissions(&collection, &owner)
522 // let mut property_writer = pallet_common::collection_info_loaded_property_writer(
523 // &collection,
524 // is_collection_admin,
525 // property_permissions,
526 // );
527
528 // #[block]
529 // {
530 // property_writer.write_token_properties(
293 true,531 // true,
294 item,532 // item,
295 props.into_iter(),533 // props.into_iter(),
296 crate::erc::ERC721TokenEvent::TokenChanged {534 // crate::erc::ERC721TokenEvent::TokenChanged {
297 token_id: item.into(),535 // token_id: item.into(),
298 }536 // }
299 .to_log(T::ContractAddress::get()),537 // .to_log(T::ContractAddress::get()),
300 )?538 // )?;
539 // }
540
541 Ok(())
301 }542 }
302543
303 delete_token_properties {544 #[benchmark]
545 fn delete_token_properties(
304 let b in 0..MAX_PROPERTIES_PER_ITEM;546 b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
305 bench_init!{547 ) -> Result<(), BenchmarkError> {
548 bench_init! {
306 owner: sub; collection: collection(owner);549 owner: sub; collection: collection(owner);
307 owner: cross_from_sub;550 owner: cross_from_sub;
308 };551 };
309 let perms = (0..b).map(|k| PropertyKeyPermission {552 let perms = (0..b)
553 .map(|k| PropertyKeyPermission {
310 key: property_key(k as usize),554 key: property_key(k as usize),
311 permission: PropertyPermission {555 permission: PropertyPermission {
312 mutable: true,556 mutable: true,
313 collection_admin: true,557 collection_admin: true,
314 token_owner: true,558 token_owner: true,
315 },559 },
316 }).collect::<Vec<_>>();560 })
561 .collect::<Vec<_>>();
317 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;562 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
318 let props = (0..b).map(|k| Property {563 let props = (0..b)
564 .map(|k| Property {
319 key: property_key(k as usize),565 key: property_key(k as usize),
320 value: property_value(),566 value: property_value(),
321 }).collect::<Vec<_>>();567 })
568 .collect::<Vec<_>>();
322 let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;569 let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
323 <Pallet<T>>::set_token_properties(&collection, &owner, item, props.into_iter(), &Unlimited)?;570 <Pallet<T>>::set_token_properties(
571 &collection,
572 &owner,
573 item,
574 props.into_iter(),
575 &Unlimited,
576 )?;
324 let to_delete = (0..b).map(|k| property_key(k as usize)).collect::<Vec<_>>();577 let to_delete = (0..b).map(|k| property_key(k as usize)).collect::<Vec<_>>();
325 }: {<Pallet<T>>::delete_token_properties(&collection, &owner, item, to_delete.into_iter(), &Unlimited)?}
326578
327 repartition_item {579 #[block]
580 {
581 <Pallet<T>>::delete_token_properties(
582 &collection,
583 &owner,
584 item,
585 to_delete.into_iter(),
586 &Unlimited,
587 )?;
588 }
589
590 Ok(())
591 }
592
593 #[benchmark]
594 fn repartition_item() -> Result<(), BenchmarkError> {
328 bench_init!{595 bench_init! {
329 owner: sub; collection: collection(owner);596 owner: sub; collection: collection(owner);
330 sender: cross_from_sub(owner); owner: cross_sub;597 sender: cross_from_sub(owner); owner: cross_sub;
331 };598 };
332 let item = create_max_item(&collection, &sender, [(owner.clone(), 100)])?;599 let item = create_max_item(&collection, &sender, [(owner.clone(), 100)])?;
333 }: {<Pallet<T>>::repartition(&collection, &owner, item, 200)?}
334600
335 token_owner {601 #[block]
602 {
603 <Pallet<T>>::repartition(&collection, &owner, item, 200)?;
604 }
605
606 Ok(())
607 }
608
609 #[benchmark]
610 fn token_owner() -> Result<(), BenchmarkError> {
336 bench_init!{611 bench_init! {
337 owner: sub; collection: collection(owner);612 owner: sub; collection: collection(owner);
338 sender: cross_from_sub(owner); owner: cross_sub;613 sender: cross_from_sub(owner); owner: cross_sub;
339 };614 };
340 let item = create_max_item(&collection, &sender, [(owner, 100)])?;615 let item = create_max_item(&collection, &sender, [(owner, 100)])?;
341 }: {<Pallet<T>>::token_owner(collection.id, item).unwrap()}
342616
343 set_allowance_for_all {617 #[block]
618 {
619 <Pallet<T>>::token_owner(collection.id, item).unwrap();
620 }
621
622 Ok(())
623 }
624
625 #[benchmark]
626 fn set_allowance_for_all() -> Result<(), BenchmarkError> {
344 bench_init!{627 bench_init! {
345 owner: sub; collection: collection(owner); owner: cross_from_sub;628 owner: sub; collection: collection(owner); owner: cross_from_sub;
346 operator: cross_sub;629 operator: cross_sub;
347 };630 };
348 }: {<Pallet<T>>::set_allowance_for_all(&collection, &owner, &operator, true)?}
349631
350 allowance_for_all {632 #[block]
633 {
634 <Pallet<T>>::set_allowance_for_all(&collection, &owner, &operator, true)?;
635 }
636
637 Ok(())
638 }
639
640 #[benchmark]
641 fn allowance_for_all() -> Result<(), BenchmarkError> {
351 bench_init!{642 bench_init! {
352 owner: sub; collection: collection(owner); owner: cross_from_sub;643 owner: sub; collection: collection(owner); owner: cross_from_sub;
353 operator: cross_sub;644 operator: cross_sub;
354 };645 };
355 }: {<Pallet<T>>::allowance_for_all(&collection, &owner, &operator)}
356646
357 repair_item {647 #[block]
648 {
649 <Pallet<T>>::allowance_for_all(&collection, &owner, &operator);
650 }
651
652 Ok(())
653 }
654
655 #[benchmark]
656 fn repair_item() -> Result<(), BenchmarkError> {
358 bench_init!{657 bench_init! {
359 owner: sub; collection: collection(owner);658 owner: sub; collection: collection(owner);
360 owner: cross_from_sub;659 owner: cross_from_sub;
361 };660 };
362 let item = create_max_item(&collection, &owner, [(owner.clone(), 100)])?;661 let item = create_max_item(&collection, &owner, [(owner.clone(), 100)])?;
662
363 }: {<Pallet<T>>::repair_item(&collection, item)?}663 #[block]
664 {
665 <Pallet<T>>::repair_item(&collection, item)?;
666 }
667
668 Ok(())
669 }
364}670}
365671
modifiedpallets/structure/src/benchmarking.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17use frame_benchmarking::{account, benchmarks};17use frame_benchmarking::v2::{account, benchmarks, BenchmarkError};
18use frame_support::traits::{fungible::Balanced, tokens::Precision, Get};18use frame_support::traits::{fungible::Balanced, tokens::Precision, Get};
19use pallet_common::Config as CommonConfig;19use pallet_common::Config as CommonConfig;
20use pallet_evm::account::CrossAccountId;20use pallet_evm::account::CrossAccountId;
21use sp_std::vec;
21use up_data_structs::{22use up_data_structs::{
22 budget::Unlimited, CollectionMode, CreateCollectionData, CreateItemData, CreateNftData,23 budget::Unlimited, CollectionMode, CreateCollectionData, CreateItemData, CreateNftData,
23};24};
2627
27const SEED: u32 = 1;28const SEED: u32 = 1;
2829
30#[benchmarks]
29benchmarks! {31mod benchmarks {
32 use super::*;
33
34 #[benchmark]
30 find_parent {35 fn find_parent() -> Result<(), BenchmarkError> {
31 let caller: T::AccountId = account("caller", 0, SEED);36 let caller: T::AccountId = account("caller", 0, SEED);
32 let caller_cross = T::CrossAccountId::from_sub(caller.clone());37 let caller_cross = T::CrossAccountId::from_sub(caller.clone());
3338
34 let _ = <T as CommonConfig>::Currency::deposit(&caller, T::CollectionCreationPrice::get(), Precision::Exact).unwrap();39 let _ = <T as CommonConfig>::Currency::deposit(
40 &caller,
41 T::CollectionCreationPrice::get(),
42 Precision::Exact,
43 )
44 .unwrap();
35 T::CollectionDispatch::create(45 T::CollectionDispatch::create(
57 caller_cross.clone(),
58 caller_cross,
59 CreateItemData::NFT(CreateNftData::default()),
60 &Unlimited,
61 )?;
62
63 #[block]
64 {
65 let parent = <Pallet<T>>::find_parent(CollectionId(1), TokenId(1))?;
66 assert!(matches!(parent, Parent::User(_)));
67 }
68
69 Ok(())
47 }: {70 }
48 let parent = <Pallet<T>>::find_parent(CollectionId(1), TokenId(1))?;
49 assert!(matches!(parent, Parent::User(_)))
50 }
51}71}
5272
modifiedpallets/unique/src/benchmarking.rsdiffbeforeafterboth
1616
17#![cfg(feature = "runtime-benchmarks")]17#![cfg(feature = "runtime-benchmarks")]
1818
19use frame_benchmarking::{account, benchmarks};19use frame_benchmarking::v2::{account, benchmarks, BenchmarkError};
20use frame_support::traits::{fungible::Balanced, tokens::Precision, Get};20use frame_support::traits::{fungible::Balanced, tokens::Precision, Get};
21use frame_system::RawOrigin;21use frame_system::RawOrigin;
22use pallet_common::{22use pallet_common::{
25 Config as CommonConfig,25 Config as CommonConfig,
26};26};
27use sp_runtime::DispatchError;27use sp_runtime::DispatchError;
28use sp_std::vec;
28use up_data_structs::{29use up_data_structs::{
29 CollectionId, CollectionLimits, CollectionMode, MAX_COLLECTION_DESCRIPTION_LENGTH,30 CollectionId, CollectionLimits, CollectionMode, MAX_COLLECTION_DESCRIPTION_LENGTH,
30 MAX_COLLECTION_NAME_LENGTH, MAX_TOKEN_PREFIX_LENGTH,31 MAX_COLLECTION_NAME_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
63 create_collection_helper::<T>(owner, CollectionMode::NFT)64 create_collection_helper::<T>(owner, CollectionMode::NFT)
64}65}
6566
67#[benchmarks]
66benchmarks! {68mod benchmarks {
69 use super::*;
70
71 #[benchmark]
67 create_collection {72 fn create_collection() -> Result<(), BenchmarkError> {
68 let col_name = create_u16_data::<{MAX_COLLECTION_NAME_LENGTH}>();73 let col_name = create_u16_data::<{ MAX_COLLECTION_NAME_LENGTH }>();
69 let col_desc = create_u16_data::<{MAX_COLLECTION_DESCRIPTION_LENGTH}>();74 let col_desc = create_u16_data::<{ MAX_COLLECTION_DESCRIPTION_LENGTH }>();
70 let token_prefix = create_data::<{MAX_TOKEN_PREFIX_LENGTH}>();75 let token_prefix = create_data::<{ MAX_TOKEN_PREFIX_LENGTH }>();
71 let mode: CollectionMode = CollectionMode::NFT;76 let mode: CollectionMode = CollectionMode::NFT;
72 let caller: T::AccountId = account("caller", 0, SEED);77 let caller: T::AccountId = account("caller", 0, SEED);
73 let _ = <T as CommonConfig>::Currency::deposit(&caller, T::CollectionCreationPrice::get(), Precision::Exact).unwrap();78 let _ = <T as CommonConfig>::Currency::deposit(
79 &caller,
80 T::CollectionCreationPrice::get(),
81 Precision::Exact,
82 )
83 .unwrap();
84
85 #[extrinsic_call]
74 }: _(RawOrigin::Signed(caller.clone()), col_name, col_desc, token_prefix, mode)86 _(
75 verify {87 RawOrigin::Signed(caller.clone()),
88 col_name,
89 col_desc,
90 token_prefix,
91 mode,
92 );
93
76 assert_eq!(<pallet_common::CollectionById<T>>::get(CollectionId(1)).unwrap().owner, caller);94 assert_eq!(
77 }95 <pallet_common::CollectionById<T>>::get(CollectionId(1))
7896 .unwrap()
97 .owner,
98 caller
99 );
100
101 Ok(())
102 }
103
104 #[benchmark]
79 destroy_collection {105 fn destroy_collection() -> Result<(), BenchmarkError> {
80 let caller: T::AccountId = account("caller", 0, SEED);106 let caller: T::AccountId = account("caller", 0, SEED);
81 let collection = create_nft_collection::<T>(caller.clone())?;107 let collection = create_nft_collection::<T>(caller.clone())?;
108
109 #[extrinsic_call]
82 }: _(RawOrigin::Signed(caller.clone()), collection)110 _(RawOrigin::Signed(caller), collection);
83111
112 Ok(())
113 }
114
115 #[benchmark]
84 add_to_allow_list {116 fn add_to_allow_list() -> Result<(), BenchmarkError> {
85 let caller: T::AccountId = account("caller", 0, SEED);117 let caller: T::AccountId = account("caller", 0, SEED);
86 let allowlist_account: T::AccountId = account("admin", 0, SEED);118 let allowlist_account: T::AccountId = account("admin", 0, SEED);
87 let collection = create_nft_collection::<T>(caller.clone())?;119 let collection = create_nft_collection::<T>(caller.clone())?;
120
121 #[extrinsic_call]
88 }: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(allowlist_account))122 _(
89123 RawOrigin::Signed(caller),
124 collection,
125 T::CrossAccountId::from_sub(allowlist_account),
126 );
127
128 Ok(())
129 }
130
131 #[benchmark]
90 remove_from_allow_list {132 fn remove_from_allow_list() -> Result<(), BenchmarkError> {
91 let caller: T::AccountId = account("caller", 0, SEED);133 let caller: T::AccountId = account("caller", 0, SEED);
92 let allowlist_account: T::AccountId = account("admin", 0, SEED);134 let allowlist_account: T::AccountId = account("admin", 0, SEED);
93 let collection = create_nft_collection::<T>(caller.clone())?;135 let collection = create_nft_collection::<T>(caller.clone())?;
94 <Pallet<T>>::add_to_allow_list(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(allowlist_account.clone()))?;136 <Pallet<T>>::add_to_allow_list(
137 RawOrigin::Signed(caller.clone()).into(),
138 collection,
139 T::CrossAccountId::from_sub(allowlist_account.clone()),
140 )?;
141
142 #[extrinsic_call]
143 _(
144 RawOrigin::Signed(caller),
145 collection,
146 T::CrossAccountId::from_sub(allowlist_account),
147 );
148
149 Ok(())
95 }: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(allowlist_account))150 }
96151
97 change_collection_owner {152 #[benchmark]
153 fn change_collection_owner() -> Result<(), BenchmarkError> {
98 let caller: T::AccountId = account("caller", 0, SEED);154 let caller: T::AccountId = account("caller", 0, SEED);
99 let collection = create_nft_collection::<T>(caller.clone())?;155 let collection = create_nft_collection::<T>(caller.clone())?;
100 let new_owner: T::AccountId = account("admin", 0, SEED);156 let new_owner: T::AccountId = account("admin", 0, SEED);
157
158 #[extrinsic_call]
101 }: _(RawOrigin::Signed(caller.clone()), collection, new_owner)159 _(RawOrigin::Signed(caller), collection, new_owner);
102160
161 Ok(())
162 }
163
164 #[benchmark]
103 add_collection_admin {165 fn add_collection_admin() -> Result<(), BenchmarkError> {
104 let caller: T::AccountId = account("caller", 0, SEED);166 let caller: T::AccountId = account("caller", 0, SEED);
105 let collection = create_nft_collection::<T>(caller.clone())?;167 let collection = create_nft_collection::<T>(caller.clone())?;
106 let new_admin: T::AccountId = account("admin", 0, SEED);168 let new_admin: T::AccountId = account("admin", 0, SEED);
169
170 #[extrinsic_call]
107 }: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(new_admin))171 _(
108172 RawOrigin::Signed(caller),
173 collection,
174 T::CrossAccountId::from_sub(new_admin),
175 );
176
177 Ok(())
178 }
179
180 #[benchmark]
109 remove_collection_admin {181 fn remove_collection_admin() -> Result<(), BenchmarkError> {
110 let caller: T::AccountId = account("caller", 0, SEED);182 let caller: T::AccountId = account("caller", 0, SEED);
111 let collection = create_nft_collection::<T>(caller.clone())?;183 let collection = create_nft_collection::<T>(caller.clone())?;
112 let new_admin: T::AccountId = account("admin", 0, SEED);184 let new_admin: T::AccountId = account("admin", 0, SEED);
113 <Pallet<T>>::add_collection_admin(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(new_admin.clone()))?;185 <Pallet<T>>::add_collection_admin(
186 RawOrigin::Signed(caller.clone()).into(),
187 collection,
188 T::CrossAccountId::from_sub(new_admin.clone()),
189 )?;
190
191 #[extrinsic_call]
192 _(
193 RawOrigin::Signed(caller),
194 collection,
195 T::CrossAccountId::from_sub(new_admin),
196 );
197
198 Ok(())
114 }: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(new_admin))199 }
115200
116 set_collection_sponsor {201 #[benchmark]
202 fn set_collection_sponsor() -> Result<(), BenchmarkError> {
117 let caller: T::AccountId = account("caller", 0, SEED);203 let caller: T::AccountId = account("caller", 0, SEED);
118 let collection = create_nft_collection::<T>(caller.clone())?;204 let collection = create_nft_collection::<T>(caller.clone())?;
205
206 #[extrinsic_call]
119 }: _(RawOrigin::Signed(caller.clone()), collection, caller.clone())207 _(RawOrigin::Signed(caller), collection, caller.clone());
120208
209 Ok(())
210 }
211
212 #[benchmark]
121 confirm_sponsorship {213 fn confirm_sponsorship() -> Result<(), BenchmarkError> {
122 let caller: T::AccountId = account("caller", 0, SEED);214 let caller: T::AccountId = account("caller", 0, SEED);
123 let collection = create_nft_collection::<T>(caller.clone())?;215 let collection = create_nft_collection::<T>(caller.clone())?;
124 <Pallet<T>>::set_collection_sponsor(RawOrigin::Signed(caller.clone()).into(), collection, caller.clone())?;216 <Pallet<T>>::set_collection_sponsor(
217 RawOrigin::Signed(caller.clone()).into(),
218 collection,
219 caller.clone(),
220 )?;
221
222 #[extrinsic_call]
223 _(RawOrigin::Signed(caller), collection);
224
225 Ok(())
125 }: _(RawOrigin::Signed(caller.clone()), collection)226 }
126227
228 #[benchmark]
127 remove_collection_sponsor {229 fn remove_collection_sponsor() -> Result<(), BenchmarkError> {
128 let caller: T::AccountId = account("caller", 0, SEED);230 let caller: T::AccountId = account("caller", 0, SEED);
129 let collection = create_nft_collection::<T>(caller.clone())?;231 let collection = create_nft_collection::<T>(caller.clone())?;
130 <Pallet<T>>::set_collection_sponsor(RawOrigin::Signed(caller.clone()).into(), collection, caller.clone())?;232 <Pallet<T>>::set_collection_sponsor(
233 RawOrigin::Signed(caller.clone()).into(),
234 collection,
235 caller.clone(),
236 )?;
131 <Pallet<T>>::confirm_sponsorship(RawOrigin::Signed(caller.clone()).into(), collection)?;237 <Pallet<T>>::confirm_sponsorship(RawOrigin::Signed(caller.clone()).into(), collection)?;
238
239 #[extrinsic_call]
240 _(RawOrigin::Signed(caller), collection);
241
242 Ok(())
132 }: _(RawOrigin::Signed(caller.clone()), collection)243 }
133244
134 set_transfers_enabled_flag {245 #[benchmark]
246 fn set_transfers_enabled_flag() -> Result<(), BenchmarkError> {
135 let caller: T::AccountId = account("caller", 0, SEED);247 let caller: T::AccountId = account("caller", 0, SEED);
136 let collection = create_nft_collection::<T>(caller.clone())?;248 let collection = create_nft_collection::<T>(caller.clone())?;
249
250 #[extrinsic_call]
137 }: _(RawOrigin::Signed(caller.clone()), collection, false)251 _(RawOrigin::Signed(caller), collection, false);
138252
139253 Ok(())
254 }
255
256 #[benchmark]
140 set_collection_limits {257 fn set_collection_limits() -> Result<(), BenchmarkError> {
141 let caller: T::AccountId = account("caller", 0, SEED);258 let caller: T::AccountId = account("caller", 0, SEED);
142 let collection = create_nft_collection::<T>(caller.clone())?;259 let collection = create_nft_collection::<T>(caller.clone())?;
143260
144 let cl = CollectionLimits {261 let cl = CollectionLimits {
145 account_token_ownership_limit: Some(0),262 account_token_ownership_limit: Some(0),
153 transfers_enabled: Some(true),270 transfers_enabled: Some(true),
154 };271 };
272
273 #[extrinsic_call]
274 set_collection_limits(RawOrigin::Signed(caller), collection, cl);
275
276 Ok(())
155 }: set_collection_limits(RawOrigin::Signed(caller.clone()), collection, cl)277 }
156278
157 force_repair_collection {279 #[benchmark]
280 fn force_repair_collection() -> Result<(), BenchmarkError> {
158 let caller: T::AccountId = account("caller", 0, SEED);281 let caller: T::AccountId = account("caller", 0, SEED);
159 let collection = create_nft_collection::<T>(caller)?;282 let collection = create_nft_collection::<T>(caller)?;
283
284 #[extrinsic_call]
160 }: _(RawOrigin::Root, collection)285 _(RawOrigin::Root, collection);
286
287 Ok(())
288 }
161}289}
162290
modifiedruntime/common/config/xcm/foreignassets.rsdiffbeforeafterboth
77 let here_id =77 let here_id =
78 ConvertAssetId::convert(&AssetId::NativeAssetId(NativeCurrency::Here)).unwrap();78 ConvertAssetId::convert(&AssetId::NativeAssetId(NativeCurrency::Here)).unwrap();
7979
80 if asset_id.clone() == parent_id {80 if *asset_id == parent_id {
81 return Some(MultiLocation::parent());81 return Some(MultiLocation::parent());
82 }82 }
8383
84 if asset_id.clone() == here_id {84 if *asset_id == here_id {
85 return Some(MultiLocation::new(85 return Some(MultiLocation::new(
86 1,86 1,
87 X1(Parachain(ParachainInfo::get().into())),87 X1(Parachain(ParachainInfo::get().into())),
88 ));88 ));
89 }89 }
9090
91 let fid =91 let fid = <AssetId as TryAsForeign<AssetId, ForeignAssetId>>::try_as_foreign(*asset_id)?;
92 <AssetId as TryAsForeign<AssetId, ForeignAssetId>>::try_as_foreign(asset_id.clone())?;
93 XcmForeignAssetIdMapping::<Runtime>::get_multi_location(fid)92 XcmForeignAssetIdMapping::<Runtime>::get_multi_location(fid)
94 }93 }
95}94}
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
569 fn dispatch_benchmark(569 fn dispatch_benchmark(
570 config: frame_benchmarking::BenchmarkConfig570 config: frame_benchmarking::BenchmarkConfig
571 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {571 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
572 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};572 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark};
573 use sp_storage::TrackedStorageKey;
573574
574 let allowlist: Vec<TrackedStorageKey> = vec![575 let allowlist: Vec<TrackedStorageKey> = vec![
575 // Total Issuance576 // Total Issuance
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
136 'sp-runtime/std',136 'sp-runtime/std',
137 'sp-session/std',137 'sp-session/std',
138 'sp-std/std',138 'sp-std/std',
139 'sp-storage/std',
139 'sp-transaction-pool/std',140 'sp-transaction-pool/std',
140 'sp-version/std',141 'sp-version/std',
141 'staging-xcm-builder/std',142 'staging-xcm-builder/std',
279sp-runtime = { workspace = true }280sp-runtime = { workspace = true }
280sp-session = { workspace = true }281sp-session = { workspace = true }
281sp-std = { workspace = true }282sp-std = { workspace = true }
283sp-storage = { workspace = true }
282sp-transaction-pool = { workspace = true }284sp-transaction-pool = { workspace = true }
283sp-version = { workspace = true }285sp-version = { workspace = true }
284staging-xcm = { workspace = true }286staging-xcm = { workspace = true }
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
271sp-runtime = { workspace = true }271sp-runtime = { workspace = true }
272sp-session = { workspace = true }272sp-session = { workspace = true }
273sp-std = { workspace = true }273sp-std = { workspace = true }
274sp-storage = { workspace = true }
274sp-transaction-pool = { workspace = true }275sp-transaction-pool = { workspace = true }
275sp-version = { workspace = true }276sp-version = { workspace = true }
276staging-xcm = { workspace = true }277staging-xcm = { workspace = true }
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
274sp-runtime = { workspace = true }274sp-runtime = { workspace = true }
275sp-session = { workspace = true }275sp-session = { workspace = true }
276sp-std = { workspace = true }276sp-std = { workspace = true }
277sp-storage = { workspace = true }
277sp-transaction-pool = { workspace = true }278sp-transaction-pool = { workspace = true }
278sp-version = { workspace = true }279sp-version = { workspace = true }
279staging-xcm = { workspace = true }280staging-xcm = { workspace = true }
modifiedtests/src/maintenance.seqtest.tsdiffbeforeafterboth
283 });283 });
284 });284 });
285
286 describe('Preimage Execution', () => {
287 const preimageHashes: string[] = [];
288
289 before(async function() {
290 await usingPlaygrounds(async (helper) => {
291 requirePalletsOrSkip(this, helper, [Pallets.Preimage, Pallets.Maintenance]);
292
293 // create a preimage to be operated with in the tests
294 const randomAccounts = await helper.arrange.createCrowd(10, 0n, superuser);
295 const randomIdentities = randomAccounts.map((acc, i) => [
296 acc.address, {
297 deposit: 0n,
298 judgements: [],
299 info: {
300 display: {
301 raw: `Random Account #${i}`,
302 },
303 },
304 },
305 ]);
306 const preimage = helper.constructApiCall('api.tx.identity.forceInsertIdentities', [randomIdentities]).method.toHex();
307 preimageHashes.push(await helper.preimage.notePreimage(bob, preimage, true));
308 });
309 });
310
311 itSub('Successfully executes call in a preimage', async ({helper}) => {
312 const result = await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [
313 preimageHashes[0], {refTime: 10000000000, proofSize: 10000},
314 ])).to.be.fulfilled;
315
316 // preimage is executed, and an appropriate event is present
317 const events = result.result.events.filter((x: any) => x.event.method === 'IdentitiesInserted' && x.event.section === 'identity');
318 expect(events.length).to.be.equal(1);
319
320 // the preimage goes back to being unrequested
321 expect(await helper.preimage.getPreimageInfo(preimageHashes[0])).to.have.property('unrequested');
322 });
323
324 itSub('Does not allow execution of a preimage that would fail', async ({helper}) => {
325 const [zeroAccount] = await helper.arrange.createAccounts([0n], superuser);
326
327 const preimage = helper.constructApiCall('api.tx.balances.forceTransfer', [
328 {Id: zeroAccount.address}, {Id: superuser.address}, 1000n,
329 ]).method.toHex();
330 const preimageHash = await helper.preimage.notePreimage(bob, preimage, true);
331 preimageHashes.push(preimageHash);
332
333 await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [
334 preimageHash, {refTime: 10000000000, proofSize: 10000},
335 ])).to.be.rejectedWith(/^Token: FundsUnavailable$/);
336 });
337
338 itSub('Does not allow preimage execution with non-root', async ({helper}) => {
339 await expect(helper.executeExtrinsic(bob, 'api.tx.maintenance.executePreimage', [
340 preimageHashes[0], {refTime: 10000000000, proofSize: 10000},
341 ])).to.be.rejectedWith(/^Misc: BadOrigin$/);
342 });
343
344 itSub('Does not allow execution of non-existent preimages', async ({helper}) => {
345 await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [
346 '0x1010101010101010101010101010101010101010101010101010101010101010', {refTime: 10000000000, proofSize: 10000},
347 ])).to.be.rejectedWith(/^Misc: Unavailable$/);
348 });
349
350 itSub('Does not allow preimage execution with less than minimum weights', async ({helper}) => {
351 await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [
352 preimageHashes[0], {refTime: 1000, proofSize: 100},
353 ])).to.be.rejectedWith(/^Misc: Exhausted$/);
354 });
355
356 after(async function() {
357 await usingPlaygrounds(async (helper) => {
358 if(helper.fetchMissingPalletNames([Pallets.Preimage, Pallets.Maintenance]).length != 0) return;
359
360 for(const hash of preimageHashes) {
361 await helper.preimage.unnotePreimage(bob, hash);
362 }
363 });
364 });
365 });
366285
367 describe('Integration Test: Maintenance mode & App Promo', () => {286 describe('Integration Test: Maintenance mode & App Promo', () => {
368 let superuser: IKeyringPair;287 let superuser: IKeyringPair;