paritytech / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
8.39k stars 2.65k forks source link

[Benchmarking] Getting info before the extrinsic fails with an error #12872

Open Chralt98 opened 1 year ago

Chralt98 commented 1 year ago

Hey valuable Substrate engineers!

I just was running the following command for benchmarking my pallets. The problem I've got is that I only see an error, but would love to know the exact extrinsic which caused it.

./target/release/zeitgeist benchmark pallet --chain=dev --steps=2 --repeat=2 --pallet=zrml_prediction_markets --extrinsic='*' --execution=Native --wasm-execution=compiled --detailed-log-output --heap-pages=4096 --template="./misc/weight_template.hbs" --output=./zrml/prediction-markets/src/weights.rs

Output, if failure:

...
Error: Input("InvalidMarketPeriod")

But there is no info about the pallet (we know it's prediction-markets here, but it could be --pallet=*) and the extrinsic benchmark which caused it. That would be useful for a quick fix. So that one can see the benchmark name before the error output.

bkchr commented 1 year ago

CC @ggwpez

ggwpez commented 1 year ago

Well, you can try running the tests first cargo test --features runtime-benchmarks in your pallet dir.
Otherwise the log output sometimes tells you which benchmark failed. You can also run them one-by-one after listing them with the --list command.

If you still see a failure only with your real runtime, then it must be a discrepancy between the mocked and the real runtime that is causing it.
Are you talking about this one https://github.com/zeitgeistpm/zeitgeist/tree/main/zrml/prediction-markets? Then please give me a commit hash that I can try.

Chralt98 commented 1 year ago

Well, you can try running the tests first cargo test --features runtime-benchmarks in your pallet dir.

That is fine, thanks. I like that.

Are you talking about this one https://github.com/zeitgeistpm/zeitgeist/tree/main/zrml/prediction-markets? Then please give me a commit hash that I can try.

No, it's okay @ggwpez . It is a specific workflow on a PR here. I just struggled multiple times and thought about telling you this. It just would be useful to print out the extrinsic name before a failure happens.

ggwpez commented 1 year ago

It literally prints this a few lines before failing Pallet: "zrml_liquidity_mining", Extrinsic: "set_per_block_distribution".
But yea, we could improve the error message a bit.

Chralt98 commented 1 year ago

Oh, this is a misunderstanding. It is not the extrinsic set_per_block_distribution. It was another extrinsic. That's why I am asking for a change.