Skip to content

test: cover studio message fee edge cases#1651

Open
MuncleUscles wants to merge 12 commits into
mainfrom
codex/studio-fee-edge-regressions
Open

test: cover studio message fee edge cases#1651
MuncleUscles wants to merge 12 commits into
mainfrom
codex/studio-fee-edge-regressions

Conversation

@MuncleUscles
Copy link
Copy Markdown
Member

@MuncleUscles MuncleUscles commented Jun 2, 2026

Summary

  • report Mode 1 message fees as GenVM-executable now that Studio passes the Mode 1 bucket through to GenVM
  • add a low-level regression that external messages reject non-zero declaredBudget at reveal, matching consensus v0.6

Validation

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

Summary by CodeRabbit

  • New Features

    • Studio fee configuration now advertises GenVM execution availability for message handling.
  • Bug Fixes

    • External messages with a non-zero declared budget are rejected at reveal time to prevent improper fee acceptance.
  • Chores

    • CI workflows updated for more reliable disk usage, timeouts, and linting tool pinning.
  • Tests

    • Integration/unit tests updated for validator synchronization and compatibility with the updated GenLayer import/API shape.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ae5d2eaa-f487-40b0-a00e-c6580f333628

📥 Commits

Reviewing files that changed from the base of the PR and between a612614 and 43fc367.

📒 Files selected for processing (1)
  • tests/integration/test_upgrade_contract.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/integration/test_upgrade_contract.py

📝 Walkthrough

Walkthrough

Expose Mode1 GenVM execution in studio fees; migrate tests and embedded contracts to import genlayer as gl with gl.contract.* APIs; add validator-propagation waits; pin GenVM linter and adjust CI/workflows; small example formatting changes.

Changes

GenVM Execution and Fee Updates

Layer / File(s) Summary
Fee configuration and external message budget validation
backend/protocol_rpc/fees.py, tests/unit/test_studio_fees.py
studio_fee_config() sets capabilities.messageFees.mode1.genvmExecution = True. Tests updated and a new unit test asserts external messages with non-zero declaredBudget raise MessageDeclaredBudgetInsufficient at reveal time.
Test & embedded contract API migration
tests/integration/icontracts/contracts/*, tests/integration/test_upgrade_contract.py, tests/test_linter_endpoint.py, tests/unit/test_get_contract_schema_for_code_endpoint.py
Test modules and embedded contract sources now add import genlayer as gl and use gl.contract.Contract, gl.contract.get_at, gl.contract.deploy, and related namespaced helpers instead of wildcard imports and older gl helpers.
Integration test infra: validator wait
tests/integration/icontracts/conftest.py, tests/integration/test_upgrade_contract.py
Add _wait_for_validator_count polling helper and call it from setup_validators and upgrade-test fixtures to wait for validator registry propagation before running tests.
CI & workflow updates
.github/workflows/*
Pin genvm-linter install to a repo commit and set GENVM_VERSION=v0.2.16; add disk cleanup steps and explicit timeouts in integration CI; tighten curl options in load-test workflow; make SonarCloud step conditional; set Codecov fail_ci_if_error=false.
Examples formatting & requirements
examples/contracts/log_indexer.py, backend/requirements.txt
Update contract header dependency identifier and reformat LogIndexer.vector_store type annotation; bump genvm-linter in backend requirements.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • cristiam86

Poem

🐰 In studio fields the changes bloom anew,
GenVM wakes and testing hops on cue,
Contracts don their gl.contract attire,
CI trimmed and pinned — lint runs without ire,
A rabbit cheers the merge — one hop, then two!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.24% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The pull request description provides a clear summary of changes and validation steps, but does not follow the structured template with distinct sections like 'What', 'Why', 'Testing done', and 'Decisions made'. Consider restructuring the description to follow the template sections (What, Why, Testing done, Decisions made) for consistency with repository standards, though the core information is present.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately summarizes the main change: adding test coverage for studio message fee edge cases, which is directly supported by the unit test additions in test_studio_fees.py.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/studio-fee-edge-regressions

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.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 2, 2026

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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/genvm-lint.yml (1)

5-17: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Trigger paths include tests/integration/icontracts/contracts/** but the lint steps never lint them.

The workflow triggers on changes under tests/integration/icontracts/contracts/** (lines 9 and 17), yet the two lint loops only iterate over examples/contracts/*.py (line 41) and tests/load/contracts/*.py tests/direct/contracts/*.py (line 56). The integration contracts migrated in this PR will trigger the job but go unlinted, so the migration is not actually validated here.

Either add the integration contracts to a lint loop or drop them from the trigger paths to avoid a misleading green check.

🔧 Example: lint integration contracts too
       - name: Lint test contracts
         env:
           # These test contracts currently pin v0.2.x runner hashes.
           GENVM_VERSION: v0.2.16
         run: |
           failed=0
-          for f in tests/load/contracts/*.py tests/direct/contracts/*.py; do
+          for f in tests/load/contracts/*.py tests/direct/contracts/*.py tests/integration/icontracts/contracts/**/*.py; do
             [ -f "$f" ] || continue
             echo "::group::$f"
             if ! genvm-lint check "$f"; then
               failed=1
             fi
             echo "::endgroup::"
           done
           exit $failed

Also applies to: 39-64

🤖 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 @.github/workflows/genvm-lint.yml around lines 5 - 17, The workflow triggers
include "tests/integration/icontracts/contracts/**" but the lint loops only
iterate over "examples/contracts/*.py" and "tests/load/contracts/*.py
tests/direct/contracts/*.py", so integration contracts are not linted; either
add the integration pattern to the lint loops (e.g., include
"tests/integration/icontracts/contracts/*.py" in the arrays or loop that
processes "examples/contracts/*.py" and the load/direct patterns) or remove
"tests/integration/icontracts/contracts/**" from the workflow triggers to avoid
a misleading pass — update the path patterns in the lint job to include the
integration contracts or remove them from the trigger paths accordingly.
🤖 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.

Inline comments:
In @.github/workflows/genvm-lint.yml:
- Around line 32-33: The CI workflow installs genvm-linter from a specific
commit that packages as genvm-linter==0.10.0 while requirements.txt pins
genvm-linter==0.7.1, causing mismatched lint behavior; pick one canonical
version and make both places consistent: either update requirements.txt to pin
genvm-linter==0.10.0 (or a matching released tag) and keep the workflow
commit/installation, or change the genvm-lint workflow to install the release
matching 0.7.1 (or use pip install genvm-linter==0.7.1); ensure the console
entry genvm-lint still maps to genvm_linter.cli:cli and update the single source
of truth (requirements.txt or the workflow) accordingly.

---

Outside diff comments:
In @.github/workflows/genvm-lint.yml:
- Around line 5-17: The workflow triggers include
"tests/integration/icontracts/contracts/**" but the lint loops only iterate over
"examples/contracts/*.py" and "tests/load/contracts/*.py
tests/direct/contracts/*.py", so integration contracts are not linted; either
add the integration pattern to the lint loops (e.g., include
"tests/integration/icontracts/contracts/*.py" in the arrays or loop that
processes "examples/contracts/*.py" and the load/direct patterns) or remove
"tests/integration/icontracts/contracts/**" from the workflow triggers to avoid
a misleading pass — update the path patterns in the lint job to include the
integration contracts or remove them from the trigger paths accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5fef2db0-e353-4da4-ac26-b010bffb3e67

📥 Commits

Reviewing files that changed from the base of the PR and between 1006ed4 and ee5f986.

📒 Files selected for processing (7)
  • .github/workflows/genvm-lint.yml
  • tests/integration/icontracts/contracts/error_execution_contract.py
  • tests/integration/icontracts/contracts/intelligent_oracle_factory.py
  • tests/integration/icontracts/contracts/multi_file_contract/__init__.py
  • tests/integration/icontracts/contracts/multi_read_erc20.py
  • tests/integration/icontracts/contracts/multi_tenant_storage.py
  • tests/integration/icontracts/contracts/read_erc20.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/integration/icontracts/contracts/error_execution_contract.py
  • tests/integration/icontracts/contracts/multi_tenant_storage.py

Comment thread .github/workflows/genvm-lint.yml Outdated
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 (1)
tests/integration/icontracts/conftest.py (1)

46-64: 💤 Low value

Polling loop aborts on the first transient RPC failure.

assert has_success_status(validators_result) inside the poll loop turns a single transient non-success response into an immediate AssertionError, defeating the purpose of retrying until the timeout. Consider treating a non-success response as a retryable iteration instead.

♻️ Optional: retry on transient failures
     while time.monotonic() < deadline:
         validators_result = post_request_localhost(
             payload("sim_getAllValidators")
         ).json()
-        assert has_success_status(validators_result)
-        last_count = len(validators_result.get("result", []))
+        if not has_success_status(validators_result):
+            time.sleep(0.5)
+            continue
+        last_count = len(validators_result.get("result", []))
         if last_count >= min_count:
🤖 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/integration/icontracts/conftest.py` around lines 46 - 64, The poll loop
in _wait_for_validator_count should not abort on a single transient RPC failure;
replace the assert has_success_status(validators_result) with logic that treats
non-success responses as retryable (e.g., if not
has_success_status(validators_result): time.sleep(0.5); continue), and only
parse/update last_count when has_success_status returns True (using
post_request_localhost and validators_result.get("result", []) accordingly),
keeping the existing timeout behavior and final AssertionError if min_count is
not reached.
🤖 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 `@tests/integration/icontracts/conftest.py`:
- Around line 46-64: The poll loop in _wait_for_validator_count should not abort
on a single transient RPC failure; replace the assert
has_success_status(validators_result) with logic that treats non-success
responses as retryable (e.g., if not has_success_status(validators_result):
time.sleep(0.5); continue), and only parse/update last_count when
has_success_status returns True (using post_request_localhost and
validators_result.get("result", []) accordingly), keeping the existing timeout
behavior and final AssertionError if min_count is not reached.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 677e9cb3-f8d0-42c4-9bb2-b6186d95dc4e

📥 Commits

Reviewing files that changed from the base of the PR and between ee5f986 and 18796ef.

📒 Files selected for processing (19)
  • .github/workflows/backend_integration_tests_pr.yml
  • .github/workflows/frontend-unit-tests.yml
  • .github/workflows/load-test-oha.yml
  • .github/workflows/unit-tests-pr.yml
  • examples/contracts/log_indexer.py
  • tests/integration/icontracts/conftest.py
  • tests/integration/icontracts/contracts/company_naming.py
  • tests/integration/icontracts/contracts/error_execution_contract.py
  • tests/integration/icontracts/contracts/error_llm_contract.py
  • tests/integration/icontracts/contracts/error_web_contract.py
  • tests/integration/icontracts/contracts/genvm_smoke_v1.py
  • tests/integration/icontracts/contracts/intelligent_oracle.py
  • tests/integration/icontracts/contracts/intelligent_oracle_factory.py
  • tests/integration/icontracts/contracts/multi_file_contract/__init__.py
  • tests/integration/icontracts/contracts/multi_file_contract/other.py
  • tests/integration/icontracts/contracts/multi_read_erc20.py
  • tests/integration/icontracts/contracts/multi_tenant_storage.py
  • tests/integration/icontracts/contracts/read_erc20.py
  • tests/integration/icontracts/contracts/utf8_roundtrip_contract.py
✅ Files skipped from review due to trivial changes (1)
  • tests/integration/icontracts/contracts/intelligent_oracle.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/integration/icontracts/contracts/multi_file_contract/init.py

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant