fuel-vm
fuel-vm copied to clipboard
Charge for the fields of transaction as part of `min_fee`
Problem overview
There are several areas of transaction verification that do not have accurate costing. While we have a good framework for pricing opcodes now, our costing of the transaction min fee leaves more to be desired.
Currently the min fee of a transaction is solely based on the amount of chargeable serialized bytes. However, this is likely insufficient for accurate transaction metering. The risks of inaccurate metering are:
- Liveness failures (i.e. skipped consensus rounds)
- Unsynchronizable nodes
- Unanticipated DA expenses, leaving the L1 committer to pick up the tab.
Solution
We've already found several places where we undercharge users https://github.com/FuelLabs/fuel-core/issues/1418.
There's likely more hot spots in transaction validation that aren't captured by our current byte pricing structure. We should investigate this further by building a fuzzing framework https://github.com/FuelLabs/fuel-core/issues/1402 that detects any discrepancies between transaction base cost vs validation time in gas units (i.e. IntoChecked::into_checked
) + disk space delta after execution https://github.com/FuelLabs/fuel-vm/issues/601. This should help capture subtle differences in disk footprint & I/O requirements such as contract bytecode being duplicated into two tables instead unlike the rest of the transaction bytes.
The action list is:
- Create benchmarks to track the impact of each field on execution time.
- https://github.com/FuelLabs/fuel-core/issues/1387
- https://github.com/FuelLabs/fuel-core/issues/1402
- https://github.com/FuelLabs/fuel-core/issues/1442
- Identify fields that should be charged.
- Apply a new charging model to the codebase. It should affect the final
min_fee
of the transaction.- https://github.com/FuelLabs/fuel-core/issues/1403
- https://github.com/FuelLabs/fuel-vm/issues/601
- https://github.com/FuelLabs/fuel-core/issues/1418
- https://github.com/FuelLabs/fuel-core/issues/1161
- Verify that a new prices/cost covers execution time.
Initial benchmarking shows we need to increase minimum fee based on predicates & per signature recovery, potentially adjust gas_per_byte / how bytes are metered.