Skip to content

Allow serializing EIP-1559 txs where priority fee exceeds max fee (Arbitrum) - #5175

Open
SnowingFox wants to merge 1 commit into
ethers-io:mainfrom
SnowingFox:fix/arbitrum-priority-fee
Open

Allow serializing EIP-1559 txs where priority fee exceeds max fee (Arbitrum)#5175
SnowingFox wants to merge 1 commit into
ethers-io:mainfrom
SnowingFox:fix/arbitrum-priority-fee

Conversation

@SnowingFox

Copy link
Copy Markdown

Problem

Transaction.inferTypes() throws BAD_DATA: priorityFee cannot be more than maxFee for valid EIP-1559 transactions on Arbitrum, where the base fee is zero and the priority fee may legitimately exceed maxFeePerGas (see the example Arbitrum One tx referenced in the issue).

As a result transaction.unsignedSerialized / transaction.serialized / transaction.from all throw for transactions that are perfectly valid on Arbitrum, so such transactions cannot be serialized or signed.

Root cause

inferTypes() in src.ts/transaction/transaction.ts enforces the EIP-1559 ordering invariant maxFeePerGas >= maxPriorityFeePerGas as a hard BAD_DATA assertion:

if (this.maxFeePerGas != null && this.maxPriorityFeePerGas != null) {
    assert(this.maxFeePerGas >= this.maxPriorityFeePerGas, "priorityFee cannot be more than maxFee", "BAD_DATA", { value: this });
}

This invariant does not hold on chains with a zero base fee (Arbitrum One, Arbitrum Nova and similar L2s), and it is not a serialization invariant: _serializeEip1559 / _serializeEip4844 write both fee fields verbatim and round-trip correctly regardless of the ordering.

Fix

Relax the ordering check in inferTypes(): do not reject a transaction solely because maxPriorityFeePerGas > maxFeePerGas. Fee ordering is a chain-level policy, not a serialization invariant, and should be enforced (if at all) by the chain at submission time. This also restores the v5 behavior, where no such assertion existed.

Test

Added regression tests in src.ts/_tests/test-transaction.ts that build a type-2 transaction with maxPriorityFeePerGas > maxFeePerGas and assert that it serializes, round-trips, and infers type 2 without throwing.

Fixes #4771

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arbitrum tx inferTypes error: priorityFee cannot be more than maxFee

1 participant