Skip to content

fix(p2p): move gas-limit admission out of GasTxValidator - #25269

Merged
vezenovm merged 1 commit into
merge-train/fairiesfrom
mv/port-25221-gas-limit-admission
Aug 19, 2026
Merged

fix(p2p): move gas-limit admission out of GasTxValidator#25269
vezenovm merged 1 commit into
merge-train/fairiesfrom
mv/port-25221-gas-limit-admission

Conversation

@vezenovm

Copy link
Copy Markdown
Contributor

Port of #25221 (merged into merge-train/fairies-v5) to the next line, via merge-train/fairies.

Fixes #25167 on this line.

createTxValidatorForAcceptingTxsOverRPC skips the gas-limits check when isSimulation is set, since gas estimation submits intentionally inflated GasSettings.forEstimation limits (2x the per-tx cap). That exemption was lost because GasTxValidator (added when fee enforcement is on) re-ran the same limit check internally, so any simulation with skipFeeEnforcement: false was rejected with TX_ERROR_GAS_LIMIT_TOO_HIGH.

Changes (same as #25221):

  • The gas-limit check is removed from GasTxValidator entirely, and GasLimitsValidator is split into MinGasLimitsValidator (protocol overhead floor) and MaxGasLimitsValidator (per-tx ceiling), making the pair the sole owner of declared gas-limit admission. Only the ceiling is exempted for isSimulation; a tx declaring less than the fixed protocol overheads can never be mined, so the floor also runs during simulation.
  • Split up the GasTxValidator module and tests; factories that relied on the embedded check now include it explicitly.

Port notes: applied cleanly except public_tx_simulator.ts, where the original PR only reworded a comment on a MAX_PROCESSABLE_L2_GAS assertion that no longer exists on this line, so that hunk was dropped.

Fixes #25167

`createTxValidatorForAcceptingTxsOverRPC` skips `GasLimitsValidator`
when `isSimulation` is set, since gas estimation submits
intentionally-inflated `GasSettings.forEstimation` limits (2x the per-tx
cap). **That exemption is lost**: `GasTxValidator` (added when fee
enforcement is on) re-ran the same limit check internally. No optional
limit defaults the ceiling to `MAX_PROCESSABLE_L2_GAS` rather than
disabling it.

Any simulation with `skipFeeEnforcement: false` was rejected with
`TX_ERROR_GAS_LIMIT_TOO_HIGH`.

- The gas-limit check is removed from `GasTxValidator` entirely, and
`GasLimitsValidator` is split into `MinGasLimitsValidator` (protocol
overhead floor) and `MaxGasLimitsValidator` (per-tx ceiling), making the
pair the sole owner of declared gas-limit admission. It is cleaner to an
have an ordered list of filters and activate them given certain
conditions rather than nesting filters. Nesting filters will inevtiably
lead to more bugs like this one.
- Split up the GasTxValidator module and tests

Factories that relied on the embedded check now include it explicitly.
The majority of the diff is some reorganization in
`yarn-project/p2p/src/msg_validators/tx_validator/gas_validator.test.ts`
due to the splitting of the validators.

The two limits have different exemption rules, which is why they are now
separate filters: only the ceiling is exempted for `isSimulation`. A tx
declaring less than the fixed protocol overheads can never be mined, so
rejecting it during simulation is the earliest useful feedback rather
than a surprise on `sendTx`.

That makes simulation stricter than the base branch, not just equal to
it. The floor previously reached the simulation path only as a side
effect of the nested call inside `GasTxValidator`, so it was already
absent whenever `skipFeeEnforcement` was set, which is the default for
`wallet.simulate()`. The send path is unaffected either way, since
`isSimulation` is only ever set by `PXE.simulateTx`.

---------

Co-authored-by: Nicolas Chamo <nicolas@chamo.com.ar>
@vezenovm
vezenovm requested a review from nchamo August 19, 2026 09:05
@vezenovm
vezenovm enabled auto-merge (squash) August 19, 2026 09:13
@vezenovm
vezenovm merged commit 766905f into merge-train/fairies Aug 19, 2026
10 checks passed
@vezenovm
vezenovm deleted the mv/port-25221-gas-limit-admission branch August 19, 2026 09:27
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