Change how `ExtrinsicBaseWeight` is calculated
Right now the ExtrinsicBaseWeight is calculated by taking no-op transactions: https://github.com/paritytech/polkadot-sdk/blob/89b67bc69e5b8cdad49c378f6db0a48873548d35/substrate/utils/frame/benchmarking-cli/src/overhead/README.md#L41
With the introduction of transaction extensions, each extension already exposes their own weight. So, right now we are including the transaction extension weight two times. Once in the ExtrinsicBaseWeight and once via the extensions itself.
To solve this we need to have a benchmark that only benchmarks the extrinsic part that isn't included by the transaction extensions. So, probably just benchmarking the extrinsic with an empty set of extensions should do the trick.
CC @ggwpez
The difficult part is that the extrinsic will fail to dispatch.
Also even bare extrinsics have some transaction extension like CheckWeight.
One solution could be to require a benchmark for the signature verification so we know we should add this for the base weight of signed extrinsics.
And then for every expensive operation of the extrinsic dispatch.
Or we keep our benchmark it gives us the total weight for signed remark, we substract all the transaction extension weight, and if the extrinsic is signed we also substract the signature verification. Then we have the base weight for bare and general transaction.
The difficult part is that the extrinsic will fail to dispatch. Also even bare extrinsics have some transaction extension like
CheckWeight.
I don't get what you mean by this.
The difficult part is that the extrinsic will fail to dispatch. Also even bare extrinsics have some transaction extension like
CheckWeight.I don't get what you mean by this.
ok, I was imagining that we would use the same Extrinsic type configured by the runtime in a bare variant. In this case, the remark will fail to apply, and it still has some transaction extension.
If we have a dedicated Extrinsic type with no transaction extension just for benchmarking purpose indeed it should be good. Like Type BenchmarkUncheckedExtrisnic = generic::UncheckedExtrinsic<Address, Call, Signature, ()>;.
But may also want to benchmark the cost of Executive::apply_extrinsic, which is not so easy.
For the bare extrinsics and CheckWeight comment, I just wanted to emphasize that bare extrinsics also execute transaction extensions when they are applied so we can't directly use them hoping to bypass transaction extensions.
Edit: but also I think the simplest way to benchmark the base weight is to keep our benchmark it gives us the total weight for signed remark, we substract all the transaction extension weight, it gives us the signed base weight, we also substract the signature verification it gives us the general and bare base weight.
Edit: but also I think the simplest way to benchmark the base weight is to keep our benchmark it gives us the total weight for signed remark, we substract all the transaction extension weight, it gives us the signed base weight, we also substract the signature verification it gives us the general and bare base weight.
Yeah this sounds like a do-able approach.