at the moment I struggle a bit with the question of "How to benchmark the Grandpa pallet". Like it seems it's not possible to auto-generate weights at the moment (see here: https://github.com/paritytech/substrate/issues/7383) and I guess just using the default weights is not really an option if we plan to use this in production (especially if we have to assume that our hardware spec isn't matching the default spec). Apart from that we also use a custom implementation for offense reporting and pass it to the grandpa instance in our runtime.

Now to my actual question: Do I have to write my own benchmark for the grandpa pallet in this case and generate the weights with that? We already did this for the session pallet.

Thanks in advance!

1 Answer 1


Sorry that there is no satisfying solution right now.
The main problem is that some pallets are to tightly coupled.
IIRC the offences pallet has a report_offence callback without a WeightInfo which is used by Babe, Grandpa and ImOnline.
This in term calls an on_offence callback which does also not have a WeightInfo 🤦
So it would start by giving these callbacks a WeightInfo and then using that in Babe etc. to calculate the correct weight.
I think another problem here is that a callbacks' weight highly depends on the runtime config and then needs to either be parametrized or benchmarked multiple times, once for each possible config.
This all would be solved by un-coupling the pallets...

PS: What did you change for the session pallet?

  • Hey Oliver, thanks for your answer, and no need to apologize! So we don't use Babe we use Aura instead, not sure if this changes anything 😅. But from my understanding, it should be possible to write a benchmark in a separate crate and implement it in our runtime for Grandpa, or? The only tricky part seems to be setting up the state of the chain in the benchmark. Are there any other options right now? In reference to your question about the session pallet: We don't use the frame staking pallet (we have our own) but the benchmark in the session pallet has a peer dependency to pallet_staking.
    – Janislav
    Commented Aug 4, 2022 at 11:42
  • Yea the setup is what makes it difficult, since the pallets are very interlinked. I don't see any obvious workaround, this is how the default_weights.rs came about, which also exist longer than they should... I guess someone would have to just fix it once and for all. Commented Aug 12, 2022 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.