difftreelog
feat(rmrk) benchmark reject_nft
in: master
3 files changed
pallets/proxy-rmrk-core/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/benchmarking.rs
+++ b/pallets/proxy-rmrk-core/src/benchmarking.rs
@@ -104,6 +104,10 @@
}
}
+ fn current_nft_id(&self) -> RmrkNftId {
+ self.current_nft_id
+ }
+
fn build<T: Config>(&mut self, owner: &T::AccountId) -> Result<RmrkNftId, DispatchError> {
create_max_nft::<T>(owner, self.collection_id)?;
self.current_nft_id += 1;
@@ -115,10 +119,11 @@
&mut self,
owner: &T::AccountId,
height: u32,
- ) -> Result<RmrkNftId, DispatchError> {
+ ) -> Result<(RmrkNftId, RmrkNftId), DispatchError> {
self.build::<T>(owner)?;
- let mut prev_nft_id = self.current_nft_id;
+ let root_nft_id = self.current_nft_id;
+ let mut prev_nft_id = root_nft_id;
for _ in 0..height {
self.build::<T>(owner)?;
@@ -141,7 +146,7 @@
let deepest_nft_id = self.current_nft_id;
- Ok(deepest_nft_id)
+ Ok((root_nft_id, deepest_nft_id))
}
}
@@ -207,7 +212,7 @@
let mut nft_builder = NftBuilder::new(collection_id);
let src_nft_id = nft_builder.build::<T>(&caller)?;
- let target_nft_id = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 2)?;
+ let (_, target_nft_id) = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 2)?;
}: _(
RawOrigin::Signed(caller),
collection_id,
@@ -230,7 +235,7 @@
let mut target_nft_builder = NftBuilder::new(target_collection_id);
let fake_target_nft_id = target_nft_builder.build::<T>(&caller)?;
- let target_nft_id = target_nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
+ let (_, target_nft_id) = target_nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
let new_owner = <RmrkAccountIdOrCollectionNftTuple<T::AccountId>>::CollectionAndNftTuple(
target_collection_id,
@@ -255,13 +260,46 @@
actual_new_owner
)
+ reject_nft {
+ let caller: T::AccountId = account("caller", 0, SEED);
+ let sender: T::AccountId = account("sender", 0, SEED);
+
+ create_max_collection::<T>(&sender)?;
+ let src_collection_id = 0;
+
+ create_max_collection::<T>(&caller)?;
+ let target_collection_id = 1;
+
+ let mut src_nft_builder = NftBuilder::new(src_collection_id);
+ let (src_root_nft_id, _) = src_nft_builder.build_tower::<T>(&sender, NESTING_BUDGET - 1)?;
+
+ let mut target_nft_builder = NftBuilder::new(target_collection_id);
+ let target_nft_id = target_nft_builder.build::<T>(&caller)?;
+
+ let new_owner = <RmrkAccountIdOrCollectionNftTuple<T::AccountId>>::CollectionAndNftTuple(
+ target_collection_id,
+ target_nft_id
+ );
+
+ <Pallet<T>>::send(
+ RawOrigin::Signed(sender.clone()).into(),
+ src_collection_id,
+ src_root_nft_id,
+ new_owner,
+ )?;
+ }: _(
+ RawOrigin::Signed(caller),
+ src_collection_id,
+ src_root_nft_id
+ )
+
set_property {
let caller: T::AccountId = account("caller", 0, SEED);
create_max_collection::<T>(&caller)?;
let collection_id = 0;
let mut nft_builder = NftBuilder::new(collection_id);
- let nft_id = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
+ let (_, nft_id) = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
let key = create_data();
let value = create_data();
@@ -279,7 +317,7 @@
let collection_id = 0;
let mut nft_builder = NftBuilder::new(collection_id);
- let nft_id = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
+ let (_, nft_id) = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
let priorities = create_u32_array();
}: _(
RawOrigin::Signed(caller),
@@ -296,7 +334,7 @@
let collection_id = 0;
let mut nft_builder = NftBuilder::new(collection_id);
- let nft_id = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
+ let (_, nft_id) = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
let resource = create_basic_resource();
}: _(
RawOrigin::Signed(caller),
@@ -313,7 +351,7 @@
let collection_id = 0;
let mut nft_builder = NftBuilder::new(collection_id);
- let nft_id = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
+ let (_, nft_id) = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
let resource = create_composable_resource();
}: _(
RawOrigin::Signed(caller),
@@ -330,7 +368,7 @@
let collection_id = 0;
let mut nft_builder = NftBuilder::new(collection_id);
- let nft_id = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
+ let (_, nft_id) = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
let resource = create_slot_resource();
}: _(
RawOrigin::Signed(caller),
@@ -347,7 +385,7 @@
let collection_id = 0;
let mut nft_builder = NftBuilder::new(collection_id);
- let nft_id = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
+ let (_, nft_id) = nft_builder.build_tower::<T>(&caller, NESTING_BUDGET - 1)?;
let resource = create_basic_resource();
<Pallet<T>>::add_basic_resource(
@@ -376,7 +414,7 @@
let mut nft_builder = NftBuilder::new(collection_id);
let root_nft_id = 1;
- let nested_nft_id = nft_builder.build_tower::<T>(&admin, NESTING_BUDGET - 1)?;
+ let (_, nested_nft_id) = nft_builder.build_tower::<T>(&admin, NESTING_BUDGET - 1)?;
let resource = create_basic_resource();
let new_owner = <RmrkAccountIdOrCollectionNftTuple<T::AccountId>>::AccountId(caller.clone());
@@ -414,7 +452,7 @@
let mut nft_builder = NftBuilder::new(collection_id);
let root_nft_id = 1;
- let nested_nft_id = nft_builder.build_tower::<T>(&admin, NESTING_BUDGET - 1)?;
+ let (_, nested_nft_id) = nft_builder.build_tower::<T>(&admin, NESTING_BUDGET - 1)?;
let resource = create_basic_resource();
<Pallet<T>>::add_basic_resource(
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth628 /// - `origin`: sender of the transaction628 /// - `origin`: sender of the transaction629 /// - `rmrk_collection_id`: collection id of the nft to be accepted629 /// - `rmrk_collection_id`: collection id of the nft to be accepted630 /// - `rmrk_nft_id`: nft id of the nft to be accepted630 /// - `rmrk_nft_id`: nft id of the nft to be accepted631 #[transactional]631 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]632 #[pallet::weight(<SelfWeightOf<T>>::reject_nft())]632 #[transactional]633 pub fn reject_nft(633 pub fn reject_nft(634 origin: OriginFor<T>,634 origin: OriginFor<T>,635 rmrk_collection_id: RmrkCollectionId,635 rmrk_collection_id: RmrkCollectionId,pallets/proxy-rmrk-core/src/weights.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/weights.rs
+++ b/pallets/proxy-rmrk-core/src/weights.rs
@@ -40,6 +40,7 @@
fn mint_nft() -> Weight;
fn send() -> Weight;
fn accept_nft() -> Weight;
+ fn reject_nft() -> Weight;
fn set_property() -> Weight;
fn set_priority() -> Weight;
fn add_basic_resource() -> Weight;
@@ -61,11 +62,10 @@
// Storage: Common CollectionProperties (r:0 w:1)
// Storage: Common CollectionById (r:0 w:1)
// Storage: RmrkCore UniqueCollectionId (r:0 w:1)
- // Storage: RmrkCore RmrkInernalCollectionId (r:0 w:1)
fn create_collection() -> Weight {
- (40_146_000 as Weight)
+ (40_456_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
- .saturating_add(T::DbWeight::get().writes(9 as Weight))
+ .saturating_add(T::DbWeight::get().writes(8 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
// Storage: Common CollectionProperties (r:1 w:1)
@@ -76,7 +76,7 @@
// Storage: Nonfungible TokensBurnt (r:0 w:1)
// Storage: Common AdminAmount (r:0 w:1)
fn destroy_collection() -> Weight {
- (44_905_000 as Weight)
+ (43_812_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
@@ -84,7 +84,7 @@
// Storage: Common CollectionById (r:1 w:1)
// Storage: Common CollectionProperties (r:1 w:0)
fn change_collection_issuer() -> Weight {
- (22_502_000 as Weight)
+ (22_032_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -94,7 +94,7 @@
// Storage: Nonfungible TokensMinted (r:1 w:0)
// Storage: Nonfungible TokensBurnt (r:1 w:0)
fn lock_collection() -> Weight {
- (23_705_000 as Weight)
+ (23_314_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -107,7 +107,7 @@
// Storage: Nonfungible TokenData (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:1)
fn mint_nft() -> Weight {
- (40_727_000 as Weight)
+ (40_075_000 as Weight)
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(5 as Weight))
}
@@ -121,7 +121,7 @@
// Storage: Nonfungible TokenChildren (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:2)
fn send() -> Weight {
- (73_288_000 as Weight)
+ (71_474_000 as Weight)
.saturating_add(T::DbWeight::get().reads(12 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
@@ -135,17 +135,32 @@
// Storage: Nonfungible TokenChildren (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:2)
fn accept_nft() -> Weight {
- (81_985_000 as Weight)
+ (79_890_000 as Weight)
.saturating_add(T::DbWeight::get().reads(15 as Weight))
.saturating_add(T::DbWeight::get().writes(7 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
// Storage: Common CollectionProperties (r:1 w:0)
// Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenProperties (r:1 w:5)
+ // Storage: Nonfungible TokenData (r:5 w:5)
+ // Storage: Nonfungible TokenChildren (r:9 w:4)
+ // Storage: Nonfungible TokensBurnt (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:5 w:5)
+ // Storage: Nonfungible Allowance (r:5 w:0)
+ // Storage: Nonfungible Owned (r:0 w:5)
+ fn reject_nft() -> Weight {
+ (236_754_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(29 as Weight))
+ .saturating_add(T::DbWeight::get().writes(25 as Weight))
+ }
+ // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
+ // Storage: Common CollectionProperties (r:1 w:0)
+ // Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn set_property() -> Weight {
- (50_535_000 as Weight)
+ (48_370_000 as Weight)
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -155,7 +170,7 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn set_priority() -> Weight {
- (49_443_000 as Weight)
+ (47_128_000 as Weight)
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -172,7 +187,7 @@
// Storage: Nonfungible Owned (r:0 w:1)
// Storage: Common CollectionPropertyPermissions (r:0 w:1)
fn add_basic_resource() -> Weight {
- (104_226_000 as Weight)
+ (101_501_000 as Weight)
.saturating_add(T::DbWeight::get().reads(16 as Weight))
.saturating_add(T::DbWeight::get().writes(12 as Weight))
}
@@ -189,7 +204,7 @@
// Storage: Nonfungible Owned (r:0 w:1)
// Storage: Common CollectionPropertyPermissions (r:0 w:1)
fn add_composable_resource() -> Weight {
- (105_197_000 as Weight)
+ (103_004_000 as Weight)
.saturating_add(T::DbWeight::get().reads(16 as Weight))
.saturating_add(T::DbWeight::get().writes(12 as Weight))
}
@@ -206,7 +221,7 @@
// Storage: Nonfungible Owned (r:0 w:1)
// Storage: Common CollectionPropertyPermissions (r:0 w:1)
fn add_slot_resource() -> Weight {
- (105_899_000 as Weight)
+ (102_613_000 as Weight)
.saturating_add(T::DbWeight::get().reads(16 as Weight))
.saturating_add(T::DbWeight::get().writes(12 as Weight))
}
@@ -221,7 +236,7 @@
// Storage: Nonfungible Allowance (r:1 w:0)
// Storage: Nonfungible Owned (r:0 w:1)
fn remove_resource() -> Weight {
- (82_997_000 as Weight)
+ (82_084_000 as Weight)
.saturating_add(T::DbWeight::get().reads(16 as Weight))
.saturating_add(T::DbWeight::get().writes(5 as Weight))
}
@@ -231,7 +246,7 @@
// Storage: Nonfungible TokenData (r:5 w:0)
// Storage: Nonfungible TokenProperties (r:2 w:1)
fn accept_resource() -> Weight {
- (56_848_000 as Weight)
+ (56_426_000 as Weight)
.saturating_add(T::DbWeight::get().reads(10 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -246,7 +261,7 @@
// Storage: Nonfungible Allowance (r:1 w:0)
// Storage: Nonfungible Owned (r:0 w:1)
fn accept_resource_removal() -> Weight {
- (86_303_000 as Weight)
+ (85_631_000 as Weight)
.saturating_add(T::DbWeight::get().reads(17 as Weight))
.saturating_add(T::DbWeight::get().writes(5 as Weight))
}
@@ -262,11 +277,10 @@
// Storage: Common CollectionProperties (r:0 w:1)
// Storage: Common CollectionById (r:0 w:1)
// Storage: RmrkCore UniqueCollectionId (r:0 w:1)
- // Storage: RmrkCore RmrkInernalCollectionId (r:0 w:1)
fn create_collection() -> Weight {
- (40_146_000 as Weight)
+ (40_456_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
- .saturating_add(RocksDbWeight::get().writes(9 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(8 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
// Storage: Common CollectionProperties (r:1 w:1)
@@ -277,7 +291,7 @@
// Storage: Nonfungible TokensBurnt (r:0 w:1)
// Storage: Common AdminAmount (r:0 w:1)
fn destroy_collection() -> Weight {
- (44_905_000 as Weight)
+ (43_812_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
}
@@ -285,7 +299,7 @@
// Storage: Common CollectionById (r:1 w:1)
// Storage: Common CollectionProperties (r:1 w:0)
fn change_collection_issuer() -> Weight {
- (22_502_000 as Weight)
+ (22_032_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -295,7 +309,7 @@
// Storage: Nonfungible TokensMinted (r:1 w:0)
// Storage: Nonfungible TokensBurnt (r:1 w:0)
fn lock_collection() -> Weight {
- (23_705_000 as Weight)
+ (23_314_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -308,7 +322,7 @@
// Storage: Nonfungible TokenData (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:1)
fn mint_nft() -> Weight {
- (40_727_000 as Weight)
+ (40_075_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
.saturating_add(RocksDbWeight::get().writes(5 as Weight))
}
@@ -322,7 +336,7 @@
// Storage: Nonfungible TokenChildren (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:2)
fn send() -> Weight {
- (73_288_000 as Weight)
+ (71_474_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(12 as Weight))
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
}
@@ -336,17 +350,32 @@
// Storage: Nonfungible TokenChildren (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:2)
fn accept_nft() -> Weight {
- (81_985_000 as Weight)
+ (79_890_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(15 as Weight))
.saturating_add(RocksDbWeight::get().writes(7 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
// Storage: Common CollectionProperties (r:1 w:0)
// Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenProperties (r:1 w:5)
+ // Storage: Nonfungible TokenData (r:5 w:5)
+ // Storage: Nonfungible TokenChildren (r:9 w:4)
+ // Storage: Nonfungible TokensBurnt (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:5 w:5)
+ // Storage: Nonfungible Allowance (r:5 w:0)
+ // Storage: Nonfungible Owned (r:0 w:5)
+ fn reject_nft() -> Weight {
+ (236_754_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(29 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(25 as Weight))
+ }
+ // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
+ // Storage: Common CollectionProperties (r:1 w:0)
+ // Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn set_property() -> Weight {
- (50_535_000 as Weight)
+ (48_370_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -356,7 +385,7 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn set_priority() -> Weight {
- (49_443_000 as Weight)
+ (47_128_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -373,7 +402,7 @@
// Storage: Nonfungible Owned (r:0 w:1)
// Storage: Common CollectionPropertyPermissions (r:0 w:1)
fn add_basic_resource() -> Weight {
- (104_226_000 as Weight)
+ (101_501_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(16 as Weight))
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
}
@@ -390,7 +419,7 @@
// Storage: Nonfungible Owned (r:0 w:1)
// Storage: Common CollectionPropertyPermissions (r:0 w:1)
fn add_composable_resource() -> Weight {
- (105_197_000 as Weight)
+ (103_004_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(16 as Weight))
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
}
@@ -407,7 +436,7 @@
// Storage: Nonfungible Owned (r:0 w:1)
// Storage: Common CollectionPropertyPermissions (r:0 w:1)
fn add_slot_resource() -> Weight {
- (105_899_000 as Weight)
+ (102_613_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(16 as Weight))
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
}
@@ -422,7 +451,7 @@
// Storage: Nonfungible Allowance (r:1 w:0)
// Storage: Nonfungible Owned (r:0 w:1)
fn remove_resource() -> Weight {
- (82_997_000 as Weight)
+ (82_084_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(16 as Weight))
.saturating_add(RocksDbWeight::get().writes(5 as Weight))
}
@@ -432,7 +461,7 @@
// Storage: Nonfungible TokenData (r:5 w:0)
// Storage: Nonfungible TokenProperties (r:2 w:1)
fn accept_resource() -> Weight {
- (56_848_000 as Weight)
+ (56_426_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(10 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -447,7 +476,7 @@
// Storage: Nonfungible Allowance (r:1 w:0)
// Storage: Nonfungible Owned (r:0 w:1)
fn accept_resource_removal() -> Weight {
- (86_303_000 as Weight)
+ (85_631_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(17 as Weight))
.saturating_add(RocksDbWeight::get().writes(5 as Weight))
}