perf(p2p): stop tx validation at the first failure where reasons are not needed - #25255
Draft
vezenovm wants to merge 11 commits into
Draft
perf(p2p): stop tx validation at the first failure where reasons are not needed#25255vezenovm wants to merge 11 commits into
vezenovm wants to merge 11 commits into
Conversation
GasTxValidator re-ran the gas-limit check that the RPC factory's isSimulation exemption is meant to skip, so simulations with fee enforcement were rejected with TX_ERROR_GAS_LIMIT_TOO_HIGH. GasLimitsValidator is now the sole owner of declared gas-limit admission; gossip stage 1 and block building include it explicitly. Fixes #25167
Co-authored-by: Maxim Vezenov <mvezenov@gmail.com>
Code move only, no behavior change. GasLimitsValidator no longer shares ownership with GasTxValidator, so it gets its own gas_limits_validator.ts and test file, matching the one-validator-per-file layout of the directory. Exports still flow through the index barrel, so external imports are unaffected.
…x_simulator.ts Co-authored-by: Nicolas Chamo <nicolas@chamo.com.ar>
The declared gas-limit floor and ceiling had different exemption rules but shared one validator, so skipping the ceiling for gas estimation also skipped the floor. Splitting them lets the RPC factory keep the floor on the simulation path while exempting only the ceiling. 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.
…not needed AggregateTxValidator runs every validator and collects every failure reason. That means a tx rejected by a free check still pays for the ones behind it: an over-limit tx reaches the fee-payer balance read, and a malformed tx reaches proof verification. Adds an opt-in fail-fast aggregate and uses it on the RPC, req/resp and pool migration paths, where the reason list is only logged or surfaced as an error string. Block building keeps the collect-all aggregate: its rejections are reported as part of block validation, where the full list is the diagnosis. Gossip is unaffected either way. LibP2PService.runValidations runs stage-1 validators concurrently because the peer penalty is the harshest severity across all failures, so it already pays for every validator on every tx.
Base automatically changed from
mv/fix-simulation-gas-limit-admission
to
merge-train/fairies-v5
August 18, 2026 14:53
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.
Stacked on #25221. Demonstrates the early-exit option raised in #25221 (comment), so the fee-payer balance read for an over-limit tx can be judged as its own change rather than by re-coupling the gas-limit checks.
AggregateTxValidatorruns every validator and collects every reason, so a tx rejected by a free check still pays for the ones behind it. AddsAggregateTxValidator.stoppingAtFirstFailureand uses it on the RPC, req/resp and pool-migration paths, where the reason list is only logged or turned into an error string. Block building keeps the collect-all aggregate: its rejections are reported as part of block validation, so the full list is the diagnosis, and a tx reaching it is expected to pass anyway.The saving is wider than the reported case: on req/resp a malformed tx no longer reaches proof verification.
Gossip does not benefit
LibP2PService.runValidationsmaps over the stage-1 record andPromise.alls it, because the peer penalty is the harshest severity across all failures. Every gossiped tx pays for every validator today and still will. So this reclaims cost on the local and pool paths, not on the adversarial one.What it costs
Two things showed up once the tests ran, both worth weighing before this lands:
aztec-nodehad a test pinning[TX_ERROR_SIZE_ABOVE_LIMIT, TX_ERROR_CALLDATA_COUNT_MISMATCH]from a single tx; it now sees only the size error.Tests
AggregateTxValidator.stoppingAtFirstFailurereturns the first reason and leaves later validators unrun.getPreviousValueIndex, which in this validator set is only reached throughGasTxValidator's public state source. Verified red first, where the same tx also returnsInsufficient fee payer balance (required=14652864, available=0).p2p: 74 suites / 1433 tests. aztec-node
server.test.ts: 82 tests.