From af1ea67e3dfe9b26c16e6228bb2d415071673c86 Mon Sep 17 00:00:00 2001 From: dastansam Date: Fri, 13 Oct 2023 17:06:51 +0300 Subject: [PATCH 01/20] Consistent collection attribute namespace --- substrate/frame/nfts/src/impl_nonfungibles.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/nfts/src/impl_nonfungibles.rs b/substrate/frame/nfts/src/impl_nonfungibles.rs index 4e2593b4057d..504ff13ab8db 100644 --- a/substrate/frame/nfts/src/impl_nonfungibles.rs +++ b/substrate/frame/nfts/src/impl_nonfungibles.rs @@ -106,7 +106,7 @@ impl, I: 'static> Inspect<::AccountId> for Palle Attribute::::get(( collection, Option::::None, - AttributeNamespace::CollectionOwner, + AttributeNamespace::Pallet, key, )) .map(|a| a.0.into()) From e2dfa29dda945c183d6a2cb65b31dce85cc1d681 Mon Sep 17 00:00:00 2001 From: dastansam Date: Tue, 17 Oct 2023 14:27:49 +0300 Subject: [PATCH 02/20] System attribute collection level --- .../runtimes/assets/asset-hub-westend/src/lib.rs | 4 ++-- substrate/bin/node/runtime/src/lib.rs | 4 ++-- substrate/frame/nfts/runtime-api/src/lib.rs | 2 +- substrate/frame/nfts/src/impl_nonfungibles.rs | 6 +++--- .../support/src/traits/tokens/nonfungible_v2.rs | 14 ++++++++++---- .../support/src/traits/tokens/nonfungibles_v2.rs | 4 ++-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 943332087627..b7665aeb35c6 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -1065,10 +1065,10 @@ impl_runtime_apis! { fn system_attribute( collection: u32, - item: u32, + item: Option, key: Vec, ) -> Option> { - >::system_attribute(&collection, &item, &key) + >::system_attribute(&collection, item.as_ref(), &key) } fn collection_attribute(collection: u32, key: Vec) -> Option> { diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 2070e3f12d04..6c04c79b8cdb 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -2627,10 +2627,10 @@ impl_runtime_apis! { fn system_attribute( collection: u32, - item: u32, + item: Option, key: Vec, ) -> Option> { - >::system_attribute(&collection, &item, &key) + >::system_attribute(&collection, item.as_ref(), &key) } fn collection_attribute(collection: u32, key: Vec) -> Option> { diff --git a/substrate/frame/nfts/runtime-api/src/lib.rs b/substrate/frame/nfts/runtime-api/src/lib.rs index cf2d444b42f8..77535c64069c 100644 --- a/substrate/frame/nfts/runtime-api/src/lib.rs +++ b/substrate/frame/nfts/runtime-api/src/lib.rs @@ -48,7 +48,7 @@ sp_api::decl_runtime_apis! { fn system_attribute( collection: CollectionId, - item: ItemId, + item: Option, key: Vec, ) -> Option>; diff --git a/substrate/frame/nfts/src/impl_nonfungibles.rs b/substrate/frame/nfts/src/impl_nonfungibles.rs index 504ff13ab8db..f33c651c08f5 100644 --- a/substrate/frame/nfts/src/impl_nonfungibles.rs +++ b/substrate/frame/nfts/src/impl_nonfungibles.rs @@ -84,12 +84,12 @@ impl, I: 'static> Inspect<::AccountId> for Palle /// By default this is `None`; no attributes are defined. fn system_attribute( collection: &Self::CollectionId, - item: &Self::ItemId, + item: Option<&Self::ItemId>, key: &[u8], ) -> Option> { let namespace = AttributeNamespace::Pallet; let key = BoundedSlice::<_, _>::try_from(key).ok()?; - Attribute::::get((collection, Some(item), namespace, key)).map(|a| a.0.into()) + Attribute::::get((collection, item, namespace, key)).map(|a| a.0.into()) } /// Returns the attribute value of `item` of `collection` corresponding to `key`. @@ -106,7 +106,7 @@ impl, I: 'static> Inspect<::AccountId> for Palle Attribute::::get(( collection, Option::::None, - AttributeNamespace::Pallet, + AttributeNamespace::CollectionOwner, key, )) .map(|a| a.0.into()) diff --git a/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs b/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs index c4463e0070f9..aed9d19ade16 100644 --- a/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs +++ b/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs @@ -63,7 +63,7 @@ pub trait Inspect { /// Returns the system attribute value of `item` corresponding to `key`. /// /// By default this is `None`; no attributes are defined. - fn system_attribute(_item: &Self::ItemId, _key: &[u8]) -> Option> { + fn system_attribute(_item: Option<&Self::ItemId>, _key: &[u8]) -> Option> { None } @@ -90,7 +90,10 @@ pub trait Inspect { /// Returns the strongly-typed system attribute value of `item` corresponding to `key`. /// /// By default this just attempts to use `system_attribute`. - fn typed_system_attribute(item: &Self::ItemId, key: &K) -> Option { + fn typed_system_attribute( + item: Option<&Self::ItemId>, + key: &K, + ) -> Option { key.using_encoded(|d| Self::system_attribute(item, d)) .and_then(|v| V::decode(&mut &v[..]).ok()) } @@ -211,7 +214,7 @@ impl< fn custom_attribute(account: &AccountId, item: &Self::ItemId, key: &[u8]) -> Option> { >::custom_attribute(account, &A::get(), item, key) } - fn system_attribute(item: &Self::ItemId, key: &[u8]) -> Option> { + fn system_attribute(item: Option<&Self::ItemId>, key: &[u8]) -> Option> { >::system_attribute(&A::get(), item, key) } fn typed_attribute(item: &Self::ItemId, key: &K) -> Option { @@ -229,7 +232,10 @@ impl< key, ) } - fn typed_system_attribute(item: &Self::ItemId, key: &K) -> Option { + fn typed_system_attribute( + item: Option<&Self::ItemId>, + key: &K, + ) -> Option { >::typed_system_attribute(&A::get(), item, key) } fn can_transfer(item: &Self::ItemId) -> bool { diff --git a/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs b/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs index ec064bdebf62..60e828cfd880 100644 --- a/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs +++ b/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs @@ -80,7 +80,7 @@ pub trait Inspect { /// By default this is `None`; no attributes are defined. fn system_attribute( _collection: &Self::CollectionId, - _item: &Self::ItemId, + _item: Option<&Self::ItemId>, _key: &[u8], ) -> Option> { None @@ -119,7 +119,7 @@ pub trait Inspect { /// By default this just attempts to use `system_attribute`. fn typed_system_attribute( collection: &Self::CollectionId, - item: &Self::ItemId, + item: Option<&Self::ItemId>, key: &K, ) -> Option { key.using_encoded(|d| Self::system_attribute(collection, item, d)) From fe31bb149f19d5a6c6c04548e5bdfdf1d23a53a8 Mon Sep 17 00:00:00 2001 From: dastansam Date: Tue, 17 Oct 2023 17:27:28 +0300 Subject: [PATCH 03/20] Update comments --- substrate/frame/nfts/src/impl_nonfungibles.rs | 4 +++- .../frame/support/src/traits/tokens/nonfungible_v2.rs | 8 ++++++-- .../frame/support/src/traits/tokens/nonfungibles_v2.rs | 9 ++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/substrate/frame/nfts/src/impl_nonfungibles.rs b/substrate/frame/nfts/src/impl_nonfungibles.rs index f33c651c08f5..fd58d91e229c 100644 --- a/substrate/frame/nfts/src/impl_nonfungibles.rs +++ b/substrate/frame/nfts/src/impl_nonfungibles.rs @@ -79,7 +79,9 @@ impl, I: 'static> Inspect<::AccountId> for Palle Attribute::::get((collection, Some(item), namespace, key)).map(|a| a.0.into()) } - /// Returns the system attribute value of `item` of `collection` corresponding to `key`. + /// Returns the system attribute value of `item` of `collection` corresponding to `key` if + /// `item` is `Some`. Otherwise, returns the system attribute value of `collection` + /// corresponding to `key`. /// /// By default this is `None`; no attributes are defined. fn system_attribute( diff --git a/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs b/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs index aed9d19ade16..d14d532651a5 100644 --- a/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs +++ b/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs @@ -60,7 +60,9 @@ pub trait Inspect { None } - /// Returns the system attribute value of `item` corresponding to `key`. + /// Returns the system attribute value of `item` of `collection` corresponding to `key` if + /// `item` is `Some`. Otherwise, returns the system attribute value of `collection` + /// corresponding to `key`. /// /// By default this is `None`; no attributes are defined. fn system_attribute(_item: Option<&Self::ItemId>, _key: &[u8]) -> Option> { @@ -87,7 +89,9 @@ pub trait Inspect { .and_then(|v| V::decode(&mut &v[..]).ok()) } - /// Returns the strongly-typed system attribute value of `item` corresponding to `key`. + /// Returns the strongly-typed system attribute value of `item` corresponding to `key` if + /// `item` is `Some`. Otherwise, returns the strongly-typed system attribute value of + /// `collection` corresponding to `key`. /// /// By default this just attempts to use `system_attribute`. fn typed_system_attribute( diff --git a/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs b/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs index 60e828cfd880..a9ac8f21f836 100644 --- a/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs +++ b/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs @@ -75,7 +75,9 @@ pub trait Inspect { None } - /// Returns the system attribute value of `item` of `collection` corresponding to `key`. + /// Returns the system attribute value of `item` of `collection` corresponding to `key` if + /// `item` is `Some`. Otherwise, returns the system attribute value of `collection` + /// corresponding to `key`. /// /// By default this is `None`; no attributes are defined. fn system_attribute( @@ -113,8 +115,9 @@ pub trait Inspect { .and_then(|v| V::decode(&mut &v[..]).ok()) } - /// Returns the strongly-typed system attribute value of `item` of `collection` corresponding to - /// `key`. + /// Returns the strongly-typed system attribute value of `item` corresponding to `key` if + /// `item` is `Some`. Otherwise, returns the strongly-typed system attribute value of + /// `collection` corresponding to `key`. /// /// By default this just attempts to use `system_attribute`. fn typed_system_attribute( From d0523362ae4dbd612434b7085125a659afc871f5 Mon Sep 17 00:00:00 2001 From: dastansam Date: Mon, 23 Oct 2023 14:09:57 +0300 Subject: [PATCH 04/20] Revert nonfungible_v2 changes --- .../src/traits/tokens/nonfungible_v2.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs b/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs index d14d532651a5..0a8c80690aab 100644 --- a/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs +++ b/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs @@ -65,7 +65,7 @@ pub trait Inspect { /// corresponding to `key`. /// /// By default this is `None`; no attributes are defined. - fn system_attribute(_item: Option<&Self::ItemId>, _key: &[u8]) -> Option> { + fn system_attribute(_item: &Self::ItemId, _key: &[u8]) -> Option> { None } @@ -94,10 +94,7 @@ pub trait Inspect { /// `collection` corresponding to `key`. /// /// By default this just attempts to use `system_attribute`. - fn typed_system_attribute( - item: Option<&Self::ItemId>, - key: &K, - ) -> Option { + fn typed_system_attribute(item: &Self::ItemId, key: &K) -> Option { key.using_encoded(|d| Self::system_attribute(item, d)) .and_then(|v| V::decode(&mut &v[..]).ok()) } @@ -218,8 +215,8 @@ impl< fn custom_attribute(account: &AccountId, item: &Self::ItemId, key: &[u8]) -> Option> { >::custom_attribute(account, &A::get(), item, key) } - fn system_attribute(item: Option<&Self::ItemId>, key: &[u8]) -> Option> { - >::system_attribute(&A::get(), item, key) + fn system_attribute(item: &Self::ItemId, key: &[u8]) -> Option> { + >::system_attribute(&A::get(), Some(item), key) } fn typed_attribute(item: &Self::ItemId, key: &K) -> Option { >::typed_attribute(&A::get(), item, key) @@ -236,11 +233,8 @@ impl< key, ) } - fn typed_system_attribute( - item: Option<&Self::ItemId>, - key: &K, - ) -> Option { - >::typed_system_attribute(&A::get(), item, key) + fn typed_system_attribute(item: &Self::ItemId, key: &K) -> Option { + >::typed_system_attribute(&A::get(), Some(item), key) } fn can_transfer(item: &Self::ItemId) -> bool { >::can_transfer(&A::get(), item) From 15a5254ca8b40d1d662cc6a0df032b5e473507b1 Mon Sep 17 00:00:00 2001 From: dastansam Date: Mon, 23 Oct 2023 14:12:37 +0300 Subject: [PATCH 05/20] More reverts --- .../src/traits/tokens/nonfungible_v2.rs | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs b/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs index 0a8c80690aab..05f76e2859d2 100644 --- a/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs +++ b/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs @@ -60,9 +60,7 @@ pub trait Inspect { None } - /// Returns the system attribute value of `item` of `collection` corresponding to `key` if - /// `item` is `Some`. Otherwise, returns the system attribute value of `collection` - /// corresponding to `key`. + /// Returns the system attribute value of `item` corresponding to `key`. /// /// By default this is `None`; no attributes are defined. fn system_attribute(_item: &Self::ItemId, _key: &[u8]) -> Option> { @@ -89,9 +87,7 @@ pub trait Inspect { .and_then(|v| V::decode(&mut &v[..]).ok()) } - /// Returns the strongly-typed system attribute value of `item` corresponding to `key` if - /// `item` is `Some`. Otherwise, returns the strongly-typed system attribute value of - /// `collection` corresponding to `key`. + /// Returns the strongly-typed system attribute value of `item` corresponding to `key`. /// /// By default this just attempts to use `system_attribute`. fn typed_system_attribute(item: &Self::ItemId, key: &K) -> Option { @@ -123,7 +119,7 @@ pub trait InspectEnumerable: Inspect { } /// Trait for providing an interface for NFT-like items which may be minted, burned and/or have -/// attributes set on them. +/// attributes and metadata set on them. pub trait Mutate: Inspect { /// Mint some `item` to be owned by `who`. /// @@ -162,6 +158,13 @@ pub trait Mutate: Inspect { key.using_encoded(|k| value.using_encoded(|v| Self::set_attribute(item, k, v))) } + /// Set the metadata `data` of an `item`. + /// + /// By default, this is not a supported operation. + fn set_metadata(_who: &AccountId, _item: &Self::ItemId, _data: &[u8]) -> DispatchResult { + Err(TokenError::Unsupported.into()) + } + /// Clear attribute of `item`'s `key`. /// /// By default, this is not a supported operation. @@ -175,6 +178,13 @@ pub trait Mutate: Inspect { fn clear_typed_attribute(item: &Self::ItemId, key: &K) -> DispatchResult { key.using_encoded(|k| Self::clear_attribute(item, k)) } + + /// Clear the metadata of an `item`. + /// + /// By default, this is not a supported operation. + fn clear_metadata(_who: &AccountId, _item: &Self::ItemId) -> DispatchResult { + Err(TokenError::Unsupported.into()) + } } /// Trait for transferring and controlling the transfer of non-fungible sets of items. From 7774e765812b969134c9bfc36be6c32be2b5f492 Mon Sep 17 00:00:00 2001 From: dastansam Date: Tue, 24 Oct 2023 18:32:01 +0300 Subject: [PATCH 06/20] Add tests --- substrate/frame/nfts/src/tests.rs | 81 +++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/substrate/frame/nfts/src/tests.rs b/substrate/frame/nfts/src/tests.rs index a82fcca01512..e9d4ccff5ee6 100644 --- a/substrate/frame/nfts/src/tests.rs +++ b/substrate/frame/nfts/src/tests.rs @@ -22,6 +22,7 @@ use enumflags2::BitFlags; use frame_support::{ assert_noop, assert_ok, traits::{ + nonfungibles_v2::Inspect, tokens::nonfungibles_v2::{Create, Destroy, Mutate}, Currency, Get, }, @@ -982,6 +983,86 @@ fn set_collection_owner_attributes_should_work() { }); } +#[test] +fn set_collection_system_attributes_should_work() { + new_test_ext().execute_with(|| { + Balances::make_free_balance_be(&account(1), 100); + + assert_ok!(Nfts::force_create( + RuntimeOrigin::root(), + account(1), + collection_config_with_all_settings_enabled() + )); + assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(1)), 0, 0, account(1), None)); + + let attribute_key = [0u8]; + let attribute_value = [0u8]; + + assert_ok!(, ItemConfig>>::set_collection_attribute( + &0, + &attribute_key, + &attribute_value + )); + + assert_eq!(attributes(0), vec![(None, AttributeNamespace::Pallet, bvec![0], bvec![0])]); + + assert_eq!( + >>::system_attribute(&0, None, &attribute_key), + Some(attribute_value.to_vec()) + ); + + // test typed system attribute + let typed_attribute_key = [0u8; 32]; + + #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)] + struct TypedAttributeValue(u32); + let typed_attribute_value = TypedAttributeValue(42); + + assert_ok!( + , ItemConfig>>::set_typed_collection_attribute( + &0, + &typed_attribute_key, + &typed_attribute_value + ) + ); + + assert_eq!( + >>::typed_system_attribute( + &0, + None, + &typed_attribute_key + ), + Some(typed_attribute_value) + ); + + // check storage + assert_eq!( + attributes(0), + [ + (None, AttributeNamespace::Pallet, bvec![0], bvec![0]), + ( + None, + AttributeNamespace::Pallet, + bvec![ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 + ], + bvec![42, 0, 0, 0] + ) + ] + ); + + // destroy collection + assert_ok!(Nfts::burn(RuntimeOrigin::root(), 0, 0)); + + let w = Nfts::get_destroy_witness(&0).unwrap(); + + assert_ok!(Nfts::destroy(RuntimeOrigin::signed(account(1)), 0, w)); + + assert_eq!(attributes(0), vec![]); + }) +} + #[test] fn set_item_owner_attributes_should_work() { new_test_ext().execute_with(|| { From 7ed21293714eccc5ced7cf93dc43d07da482e9d4 Mon Sep 17 00:00:00 2001 From: dastansam Date: Tue, 24 Oct 2023 18:40:59 +0300 Subject: [PATCH 07/20] Extract collection_id in tests --- substrate/frame/nfts/src/tests.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/substrate/frame/nfts/src/tests.rs b/substrate/frame/nfts/src/tests.rs index e9d4ccff5ee6..74c89debe533 100644 --- a/substrate/frame/nfts/src/tests.rs +++ b/substrate/frame/nfts/src/tests.rs @@ -995,11 +995,12 @@ fn set_collection_system_attributes_should_work() { )); assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(1)), 0, 0, account(1), None)); + let collection_id = 0; let attribute_key = [0u8]; let attribute_value = [0u8]; assert_ok!(, ItemConfig>>::set_collection_attribute( - &0, + &collection_id, &attribute_key, &attribute_value )); @@ -1007,20 +1008,23 @@ fn set_collection_system_attributes_should_work() { assert_eq!(attributes(0), vec![(None, AttributeNamespace::Pallet, bvec![0], bvec![0])]); assert_eq!( - >>::system_attribute(&0, None, &attribute_key), + >>::system_attribute( + &collection_id, + None, + &attribute_key + ), Some(attribute_value.to_vec()) ); // test typed system attribute let typed_attribute_key = [0u8; 32]; - #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)] struct TypedAttributeValue(u32); let typed_attribute_value = TypedAttributeValue(42); assert_ok!( , ItemConfig>>::set_typed_collection_attribute( - &0, + &collection_id, &typed_attribute_key, &typed_attribute_value ) @@ -1028,7 +1032,7 @@ fn set_collection_system_attributes_should_work() { assert_eq!( >>::typed_system_attribute( - &0, + &collection_id, None, &typed_attribute_key ), @@ -1037,7 +1041,7 @@ fn set_collection_system_attributes_should_work() { // check storage assert_eq!( - attributes(0), + attributes(collection_id), [ (None, AttributeNamespace::Pallet, bvec![0], bvec![0]), ( @@ -1052,14 +1056,10 @@ fn set_collection_system_attributes_should_work() { ] ); - // destroy collection - assert_ok!(Nfts::burn(RuntimeOrigin::root(), 0, 0)); - + assert_ok!(Nfts::burn(RuntimeOrigin::root(), collection_id, 0)); let w = Nfts::get_destroy_witness(&0).unwrap(); - - assert_ok!(Nfts::destroy(RuntimeOrigin::signed(account(1)), 0, w)); - - assert_eq!(attributes(0), vec![]); + assert_ok!(Nfts::destroy(RuntimeOrigin::signed(account(1)), collection_id, w)); + assert_eq!(attributes(collection_id), vec![]); }) } From 77420ffac0a8b867c507d62d5bf602436c6b118d Mon Sep 17 00:00:00 2001 From: dastansam Date: Tue, 24 Oct 2023 18:46:48 +0300 Subject: [PATCH 08/20] Fix import --- substrate/frame/nfts/src/tests.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/substrate/frame/nfts/src/tests.rs b/substrate/frame/nfts/src/tests.rs index 74c89debe533..aeebf51b7c78 100644 --- a/substrate/frame/nfts/src/tests.rs +++ b/substrate/frame/nfts/src/tests.rs @@ -22,8 +22,7 @@ use enumflags2::BitFlags; use frame_support::{ assert_noop, assert_ok, traits::{ - nonfungibles_v2::Inspect, - tokens::nonfungibles_v2::{Create, Destroy, Mutate}, + tokens::nonfungibles_v2::{Create, Destroy, Inspect, Mutate}, Currency, Get, }, }; From a226d27f0cddb4180b839cf059d25b08ff067cad Mon Sep 17 00:00:00 2001 From: Dastan <88332432+dastansam@users.noreply.github.com> Date: Mon, 19 Feb 2024 18:59:11 +0100 Subject: [PATCH 09/20] Feat/benchmark cli list (#1) * Consistent collection attribute namespace * System attribute collection level * Update comments * Revert nonfungible_v2 changes * More reverts * Add tests * Extract collection_id in tests * Fix import * Add `list-pallets` and `all` flags --- .../benchmarking-cli/src/pallet/command.rs | 39 +++++++++++++++---- .../frame/benchmarking-cli/src/pallet/mod.rs | 18 +++++++-- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index dce49db15f7d..06d80da031b5 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -191,6 +191,7 @@ impl PalletCmd { let spec = config.chain_spec; let pallet = self.pallet.clone().unwrap_or_default(); let pallet = pallet.as_bytes(); + let extrinsic = self.extrinsic.clone().unwrap_or_default(); let extrinsic_split: Vec<&str> = extrinsic.split(',').collect(); let extrinsics: Vec<_> = extrinsic_split.iter().map(|x| x.trim().as_bytes()).collect(); @@ -309,9 +310,9 @@ impl PalletCmd { return Err("No benchmarks found which match your input.".into()) } - if self.list { + if self.list || self.list_pallets { // List benchmarks instead of running them - list_benchmark(benchmarks_to_run); + list_benchmark(benchmarks_to_run, self.list_pallets); return Ok(()) } @@ -761,13 +762,35 @@ fn list_benchmark( Vec<(BenchmarkParameter, u32, u32)>, Vec<(String, String)>, )>, + pallets_only: bool, ) { // Sort and de-dub by pallet and function name. - benchmarks_to_run.sort_by(|(pa, sa, _, _), (pb, sb, _, _)| (pa, sa).cmp(&(pb, sb))); - benchmarks_to_run.dedup_by(|(pa, sa, _, _), (pb, sb, _, _)| (pa, sa) == (pb, sb)); - - println!("pallet, benchmark"); - for (pallet, extrinsic, _, _) in benchmarks_to_run { - println!("{}, {}", String::from_utf8_lossy(&pallet), String::from_utf8_lossy(&extrinsic)); + benchmarks_to_run.sort_by( + |(pa, sa, _, _), (pb, sb, _, _)| { + if pallets_only { + pa.cmp(pb) + } else { + (pa, sa).cmp(&(pb, sb)) + } + }, + ); + benchmarks_to_run.dedup_by( + |(pa, sa, _, _), (pb, sb, _, _)| if pallets_only { pa == pb } else { (pa, sa) == (pb, sb) }, + ); + + if pallets_only { + println!("pallet"); + for (pallet, _, _, _) in benchmarks_to_run { + println!("{}", String::from_utf8_lossy(&pallet)); + } + } else { + println!("pallet, benchmark"); + for (pallet, extrinsic, _, _) in benchmarks_to_run { + println!( + "{}, {}", + String::from_utf8_lossy(&pallet), + String::from_utf8_lossy(&extrinsic) + ); + } } } diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs index c69ce1765fc9..c23a565e4f0c 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -35,13 +35,19 @@ fn parse_pallet_name(pallet: &str) -> std::result::Result { #[derive(Debug, clap::Parser)] pub struct PalletCmd { /// Select a FRAME Pallet to benchmark, or `*` for all (in which case `extrinsic` must be `*`). - #[arg(short, long, value_parser = parse_pallet_name, required_unless_present_any = ["list", "json_input"])] + #[arg(short, long, value_parser = parse_pallet_name, required_unless_present_any = ["list", "list_pallets", "json_input","all"], default_value_if("is_pallets", "true", Some("*".into())))] pub pallet: Option, /// Select an extrinsic inside the pallet to benchmark, or `*` for all. - #[arg(short, long, required_unless_present_any = ["list", "json_input"])] + #[arg(short, long, required_unless_present_any = ["list", "list_pallets", "json_input", "all"], default_value_if("is_pallets", "true", Some("*".into())))] pub extrinsic: Option, + /// Run benchmarks for all pallets and extrinsics. + /// + /// This is equivalent to running `--pallet * --extrinsic *`. + #[arg(long)] + pub all: bool, + /// Select how many samples we should take across the variable components. #[arg(short, long, default_value_t = 50)] pub steps: u32, @@ -158,12 +164,16 @@ pub struct PalletCmd { #[arg(long = "db-cache", value_name = "MiB", default_value_t = 1024)] pub database_cache_size: u32, - /// List the benchmarks that match your query rather than running them. + /// List all available pallets and extrinsics. /// - /// When nothing is provided, we list all benchmarks. + /// The format is CSV with header `pallet, extrinsic`. #[arg(long)] pub list: bool, + /// List all available pallets only. + #[arg(long)] + pub list_pallets: bool, + /// If enabled, the storage info is not displayed in the output next to the analysis. /// /// This is independent of the storage info appearing in the *output file*. Use a Handlebar From 3a7180754477e867bf7f5dfd0fc9c5a59757a49b Mon Sep 17 00:00:00 2001 From: dastansam Date: Tue, 20 Feb 2024 19:33:04 +0100 Subject: [PATCH 10/20] Resolve comments --- .../benchmarking-cli/src/pallet/command.rs | 67 ++++++++++--------- .../frame/benchmarking-cli/src/pallet/mod.rs | 33 ++++++--- 2 files changed, 57 insertions(+), 43 deletions(-) diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index 06d80da031b5..bc6bf9d4aaab 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::{writer, PalletCmd}; +use super::{writer, ListOutput, PalletCmd}; use codec::{Decode, Encode}; use frame_benchmarking::{ Analysis, BenchmarkBatch, BenchmarkBatchSplitResults, BenchmarkList, BenchmarkParameter, @@ -39,7 +39,13 @@ use sp_externalities::Extensions; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::traits::Hash; use sp_state_machine::StateMachine; -use std::{collections::HashMap, fmt::Debug, fs, str::FromStr, time}; +use std::{ + collections::{BTreeMap, BTreeSet, HashMap}, + fmt::Debug, + fs, + str::FromStr, + time, +}; /// Logging target const LOG_TARGET: &'static str = "frame::benchmark::pallet"; @@ -310,9 +316,8 @@ impl PalletCmd { return Err("No benchmarks found which match your input.".into()) } - if self.list || self.list_pallets { - // List benchmarks instead of running them - list_benchmark(benchmarks_to_run, self.list_pallets); + if let Some(list_output) = self.list { + list_benchmark(benchmarks_to_run, list_output); return Ok(()) } @@ -756,41 +761,39 @@ impl CliConfiguration for PalletCmd { /// List the benchmarks available in the runtime, in a CSV friendly format. fn list_benchmark( - mut benchmarks_to_run: Vec<( + benchmarks_to_run: Vec<( Vec, Vec, Vec<(BenchmarkParameter, u32, u32)>, Vec<(String, String)>, )>, - pallets_only: bool, + list_output: ListOutput, ) { // Sort and de-dub by pallet and function name. - benchmarks_to_run.sort_by( - |(pa, sa, _, _), (pb, sb, _, _)| { - if pallets_only { - pa.cmp(pb) - } else { - (pa, sa).cmp(&(pb, sb)) + // convert it to a `BTreeMap>` for pretty printing. + let mut benchmarks = BTreeMap::new(); + + benchmarks_to_run.iter().for_each(|(pallet, extrinsic, _, _)| { + benchmarks + .entry(String::from_utf8_lossy(pallet).to_string()) + .or_insert_with(BTreeSet::new) + .insert(String::from_utf8_lossy(extrinsic).to_string()); + }); + + match list_output { + ListOutput::All => { + println!("pallet,extrinsic"); + for (pallet, extrinsics) in benchmarks { + for extrinsic in extrinsics { + println!("{},{}", pallet, extrinsic); + } + } + }, + ListOutput::Pallets => { + println!("pallet"); + for (pallet, _) in benchmarks { + println!("{}", pallet); } }, - ); - benchmarks_to_run.dedup_by( - |(pa, sa, _, _), (pb, sb, _, _)| if pallets_only { pa == pb } else { (pa, sa) == (pb, sb) }, - ); - - if pallets_only { - println!("pallet"); - for (pallet, _, _, _) in benchmarks_to_run { - println!("{}", String::from_utf8_lossy(&pallet)); - } - } else { - println!("pallet, benchmark"); - for (pallet, extrinsic, _, _) in benchmarks_to_run { - println!( - "{}, {}", - String::from_utf8_lossy(&pallet), - String::from_utf8_lossy(&extrinsic) - ); - } } } diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs index c23a565e4f0c..199379fce5af 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -19,6 +19,7 @@ mod command; mod writer; use crate::shared::HostInfoParams; +use clap::{Arg, ValueEnum}; use sc_cli::{ WasmExecutionMethod, WasmtimeInstantiationStrategy, DEFAULT_WASMTIME_INSTANTIATION_STRATEGY, DEFAULT_WASM_EXECUTION_METHOD, @@ -31,15 +32,30 @@ fn parse_pallet_name(pallet: &str) -> std::result::Result { Ok(pallet.replace("-", "_")) } +/// List options for available benchmarks. +#[derive(Debug, Clone, Copy, ValueEnum)] +pub enum ListOutput { + /// List all available pallets and extrinsics. + All, + /// List all available pallets only. + Pallets, +} + +impl Default for ListOutput { + fn default() -> Self { + ListOutput::All + } +} + /// Benchmark the extrinsic weight of FRAME Pallets. #[derive(Debug, clap::Parser)] pub struct PalletCmd { /// Select a FRAME Pallet to benchmark, or `*` for all (in which case `extrinsic` must be `*`). - #[arg(short, long, value_parser = parse_pallet_name, required_unless_present_any = ["list", "list_pallets", "json_input","all"], default_value_if("is_pallets", "true", Some("*".into())))] + #[arg(short, long, value_parser = parse_pallet_name, required_unless_present_any = ["list", "json_input", "all"], default_value_if("all", "true", Some("*".into())))] pub pallet: Option, /// Select an extrinsic inside the pallet to benchmark, or `*` for all. - #[arg(short, long, required_unless_present_any = ["list", "list_pallets", "json_input", "all"], default_value_if("is_pallets", "true", Some("*".into())))] + #[arg(short, long, required_unless_present_any = ["list", "json_input", "all"], default_value_if("all", "true", Some("*".into())))] pub extrinsic: Option, /// Run benchmarks for all pallets and extrinsics. @@ -164,15 +180,10 @@ pub struct PalletCmd { #[arg(long = "db-cache", value_name = "MiB", default_value_t = 1024)] pub database_cache_size: u32, - /// List all available pallets and extrinsics. - /// - /// The format is CSV with header `pallet, extrinsic`. - #[arg(long)] - pub list: bool, - - /// List all available pallets only. - #[arg(long)] - pub list_pallets: bool, + /// List and print available benchmarks in a csv-friendly format. + /// NOTE: `num_args` and `require_equals` are required to allow `--list` + #[arg(long, value_enum, ignore_case = true, num_args = 0..=1, require_equals = true, default_missing_value("All"))] + pub list: Option, /// If enabled, the storage info is not displayed in the output next to the analysis. /// From c297616739e70adcd6dacf001000ffd43167c900 Mon Sep 17 00:00:00 2001 From: dastansam Date: Tue, 20 Feb 2024 19:37:03 +0100 Subject: [PATCH 11/20] Fix comment --- substrate/utils/frame/benchmarking-cli/src/pallet/command.rs | 3 +-- substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index bc6bf9d4aaab..8865b090d247 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -769,10 +769,9 @@ fn list_benchmark( )>, list_output: ListOutput, ) { - // Sort and de-dub by pallet and function name. - // convert it to a `BTreeMap>` for pretty printing. let mut benchmarks = BTreeMap::new(); + // Sort and de-dub by pallet and function name. benchmarks_to_run.iter().for_each(|(pallet, extrinsic, _, _)| { benchmarks .entry(String::from_utf8_lossy(pallet).to_string()) diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs index 199379fce5af..264551497ab3 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -19,7 +19,7 @@ mod command; mod writer; use crate::shared::HostInfoParams; -use clap::{Arg, ValueEnum}; +use clap::ValueEnum; use sc_cli::{ WasmExecutionMethod, WasmtimeInstantiationStrategy, DEFAULT_WASMTIME_INSTANTIATION_STRATEGY, DEFAULT_WASM_EXECUTION_METHOD, From f197670bfc0d4c715fce63d3e63b7858ba021a5f Mon Sep 17 00:00:00 2001 From: dastansam Date: Tue, 20 Feb 2024 19:46:12 +0100 Subject: [PATCH 12/20] Simplify print --- .../benchmarking-cli/src/pallet/command.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index 8865b090d247..838d735be7d4 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -779,20 +779,15 @@ fn list_benchmark( .insert(String::from_utf8_lossy(extrinsic).to_string()); }); - match list_output { - ListOutput::All => { - println!("pallet,extrinsic"); - for (pallet, extrinsics) in benchmarks { + for (pallet, extrinsics) in benchmarks { + match list_output { + ListOutput::All => for extrinsic in extrinsics { println!("{},{}", pallet, extrinsic); - } - } - }, - ListOutput::Pallets => { - println!("pallet"); - for (pallet, _) in benchmarks { + }, + ListOutput::Pallets => { println!("{}", pallet); - } - }, + }, + } } } From 5523943d60d750a1f0cf5dedb35f6f2d89cb7d7b Mon Sep 17 00:00:00 2001 From: dastansam Date: Tue, 20 Feb 2024 20:20:14 +0100 Subject: [PATCH 13/20] Fix run_all_benchmarks script --- substrate/scripts/run_all_benchmarks.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/substrate/scripts/run_all_benchmarks.sh b/substrate/scripts/run_all_benchmarks.sh index 83848100a7e5..f5b5fe7c4115 100755 --- a/substrate/scripts/run_all_benchmarks.sh +++ b/substrate/scripts/run_all_benchmarks.sh @@ -59,11 +59,12 @@ done if [ "$skip_build" != true ] then echo "[+] Compiling Substrate benchmarks..." - cargo build --profile=production --locked --features=runtime-benchmarks --bin substrate + cargo build --profile=production --locked --features=runtime-benchmarks --bin substrate-node fi # The executable to use. -SUBSTRATE=./target/production/substrate +# Parent directory because of the monorepo structure. +SUBSTRATE=../target/production/substrate-node # Manually exclude some pallets. EXCLUDED_PALLETS=( @@ -80,11 +81,7 @@ EXCLUDED_PALLETS=( # Load all pallet names in an array. ALL_PALLETS=($( - $SUBSTRATE benchmark pallet --list --chain=dev |\ - tail -n+2 |\ - cut -d',' -f1 |\ - sort |\ - uniq + $SUBSTRATE benchmark pallet --list=pallets --chain=dev )) # Filter out the excluded pallets by concatenating the arrays and discarding duplicates. From d9e0f789326f5acb45a4faf4a7726681b3c106bf Mon Sep 17 00:00:00 2001 From: dastansam Date: Tue, 20 Feb 2024 23:14:50 +0100 Subject: [PATCH 14/20] Add no-csv-header option --- substrate/scripts/run_all_benchmarks.sh | 2 +- .../benchmarking-cli/src/pallet/command.rs | 26 +++++++++++++------ .../frame/benchmarking-cli/src/pallet/mod.rs | 4 +++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/substrate/scripts/run_all_benchmarks.sh b/substrate/scripts/run_all_benchmarks.sh index f5b5fe7c4115..6dd7cede319f 100755 --- a/substrate/scripts/run_all_benchmarks.sh +++ b/substrate/scripts/run_all_benchmarks.sh @@ -81,7 +81,7 @@ EXCLUDED_PALLETS=( # Load all pallet names in an array. ALL_PALLETS=($( - $SUBSTRATE benchmark pallet --list=pallets --chain=dev + $SUBSTRATE benchmark pallet --list=pallets --no-csv-header --chain=dev )) # Filter out the excluded pallets by concatenating the arrays and discarding duplicates. diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index 838d735be7d4..57c045f3c15c 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -317,7 +317,7 @@ impl PalletCmd { } if let Some(list_output) = self.list { - list_benchmark(benchmarks_to_run, list_output); + list_benchmark(benchmarks_to_run, list_output, self.no_csv_header); return Ok(()) } @@ -768,6 +768,7 @@ fn list_benchmark( Vec<(String, String)>, )>, list_output: ListOutput, + no_csv_header: bool, ) { let mut benchmarks = BTreeMap::new(); @@ -779,15 +780,24 @@ fn list_benchmark( .insert(String::from_utf8_lossy(extrinsic).to_string()); }); - for (pallet, extrinsics) in benchmarks { - match list_output { - ListOutput::All => + match list_output { + ListOutput::All => { + if !no_csv_header { + println!("pallet,extrinsic"); + } + for (pallet, extrinsics) in benchmarks { for extrinsic in extrinsics { println!("{},{}", pallet, extrinsic); - }, - ListOutput::Pallets => { + } + } + }, + ListOutput::Pallets => { + if !no_csv_header { + println!("pallet"); + }; + for pallet in benchmarks.keys() { println!("{}", pallet); - }, - } + } + }, } } diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs index 264551497ab3..0f5ceca7239a 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -185,6 +185,10 @@ pub struct PalletCmd { #[arg(long, value_enum, ignore_case = true, num_args = 0..=1, require_equals = true, default_missing_value("All"))] pub list: Option, + /// Don't include csv header when listing benchmarks. + #[arg(long, requires("list"))] + pub no_csv_header: bool, + /// If enabled, the storage info is not displayed in the output next to the analysis. /// /// This is independent of the storage info appearing in the *output file*. Use a Handlebar From a883fdeeec846b7de632d4fa582abb0dca0270ca Mon Sep 17 00:00:00 2001 From: Dastan <88332432+dastansam@users.noreply.github.com> Date: Wed, 21 Feb 2024 13:23:04 +0200 Subject: [PATCH 15/20] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- substrate/utils/frame/benchmarking-cli/src/pallet/command.rs | 4 ++-- substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index 57c045f3c15c..d5dc6226ab9f 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -787,7 +787,7 @@ fn list_benchmark( } for (pallet, extrinsics) in benchmarks { for extrinsic in extrinsics { - println!("{},{}", pallet, extrinsic); + println!("{pallet},{extrinsic}"); } } }, @@ -796,7 +796,7 @@ fn list_benchmark( println!("pallet"); }; for pallet in benchmarks.keys() { - println!("{}", pallet); + println!("{pallet}"); } }, } diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs index 0f5ceca7239a..89e9781e3753 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -181,6 +181,7 @@ pub struct PalletCmd { pub database_cache_size: u32, /// List and print available benchmarks in a csv-friendly format. + /// /// NOTE: `num_args` and `require_equals` are required to allow `--list` #[arg(long, value_enum, ignore_case = true, num_args = 0..=1, require_equals = true, default_missing_value("All"))] pub list: Option, From 852b947dfa0c89b0b830f1d30b965945c05cc152 Mon Sep 17 00:00:00 2001 From: dastansam Date: Wed, 21 Feb 2024 14:19:46 +0100 Subject: [PATCH 16/20] Remove Default impl --- substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs index 89e9781e3753..6dc56c0724ea 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -41,12 +41,6 @@ pub enum ListOutput { Pallets, } -impl Default for ListOutput { - fn default() -> Self { - ListOutput::All - } -} - /// Benchmark the extrinsic weight of FRAME Pallets. #[derive(Debug, clap::Parser)] pub struct PalletCmd { From ddf80f9d23f06b1725babe20d35fee6637674c1e Mon Sep 17 00:00:00 2001 From: dastansam Date: Wed, 21 Feb 2024 15:11:50 +0100 Subject: [PATCH 17/20] Add prdoc --- prdoc/pr_3395.prdoc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 prdoc/pr_3395.prdoc diff --git a/prdoc/pr_3395.prdoc b/prdoc/pr_3395.prdoc new file mode 100644 index 000000000000..66327429c07a --- /dev/null +++ b/prdoc/pr_3395.prdoc @@ -0,0 +1,13 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: `benchmarking-cli`: refactor `list` and add `--all` option + +doc: + - audience: Node Dev + description: | + Makes `--list` accept two values: "all" and "pallets". The former will list all available benchmarks, the latter will list only pallets. + Also adds `--all` option to run all the available benchmarks. + +crates: + - name: frame-benchmarking-cli From 2f3fc8ed93eb0c7d44d402935b043bf7224859e4 Mon Sep 17 00:00:00 2001 From: dastansam Date: Wed, 21 Feb 2024 15:12:42 +0100 Subject: [PATCH 18/20] Small change --- prdoc/pr_3395.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_3395.prdoc b/prdoc/pr_3395.prdoc index 66327429c07a..3fc724181f8e 100644 --- a/prdoc/pr_3395.prdoc +++ b/prdoc/pr_3395.prdoc @@ -1,7 +1,7 @@ # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json -title: `benchmarking-cli`: refactor `list` and add `--all` option +title: `benchmarking-cli`: refactor `--list` and add `--all` option doc: - audience: Node Dev From d8a0eabd2ad8bb8930bbb8419a8660abf917fbe7 Mon Sep 17 00:00:00 2001 From: dastansam Date: Wed, 21 Feb 2024 15:13:58 +0100 Subject: [PATCH 19/20] Fix prdoc --- prdoc/pr_3395.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_3395.prdoc b/prdoc/pr_3395.prdoc index 3fc724181f8e..803b0aa70071 100644 --- a/prdoc/pr_3395.prdoc +++ b/prdoc/pr_3395.prdoc @@ -1,7 +1,7 @@ # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json -title: `benchmarking-cli`: refactor `--list` and add `--all` option +title: "`benchmarking-cli`: refactor `--list` and add `--all` option" doc: - audience: Node Dev From 1d58eeb117d491c6255f781548b849c4b4efc361 Mon Sep 17 00:00:00 2001 From: dastansam Date: Wed, 21 Feb 2024 15:28:15 +0100 Subject: [PATCH 20/20] Better pr doc --- prdoc/pr_3395.prdoc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/prdoc/pr_3395.prdoc b/prdoc/pr_3395.prdoc index 803b0aa70071..a10fb84fd7f5 100644 --- a/prdoc/pr_3395.prdoc +++ b/prdoc/pr_3395.prdoc @@ -1,13 +1,14 @@ # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json -title: "`benchmarking-cli`: refactor `--list` and add `--all` option" +title: "`benchmarking-cli` `pallet` subcommand: refactor `--list` and add `--all` option" doc: - audience: Node Dev description: | - Makes `--list` accept two values: "all" and "pallets". The former will list all available benchmarks, the latter will list only pallets. - Also adds `--all` option to run all the available benchmarks. + `pallet` subcommand's `--list` now accepts two values: "all" and "pallets". The former will list all available benchmarks, the latter will list only pallets. + Also adds `--all` to run all the available benchmarks and `--no-csv-header` to omit the csv-style header in the output. + NOTE: changes are backward compatible. crates: - name: frame-benchmarking-cli