Repository navigation
feat: --fee-profile reporter — measure per-method fees for developer suggestions - #94
Conversation
…suggestions Opt-in pytest options --fee-profile=PATH and --fee-profile-headroom (default 1.25). Every deploy/write executed through gltest records the consumed fee data from Studio receipts (fees.consumed.executionConsumed / messageFeesConsumed); at session end PATH is written as a JSON fee profile (max observed x headroom, decimal strings) that frontends pass verbatim as 'suggestions' to createTransactionKit from @genlayer/transaction-kit. Time-unit allocations are omitted: the backend reports consumed fee amounts only, not time-unit usage. Testnet receipts expose no consumed-fee data yet, so profiles measured there come out empty (warned at session end). Also catches uv.lock up with the genlayer-py<0.20.0 pin relax from #91.
|
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 ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
First real end-to-end measurement completed (studio stack with GenVM built from main — see genlayer-studio#1674 validation comments). Two findings to fold into this PR:
First measured profile for reference (Storage contract, 1.25 headroom over consumed ~314.5k): { "deploy": { "executionBudgetPerRound": "393170", "totalMessageFees": "0" },
"methods": { "update_storage": { "executionBudgetPerRound": "393143", "totalMessageFees": "0" } } } |
What
Opt-in fee-profile reporter for gltest:
--fee-profile=PATH(+--fee-profile-headroom, default 1.25). Every deploy and write executed through gltest records the consumed fee data from its receipt; at session end PATH is written as a JSON fee profile sized at max observed × headroom, all values as decimal strings.The file is designed to be shipped to the frontend verbatim and passed as
suggestionstocreateTransactionKit(@genlayer/transaction-kitcore, suggestions API as of 747165a):When a suggestion matches a call, the kit's
PolicyQuote.sourcebecomes'developer'and the panel renders "Sized from the developer's measured fee profile".Output schema
{ "version": 1, "network": "studionet", "measuredAt": "2026-06-10T12:00:00Z", "deploy": { "executionBudgetPerRound": "625000", "totalMessageFees": "0" }, "methods": { "create_bet": { "executionBudgetPerRound": "312500", "totalMessageFees": "12500" } } }What is measured
Studio/localnet receipts carry a canonical
feesobject; the reporter readsfees.consumed:executionBudgetPerRound←consumed.executionConsumed(Studio's chargeable per-round sum: receipt + nondet output + storage)totalMessageFees←consumed.messageFeesConsumed(a measured0is recorded — it is a real measurement)leaderTimeunitsAllocation/validatorTimeunitsAllocationare never emitted: the backend reports consumed fee amounts, not time-unit usage. Missing keys fall back to preset/network defaults in the kit.Testnet receipts (decoded from the consensus contracts) expose no consumed-fee data yet, and direct/sim mode is gasless — sessions there produce an empty profile with a session-end warning instead of fake numbers.
Implementation
gltest/fees/—FeeProfileCollector(max-tracking, Decimal-based headroom withceil, JSON writer), singleton +maybe_record_fee_observationno-op guard.Contract.transactandContractFactory.deploy_contract_txafterwait_for_transaction_receipt— one-line, never raises.PluginConfig.fee_profile_path/.fee_profile_headroom,GeneralConfigaccessors,pytest_sessionstartreset,pytest_sessionfinishwrite (reporter errors never fail the run).uv.lockcaught up with thegenlayer-py<0.20.0pin relax from feat(gltest): fee-aware transactions and backend-agnostic success assertions #91.Verification
uv run gltest tests/gltest/ tests/gltest_cli/→ 101 passeduv run gltest tests/glsim/→ 71 passed;tests/gltest_direct/test_sdk_loader.py→ 12 passed