From 17d61ffe263bf3f1b0e1fa7c29f0bd8c5549133e Mon Sep 17 00:00:00 2001 From: gabriele-0201 Date: Wed, 13 Dec 2023 17:58:41 +0100 Subject: [PATCH] fix benchmarks --- .../pallets/blobs/src/benchmarking.rs | 27 +++++++------------ .../sugondat-kusama/src/xcm_config.rs | 7 ----- .../runtimes/test/src/xcm_config.rs | 7 ----- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/sugondat-chain/pallets/blobs/src/benchmarking.rs b/sugondat-chain/pallets/blobs/src/benchmarking.rs index ea09058c..5e4cc649 100644 --- a/sugondat-chain/pallets/blobs/src/benchmarking.rs +++ b/sugondat-chain/pallets/blobs/src/benchmarking.rs @@ -7,7 +7,7 @@ use codec::Encode; use frame_benchmarking::__private::traits::Hooks; #[allow(unused)] use frame_benchmarking::v2::{benchmarks, impl_benchmark_test_suite, whitelisted_caller}; -use frame_support::{traits::Get, BoundedVec}; +use frame_support::traits::Get; use frame_system::RawOrigin; use sp_std::vec; @@ -30,12 +30,8 @@ mod benchmarks { sp_io::storage::set(b":extrinsic_index", &(ext_index).encode()); Blobs::::submit_blob( RawOrigin::Signed(caller.clone()).into(), - ext_index, - ext_index - .to_le_bytes() - .to_vec() - .try_into() - .expect("Impossible convert blob into BoundedVec"), + (ext_index as u128).into(), + ext_index.to_le_bytes().to_vec(), ) .expect("Preparation Extrinsic failed"); } @@ -56,20 +52,16 @@ mod benchmarks { sp_io::storage::set(b":extrinsic_index", &(x).encode()); // Create a random blob that needs to be hashed on chain - let blob: BoundedVec = vec![23u8] - .repeat(y as usize) - .try_into() - .expect("Impossible convert blob into BoundedVec"); - + let blob = vec![23u8; y as usize]; #[extrinsic_call] - _(RawOrigin::Signed(caller), 0, blob); + _(RawOrigin::Signed(caller), 0.into(), blob); // Check that an item is inserted in the BlobList and // the new value stored in TotalBlobs are correct assert_eq!(BlobList::::get().len(), x as usize + 1); assert_eq!(TotalBlobs::::get(), x as u32 + 1); // the blob size of all the previus sumbitted blob si 4 bytes (u32.to_le_bytes()) - assert_eq!(TotalBlobsSize::::get(), (x * 4) + y); + assert_eq!(TotalBlobSize::::get(), (x * 4) + y); } #[benchmark] @@ -84,9 +76,10 @@ mod benchmarks { Blobs::::on_finalize(15u32.into()); } - assert_eq!(BlobList::::get().len(), x as usize); - assert_eq!(TotalBlobs::::get(), x as u32); - assert_eq!(TotalBlobsSize::::get(), x * 4); + // Every storage Item should be killed + assert_eq!(BlobList::::get().len(), 0); + assert_eq!(TotalBlobs::::get(), 0); + assert_eq!(TotalBlobSize::::get(), 0); } impl_benchmark_test_suite!(Blobs, crate::mock::new_test_ext(), crate::mock::Test); diff --git a/sugondat-chain/runtimes/sugondat-kusama/src/xcm_config.rs b/sugondat-chain/runtimes/sugondat-kusama/src/xcm_config.rs index 3ba94324..244fdc99 100644 --- a/sugondat-chain/runtimes/sugondat-kusama/src/xcm_config.rs +++ b/sugondat-chain/runtimes/sugondat-kusama/src/xcm_config.rs @@ -188,11 +188,6 @@ pub type TrustedTeleporters = (); /// The parent relay chain is the accepted reserve for the native asset. pub type TrustedReserve = ParentRelayChainAndAsset; -#[cfg(feature = "runtime-benchmarks")] -parameter_types! { - pub ReachableDest: Option = Some(Parent.into()); -} - impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; @@ -219,8 +214,6 @@ impl pallet_xcm::Config for Runtime { type MaxLockers = ConstU32<8>; // TODO: needs benchmarked weights type WeightInfo = pallet_xcm::TestWeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); diff --git a/sugondat-chain/runtimes/test/src/xcm_config.rs b/sugondat-chain/runtimes/test/src/xcm_config.rs index 07be91d3..ff30a0a7 100644 --- a/sugondat-chain/runtimes/test/src/xcm_config.rs +++ b/sugondat-chain/runtimes/test/src/xcm_config.rs @@ -150,11 +150,6 @@ pub type XcmRouter = WithUniqueTopic<( XcmpQueue, )>; -#[cfg(feature = "runtime-benchmarks")] -parameter_types! { - pub ReachableDest: Option = Some(Parent.into()); -} - impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; @@ -180,8 +175,6 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = LocationToAccountId; type MaxLockers = ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = ();