near / nearcore

Reference client for NEAR Protocol
https://near.org
GNU General Public License v3.0
2.32k stars 622 forks source link

Refactor gas profiles to store call counts #8795

Closed aborg-dev closed 1 year ago

aborg-dev commented 1 year ago

At the moment the ProfileDataV3 stores the total consumed gas for each host function and action. This makes Compute Cost calculation harder than necessary because we need to divide the total consumed gas by the host function call before multiplying it by the corresponding compute cost.

We could simplify this by instead storing the call count for each ExtCost inside the profile as it can be used to derive both resulting gas usage and compute usage.

Relatedly, we also store a counter EXT_COSTS_COUNTER alongside GasCounter for the use in parameter estimator. We should consider whether it should be merged directly into GasCounter to eliminate duplication with Profiles that we track anyway unconditionally.

aborg-dev commented 1 year ago

This is no longer feasible as we need to store fractional gas usage for https://github.com/near/nearcore/pull/8914. See https://github.com/near/nearcore/issues/8908 for more context