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

Add a new method in Budget that charges several cost types in a group #1370

Closed
jayz22 opened this issue Mar 26, 2024 · 2 comments
Closed

Add a new method in Budget that charges several cost types in a group #1370

jayz22 opened this issue Mar 26, 2024 · 2 comments

Comments

@jayz22
Copy link
Contributor

jayz22 commented Mar 26, 2024

#1359 introduced a pattern where several cost types have to be charged in group.
Specifically those ParseWasm* and InstantiateWasm* types (10 of them each) must always be charged together. In fact, only the first member in the each group contains the constant cost term that are shared by the group.
A new method in Budget that accepts an array of CostTypes and inputs provides the following benefits:

  • More efficient. Only single mutable borrow of the budget, and can perform more efficient computation (e.g. vector multiplication).
  • Making sure the entirety of the group is charged. We can predefine those groups as constant arrays of [ContractCostType; 10].
@graydon
Copy link
Contributor

graydon commented Mar 27, 2024

The cost to make a charge is quite small and this happens on a very expensive codepath; I'm not concerned about the cost. I agree such an interface might make for a bit of a correctness check (making sure that all the charges happen and none get left out) but .. it seems like it might be quite a bit of plumbing to accomplish, and even then wouldn't necessarily work long term since if we ever add an extension we'd need to runtime protocol-gate it, breaking the static (type-based) grouping.

@jayz22
Copy link
Contributor Author

jayz22 commented Apr 4, 2024

Closing as not planned.

@jayz22 jayz22 closed this as completed Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants