pendulum-chain / pendulum-chain/pendulum

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

Open
#177 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:chore
Dominant language
Rust
Stars
45
Forks
13
Avg merge
5d 15h
Merged PRs (30d)
4

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the vesting-manager pallet's remove_vesting_schedule extrinsic and inspect how its hardcoded weight is represented. Read the pallet's mock.rs and benchmarking.rs along with its runtime integration, then build with the benchmarking feature and run ./target/release/spacewalk-standalone benchmark pallet. Done means the extrinsic uses generated benchmark-based weights instead of the hardcoded 10_000_000 value.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
blockchain, build-system, testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.