Skip to content

Conversation

@naijauser
Copy link
Contributor

Description

This PR explores the use of a custom Benchmarking Config Trait that houses Benchmarking helpers based on @bkchr 's suggestion in #162. It's an attempt to replace the existing approach that uses a type in the pallet Config.

Inside benchmarking.rs

pub trait BenchmarkConfig: pallet::Config {
	type Helper: BenchmarkHelper<Self>;
}

pub trait BenchmarkHelper<T: Config> {
	fn initialize_and_get_id() -> u32;
}

impl<T: Config> BenchmarkHelper<T> for () {
	fn initialize_and_get_id() -> u32 {
	    ...
	}
}

#[benchmarks(where T: BenchmarkConfig)]
mod benchmarks {
    ...
}

Inside the Runtime lib.rs

impl pallet_example_custom_benchmarking_config::benchmarking::BenchmarkConfig for Runtime {
	type Helper = ();
}

Checklist

  • My PR includes a detailed description as outlined in the "Description" and its two subsections above.
  • My PR follows the labeling requirements of this project (at minimum one label for T required)
    • External contributors: Use /cmd label <label-name> to add labels
    • Maintainers can also add labels manually
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

@naijauser naijauser requested a review from a team as a code owner January 14, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant