Repository navigation
perf: fetch nonce, block, and priority fee concurrently in prepareTransactionRequest - #5505
Merged
Merged
Conversation
…nsactionRequest The nonce, latest block, and priority fee were requested one after another, although none of them depends on the others when the chain has no fee hooks. They are now requested together, so preparing a transaction takes two round trips instead of four once the chain's EIP-1559 support is cached. Chains that define function fee hooks keep the sequential order, since the hooks receive the block and the request. Co-authored-by: jxom <[email protected]>
A failed nonce request now takes precedence over errors from the parameters fetched concurrently with it. Fee hooks are detected from any function-valued chain fee, and the concurrency tests record requests with a real http transport. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d0ba-847b-7727-be9d-a69b96b1d6b7 Co-authored-by: jxom <[email protected]>
🦋 Changeset detectedLatest commit: 9cd7df5 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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. |
Contributor
|
Published pnpm add viem@pr-5505
pnpm add [email protected] |
Merged
This branch had an error being deployed
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.
Supersedes #5501 by @backseats. Their commit is kept as is, and the review fixes are in a second commit.
prepareTransactionRequestused to request the nonce, the latest block, and the priority fee one after another, even though none of them depends on the others when the chain has no fee hooks. They are now requested together.eth_estimateGasstill runs last, with the nonce and fees filled in.Effect
Measured against Anvil with a real
httptransport, 150 ms of added latency per request, andeth_fillTransactiondisabled. Each cell shows requests / round trips.maintype: 'eip1559'noncesuppliedgasPrice(legacy)maxFeePerGas+maxPriorityFeePerGasmaxFeePerGasmaxPriorityFeePerGasparameterswithoutfeesnonceManagerNo case sends extra requests. Nodes that support
eth_fillTransactionstill use a single request.Behavior
feeskeep the sequential order, so the hooks still receive the block and a request that includes the nonce.main. (Review fix.)type: 'eip1559': on a chain without EIP-1559,eth_maxPriorityFeePerGasis sent before the sameEip1559FeesNotSupportedErroris thrown.internal_estimateMaxPriorityFeePerGas: it now accepts a block promise, so itseth_gasPricefallback reuses the block request. The publicestimateMaxPriorityFeePerGasis unchanged.Tests
httptransport'sonFetchRequestandonFetchResponsehooks. One test asserts that the three requests overlap, and it fails onmain. Another asserts that they stay sequential on a chain with a fee hook.createRpcProxyto make both the nonce and the block requests fail. It fails without the fix.with eth_fillTransaction > args: maxFeePerGas (under default tip)also fails onmainwith Anvil 1.9.0.