stellar / rs-soroban-env

Rust environment for Soroban contracts.
Apache License 2.0
59 stars 40 forks source link

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

Closed jayz22 closed 4 months ago

jayz22 commented 4 months ago

https://github.com/stellar/rs-soroban-env/pull/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:

graydon commented 4 months ago

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 commented 4 months ago

Closing as not planned.