Repository navigation
fix: pass the latest block to chain fee hooks in estimateFeesPerGas - #5611
Closed
mortezashojaei wants to merge 1 commit into
Closed
mortezashojaei wants to merge 1 commit into
mortezashojaei wants to merge 1 commit into
Conversation
When estimateFeesPerGas was called without a block, the chain fees.estimateFeesPerGas hook received the caller's undefined block instead of the block the action had fetched, and fees.baseFeeMultiplier ran before any block was fetched. Both hooks now receive the latest block, as ChainFeesFnParameters and the chain fees docs describe.
|
@mortezashojaei is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 3bc1852 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 |
Member
|
Thanks @mortezashojaei, nice catch and a clear write-up! We continued this in #5613, which keeps your commit and reworks the tests to extend the existing hook cases. Closing in favor of it. |
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.
ChainFeesFnParameters.blockis documented as "The latest block" (src/types/chain.ts, andsite/pages/docs/chains/fees.mdforbaseFeeMultiplier,defaultPriorityFeeandestimateFeesPerGas). But whenestimateFeesPerGas(client)is called directly, without ablock, two chain fee hooks receiveblock: undefined:fees.estimateFeesPerGasis called withblock: block_ as Block, the caller-supplied block, even though the action has just fetched the latest block (the fetch happens precisely because a fee hook is defined).fees.baseFeeMultiplier, when it is a function, runs before the block is fetched and also receivesblock_.A hook that reads
blockas documented throwsTypeError: Cannot read properties of undefined.prepareTransactionRequestalways passes a block, so it is unaffected.fillTransactionalready fetches the block before callingbaseFeeMultiplier, andestimateMaxPriorityFeePerGasdoes the same for its own hook.Repro
Fix
blocktofees.estimateFeesPerGas.fees.baseFeeMultiplier.No requests are added. The only ordering change is that a static
baseFeeMultiplierbelow 1 now throwsBaseFeeScalarErrorafter the block request instead of before it.Tests
Added
behavior: chain fee hooks receive the latest blocktoestimateFeesPerGas.test.ts, with one test per hook. They usecreateRpcProxyto return a fixed block, and each hook's result depends onblock.number. Both tests fail onmainwith theTypeErrorabove and pass with this change. The file's other tests still pass.