pendulum icon indicating copy to clipboard operation
pendulum copied to clipboard

Add weights/runtime mock/benchmarking to vesting-manager pallet

Open RustNinja opened this issue 2 years ago • 1 comments

remove_vesting_schedule extrinsic uses hardcoded weighs

#[pallet::weight(10_000_000)]

#[pallet::call]
	impl<T: Config> Pallet<T> {
        #[pallet::call_index(0)]
        #[pallet::weight(10_000_000)]
        pub fn remove_vesting_schedule(
	        origin: OriginFor<T>,
	        who: AccountIdLookupOf<T>,
	        schedule_index: u32,
        ) -> DispatchResultWithPostInfo {
	        ensure_root(origin)?;
	        let who = T::Lookup::lookup(who)?;
	        T::VestingSchedule::remove_vesting_schedule(&who, schedule_index)?;
        
	        Self::deposit_event(Event::VestingScheduleRemoved { who, schedule_index });
        
	        // waive the fee
	        Ok(Pays::No.into())
        }
}

To automatically regenerate weight for extrinsic need :

  • add mock.rs
  • add benchmarking.rs
  • add pallet to runtime
  • build runtime with benchmarking feature
  • run ./target/release/spacewalk-standalone benchmark pallet to regenerate weights.

RustNinja avatar Mar 18 '23 23:03 RustNinja

Moved to icebox.

TorstenStueber avatar Dec 16 '23 18:12 TorstenStueber