Skip to content

fix: raise TipAboveFeeCapError when parsing a zero maxFeePerGas - #5318

Merged
jxom merged 11 commits into
mainfrom
claude/parse-tip-above-zero-fee-cap
Nov 1, 2026
Merged

jxom merged 11 commits into
mainfrom
claude/parse-tip-above-zero-fee-cap

Conversation

@jxom

@jxom jxom commented Oct 27, 2026

Copy link
Copy Markdown
Member

Replaces #5316. Stacked on #5313; until it merges, review only the last two commits (1bbf73c, c1962b8). On main, assertTransactionEIP1559 still skips a 0n fee cap, so this needs #5313.

Summary

RLP encodes 0 as 0x, and the EIP-1559, EIP-7702 and EIP-4844 parsers dropped 0x fields. A zero fee cap came back as undefined, so assertTransactionEIP1559 skipped the tip check and a transaction with a tip above a zero fee cap parsed without error.

  • 1bbf73c (from fix: raise TipAboveFeeCapError when parsing a zero maxFeePerGas #5316, authored by @mortezashojaei): decodes a 0x fee cap as 0n when the tip is present, so TipAboveFeeCapError is raised.
  • c1962b8: decodes the tip first and keys the 0n fee cap on the decoded, non-zero tip instead of the raw tip field. Before, a malformed (non-hex) tip added maxFeePerGas: 0n while the tip was dropped, and a non-canonical 0x00 tip added maxFeePerGas: 0n, unlike a canonical zero-fee transaction. Also adds zero fees tests for EIP-7702 and EIP-4844.

If both fees are zero, the output is unchanged (no fee fields).

Tests

  • parseTransaction, assertTransaction, Celo and OP Stack parser tests pass (125). The new zero fee cap with zero tip test fails without c1962b8.
  • These ran with a local Vitest config without the Anvil global setup, since the harness proxy could not bind IPv6 in the sandbox; the tests touched do not use a chain.
  • Biome is clean.

Not included: Celo's CIP-42 and CIP-64 parsers have the same gap, and their asserts use isPresent, which treats 0n as empty. That is a separate fix.


Generated by Claude Code

@changeset-bot

changeset-bot Bot commented Oct 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c1962b8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
viem Ready Ready Preview Oct 27, 2026 7:26am UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T07:25:27.520068Z c1962b8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1962b8b7a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"viem": patch
---

Fixed `parseTransaction` not raising `TipAboveFeeCapError` when the encoded `maxFeePerGas` is zero.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Consolidate the duplicate changeset

Remove this changeset and retain the broader tip-above-zero-fee-cap.md entry, which already covers the same parseTransaction zero-fee-cap fix; keeping both causes the patch to appear twice in the generated release notes and conflicts with the repository requirement to update an existing same-area changeset rather than adding a duplicate.

AGENTS.md reference: AGENTS.md:L240-L244

Useful? React with 👍 / 👎.

Comment on lines +409 to +410
test('args: maxFeePerGas (zero, under default tip)', async () => {
await setup()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Replace the mock-dependent fee test

Move this new case out of the mocked without eth_fillTransaction suite or exercise the unsupported-method path against a configured test node: the suite's beforeEach replaces fillTransaction with vi.spyOn(...).mockRejectedValue(...), so this coverage depends on a stub rather than real behavior and violates the repository's explicit prohibition on mocks in tests.

AGENTS.md reference: AGENTS.md:L153-L157

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

Published [email protected] under the pr-5318 dist-tag, which follows this pull request until it closes.

pnpm add viem@pr-5318
pnpm add [email protected]

@jxom
jxom merged commit 57db085 into main Nov 1, 2026
41 checks passed
@jxom
jxom deleted the claude/parse-tip-above-zero-fee-cap branch November 1, 2026 20:47
@github-actions github-actions Bot mentioned this pull request Nov 1, 2026
jxom added a commit to wevm/ox that referenced this pull request Nov 1, 2026
…s, and `AbiItem` (#561)

* fix: validate struct names and field types in `TypedData.assert`

Ports wevm/viem#5308 and wevm/viem#5370. A struct name must contain
only letters, digits, `_` and `$`, and must not be a Solidity type. A
field type must be a struct in `types` or an EIP-712 atomic or dynamic
type, so `uint`, `uint7` and `bytes0` throw the new
`TypedData.InvalidTypeError`. Every struct is checked, including structs
referenced only as array elements. `findTypeDependencies` strips only the
array suffix, so struct names with `$` are encoded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq

* fix: reject a tip above a zero `maxFeePerGas` in transaction envelopes

Ports wevm/viem#5318 and wevm/viem#5319. `TxEnvelopeEip1559.assert` and
`TxEnvelopeTempo.assert` compared fees only when both were truthy, so a
zero `maxFeePerGas` skipped the check. `deserialize` for EIP-1559,
EIP-4844, EIP-7702, and Tempo envelopes reads an empty `maxFeePerGas` as
zero when a tip is set. `TipAboveFeeCapError` and `FeeCapTooHighError`
now show zero values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq

* fix: treat indistinguishable overloads as ambiguous in `AbiItem.fromAbi`

Ports wevm/viem#5339. Distinct types that both match an argument, such
as `bytes32` and `bytes` or `uint256` and `int256`, and arrays of the
same element type with different shapes now throw
`AbiItem.AmbiguityError` instead of resolving to the last match. An
integer overload matches only a value in its range, and a fixed bytes
overload matches only a value of its size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq

---------

Co-authored-by: Claude <[email protected]>
jxom added a commit to wevm/ox that referenced this pull request Nov 1, 2026
…d `AbiItem` (#560)

* fix: validate struct names and field types in `TypedData.assert`

Ports wevm/viem#5308 and wevm/viem#5370. A struct name must contain
only letters, digits, `_` and `$`, and must not be a Solidity type. A
field type must be a struct in `types` or an EIP-712 atomic or dynamic
type, so `uint`, `uint7` and `bytes0` throw the new
`TypedData.InvalidTypeError`. Every struct is checked, including structs
referenced only as array elements. `findTypeDependencies` strips only the
array suffix, so struct names with `$` are encoded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq

* fix: reject a tip above a zero `maxFeePerGas` in transaction envelopes

Ports wevm/viem#5318 and wevm/viem#5319. `TxEnvelopeEip1559.assert` and
`TxEnvelopeTempo.assert` compared fees only when both were truthy, so a
zero `maxFeePerGas` skipped the check. `deserialize` for EIP-1559,
EIP-4844, EIP-7702, and Tempo envelopes reads an empty `maxFeePerGas` as
zero when a tip is set. `TipAboveFeeCapError` and `FeeCapTooHighError`
now show zero values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq

* fix: treat indistinguishable overloads as ambiguous in `AbiItem.fromAbi`

Ports wevm/viem#5339. Distinct types that both match an argument, such
as `bytes32` and `bytes` or `uint256` and `int256`, and arrays of the
same element type with different shapes now throw
`AbiItem.AmbiguityError` instead of resolving to the last match. An
integer overload matches only a value in its range, and a fixed bytes
overload matches only a value of its size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq

---------

Co-authored-by: Claude <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — c1962b8b Deployed Oct 27, 2026 by vercel[bot]
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.

3 participants