perf(p2p): stop tx validation at the first failure where reasons are not needed - #25255
Draft
vezenovm wants to merge 1 commit into
Draft
perf(p2p): stop tx validation at the first failure where reasons are not needed#25255vezenovm wants to merge 1 commit into
vezenovm wants to merge 1 commit into
Conversation
…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.
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.