chore: backport #20806 (price bump for RPC transaction replacement) to v4#21036
Merged
mrzeszutko merged 2 commits intobackport-to-v4-stagingfrom Mar 3, 2026
Merged
Conversation
Adds a configurable percentage-based "price bump" requirement for RPC-submitted transactions that clash on nullifiers with existing pool transactions, or that need to evict the lowest-priority tx when the pool is full. This prevents spam via infinitesimally small fee increments. - When a tx arrives via RPC with nullifier conflicts, it must now pay at least X% above each conflicting tx's priority fee (default: 10%) — i.e. `>= existingFee + existingFee * bump / 100` - The same bump applies to pool-full eviction via `LowPriorityPreAddRule` - P2P gossip path is unchanged — continues using `comparePriority` (fee + hash tiebreaker) with no bump - Rejection errors now include the minimum required fee so callers know how much to bid - New env var `P2P_RPC_PRICE_BUMP_PERCENTAGE` (default: 10) controls the bump percentage - `getMinimumPriceBumpFee(existingFee, priceBumpPercentage)` helper computes the threshold using integer arithmetic: `existingFee + max(existingFee * bump / 100, 1)` — the minimum bump is always at least 1 unit, so replacement always requires paying strictly more (even with 0% bump or zero existing fee) - `priceBumpPercentage` is typed as `bigint` throughout the config chain to avoid `BigInt()` conversion issues with non-integer values - `checkNullifierConflict` accepts an optional `priceBumpPercentage` param; when set, uses fee-only `>=` comparison against the bumped threshold instead of `comparePriority` - `NullifierConflictRule` now passes `context.priceBumpPercentage` through to the conflict check (previously ignored context entirely) - `LowPriorityPreAddRule` uses the bumped fee threshold when both `feeComparisonOnly` and `priceBumpPercentage` are set - Config flows: `P2P_RPC_PRICE_BUMP_PERCENTAGE` env var -> `P2PConfig` -> `TxPoolV2Config` -> `PreAddContext` (only for RPC path) - `NULLIFIER_CONFLICT` rejection error enriched with `minimumPriceBumpFee` and `txPriorityFee` fields - 15 new unit tests across `tx_metadata.test.ts`, `nullifier_conflict_rule.test.ts`, and `low_priority_pre_add_rule.test.ts` - Tests cover: exact threshold acceptance, below-threshold rejection, well-above threshold, 0% bump edge case, P2P path unchanged, error field population - All existing tests continue to pass Fixes A-452
Collaborator
Author
Flakey Tests🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry. |
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.
Backport of #20806 to v4.
Adds a configurable percentage-based price bump requirement for RPC-submitted transactions that clash on nullifiers with existing pool transactions, or that need to evict the lowest-priority tx when the pool is full. This prevents spam via infinitesimally small fee increments.
Conflict resolution
Three files had conflicts due to
dropTransactionsProbability(present on next, absent on v4):docs/docs-operate/operators/reference/changelog/v4.md— added the price bump changelog section without the unrelated "Setup allow list" sectionyarn-project/p2p/src/client/factory.ts— addedpriceBumpPercentageconfig pass-through (withoutdropTransactionsProbability)yarn-project/p2p/src/mem_pools/tx_pool_v2/interfaces.ts— addedpriceBumpPercentageto type and defaults (withoutdropTransactionsProbability)ClaudeBox log: http://ci.aztec-labs.com/ff393a9b4d8e95fb-1