Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frame::benchmarking: Support custom Config trait #162

Open
bkchr opened this issue Jun 21, 2023 · 3 comments
Open

frame::benchmarking: Support custom Config trait #162

bkchr opened this issue Jun 21, 2023 · 3 comments
Labels
I5-enhancement An additional feature request. T1-FRAME This PR/Issue is related to core FRAME, the framework.

Comments

@bkchr
Copy link
Member

bkchr commented Jun 21, 2023

When creating a benchmark, sometimes it requires special logic. Currently we add this logic to the main Config trait, hidden behind the runtime-benchmarks feature flag. It would be cleaner if there would be a benchmarking specific Config trait. This trait could maybe set the pallet Config trait directly as super trait and then we may not need to change that much?

CC @ggwpez @sam0x17

@ggwpez
Copy link
Member

ggwpez commented Jun 21, 2023

Pallet NFT is grouping all benchmark related things into its own trait, so it just adds one item to the Config.

Do you mean we should add a new item like #[pallet::benchmark_config] to the pallet?
Benchmarks already support where bounds, so maybe it is enough to add <T as Config>: BenchmarkHelperTrait and then have a impl pallet::BenchmarkHelperTrait for Runtime in the runtime file without any change in FRAME.

Would be a good thing to explore in a benchmarking examples pallet.

@bkchr
Copy link
Member Author

bkchr commented Jun 21, 2023

Do you mean we should add a new item like #[pallet::benchmark_config] to the pallet?

Yeah something like this.

trait BenchmarkingConfig: pallet::Config {
    type Whatever;
}

In the end this is just some "cosmetic". IMO it feels "dirty" to add the benchmarking helper to the main pallet Config.

@sam0x17
Copy link
Contributor

sam0x17 commented Jun 21, 2023

This seems reasonable to me

@juangirini juangirini transferred this issue from paritytech/substrate Aug 24, 2023
@the-right-joyce the-right-joyce added I5-enhancement An additional feature request. T1-FRAME This PR/Issue is related to core FRAME, the framework. and removed J0-enhancement labels Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I5-enhancement An additional feature request. T1-FRAME This PR/Issue is related to core FRAME, the framework.
Projects
Status: Backlog
Development

No branches or pull requests

5 participants