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

Clarifications on Gas and Weight Measurement in Frontier Precompiles #1458

Open
magecnion opened this issue Jun 19, 2024 · 0 comments
Open
Labels

Comments

@magecnion
Copy link

magecnion commented Jun 19, 2024

Question

Hello, I have included Frontier in my runtime and I am trying to correctly measure the gas and weights of my precompiles. I have some questions about using the functions that Frontier provides.

  1. What is the reasoning behind performing a record and then a refund? Why not do a record directly after the call?
    UPDATE: I have understood that record+refund is the way to charge computation costs even in the case of dispatch errors. But shouldn't record_cost follow the same approach as record_external_cost, where the cost is first recorded and then refunded?
  2. Within the refund function, a record_cost is also performed. I do not understand the difference between record_cost and record_external_cost. From my understanding, the cost is being recorded twice, causing my call to cost double the gas it should.
  3. Within the refund function, if we are already using the proof_size of the weight, why not also use it to measure the ref_time? There is a comment that explains: TODO: refund ref time when precompile will be benchmarked, but I do not understand what this means.
  4. I am using record_external_cost directly instead of using try_dispatch, which indirectly calls it. My surprise is that this function has no effect on the costs of my call. Investigating the pallet-evm code, I see that in the call there are two parameters set to None which are the ones that later in the code cause the cost not to be recorded. What is the reasoning behind 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

1 participant