Skip to content

fix: allow studio mode1 message fee buckets#1650

Merged
MuncleUscles merged 3 commits into
mainfrom
codex/studio-fee-scenarios
Jun 2, 2026
Merged

fix: allow studio mode1 message fee buckets#1650
MuncleUscles merged 3 commits into
mainfrom
codex/studio-fee-scenarios

Conversation

@MuncleUscles
Copy link
Copy Markdown
Member

@MuncleUscles MuncleUscles commented Jun 2, 2026

Description

Allows fee-bearing Mode 1 message transactions in Studio to reach GenVM with a positive message bucket and an empty allocation list. Consensus v0.6 now defines Mode 1 as bucket-only, with per-emission feeParams/declaredBudget supplied by GenVM emissions, so Studio should not reject it before execution.

Updates unit coverage for:

  • the fee adapter returning [] for fee-bearing Mode 1 allocations
  • node execution passing bucket_totals[2] to GenVM while message_fee_allocation remains []

Verification

  • .venv/bin/python -m pytest tests/unit/test_studio_fees.py::test_genvm_message_fee_allocation_uses_empty_allocation_list_for_fee_bearing_mode1 tests/unit/test_node_state_proxy_metrics.py::test_run_genvm_passes_mode1_message_bucket_with_empty_allocations -q
  • .venv/bin/python -m pytest tests/unit/test_studio_fees.py tests/unit/test_node_state_proxy_metrics.py -q
  • .venv/bin/pre-commit run --files backend/protocol_rpc/fees.py tests/unit/test_node_state_proxy_metrics.py tests/unit/test_studio_fees.py

Summary by CodeRabbit

Bug Fixes

  • Mode 1 message fee allocation now properly handles bucket-based scenarios without requiring per-emission support
  • Transaction value conversion process refined

Tests

  • Test suite updated to verify Mode 1 message bucket handling with GenVM when emission allocations are absent

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

Warning

Review limit reached

@MuncleUscles, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 16 minutes and 32 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: baa70426-3a32-452a-9231-4f64815323c2

📥 Commits

Reviewing files that changed from the base of the PR and between 30ec47f and d2cc6ec.

📒 Files selected for processing (1)
  • tests/unit/test_transactions_parser.py
📝 Walkthrough

Walkthrough

This PR removes the Mode1MessageFeesRequireGenVMPerEmissionSupport exception and updates fee allocation to return an empty list for Mode1 messages; it also changes transaction value parsing to use direct integer coercion instead of the _json_safe_numbers helper.

Changes

Mode1 GenVM Bucket-Only Fee Allocation and Transaction Value Coercion

Layer / File(s) Summary
Mode1 GenVM bucket-only fee allocation
backend/protocol_rpc/fees.py, tests/unit/test_studio_fees.py, tests/unit/test_node_state_proxy_metrics.py
Exception class Mode1MessageFeesRequireGenVMPerEmissionSupport is removed; genvm_message_fee_allocation now returns an empty list when message allocations are unavailable instead of raising. Studio fees and proxy metrics tests are updated to verify the new empty-list behavior and confirm GenVM receives the message bucket via bucket_totals[2].
Transaction value integer coercion
backend/database_handler/transactions_processor.py
The _parse_transaction_data method now coerces transaction values directly to int() when present, replacing the prior _json_safe_numbers helper function call.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Mode1 fees now flow to GenVM's bucket so clear,
No exception to fear when allocations aren't here,
And transaction values, precise as can be,
Convert straight to int—simple, honest, decree!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: allow studio mode1 message fee buckets' clearly summarizes the main change: enabling Mode 1 message fee buckets in Studio.
Description check ✅ Passed The description covers what changed, why (Consensus v0.6 bucket-only semantics), testing done, and verification steps, but misses some sections from the template like 'Decisions made' and 'User facing release notes'.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/studio-fee-scenarios

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
tests/unit/test_node_state_proxy_metrics.py (1)

449-453: ⚡ Quick win

Consider using GENVM_UNMETERED_DATA_FEE_BUCKET constant instead of magic number.

The magic number (1 << 256) - 1 appears inline, but test_studio_fees.py imports and uses the GENVM_UNMETERED_DATA_FEE_BUCKET constant for the same value (see line 1526 in test_studio_fees.py). Using the constant would improve readability and maintainability.

📖 Suggested refactor
+from backend.protocol_rpc.fees import (
+    GENVM_UNMETERED_DATA_FEE_BUCKET,
     StudioFeePolicy,
     create_fee_accounting,
     required_fee_deposit,
 )
     assert fee_context.bucket_totals == [
-        (1 << 256) - 1,
-        (1 << 256) - 1,
+        GENVM_UNMETERED_DATA_FEE_BUCKET,
+        GENVM_UNMETERED_DATA_FEE_BUCKET,
         55,
     ]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/test_node_state_proxy_metrics.py` around lines 449 - 453, Replace
the repeated magic number (1 << 256) - 1 in the assertion for
fee_context.bucket_totals with the existing GENVM_UNMETERED_DATA_FEE_BUCKET
constant used elsewhere (e.g., in test_studio_fees.py); update the assertion so
the first two elements reference GENVM_UNMETERED_DATA_FEE_BUCKET instead of the
literal to improve readability and maintainability while keeping the expected
third element (55) unchanged.
backend/database_handler/transactions_processor.py (1)

93-93: ⚡ Quick win

Add return type hint.

The method signature lacks a return type hint. As per coding guidelines, all Python code should include type hints.

📝 Suggested fix
 `@staticmethod`
-def _parse_transaction_data(transaction_data: Transactions) -> dict:
+def _parse_transaction_data(transaction_data: Transactions) -> dict[str, any]:

As per coding guidelines: "Include type hints in all Python code".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/database_handler/transactions_processor.py` at line 93, The function
_parse_transaction_data currently lacks an explicit return type; update its
signature to include a precise type hint (for example -> Dict[str, Any] or ->
dict[str, Any]) and ensure typing imports (Dict, Any or use built-in generic
dict with str/Any) are added or adjusted at the top of the module; modify the
signature for _parse_transaction_data(transaction_data: Transactions) to include
the chosen return type and update any related type imports to satisfy the
project's typing guidelines.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@backend/database_handler/transactions_processor.py`:
- Line 93: The function _parse_transaction_data currently lacks an explicit
return type; update its signature to include a precise type hint (for example ->
Dict[str, Any] or -> dict[str, Any]) and ensure typing imports (Dict, Any or use
built-in generic dict with str/Any) are added or adjusted at the top of the
module; modify the signature for _parse_transaction_data(transaction_data:
Transactions) to include the chosen return type and update any related type
imports to satisfy the project's typing guidelines.

In `@tests/unit/test_node_state_proxy_metrics.py`:
- Around line 449-453: Replace the repeated magic number (1 << 256) - 1 in the
assertion for fee_context.bucket_totals with the existing
GENVM_UNMETERED_DATA_FEE_BUCKET constant used elsewhere (e.g., in
test_studio_fees.py); update the assertion so the first two elements reference
GENVM_UNMETERED_DATA_FEE_BUCKET instead of the literal to improve readability
and maintainability while keeping the expected third element (55) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 469391a7-6e5e-4216-a50a-4076c86bd2a0

📥 Commits

Reviewing files that changed from the base of the PR and between 74bd055 and 30ec47f.

📒 Files selected for processing (4)
  • backend/database_handler/transactions_processor.py
  • backend/protocol_rpc/fees.py
  • tests/unit/test_node_state_proxy_metrics.py
  • tests/unit/test_studio_fees.py

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 2, 2026

@MuncleUscles MuncleUscles merged commit 9b81641 into main Jun 2, 2026
12 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

🎉 This PR is included in version 0.121.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant