We use some external pallets that are highly configurable. The weight of the extrinsics in these pallets is highly dependent on the callback supplied in the config, and the existing benchmarks don't properly account for that. Is there any way to write a custom benchmark for an externally defined pallet?
In general it should not be necessary to implement custom benchmarks for external pallets.
You just have to configure the concrete callbacks in your runtime and re-run the benchmark. The weight of the callbacks will then be included in the output.
This is easier that to annotate weights in interface. Otherwise all interfaces that can be used as callback would need to expose their weight info as well.
In your example i dont see a difference. Since every runtime config needs to re-run benches, the effort for the
CurrencyHooks will be included.
Yes, you always should generate the weights based on your runtime configuration and your hardware requirements.
See and example from one of the FRAME pallets: the
In Polkadot has its own Weights file and is different than the Wights file in another chain, Kusama for example.
Then in your Config have to specify your Weights. See the runtime file in Kusama.
Take a look into this previous answer on StackExchange: Benchmark FRAME pallets, for a more complete explanation about it.
For anyone finding this post in the future.. We got a working solution based on the frame_system benchmarks. See our custom benchmark here. The idea is to define a new dummy
Config item, write benchmarks for them, and apply the generated weights to the original pallet.