fix(p2p): move gas-limit admission out of GasTxValidator - #25269
Merged
Conversation
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>
nchamo
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of #25221 (merged into
merge-train/fairies-v5) to thenextline, viamerge-train/fairies.Fixes #25167 on this line.
createTxValidatorForAcceptingTxsOverRPCskips the gas-limits check whenisSimulationis set, since gas estimation submits intentionally inflatedGasSettings.forEstimationlimits (2x the per-tx cap). That exemption was lost becauseGasTxValidator(added when fee enforcement is on) re-ran the same limit check internally, so any simulation withskipFeeEnforcement: falsewas rejected withTX_ERROR_GAS_LIMIT_TOO_HIGH.Changes (same as #25221):
GasTxValidatorentirely, andGasLimitsValidatoris split intoMinGasLimitsValidator(protocol overhead floor) andMaxGasLimitsValidator(per-tx ceiling), making the pair the sole owner of declared gas-limit admission. Only the ceiling is exempted forisSimulation; a tx declaring less than the fixed protocol overheads can never be mined, so the floor also runs during simulation.GasTxValidatormodule 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 aMAX_PROCESSABLE_L2_GASassertion that no longer exists on this line, so that hunk was dropped.