difftreelog
fix benchmarks
in: master
6 files changed
node/cli/src/command.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// Original license18// This file is part of Substrate.1920// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.21// SPDX-License-Identifier: Apache-2.02223// Licensed under the Apache License, Version 2.0 (the "License");24// you may not use this file except in compliance with the License.25// You may obtain a copy of the License at26//27// http://www.apache.org/licenses/LICENSE-2.028//29// Unless required by applicable law or agreed to in writing, software30// distributed under the License is distributed on an "AS IS" BASIS,31// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.32// See the License for the specific language governing permissions and33// limitations under the License.3435use cumulus_primitives_core::ParaId;36use log::info;37use sc_cli::{38 ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,39 NetworkParams, Result, SharedParams, SubstrateCli,40};41use sc_service::config::{BasePath, PrometheusConfig};42use sp_runtime::traits::AccountIdConversion;43use up_common::types::opaque::RuntimeId;4445#[cfg(feature = "runtime-benchmarks")]46use crate::chain_spec::default_runtime;47#[cfg(feature = "runtime-benchmarks")]48use crate::service::DefaultRuntimeExecutor;49#[cfg(feature = "quartz-runtime")]50use crate::service::QuartzRuntimeExecutor;51#[cfg(feature = "unique-runtime")]52use crate::service::UniqueRuntimeExecutor;53use crate::{54 chain_spec::{self, RuntimeIdentification, ServiceId, ServiceIdentification},55 cli::{Cli, RelayChainCli, Subcommand},56 service::{new_partial, start_dev_node, start_node, OpalRuntimeExecutor},57};5859macro_rules! no_runtime_err {60 ($runtime_id:expr) => {61 format!(62 "No runtime valid runtime was found for chain {:#?}",63 $runtime_id64 )65 };66}6768fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {69 Ok(match id {70 "dev" => Box::new(chain_spec::development_config()),71 "" | "local" => Box::new(chain_spec::local_testnet_config()),72 path => {73 let path = std::path::PathBuf::from(path);74 #[allow(clippy::redundant_clone)]75 let chain_spec = Box::new(chain_spec::OpalChainSpec::from_json_file(path.clone())?)76 as Box<dyn sc_service::ChainSpec>;7778 match chain_spec.runtime_id() {79 #[cfg(feature = "unique-runtime")]80 RuntimeId::Unique => Box::new(chain_spec::UniqueChainSpec::from_json_file(path)?),8182 #[cfg(feature = "quartz-runtime")]83 RuntimeId::Quartz => Box::new(chain_spec::QuartzChainSpec::from_json_file(path)?),8485 RuntimeId::Opal => chain_spec,86 runtime_id => return Err(no_runtime_err!(runtime_id)),87 }88 }89 })90}9192impl SubstrateCli for Cli {93 // TODO use args94 fn impl_name() -> String {95 format!("{} Node", Self::node_name())96 }9798 fn impl_version() -> String {99 env!("SUBSTRATE_CLI_IMPL_VERSION").into()100 }101 // TODO use args102 fn description() -> String {103 format!(104 "{} Node\n\nThe command-line arguments provided first will be \105 passed to the parachain node, while the arguments provided after -- will be passed \106 to the relaychain node.\n\n\107 {} [parachain-args] -- [relaychain-args]",108 Self::node_name(),109 Self::executable_name()110 )111 }112113 fn author() -> String {114 env!("CARGO_PKG_AUTHORS").into()115 }116117 //TODO use args118 fn support_url() -> String {119 "support@unique.network".into()120 }121122 fn copyright_start_year() -> i32 {123 2019124 }125126 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {127 load_spec(id)128 }129}130131impl SubstrateCli for RelayChainCli {132 // TODO use args133 fn impl_name() -> String {134 format!("{} Node", Cli::node_name())135 }136137 fn impl_version() -> String {138 env!("SUBSTRATE_CLI_IMPL_VERSION").into()139 }140 // TODO use args141 fn description() -> String {142 format!(143 "{} Node\n\nThe command-line arguments provided first will be \144 passed to the parachain node, while the arguments provided after -- will be passed \145 to the relaychain node.\n\n\146 parachain-collator [parachain-args] -- [relaychain-args]",147 Cli::node_name()148 )149 }150151 fn author() -> String {152 env!("CARGO_PKG_AUTHORS").into()153 }154 // TODO use args155 fn support_url() -> String {156 "support@unique.network".into()157 }158159 fn copyright_start_year() -> i32 {160 2019161 }162163 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {164 polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)165 }166}167168macro_rules! async_run_with_runtime {169 (170 $runtime:path, $runtime_api:path, $executor:path,171 $runner:ident, $components:ident, $cli:ident, $cmd:ident, $config:ident,172 $( $code:tt )*173 ) => {174 $runner.async_run(|$config| {175 let $components = new_partial::<176 $runtime, $runtime_api, $executor, _177 >(178 &$config,179 crate::service::parachain_build_import_queue::<$runtime, _, _>,180 )?;181 let task_manager = $components.task_manager;182183 { $( $code )* }.map(|v| (v, task_manager))184 })185 };186}187188macro_rules! construct_async_run {189 (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{190 let runner = $cli.create_runner($cmd)?;191192 match runner.config().chain_spec.runtime_id() {193 #[cfg(feature = "unique-runtime")]194 RuntimeId::Unique => async_run_with_runtime!(195 unique_runtime::Runtime, unique_runtime::RuntimeApi, UniqueRuntimeExecutor,196 runner, $components, $cli, $cmd, $config, $( $code )*197 ),198199 #[cfg(feature = "quartz-runtime")]200 RuntimeId::Quartz => async_run_with_runtime!(201 quartz_runtime::Runtime, quartz_runtime::RuntimeApi, QuartzRuntimeExecutor,202 runner, $components, $cli, $cmd, $config, $( $code )*203 ),204205 RuntimeId::Opal => async_run_with_runtime!(206 opal_runtime::Runtime, opal_runtime::RuntimeApi, OpalRuntimeExecutor,207 runner, $components, $cli, $cmd, $config, $( $code )*208 ),209210 runtime_id => Err(no_runtime_err!(runtime_id).into())211 }212 }}213}214215macro_rules! sync_run_with_runtime {216 (217 $runtime:path, $runtime_api:path, $executor:path,218 $runner:ident, $components:ident, $cli:ident, $cmd:ident, $config:ident,219 $( $code:tt )*220 ) => {221 $runner.sync_run(|$config| {222 let $components = new_partial::<223 $runtime, $runtime_api, $executor, _224 >(225 &$config,226 crate::service::parachain_build_import_queue::<$runtime, _, _>,227 )?;228229 $( $code )*230 })231 };232}233234macro_rules! construct_sync_run {235 (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{236 let runner = $cli.create_runner($cmd)?;237238 match runner.config().chain_spec.runtime_id() {239 #[cfg(feature = "unique-runtime")]240 RuntimeId::Unique => sync_run_with_runtime!(241 unique_runtime::Runtime, unique_runtime::RuntimeApi, UniqueRuntimeExecutor,242 runner, $components, $cli, $cmd, $config, $( $code )*243 ),244245 #[cfg(feature = "quartz-runtime")]246 RuntimeId::Quartz => sync_run_with_runtime!(247 quartz_runtime::Runtime, quartz_runtime::RuntimeApi, QuartzRuntimeExecutor,248 runner, $components, $cli, $cmd, $config, $( $code )*249 ),250251 RuntimeId::Opal => sync_run_with_runtime!(252 opal_runtime::Runtime, opal_runtime::RuntimeApi, OpalRuntimeExecutor,253 runner, $components, $cli, $cmd, $config, $( $code )*254 ),255256 runtime_id => Err(no_runtime_err!(runtime_id).into())257 }258 }}259}260261macro_rules! start_node_using_chain_runtime {262 ($start_node_fn:ident($config:expr $(, $($args:expr),+)?) $($code:tt)*) => {263 match $config.chain_spec.runtime_id() {264 #[cfg(feature = "unique-runtime")]265 RuntimeId::Unique => $start_node_fn::<266 unique_runtime::Runtime,267 unique_runtime::RuntimeApi,268 UniqueRuntimeExecutor,269 >($config $(, $($args),+)?) $($code)*,270271 #[cfg(feature = "quartz-runtime")]272 RuntimeId::Quartz => $start_node_fn::<273 quartz_runtime::Runtime,274 quartz_runtime::RuntimeApi,275 QuartzRuntimeExecutor,276 >($config $(, $($args),+)?) $($code)*,277278 RuntimeId::Opal => $start_node_fn::<279 opal_runtime::Runtime,280 opal_runtime::RuntimeApi,281 OpalRuntimeExecutor,282 >($config $(, $($args),+)?) $($code)*,283284 runtime_id => Err(no_runtime_err!(runtime_id).into()),285 }286 };287}288289/// Parse command line arguments into service configuration.290pub fn run() -> Result<()> {291 let cli = Cli::from_args();292293 match &cli.subcommand {294 Some(Subcommand::Key(cmd)) => cmd.run(&cli),295 Some(Subcommand::BuildSpec(cmd)) => {296 let runner = cli.create_runner(cmd)?;297 runner.sync_run(|config| cmd.run(config.chain_spec, config.network))298 }299 Some(Subcommand::CheckBlock(cmd)) => {300 construct_async_run!(|components, cli, cmd, config| {301 Ok(cmd.run(components.client, components.import_queue))302 })303 }304 Some(Subcommand::ExportBlocks(cmd)) => {305 construct_async_run!(|components, cli, cmd, config| {306 Ok(cmd.run(components.client, config.database))307 })308 }309 Some(Subcommand::ExportState(cmd)) => {310 construct_async_run!(|components, cli, cmd, config| {311 Ok(cmd.run(components.client, config.chain_spec))312 })313 }314 Some(Subcommand::ImportBlocks(cmd)) => {315 construct_async_run!(|components, cli, cmd, config| {316 Ok(cmd.run(components.client, components.import_queue))317 })318 }319 Some(Subcommand::PurgeChain(cmd)) => {320 let runner = cli.create_runner(cmd)?;321322 runner.sync_run(|config| {323 let polkadot_cli = RelayChainCli::new(324 &config,325 [RelayChainCli::executable_name()]326 .iter()327 .chain(cli.relaychain_args.iter()),328 );329330 let polkadot_config = SubstrateCli::create_configuration(331 &polkadot_cli,332 &polkadot_cli,333 config.tokio_handle.clone(),334 )335 .map_err(|err| format!("Relay chain argument error: {err}"))?;336337 cmd.run(config, polkadot_config)338 })339 }340 Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| {341 Ok(cmd.run(components.client, components.backend, None))342 }),343 Some(Subcommand::ExportGenesisState(cmd)) => {344 construct_sync_run!(|components, cli, cmd, _config| {345 let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;346 cmd.run(&*spec, &*components.client)347 })348 }349 Some(Subcommand::ExportGenesisWasm(cmd)) => {350 construct_sync_run!(|_components, cli, cmd, _config| {351 let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;352 cmd.run(&*spec)353 })354 }355 #[cfg(feature = "runtime-benchmarks")]356 Some(Subcommand::Benchmark(cmd)) => {357 use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};358 use polkadot_cli::Block;359 use sp_io::SubstrateHostFunctions;360361 let runner = cli.create_runner(cmd)?;362 // Switch on the concrete benchmark sub-command-363 match cmd {364 BenchmarkCmd::Pallet(cmd) => {365 runner.sync_run(|config| cmd.run::<Block, SubstrateHostFunctions>(config))366 }367 BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {368 let partials = new_partial::<369 opal_runtime::Runtime,370 opal_runtime::RuntimeApi,371 OpalRuntimeExecutor,372 _,373 >(374 &config,375 crate::service::parachain_build_import_queue::<opal_runtime::Runtime, _, _>,376 )?;377 cmd.run(partials.client)378 }),379 BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {380 let partials = new_partial::<381 opal_runtime::Runtime,382 opal_runtime::RuntimeApi,383 OpalRuntimeExecutor,384 _,385 >(386 &config,387 crate::service::parachain_build_import_queue::<opal_runtime::Runtime, _, _>,388 )?;389 let db = partials.backend.expose_db();390 let storage = partials.backend.expose_storage();391392 cmd.run(config, partials.client.clone(), db, storage)393 }),394 BenchmarkCmd::Machine(cmd) => {395 runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()))396 }397 BenchmarkCmd::Overhead(_) | BenchmarkCmd::Extrinsic(_) => {398 Err("Unsupported benchmarking command".into())399 }400 }401 }402 #[cfg(feature = "try-runtime")]403 Some(Subcommand::TryRuntime(cmd)) => {404 use std::{future::Future, pin::Pin};405406 use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};407 use try_runtime_cli::block_building_info::timestamp_with_aura_info;408409 let runner = cli.create_runner(cmd)?;410411 // grab the task manager.412 let registry = &runner413 .config()414 .prometheus_config415 .as_ref()416 .map(|cfg| &cfg.registry);417 let task_manager =418 sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry)419 .map_err(|e| format!("Error: {e:?}"))?;420 let info_provider = Some(timestamp_with_aura_info(12000));421422 runner.async_run(|config| -> Result<(Pin<Box<dyn Future<Output = _>>>, _)> {423 Ok((424 match config.chain_spec.runtime_id() {425 #[cfg(feature = "unique-runtime")]426 RuntimeId::Unique => Box::pin(cmd.run::<Block, ExtendedHostFunctions<427 sp_io::SubstrateHostFunctions,428 <UniqueRuntimeExecutor as NativeExecutionDispatch>::ExtendHostFunctions,429 >, _>(info_provider)),430431 #[cfg(feature = "quartz-runtime")]432 RuntimeId::Quartz => Box::pin(cmd.run::<Block, ExtendedHostFunctions<433 sp_io::SubstrateHostFunctions,434 <QuartzRuntimeExecutor as NativeExecutionDispatch>::ExtendHostFunctions,435 >, _>(info_provider)),436437 RuntimeId::Opal => Box::pin(cmd.run::<Block, ExtendedHostFunctions<438 sp_io::SubstrateHostFunctions,439 <OpalRuntimeExecutor as NativeExecutionDispatch>::ExtendHostFunctions,440 >, _>(info_provider)),441 runtime_id => return Err(no_runtime_err!(runtime_id).into()),442 },443 task_manager,444 ))445 })446 }447 #[cfg(not(feature = "try-runtime"))]448 Some(Subcommand::TryRuntime) => {449 Err("Try-runtime must be enabled by `--features try-runtime`.".into())450 }451 None => {452 let runner = cli.create_runner(&cli.run.normalize())?;453 let collator_options = cli.run.collator_options();454455 runner.run_node_until_exit(|config| async move {456 let hwbench = if !cli.no_hardware_benchmarks {457 config.database.path().map(|database_path| {458 let _ = std::fs::create_dir_all(database_path);459 sc_sysinfo::gather_hwbench(Some(database_path))460 })461 } else {462 None463 };464465 let extensions = chain_spec::Extensions::try_get(&*config.chain_spec);466467 let service_id = config.chain_spec.service_id();468 let relay_chain_id = extensions.map(|e| e.relay_chain.clone());469 let is_dev_service = matches![service_id, ServiceId::Dev]470 || relay_chain_id == Some("dev-service".into());471472 if is_dev_service {473 info!("Running Dev service");474475 let mut config = config;476477 config.state_pruning = Some(sc_service::PruningMode::ArchiveAll);478479 return start_node_using_chain_runtime! {480 start_dev_node(config, cli.idle_autoseal_interval, cli.autoseal_finalization_delay, cli.disable_autoseal_on_tx).map_err(Into::into)481 };482 };483484 let para_id = extensions485 .map(|e| e.para_id)486 .ok_or("Could not find parachain ID in chain-spec.")?;487488 let polkadot_cli = RelayChainCli::new(489 &config,490 [RelayChainCli::executable_name()]491 .iter()492 .chain(cli.relaychain_args.iter()),493 );494495 let para_id = ParaId::from(para_id);496497 let parachain_account =498 AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(499 ¶_id,500 );501502 let polkadot_config = SubstrateCli::create_configuration(503 &polkadot_cli,504 &polkadot_cli,505 config.tokio_handle.clone(),506 )507 .map_err(|err| format!("Relay chain argument error: {err}"))?;508509 info!("Parachain id: {:?}", para_id);510 info!("Parachain Account: {}", parachain_account);511 info!(512 "Is collating: {}",513 if config.role.is_authority() {514 "yes"515 } else {516 "no"517 }518 );519520 start_node_using_chain_runtime! {521 start_node(config, polkadot_config, collator_options, para_id, hwbench)522 .await523 .map(|r| r.0)524 .map_err(Into::into)525 }526 })527 }528 }529}530531impl DefaultConfigurationValues for RelayChainCli {532 fn p2p_listen_port() -> u16 {533 30334534 }535536 fn rpc_listen_port() -> u16 {537 9945538 }539540 fn prometheus_listen_port() -> u16 {541 9616542 }543}544545impl CliConfiguration<Self> for RelayChainCli {546 fn shared_params(&self) -> &SharedParams {547 self.base.base.shared_params()548 }549550 fn import_params(&self) -> Option<&ImportParams> {551 self.base.base.import_params()552 }553554 fn network_params(&self) -> Option<&NetworkParams> {555 self.base.base.network_params()556 }557558 fn keystore_params(&self) -> Option<&KeystoreParams> {559 self.base.base.keystore_params()560 }561562 fn base_path(&self) -> Result<Option<BasePath>> {563 Ok(self564 .shared_params()565 .base_path()?566 .or_else(|| Some(self.base_path.clone().into())))567 }568569 fn prometheus_config(570 &self,571 default_listen_port: u16,572 chain_spec: &Box<dyn ChainSpec>,573 ) -> Result<Option<PrometheusConfig>> {574 self.base575 .base576 .prometheus_config(default_listen_port, chain_spec)577 }578579 fn init<F>(580 &self,581 _support_url: &String,582 _impl_version: &String,583 _logger_hook: F,584 _config: &sc_service::Configuration,585 ) -> Result<()> {586 unreachable!("PolkadotCli is never initialized; qed");587 }588589 fn chain_id(&self, is_dev: bool) -> Result<String> {590 let chain_id = self.base.base.chain_id(is_dev)?;591592 Ok(if chain_id.is_empty() {593 self.chain_id.clone().unwrap_or_default()594 } else {595 chain_id596 })597 }598599 fn role(&self, is_dev: bool) -> Result<sc_service::Role> {600 self.base.base.role(is_dev)601 }602603 fn transaction_pool(&self, is_dev: bool) -> Result<sc_service::config::TransactionPoolOptions> {604 self.base.base.transaction_pool(is_dev)605 }606607 fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {608 self.base.base.rpc_methods()609 }610611 fn rpc_max_connections(&self) -> Result<u32> {612 self.base.base.rpc_max_connections()613 }614615 fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {616 self.base.base.rpc_cors(is_dev)617 }618619 fn default_heap_pages(&self) -> Result<Option<u64>> {620 self.base.base.default_heap_pages()621 }622623 fn force_authoring(&self) -> Result<bool> {624 self.base.base.force_authoring()625 }626627 fn disable_grandpa(&self) -> Result<bool> {628 self.base.base.disable_grandpa()629 }630631 fn max_runtime_instances(&self) -> Result<Option<usize>> {632 self.base.base.max_runtime_instances()633 }634635 fn announce_block(&self) -> Result<bool> {636 self.base.base.announce_block()637 }638639 fn telemetry_endpoints(640 &self,641 chain_spec: &Box<dyn ChainSpec>,642 ) -> Result<Option<sc_telemetry::TelemetryEndpoints>> {643 self.base.base.telemetry_endpoints(chain_spec)644 }645}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// Original license18// This file is part of Substrate.1920// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.21// SPDX-License-Identifier: Apache-2.02223// Licensed under the Apache License, Version 2.0 (the "License");24// you may not use this file except in compliance with the License.25// You may obtain a copy of the License at26//27// http://www.apache.org/licenses/LICENSE-2.028//29// Unless required by applicable law or agreed to in writing, software30// distributed under the License is distributed on an "AS IS" BASIS,31// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.32// See the License for the specific language governing permissions and33// limitations under the License.3435use cumulus_primitives_core::ParaId;36use log::info;37use sc_cli::{38 ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,39 NetworkParams, Result, SharedParams, SubstrateCli,40};41use sc_service::config::{BasePath, PrometheusConfig};42use sp_runtime::traits::AccountIdConversion;43use up_common::types::opaque::RuntimeId;4445#[cfg(feature = "quartz-runtime")]46use crate::service::QuartzRuntimeExecutor;47#[cfg(feature = "unique-runtime")]48use crate::service::UniqueRuntimeExecutor;49use crate::{50 chain_spec::{self, RuntimeIdentification, ServiceId, ServiceIdentification},51 cli::{Cli, RelayChainCli, Subcommand},52 service::{new_partial, start_dev_node, start_node, OpalRuntimeExecutor},53};5455macro_rules! no_runtime_err {56 ($runtime_id:expr) => {57 format!(58 "No runtime valid runtime was found for chain {:#?}",59 $runtime_id60 )61 };62}6364fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {65 Ok(match id {66 "dev" => Box::new(chain_spec::development_config()),67 "" | "local" => Box::new(chain_spec::local_testnet_config()),68 path => {69 let path = std::path::PathBuf::from(path);70 #[allow(clippy::redundant_clone)]71 let chain_spec = Box::new(chain_spec::OpalChainSpec::from_json_file(path.clone())?)72 as Box<dyn sc_service::ChainSpec>;7374 match chain_spec.runtime_id() {75 #[cfg(feature = "unique-runtime")]76 RuntimeId::Unique => Box::new(chain_spec::UniqueChainSpec::from_json_file(path)?),7778 #[cfg(feature = "quartz-runtime")]79 RuntimeId::Quartz => Box::new(chain_spec::QuartzChainSpec::from_json_file(path)?),8081 RuntimeId::Opal => chain_spec,82 runtime_id => return Err(no_runtime_err!(runtime_id)),83 }84 }85 })86}8788impl SubstrateCli for Cli {89 // TODO use args90 fn impl_name() -> String {91 format!("{} Node", Self::node_name())92 }9394 fn impl_version() -> String {95 env!("SUBSTRATE_CLI_IMPL_VERSION").into()96 }97 // TODO use args98 fn description() -> String {99 format!(100 "{} Node\n\nThe command-line arguments provided first will be \101 passed to the parachain node, while the arguments provided after -- will be passed \102 to the relaychain node.\n\n\103 {} [parachain-args] -- [relaychain-args]",104 Self::node_name(),105 Self::executable_name()106 )107 }108109 fn author() -> String {110 env!("CARGO_PKG_AUTHORS").into()111 }112113 //TODO use args114 fn support_url() -> String {115 "support@unique.network".into()116 }117118 fn copyright_start_year() -> i32 {119 2019120 }121122 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {123 load_spec(id)124 }125}126127impl SubstrateCli for RelayChainCli {128 // TODO use args129 fn impl_name() -> String {130 format!("{} Node", Cli::node_name())131 }132133 fn impl_version() -> String {134 env!("SUBSTRATE_CLI_IMPL_VERSION").into()135 }136 // TODO use args137 fn description() -> String {138 format!(139 "{} Node\n\nThe command-line arguments provided first will be \140 passed to the parachain node, while the arguments provided after -- will be passed \141 to the relaychain node.\n\n\142 parachain-collator [parachain-args] -- [relaychain-args]",143 Cli::node_name()144 )145 }146147 fn author() -> String {148 env!("CARGO_PKG_AUTHORS").into()149 }150 // TODO use args151 fn support_url() -> String {152 "support@unique.network".into()153 }154155 fn copyright_start_year() -> i32 {156 2019157 }158159 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {160 polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)161 }162}163164macro_rules! async_run_with_runtime {165 (166 $runtime:path, $runtime_api:path, $executor:path,167 $runner:ident, $components:ident, $cli:ident, $cmd:ident, $config:ident,168 $( $code:tt )*169 ) => {170 $runner.async_run(|$config| {171 let $components = new_partial::<172 $runtime, $runtime_api, $executor, _173 >(174 &$config,175 crate::service::parachain_build_import_queue::<$runtime, _, _>,176 )?;177 let task_manager = $components.task_manager;178179 { $( $code )* }.map(|v| (v, task_manager))180 })181 };182}183184macro_rules! construct_async_run {185 (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{186 let runner = $cli.create_runner($cmd)?;187188 match runner.config().chain_spec.runtime_id() {189 #[cfg(feature = "unique-runtime")]190 RuntimeId::Unique => async_run_with_runtime!(191 unique_runtime::Runtime, unique_runtime::RuntimeApi, UniqueRuntimeExecutor,192 runner, $components, $cli, $cmd, $config, $( $code )*193 ),194195 #[cfg(feature = "quartz-runtime")]196 RuntimeId::Quartz => async_run_with_runtime!(197 quartz_runtime::Runtime, quartz_runtime::RuntimeApi, QuartzRuntimeExecutor,198 runner, $components, $cli, $cmd, $config, $( $code )*199 ),200201 RuntimeId::Opal => async_run_with_runtime!(202 opal_runtime::Runtime, opal_runtime::RuntimeApi, OpalRuntimeExecutor,203 runner, $components, $cli, $cmd, $config, $( $code )*204 ),205206 runtime_id => Err(no_runtime_err!(runtime_id).into())207 }208 }}209}210211macro_rules! sync_run_with_runtime {212 (213 $runtime:path, $runtime_api:path, $executor:path,214 $runner:ident, $components:ident, $cli:ident, $cmd:ident, $config:ident,215 $( $code:tt )*216 ) => {217 $runner.sync_run(|$config| {218 let $components = new_partial::<219 $runtime, $runtime_api, $executor, _220 >(221 &$config,222 crate::service::parachain_build_import_queue::<$runtime, _, _>,223 )?;224225 $( $code )*226 })227 };228}229230macro_rules! construct_sync_run {231 (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{232 let runner = $cli.create_runner($cmd)?;233234 match runner.config().chain_spec.runtime_id() {235 #[cfg(feature = "unique-runtime")]236 RuntimeId::Unique => sync_run_with_runtime!(237 unique_runtime::Runtime, unique_runtime::RuntimeApi, UniqueRuntimeExecutor,238 runner, $components, $cli, $cmd, $config, $( $code )*239 ),240241 #[cfg(feature = "quartz-runtime")]242 RuntimeId::Quartz => sync_run_with_runtime!(243 quartz_runtime::Runtime, quartz_runtime::RuntimeApi, QuartzRuntimeExecutor,244 runner, $components, $cli, $cmd, $config, $( $code )*245 ),246247 RuntimeId::Opal => sync_run_with_runtime!(248 opal_runtime::Runtime, opal_runtime::RuntimeApi, OpalRuntimeExecutor,249 runner, $components, $cli, $cmd, $config, $( $code )*250 ),251252 runtime_id => Err(no_runtime_err!(runtime_id).into())253 }254 }}255}256257macro_rules! start_node_using_chain_runtime {258 ($start_node_fn:ident($config:expr $(, $($args:expr),+)?) $($code:tt)*) => {259 match $config.chain_spec.runtime_id() {260 #[cfg(feature = "unique-runtime")]261 RuntimeId::Unique => $start_node_fn::<262 unique_runtime::Runtime,263 unique_runtime::RuntimeApi,264 UniqueRuntimeExecutor,265 >($config $(, $($args),+)?) $($code)*,266267 #[cfg(feature = "quartz-runtime")]268 RuntimeId::Quartz => $start_node_fn::<269 quartz_runtime::Runtime,270 quartz_runtime::RuntimeApi,271 QuartzRuntimeExecutor,272 >($config $(, $($args),+)?) $($code)*,273274 RuntimeId::Opal => $start_node_fn::<275 opal_runtime::Runtime,276 opal_runtime::RuntimeApi,277 OpalRuntimeExecutor,278 >($config $(, $($args),+)?) $($code)*,279280 runtime_id => Err(no_runtime_err!(runtime_id).into()),281 }282 };283}284285/// Parse command line arguments into service configuration.286pub fn run() -> Result<()> {287 let cli = Cli::from_args();288289 match &cli.subcommand {290 Some(Subcommand::Key(cmd)) => cmd.run(&cli),291 Some(Subcommand::BuildSpec(cmd)) => {292 let runner = cli.create_runner(cmd)?;293 runner.sync_run(|config| cmd.run(config.chain_spec, config.network))294 }295 Some(Subcommand::CheckBlock(cmd)) => {296 construct_async_run!(|components, cli, cmd, config| {297 Ok(cmd.run(components.client, components.import_queue))298 })299 }300 Some(Subcommand::ExportBlocks(cmd)) => {301 construct_async_run!(|components, cli, cmd, config| {302 Ok(cmd.run(components.client, config.database))303 })304 }305 Some(Subcommand::ExportState(cmd)) => {306 construct_async_run!(|components, cli, cmd, config| {307 Ok(cmd.run(components.client, config.chain_spec))308 })309 }310 Some(Subcommand::ImportBlocks(cmd)) => {311 construct_async_run!(|components, cli, cmd, config| {312 Ok(cmd.run(components.client, components.import_queue))313 })314 }315 Some(Subcommand::PurgeChain(cmd)) => {316 let runner = cli.create_runner(cmd)?;317318 runner.sync_run(|config| {319 let polkadot_cli = RelayChainCli::new(320 &config,321 [RelayChainCli::executable_name()]322 .iter()323 .chain(cli.relaychain_args.iter()),324 );325326 let polkadot_config = SubstrateCli::create_configuration(327 &polkadot_cli,328 &polkadot_cli,329 config.tokio_handle.clone(),330 )331 .map_err(|err| format!("Relay chain argument error: {err}"))?;332333 cmd.run(config, polkadot_config)334 })335 }336 Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| {337 Ok(cmd.run(components.client, components.backend, None))338 }),339 Some(Subcommand::ExportGenesisState(cmd)) => {340 construct_sync_run!(|components, cli, cmd, _config| {341 let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;342 cmd.run(&*spec, &*components.client)343 })344 }345 Some(Subcommand::ExportGenesisWasm(cmd)) => {346 construct_sync_run!(|_components, cli, cmd, _config| {347 let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;348 cmd.run(&*spec)349 })350 }351 #[cfg(feature = "runtime-benchmarks")]352 Some(Subcommand::Benchmark(cmd)) => {353 use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};354 use polkadot_cli::Block;355 use sp_io::SubstrateHostFunctions;356357 let runner = cli.create_runner(cmd)?;358 // Switch on the concrete benchmark sub-command-359 match cmd {360 BenchmarkCmd::Pallet(cmd) => {361 runner.sync_run(|config| cmd.run::<Block, SubstrateHostFunctions>(config))362 }363 BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {364 let partials = new_partial::<365 opal_runtime::Runtime,366 opal_runtime::RuntimeApi,367 OpalRuntimeExecutor,368 _,369 >(370 &config,371 crate::service::parachain_build_import_queue::<opal_runtime::Runtime, _, _>,372 )?;373 cmd.run(partials.client)374 }),375 BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {376 let partials = new_partial::<377 opal_runtime::Runtime,378 opal_runtime::RuntimeApi,379 OpalRuntimeExecutor,380 _,381 >(382 &config,383 crate::service::parachain_build_import_queue::<opal_runtime::Runtime, _, _>,384 )?;385 let db = partials.backend.expose_db();386 let storage = partials.backend.expose_storage();387388 cmd.run(config, partials.client.clone(), db, storage)389 }),390 BenchmarkCmd::Machine(cmd) => {391 runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()))392 }393 BenchmarkCmd::Overhead(_) | BenchmarkCmd::Extrinsic(_) => {394 Err("Unsupported benchmarking command".into())395 }396 }397 }398 #[cfg(feature = "try-runtime")]399 Some(Subcommand::TryRuntime(cmd)) => {400 use std::{future::Future, pin::Pin};401402 use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};403 use try_runtime_cli::block_building_info::timestamp_with_aura_info;404405 let runner = cli.create_runner(cmd)?;406407 // grab the task manager.408 let registry = &runner409 .config()410 .prometheus_config411 .as_ref()412 .map(|cfg| &cfg.registry);413 let task_manager =414 sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry)415 .map_err(|e| format!("Error: {e:?}"))?;416 let info_provider = Some(timestamp_with_aura_info(12000));417418 runner.async_run(|config| -> Result<(Pin<Box<dyn Future<Output = _>>>, _)> {419 Ok((420 match config.chain_spec.runtime_id() {421 #[cfg(feature = "unique-runtime")]422 RuntimeId::Unique => Box::pin(cmd.run::<Block, ExtendedHostFunctions<423 sp_io::SubstrateHostFunctions,424 <UniqueRuntimeExecutor as NativeExecutionDispatch>::ExtendHostFunctions,425 >, _>(info_provider)),426427 #[cfg(feature = "quartz-runtime")]428 RuntimeId::Quartz => Box::pin(cmd.run::<Block, ExtendedHostFunctions<429 sp_io::SubstrateHostFunctions,430 <QuartzRuntimeExecutor as NativeExecutionDispatch>::ExtendHostFunctions,431 >, _>(info_provider)),432433 RuntimeId::Opal => Box::pin(cmd.run::<Block, ExtendedHostFunctions<434 sp_io::SubstrateHostFunctions,435 <OpalRuntimeExecutor as NativeExecutionDispatch>::ExtendHostFunctions,436 >, _>(info_provider)),437 runtime_id => return Err(no_runtime_err!(runtime_id).into()),438 },439 task_manager,440 ))441 })442 }443 #[cfg(not(feature = "try-runtime"))]444 Some(Subcommand::TryRuntime) => {445 Err("Try-runtime must be enabled by `--features try-runtime`.".into())446 }447 None => {448 let runner = cli.create_runner(&cli.run.normalize())?;449 let collator_options = cli.run.collator_options();450451 runner.run_node_until_exit(|config| async move {452 let hwbench = if !cli.no_hardware_benchmarks {453 config.database.path().map(|database_path| {454 let _ = std::fs::create_dir_all(database_path);455 sc_sysinfo::gather_hwbench(Some(database_path))456 })457 } else {458 None459 };460461 let extensions = chain_spec::Extensions::try_get(&*config.chain_spec);462463 let service_id = config.chain_spec.service_id();464 let relay_chain_id = extensions.map(|e| e.relay_chain.clone());465 let is_dev_service = matches![service_id, ServiceId::Dev]466 || relay_chain_id == Some("dev-service".into());467468 if is_dev_service {469 info!("Running Dev service");470471 let mut config = config;472473 config.state_pruning = Some(sc_service::PruningMode::ArchiveAll);474475 return start_node_using_chain_runtime! {476 start_dev_node(config, cli.idle_autoseal_interval, cli.autoseal_finalization_delay, cli.disable_autoseal_on_tx).map_err(Into::into)477 };478 };479480 let para_id = extensions481 .map(|e| e.para_id)482 .ok_or("Could not find parachain ID in chain-spec.")?;483484 let polkadot_cli = RelayChainCli::new(485 &config,486 [RelayChainCli::executable_name()]487 .iter()488 .chain(cli.relaychain_args.iter()),489 );490491 let para_id = ParaId::from(para_id);492493 let parachain_account =494 AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(495 ¶_id,496 );497498 let polkadot_config = SubstrateCli::create_configuration(499 &polkadot_cli,500 &polkadot_cli,501 config.tokio_handle.clone(),502 )503 .map_err(|err| format!("Relay chain argument error: {err}"))?;504505 info!("Parachain id: {:?}", para_id);506 info!("Parachain Account: {}", parachain_account);507 info!(508 "Is collating: {}",509 if config.role.is_authority() {510 "yes"511 } else {512 "no"513 }514 );515516 start_node_using_chain_runtime! {517 start_node(config, polkadot_config, collator_options, para_id, hwbench)518 .await519 .map(|r| r.0)520 .map_err(Into::into)521 }522 })523 }524 }525}526527impl DefaultConfigurationValues for RelayChainCli {528 fn p2p_listen_port() -> u16 {529 30334530 }531532 fn rpc_listen_port() -> u16 {533 9945534 }535536 fn prometheus_listen_port() -> u16 {537 9616538 }539}540541impl CliConfiguration<Self> for RelayChainCli {542 fn shared_params(&self) -> &SharedParams {543 self.base.base.shared_params()544 }545546 fn import_params(&self) -> Option<&ImportParams> {547 self.base.base.import_params()548 }549550 fn network_params(&self) -> Option<&NetworkParams> {551 self.base.base.network_params()552 }553554 fn keystore_params(&self) -> Option<&KeystoreParams> {555 self.base.base.keystore_params()556 }557558 fn base_path(&self) -> Result<Option<BasePath>> {559 Ok(self560 .shared_params()561 .base_path()?562 .or_else(|| Some(self.base_path.clone().into())))563 }564565 fn prometheus_config(566 &self,567 default_listen_port: u16,568 chain_spec: &Box<dyn ChainSpec>,569 ) -> Result<Option<PrometheusConfig>> {570 self.base571 .base572 .prometheus_config(default_listen_port, chain_spec)573 }574575 fn init<F>(576 &self,577 _support_url: &String,578 _impl_version: &String,579 _logger_hook: F,580 _config: &sc_service::Configuration,581 ) -> Result<()> {582 unreachable!("PolkadotCli is never initialized; qed");583 }584585 fn chain_id(&self, is_dev: bool) -> Result<String> {586 let chain_id = self.base.base.chain_id(is_dev)?;587588 Ok(if chain_id.is_empty() {589 self.chain_id.clone().unwrap_or_default()590 } else {591 chain_id592 })593 }594595 fn role(&self, is_dev: bool) -> Result<sc_service::Role> {596 self.base.base.role(is_dev)597 }598599 fn transaction_pool(&self, is_dev: bool) -> Result<sc_service::config::TransactionPoolOptions> {600 self.base.base.transaction_pool(is_dev)601 }602603 fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {604 self.base.base.rpc_methods()605 }606607 fn rpc_max_connections(&self) -> Result<u32> {608 self.base.base.rpc_max_connections()609 }610611 fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {612 self.base.base.rpc_cors(is_dev)613 }614615 fn default_heap_pages(&self) -> Result<Option<u64>> {616 self.base.base.default_heap_pages()617 }618619 fn force_authoring(&self) -> Result<bool> {620 self.base.base.force_authoring()621 }622623 fn disable_grandpa(&self) -> Result<bool> {624 self.base.base.disable_grandpa()625 }626627 fn max_runtime_instances(&self) -> Result<Option<usize>> {628 self.base.base.max_runtime_instances()629 }630631 fn announce_block(&self) -> Result<bool> {632 self.base.base.announce_block()633 }634635 fn telemetry_endpoints(636 &self,637 chain_spec: &Box<dyn ChainSpec>,638 ) -> Result<Option<sc_telemetry::TelemetryEndpoints>> {639 self.base.base.telemetry_endpoints(chain_spec)640 }641}node/cli/src/service.rsdiffbeforeafterboth--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -93,23 +93,6 @@
/// Opal native executor instance.
pub struct OpalRuntimeExecutor;
-#[cfg(all(feature = "unique-runtime", feature = "runtime-benchmarks"))]
-pub type DefaultRuntimeExecutor = UniqueRuntimeExecutor;
-
-#[cfg(all(
- not(feature = "unique-runtime"),
- feature = "quartz-runtime",
- feature = "runtime-benchmarks"
-))]
-pub type DefaultRuntimeExecutor = QuartzRuntimeExecutor;
-
-#[cfg(all(
- not(feature = "unique-runtime"),
- not(feature = "quartz-runtime"),
- feature = "runtime-benchmarks"
-))]
-pub type DefaultRuntimeExecutor = OpalRuntimeExecutor;
-
#[cfg(feature = "unique-runtime")]
impl NativeExecutionDispatch for UniqueRuntimeExecutor {
/// Only enable the benchmarking host functions when we actually want to benchmark.
pallets/app-promotion/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/app-promotion/src/benchmarking.rs
+++ b/pallets/app-promotion/src/benchmarking.rs
@@ -109,7 +109,7 @@
}
#[benchmark]
- fn payout_stakers(b: Linear<0, 100>) -> Result<(), BenchmarkError> {
+ fn payout_stakers(b: Linear<1, 100>) -> Result<(), BenchmarkError> {
let pallet_admin = account::<T::AccountId>("admin", 1, SEED);
PromototionPallet::<T>::set_admin_address(
RawOrigin::Root.into(),
pallets/collator-selection/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/collator-selection/src/benchmarking.rs
+++ b/pallets/collator-selection/src/benchmarking.rs
@@ -171,7 +171,8 @@
// Both invulnerables and candidates count together against MaxCollators.
// Maybe try putting it in braces? 1 .. (T::MaxCollators::get() - 2)
#[benchmark]
- fn add_invulnerable<T>(b: Linear<1, MAX_COLLATORS>) -> Result<(), BenchmarkError> {
+ fn add_invulnerable<T>(b: Linear<2, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
+ let b = b - 1;
register_validators::<T>(b);
register_invulnerables::<T>(b);
@@ -268,7 +269,8 @@
// worst case is when we have all the max-candidate slots filled except one, and we fill that
// one.
#[benchmark]
- fn onboard(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
+ fn onboard(c: Linear<2, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
+ let c = c - 1;
register_validators::<T>(c);
register_candidates::<T>(c);
@@ -293,9 +295,7 @@
// worst case is the last candidate leaving.
#[benchmark]
- fn offboard(c: Linear<0, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
- let c = c + 1;
-
+ fn offboard(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
register_validators::<T>(c);
register_candidates::<T>(c);
@@ -317,8 +317,7 @@
// worst case is the last candidate leaving.
#[benchmark]
- fn release_license(c: Linear<0, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
- let c = c + 1;
+ fn release_license(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
let bond = balance_unit::<T>();
register_validators::<T>(c);
@@ -343,8 +342,7 @@
// worst case is the last candidate leaving.
#[benchmark]
- fn force_release_license(c: Linear<0, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
- let c = c + 1;
+ fn force_release_license(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
let bond = balance_unit::<T>();
register_validators::<T>(c);
@@ -400,12 +398,9 @@
// worst case for new session.
#[benchmark]
fn new_session(
- r: Linear<0, MAX_INVULNERABLES>,
- c: Linear<0, MAX_INVULNERABLES>,
+ r: Linear<1, MAX_INVULNERABLES>,
+ c: Linear<1, MAX_INVULNERABLES>,
) -> Result<(), BenchmarkError> {
- let r = r + 1;
- let c = c + 1;
-
frame_system::Pallet::<T>::set_block_number(0u32.into());
register_validators::<T>(c);
pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -17,9 +17,7 @@
use frame_benchmarking::v2::{account, benchmarks, BenchmarkError};
use pallet_common::{
bench_init,
- benchmarking::{
- create_collection_raw, load_is_admin_and_property_permissions, property_key, property_value,
- },
+ benchmarking::{create_collection_raw, property_key, property_value},
CommonCollectionOperations,
};
use sp_std::prelude::*;
@@ -334,49 +332,51 @@
Ok(())
}
+ // TODO:
#[benchmark]
fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
- bench_init! {
- owner: sub; collection: collection(owner);
- owner: cross_from_sub;
- };
+ // bench_init! {
+ // owner: sub; collection: collection(owner);
+ // owner: cross_from_sub;
+ // };
- let perms = (0..b)
- .map(|k| PropertyKeyPermission {
- key: property_key(k as usize),
- permission: PropertyPermission {
- mutable: false,
- collection_admin: true,
- token_owner: true,
- },
- })
- .collect::<Vec<_>>();
- <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
- let props = (0..b)
- .map(|k| Property {
- key: property_key(k as usize),
- value: property_value(),
- })
- .collect::<Vec<_>>();
- let item = create_max_item(&collection, &owner, owner.clone())?;
+ // let perms = (0..b)
+ // .map(|k| PropertyKeyPermission {
+ // key: property_key(k as usize),
+ // permission: PropertyPermission {
+ // mutable: false,
+ // collection_admin: true,
+ // token_owner: true,
+ // },
+ // })
+ // .collect::<Vec<_>>();
+ // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
+ #[block]
+ {}
+ // let props = (0..b)
+ // .map(|k| Property {
+ // key: property_key(k as usize),
+ // value: property_value(),
+ // })
+ // .collect::<Vec<_>>();
+ // let item = create_max_item(&collection, &owner, owner.clone())?;
// let (is_collection_admin, property_permissions) =
// load_is_admin_and_property_permissions(&collection, &owner);
- todo!();
- #[block]
- {
- // let mut property_writer =
- // pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
+ // #[block]
+ // {
+ // let mut property_writer =
+ // pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
- // property_writer.write_token_properties(
- // item,
- // props.into_iter(),
- // crate::erc::ERC721TokenEvent::TokenChanged {
- // token_id: item.into(),
- // }
- // .to_log(T::ContractAddress::get()),
- // )?;
- }
+ // property_writer.write_token_properties(
+ // item,
+ // props.into_iter(),
+ // crate::erc::ERC721TokenEvent::TokenChanged {
+ // token_id: item.into(),
+ // }
+ // .to_log(T::ContractAddress::get()),
+ // )?;
+ // }
Ok(())
}
pallets/refungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -490,35 +490,35 @@
Ok(())
}
+ // TODO:
#[benchmark]
fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
- bench_init! {
- owner: sub; collection: collection(owner);
- owner: cross_from_sub;
- };
+ // bench_init! {
+ // owner: sub; collection: collection(owner);
+ // owner: cross_from_sub;
+ // };
+
+ // let perms = (0..b)
+ // .map(|k| PropertyKeyPermission {
+ // key: property_key(k as usize),
+ // permission: PropertyPermission {
+ // mutable: false,
+ // collection_admin: true,
+ // token_owner: true,
+ // },
+ // })
+ // .collect::<Vec<_>>();
+ // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
- let perms = (0..b)
- .map(|k| PropertyKeyPermission {
- key: property_key(k as usize),
- permission: PropertyPermission {
- mutable: false,
- collection_admin: true,
- token_owner: true,
- },
- })
- .collect::<Vec<_>>();
- <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
+ #[block]
+ {}
// let props = (0..b).map(|k| Property {
// key: property_key(k as usize),
// value: property_value(),
// }).collect::<Vec<_>>();
// let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
- // let (is_collection_admin, property_permissions) = load_is_admin_and_property_permissions(&collection, &owner);
-
- #[block]
- {}
- todo!();
+ // let (is_collection_admin, property_permissions) = load_is_admin_and_property_permissions(&collection, &owner)
// let mut property_writer = pallet_common::collection_info_loaded_property_writer(
// &collection,
// is_collection_admin,