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

Benchmark of Precompile executed code #1348

Open
PierreOssun opened this issue Mar 20, 2024 · 3 comments
Open

Benchmark of Precompile executed code #1348

PierreOssun opened this issue Mar 20, 2024 · 3 comments
Labels

Comments

@PierreOssun
Copy link

Question

Hello,
I would like to know if there is a way to benchmark code executed in a precompile prior to the pallet dispatch call.
For example in this code it first:

  • ensure that the caller matches the public key
  • derive the accountId from this public key

to finally dispatch the call on behalf of this AccountId.
However only the Weight from the dispatched call will be charged, not the weight for this pre-execution.
As a DoS protection we are charging a overestimated ref_time amount.

Is there a way to properly benchmark this piece of code ?

@boundless-forest
Copy link
Collaborator

I think the gas fee has been handled in the try_dispatch, no need to record_gas manually before try_dispatch.

@PierreOssun
Copy link
Author

Hi @boundless-forest,
In try_dispatch only the weight of the RuntimeCall is recorded. See here.
Also in this test that the expect_cost charged is equal to the weight of the call (prior calling dispatch, the weight of the call calculated by benchmarking) and the const gas that is charged at the beginning of the precompile.
But all the execution in the precompile prior to dispatch the call is not automatically charged, hence will need proper benchmarking

@magecnion
Copy link

I'm facing the same problem; I need to benchmark the precompiles properly. Any updates on that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants