Repository navigation
Description
AppliesTo: master (10ae5aae) / V1 (39e19138)
Goal
Use the actual compute units (CU) consumed by executed transactions to improve the budgets requested for future commit transactions. Start unfamiliar work with the maximum 1.4 million CU, then use measurements to reduce the budget for similar work.
This is a follow-up under #1918 and is not a priority for this week. It also relates to the CU-exhaustion failures in #1906 and the compute-budget work in #1779.
Why
Fixed CU estimates can be too small for expensive transactions and unnecessarily large for cheap ones. We want the validator to learn from execution without maintaining a separate, detailed formula for the starting estimate.
On master at 10ae5aae, the committor already reads actual CU consumption from successful transactions for metrics. Extend this into a feedback loop that keeps useful observations for future budget decisions.
Starting at 1.4 million CU means paying higher priority fees while learning. Repeated workloads should then use smaller budgets. Rare workloads and new program versions may continue to need the initial allowance; reducing fees quickly is not guaranteed.
Scope
The intended flow is:
-
Start unfamiliar work with 1.4 million CU. Use this when there is no suitable history, including when a transaction differs substantially from the work already observed.
-
Record actual consumption after successful execution. Read the structured CU value from transaction metadata and keep it with the characteristics of the transaction. Missing measurements must not cause us to lower a budget.
-
Use those observations for similar transactions. Choose a conservative value from the available history and add headroom. Do not lower the budget aggressively after one cheap execution.
-
Recover from confirmed CU exhaustion. Use the same budget-selection helper to request a higher limit, potentially back to 1.4 million CU. Limit retries and retry only the transaction known to have failed. Never replay settlement that already succeeded or a submission whose outcome is still unknown.
Group observations by the work performed, such as delivery method, diff segment count, data size, and instruction mix. Do not group by account address or transaction signature, since that would make every new account start learning again. Separate observations when the executing program changes. Keep history bounded and preserve useful observations across restarts.
A transaction's CU total covers all its instructions. Do not attribute that total to each individual task. A transaction that exhausts its budget gives an incomplete measurement: it shows the allowance was insufficient, but does not reveal the cost of completing the remaining work. Generic program failures should trigger CU recovery only when there is evidence of CU exhaustion.
All budgets remain at or below 1.4 million CU. If the transaction still cannot execute at that limit, increasing the budget cannot solve it. Any change of delivery or splitting must preserve accounts that need to commit together.
Validate unfamiliar workloads, repeated workloads, unusual inputs, missing measurements, restarts, program upgrades, and confirmed CU failures. Compare requested CU, actual consumption, fees, and failure rates to establish whether the feedback improves budgeting.
Activity