fix: validate cached quote nonce before reuse at send#14
Open
AlonzoRicardo wants to merge 2 commits into
Open
Conversation
A cached quote's built sponsoredOp was reused at send time with no nonce check, so a quote whose nonce drifted before the matching send (e.g. an intervening tx mined) was submitted with a stale nonce. Add _consumeFreshQuote, which drops the cached quote when its sponsoredOp.nonce no longer matches the on-chain nonce so the existing path re-quotes at the current nonce. Un-skips and rewrites the previously-disabled regression test accordingly. Ports the consume-at-send validation from tetherto/wdk-wallet-evm-erc-4337#98.
Addresses review feedback on the reference PR (tetherto/wdk-wallet-evm-erc-4337#98): the cached-quote reuse path now does a lightweight on-chain nonce read, so the JSDoc no longer implies the cached send skips all round-trips.
claudiovb
approved these changes
Jun 16, 2026
claudiovb
left a comment
There was a problem hiding this comment.
LGTM.
Not scope of this PR but we should have a follow up task to fix the failover test to fix the linter.
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.
Description
Ports the consume-at-send nonce validation from
wdk-wallet-evm-erc-4337#98 to the 7702 gasless module. Before reusing a cached quote at send time, the quote's UserOperation nonce is checked against the live on-chain nonce; if the chain advanced since the quote, the cached quote is discarded and re-quoted at the current nonce. The common case (quote → immediate send, nonce unchanged) still reuses the cached op with only one extrafetchAccountNonceread.Motivation and Context
On
main,sendTransaction/transferconsume a cached quote and reuse its builtsponsoredOpwith no nonce validation. If the chain advances betweenquoteSendTransaction/quoteTransferand the matching send — e.g. an intervening transaction mines — the cached op is submitted with a stale nonce.This adds a
_consumeFreshQuote(tx)step: consume the cached quote, and if itssponsoredOp.nonceno longer matches the on-chain nonce, drop it so the existing inline path re-quotes at the current nonce with a fresh fee. This is the same correctness guarantee the erc-4337 module gained in #98, adapted to this module's current structure (the post-send bump approach has already been removed here, so there is no_bumpCachedNoncesto replace).Type of change
Verification
standardlint clean.test.skip-ped regression (should not consume cached transfer fee when approve is called in between) is un-skipped and rewritten to assert re-quote-on-stale-nonce: a cached transfer quote is re-quoted (not blindly reused) once an intervening send has mined, while the common reuse path (nonce unchanged) is unaffected.Related: tetherto/wdk-wallet-evm-erc-4337#98