Skip to content

feat: Rex4 relative gas detention cap for volatile data access#184

Merged
Troublor merged 2 commits intomainfrom
cz/feat/gas-detention-cap
Mar 10, 2026
Merged

feat: Rex4 relative gas detention cap for volatile data access#184
Troublor merged 2 commits intomainfrom
cz/feat/gas-detention-cap

Conversation

@RealiCZ
Copy link
Contributor

@RealiCZ RealiCZ commented Mar 9, 2026

Summary

Rex4 changes gas detention from an absolute cap to a relative cap.

  • Previously, when a transaction accessed volatile data (block env, beneficiary, oracle), the compute gas limit was capped at an absolute value (e.g., 20M).
  • If the transaction had already consumed >20M compute gas before the access, it halted immediately — even though the intent is to limit post-access computation, not penalize prior work.
  • Now in Rex4+, the detention cap is relative to current usage at the access point: effective_limit = usage_at_access + cap. A transaction that used 25M gas before accessing TIMESTAMP gets an effective limit of 45M (25M + 20M), allowing 20M more gas after access. Pre-Rex4 specs retain the absolute-cap behavior for backward compatibility.

Changes

  • ComputeGasTracker::set_detained_limit(): Computes relative cap (tx_usage + cap) for REX4+, absolute cap for pre-REX4.
  • execution_result(): Detects detention-caused halts by comparing against detained_limit instead of the raw cap. Reports detained_limit in VolatileDataAccessOutOfGas.limit so actual > limit always holds.

Test plan

  • cargo test -p mega-evm -- gas_detention — 5 new REX4 relative cap tests pass
  • cargo test -p mega-evm — full test suite (488 tests) passes

@RealiCZ RealiCZ force-pushed the cz/feat/gas-detention-cap branch from dbfa572 to 4c793f1 Compare March 9, 2026 09:09
@Troublor Troublor merged commit ef336d2 into main Mar 10, 2026
2 checks passed
@Troublor Troublor deleted the cz/feat/gas-detention-cap branch March 10, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants