test(l2): pin operator-fee priority-fee underflow on validation gap#6537
Draft
avilagaston9 wants to merge 1 commit intomainfrom
Draft
test(l2): pin operator-fee priority-fee underflow on validation gap#6537avilagaston9 wants to merge 1 commit intomainfrom
avilagaston9 wants to merge 1 commit intomainfrom
Conversation
`validate_sufficient_max_fee_per_gas_l2` enforces only `max_fee_per_gas >= base_fee_per_gas + operator_fee_per_gas`. It does not check `max_priority_fee_per_gas >= operator_fee_per_gas`, so a user-submitted EIP-1559 transaction can satisfy the validator and still set `max_priority_fee_per_gas` below the operator fee. The resulting `gas_price = min(max_priority + base_fee, max_fee)` then sits below `base_fee + operator_fee`, and `compute_priority_fee_per_gas` computes `(gas_price - base_fee) - operator_fee`, which underflows — surfacing as `VMError::Internal(InternalError::Underflow)` rather than a `TxValidationError`. Internal errors are reserved for invariant violations; user-controlled inputs must never reach them. The new test `priority_fee_below_operator_fee_underflows_in_finalize` constructs a VM with base_fee=10, operator_fee=100, max_fee=200, max_priority=50 — exactly the case the validator misses — and asserts the current (buggy) behaviour where `vm.execute()` returns `VMError::Internal(InternalError::Underflow)`. The assertion is written so that any change in error handling (e.g. replacing the internal-error path with a proper `TxValidationError` once the validator is tightened) will fail this test, prompting an explicit update.
1 task
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.
Motivation
validate_sufficient_max_fee_per_gas_l2only enforcesmax_fee_per_gas >= base_fee_per_gas + operator_fee_per_gas. It doesnot check
max_priority_fee_per_gas >= operator_fee_per_gas. A usercan submit an EIP-1559 transaction that passes that validator with
max_priority_fee_per_gasset below the operator fee. The effectivegas_price = min(max_priority + base_fee, max_fee)then sits belowbase_fee + operator_fee, andcompute_priority_fee_per_gascomputes(gas_price - base_fee) - operator_feewhich underflows. The errorsurfaces as
VMError::Internal(InternalError::Underflow)rather thana
TxValidationError. Internal errors are reserved for invariantviolations; a user-controlled input must never hit them.
Description
Adds a regression test
priority_fee_below_operator_fee_underflows_in_finalizein
test/tests/levm/l2_hook_tests.rsthat constructs the missing-caseinputs (
base_fee=10,operator_fee=100,max_fee=200,max_priority=50) and pins the current (buggy) outcome — the VMreturns
VMError::Internal(InternalError::Underflow). The assertion iswritten so that any change in error handling (for example, tightening
validate_sufficient_max_fee_per_gas_l2to also rejectmax_priority_fee_per_gas < operator_fee_per_gas, which would makethis case bounce out as a
TxValidationError) breaks this test,prompting an explicit update of the expected error.
The fix itself is intentionally not in this PR — surfacing the gap and
its reproducer first lets the right validation error variant be picked
deliberately. Two reasonable shapes:
validate_sufficient_max_fee_per_gas_l2to also requiretx_max_priority_fee_per_gas >= operator_fee_per_gasand returnthe existing
TxValidationError::InsufficientMaxFeePerGas(or amore specific new variant).
compute_priority_fee_per_gasso thecoinbase simply receives no priority fee instead of crashing —
weaker, but matches how some L2s "round down to zero" rather
than reject.
Reproduction
The test passes on
main(the bug is real and reachable).Impact
A user-submitted L2 transaction with operator fee active and
max_priority_fee_per_gas < operator_fee_per_gas(withmax_fee_per_gas >= base_fee + operator_fee) reaches theinternal-error path during finalize. Whether the consequence is
"tx silently dropped from the block" or "block production aborts"
depends on the caller's handling of
VMError::Internal, but ineither case the validator should have rejected the tx upfront —
internal errors are not the right escape hatch for malformed user
input.
Checklist
STORE_SCHEMA_VERSION(crates/storage/lib.rs) if the PR includes breaking changes to theStorerequiring a re-sync.