Repository navigation
fix(fees): stop double-counting the observed execution fee - #242
Conversation
Fee estimates built from a simulation sized executionBudgetPerRound from
execution_fee_consumed + feeReport.totalEstimatedFee. Both are the execution
fee consumed by the same simulated round, so the recommended budget came out
about twice what the round needs (rc.11 studio-next vector: 188,707,800,000,000
instead of 94,623,000,000,000).
observedSimulationFeeUsage now mirrors Studio v0.123.0-rc.11
(backend/protocol_rpc/fees.py: recommended_fee_preset and
_observed_chargeable_execution_fee):
observed = execution_fee_consumed if > 0
else feeReport.chargeableExecution.totalExecution if > 0
else feeReport.totalEstimatedFee
budget = max(observed, feeReport.genvmBuckets.execution)
per round = max(policy.executionBudgetFloor, budget + headroom), or 0
when nothing was observed
executionFeeConsumed and executionFeeReportTotal stay on SimulationFeeUsage
for existing consumers but no longer feed a sum. New fields report the
figures actually used: observedExecutionFee, genvmExecutionRequired and
observedExecutionBudget. StudioGenvmFeeBucketReport gains the execution,
receipt and layout keys Studio already emits.
estimateTransactionFeesForWrite still returns Studio's recommendedPreset when
present; its observed block and its gen_call fallback use the corrected
logic through the same helper.
Validation: the rc.11 vector now yields 94,623,000,000,000 (1.2 x
78,852,500,000,000, matching Studio's preset). New tests cover the
chargeableExecution fallback, the totalEstimatedFee fallback, a missing
genvmBuckets, an all-zero report, the policy floor, and the gen_call
fallback of estimateTransactionFeesForWrite. npm test -- --run (213 passed,
no type errors), npm run lint, tsc --noEmit and npm run build all pass.
Fixes #241
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Fixes #241
What
execution_fee_consumedandfeeReport.totalEstimatedFee. It now mirrors Studio v0.123.0-rc.11recommended_fee_preset/_observed_chargeable_execution_fee(backend/protocol_rpc/fees.py):execution_fee_consumedif > 0, elsefeeReport.chargeableExecution.totalExecutionif > 0, elsefeeReport.totalEstimatedFeefeeReport.genvmBuckets.execution)src/contracts/actions.ts(observedSimulationFeeUsage),src/types/transactions.ts.chargeableExecutionandgenvmBucketsare read in camelCase, the only form Studio emits; absent means 0.executionFeeConsumedandexecutionFeeReportTotalfor existing consumers (no longer summed) and addsobservedExecutionFee,genvmExecutionRequired,observedExecutionBudget(onSimulationFeeUsage);StudioGenvmFeeBucketReportgainsexecution,receipt,layout.Why
Both summed figures are the execution fee of the same simulated round, so
executionBudgetPerRoundcame out about 2x: on a real rc.11 simulation on studio-next, 188707800000000 instead of 94623000000000. Estimates from simulation (and theestimateTransactionFeesForWritefallback when Studio returns no preset) deposited twice what the round needs.estimateTransactionFeesForWritealready prefers Studio'srecommendedPreset, so on rc.11 its distribution was right, but itsobservedblock showed the inflated figure.Testing done
recommended_fee_presetcomputes from those inputs.npm test(vitest --typecheck): 213 passed, no type errors.tsc --noEmitand eslint clean. New cases intests/contracts-actions.test.ts.recommendedExecutionBudgetPerRound94623000000000, equal to the server preset'sexecutionBudgetPerRound. (checked with genlayer-py; the logic is identical.)Decisions made
executionBudgetFloor). Studio's preset floor also takesgenvmStartBudgetFloorand receipt headroom for message-emitting txs into account; on rc.11 defaultsgenvmBuckets.executionalready exceeds it, so results match. Aligning the floor is a possible follow-up.Checks
Reviewing tips
The behavioral change is the single block in the observed-usage helper; the rest is tests and reporting fields.
User facing release notes
Fee estimates from simulation no longer double the execution budget per round, so deposits for writes and deploys estimated from a simulation are about half of what they were and match Studio's recommended preset.