Open holic opened 1 month ago
Latest commit: aec51837d528234a54572a408344caa67e9af6d8
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
@holic is attempting to deploy a commit to the Wevm Team on Vercel.
A member of the Team first needs to authorize it.
This change does work for my context (nonce is reset and I no longer get "nonce too high" errors), but I just noticed this line: https://github.com/wevm/viem/blob/5f350ecf63b2da861c8dcb60e77fbcae3e7192ab/src/utils/nonceManager.ts#L85-L87
I think this means this change needs a deeper refactor to make sense? Will play with this more locally and report back with an alternative.
Added a test to demonstrate the expected behavior.
I am using the default nonce manager to trigger a bunch of transactions in a queue to ensure they land in the mempool in order. If any transaction fails to submit to the mempool, I call
nonceManager.reset()
.For example:
If
tx:1
fails, I callnonceManager.reset()
and retry it. However, the logic that looks up the nonce after reset also takes into account the previously cached nonce in the nonce manager:https://github.com/wevm/viem/blob/5f350ecf63b2da861c8dcb60e77fbcae3e7192ab/src/utils/nonceManager.ts#L79-L84
Since the queue is blocked on
tx:1
, our nonce at the source should still benonce:1
. But because of the logic above, the nonce returned will actually benonce:4
(because of our previously queued txs).IMO
.reset
should reset the state of the nonce manager back to the source, including the cached nonce value.PR-Codex overview
The focus of this PR is to add tests for the
nonceManager
reset functionality and ensure correct nonce handling during transactions.Detailed summary
nonceManager
reset functionality