Repository navigation
Conversation
On a client that has not detected the network's transaction type yet, prepareTransactionRequest requested the latest block and only then the priority fee. Without chain fee hooks, the priority fee is now estimated concurrently with that block. On legacy networks the estimate goes unused, once per client. Co-authored-by: jxom <[email protected]> Amp-Thread-ID: https://ampcode.com/threads/T-01a1e1b3-ba60-755b-bfd0-1a31a4a5bf1e
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: ab64489 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 30d96ee600
ℹ️ 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".
| expect(requests).toMatchInlineSnapshot(` | ||
| { | ||
| "eth_estimateGas": [], | ||
| "eth_getBlockByNumber": [], | ||
| "eth_getTransactionCount": [], | ||
| "eth_maxPriorityFeePerGas": [], |
There was a problem hiding this comment.
Assert fee-hook outputs instead of recorded RPC calls
The new fee-hook test discards the prepared transaction and asserts only the recorded RPC call overlap; the preceding new test also snapshots this call tracking. This violates AGENTS.md's explicit requirement to test observable outputs rather than call tracking. In particular, the fee-hook test can pass even if the hook's result is ignored, provided the RPC ordering remains unchanged. Make the hook produce distinguishable fee values and assert those values in the prepared transaction.
AGENTS.md reference: AGENTS.md:L204-L208
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Partly addressed in ab64489. The fee hook test now uses a distinguishable multiplier (1.5) and snapshots the prepared request, so maxFeePerGas shows the hook's result (16 gwei vs 13 gwei by default). Keeping this. Recording which requests overlap through a real http transport is how the concurrency rule for these changes is enforced (same approach as the landed #5505 tests). The result alone can't tell a concurrent implementation from a sequential one, since both return the same value. The snapshot records rounds of requests, not hook invocations, so it fails exactly when a waterfall comes back.
| method, | ||
| params: ['latest', false], | ||
| }) | ||
| return { result: { ...block, baseFeePerGas: undefined } } |
There was a problem hiding this comment.
Exercise legacy behavior without stubbing block responses
The new legacy-network test fabricates a legacy block by removing baseFeePerGas from an actual EIP-1559 block response. Although the proxy uses real HTTP, this response override is still a stub, which AGENTS.md explicitly prohibits. It also leaves the remaining RPC methods backed by an EIP-1559 node rather than exercising a real legacy network. Configure a real test chain without EIP-1559 support and assert the resulting prepared transaction instead.
AGENTS.md reference: AGENTS.md:L155-L158
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Keeping this. The shared Anvil instances are all EIP-1559 forks, and adding a pre-London Anvil to the global setup for one test is out of scope here. The proxy only removes baseFeePerGas from real block responses, and every other request goes to Anvil. The test asserts the prepared transaction (legacy type, gas price, no EIP-1559 fields).
|
Published pnpm add viem@pr-5529
pnpm add [email protected] |
|
Bundled into #5543 as its own commit, so this PR is superseded. Closing in favour of the bundle. |
On a client that has not detected the network's transaction type yet,
prepareTransactionRequestrequested the latest block to detect it, and only then the priority fee. Without chain fee hooks, the priority fee is now estimated concurrently with that block.Effect
Real in-process
node:httpJSON-RPC server adding 50 ms per request, real Viem clients overhttp(url),eth_fillTransactionunsupported.mainTrade-off
On a legacy network, the speculative priority fee goes unused: one wasted
eth_maxPriorityFeePerGasrequest per client, or two when the node does not support it (the fallback also sendseth_gasPrice). This happens once per client, because the detected type is cached. In exchange, every new client on an EIP-1559 network saves a round trip on its first transaction, which matters most for serverless apps that create a client per request. Legacy networks are rare now, so I think it's worth it, but it's separate so it can be dropped on its own.Behavior
feesis being filled and the chain has no function underfees; chains with fee hooks keep the sequential order..catch(() => {})attached when it is created, and is awaited in the same place as before, so a type-detection block error still surfaces first.Tests
httptransport): on a new client,eth_maxPriorityFeePerGasis sent while the type-detection block is pending. It fails without the change.createRpcProxyserves blocks withoutbaseFeePerGas): the request comes back aslegacywith a gas price and no EIP-1559 fields.with eth_fillTransaction > args: maxFeePerGas (under default tip)fails, and it fails the same way onmainwith Anvil 1.9.0.Independent of #5527 and #5528, which also touch
prepareTransactionRequest. All three merge cleanly together.