Repository navigation
Conversation
With a nonceManager, prepareTransactionRequest awaited the consumed nonce before requesting the block and fees. consume is still called at the same point, so concurrent prepares keep receiving nonces in call order, but the nonce is now awaited together with the other parameters. It is still awaited first when eth_fillTransaction is attempted or the chain has a prepareTransactionRequest hook, since both read it from the request, and a nonce error still takes precedence over the errors of the other parameters. 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: 11e1f87 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: 7851af227b
ℹ️ 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".
| } from '../../utils/index.js' | ||
| import { jsonRpc } from '../../utils/nonceManager.js' |
There was a problem hiding this comment.
Import the nonce-manager APIs through package entrypoints
The newly added createNonceManager and jsonRpc imports use relative source paths even though both are publicly exported from viem/nonce. This violates AGENTS.md's requirement to “Import public APIs from package entrypoints in tests” and bypasses the public entrypoint in the new regression coverage. Import these APIs from viem/nonce; internal helpers can remain relative.
AGENTS.md reference: AGENTS.md:L188-L193
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 11e1f87: createNonceManager now comes from 'viem'. jsonRpc stays relative, because no entrypoint mapped in the test config exports it (viem/nonce has no path alias in test/tsconfig.json).
|
|
||
| const request = await prepareTransactionRequest(recordingClient, args) | ||
|
|
||
| expect(request.nonce).toMatchInlineSnapshot(`953`) |
There was a problem hiding this comment.
Snapshot the complete prepared transaction
The new regression test snapshots only request.nonce, contrary to AGENTS.md's explicit requirement to snapshot whole objects rather than cherry-picking individual fields. The RPC-recording snapshot does not cover the returned transaction's other properties, so it cannot confirm that overlapping nonce consumption preserves the prepared result. Snapshot the complete request after omitting any nondeterministic properties, and apply the same approach to the new fill-transaction test.
AGENTS.md reference: AGENTS.md:L212-L215
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 11e1f87: both new tests now snapshot the whole prepared request, minus account.
…ager from viem Amp-Thread-ID: https://ampcode.com/threads/T-01a1e1b3-ba60-755b-bfd0-1a31a4a5bf1e Co-authored-by: jxom <[email protected]>
|
Published pnpm add viem@pr-5528
pnpm add [email protected] |
|
Bundled into #5543 as its own commit, so this PR is superseded. Closing in favour of the bundle. |
With a
nonceManager,prepareTransactionRequestawaitednonceManager.consumebefore it requested the block and fees, so the nonce cost a round trip of its own.consumeis still called at the same point, so concurrent prepares sharing a nonce manager receive nonces in call order. The returned promise is now awaited with the other parameters, the same way as theeth_getTransactionCountnonce since #5505.Effect
Real in-process
node:httpJSON-RPC server adding 50 ms per request, real Viem clients overhttp(url),eth_fillTransactionunsupported.mainnonceManager, EIP-1559 networkBehavior
consumereserves the nonce synchronously when it is called, and it is called at the same point as before.eth_fillTransactionand chainprepareTransactionRequesthooks: both read the nonce from the request, so the nonce is still awaited before them, and the decision to attempteth_fillTransactionis the same as onmain.feesstill await the nonce before the fee requests..catch(() => {})attached when it is created.Tests
httptransport): the block and priority fee requests are sent while the nonce manager'seth_getTransactionCountis pending, and 3 concurrent prepares then get 954, 955, 956 in call order.eth_fillTransactiontest: the fill request is sent only after the nonce manager'seth_getTransactionCountresolves. It fails when the early await is removed.createRpcProxytest delays a failingeth_getTransactionCountand fails the block right away; the nonce error is thrown.createRecordingClientmoved to the top of the test file so theeth_fillTransactiondescribe block can use it.with eth_fillTransaction > args: maxFeePerGas (under default tip)fails, and it fails the same way onmainwith Anvil 1.9.0.Independent of #5527 and #5529, which also touch
prepareTransactionRequest. All three merge cleanly together.