test(fees): cover allocation tree emit trap gates#309
Conversation
Add intercontract cases asserting that an empty or under-budget message-fee-allocation tree makes emit hard-trap instead of silently emitting nothing. Golden stdout/hash files are produced on Linux CI; the nix test shell does not instantiate on macOS.
|
|
📝 WalkthroughWalkthroughThis PR adds four regression test scenarios covering message fee allocation failure modes. The tests verify that genvm hard-traps (rather than silently emitting) when budget is exhausted or when allocation trees are empty across internal messaging, deployment, external ETH send, and post-message emission paths. ChangesIntercontract Fee Allocation Regression Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@tests/cases/stable/py/intercontract/alloc_budget_exhausted.py`:
- Line 3: The file currently uses a wildcard import ("from genlayer.types import
*") which triggers Ruff F403; replace it with explicit imports of only the
symbols used in this test (inspect the file for identifiers from genlayer.types
and import them directly, e.g. "from genlayer.types import SymbolA, SymbolB"
replacing SymbolA/SymbolB with the actual names), ensuring no unused names
remain so lint passes; keep the import statement on the same line where "from
genlayer.types import *" appears and remove the wildcard.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 25e9d63d-41c7-427a-a9d7-31c447431c39
📒 Files selected for processing (8)
tests/cases/stable/py/intercontract/alloc_budget_exhausted.jsonnettests/cases/stable/py/intercontract/alloc_budget_exhausted.pytests/cases/stable/py/intercontract/alloc_empty_deploy.jsonnettests/cases/stable/py/intercontract/alloc_empty_deploy.pytests/cases/stable/py/intercontract/alloc_empty_eth_send.jsonnettests/cases/stable/py/intercontract/alloc_empty_eth_send.pytests/cases/stable/py/intercontract/alloc_empty_post_message.jsonnettests/cases/stable/py/intercontract/alloc_empty_post_message.py
| @@ -0,0 +1,16 @@ | |||
| # { "Depends": "py-genlayer:test" } | |||
| import genlayer as gl | |||
| from genlayer.types import * | |||
There was a problem hiding this comment.
Replace wildcard import to satisfy Ruff F403.
Line 3 uses from genlayer.types import *, which Ruff flags and can fail lint-gated CI. Import only referenced symbols explicitly.
Suggested fix
-from genlayer.types import *
+from genlayer.types import Address🧰 Tools
🪛 Ruff (0.15.15)
[error] 3-3: from genlayer.types import * used; unable to detect undefined names
(F403)
🤖 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/cases/stable/py/intercontract/alloc_budget_exhausted.py` at line 3, The
file currently uses a wildcard import ("from genlayer.types import *") which
triggers Ruff F403; replace it with explicit imports of only the symbols used in
this test (inspect the file for identifiers from genlayer.types and import them
directly, e.g. "from genlayer.types import SymbolA, SymbolB" replacing
SymbolA/SymbolB with the actual names), ensuring no unused names remain so lint
passes; keep the import statement on the same line where "from genlayer.types
import *" appears and remove the wildcard.
Source: Linters/SAST tools
Description
Adds four
intercontractintegration cases pinning genvm's behavior when the node-provided message-fee-allocation tree cannot fund an emitted message. genvm is a pure consumer of this tree (executor/src/wasi/genlayer_sdk.rs); when no matching node exists or its budget is too small, an emit must hard-trap, never silently produce zero emissions.These guard the genvm side of a cross-repo issue where an empty allocation tree (the node's
DisallowedFeeAllocation([])fallback, returned when the deployed consensus provisioned nothing) led to zero internal messages while the parent still finalized. Root cause is consensus/node; this locks genvm so a silent-zero cannot regress here.Tests
alloc_empty_post_message— empty tree, PostMessage emit must trap (OOM fees internal)alloc_empty_deploy— empty tree, DeployContract emit must trapalloc_empty_eth_send— empty tree, external EthSend must trap (OOM fees external); the balance check passes first, so the trap comes from the allocation lookupalloc_budget_exhausted— a matching wildcard node butbudgetbelow the computed message fee, must trap on the budget gateThe positive direction (populated wildcard tree -> emission succeeds) is already covered by the existing
send_message/deploy/send_message_ethcases.Golden files
The
.stdout/.hashexpected files are intentionally not included. The runner auto-blesses them on first run, but the nix test shell only instantiates on Linux (it pulls glibc), so they must be generated on Linux/CI. Run the fouralloc_*cases once on Linux and commit the blessed goldens.Test-only change; no runtime behavior change.
Summary by CodeRabbit