-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better nonce handling #1609
Better nonce handling #1609
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clean up the defaults (looks like you actually do want to handle None?) and then it looks good!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1609 +/- ##
==========================================
+ Coverage 81.15% 81.48% +0.33%
==========================================
Files 98 98
Lines 7295 7248 -47
==========================================
- Hits 5920 5906 -14
+ Misses 1375 1342 -33
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There's an issue in nonce handling in that calling a trade that e.g., previews the call before submitting can fail itself (e.g., slippage), which ends up updating the internal nonce count before the transaction gets submitted. We solve this by passing in a nonce function instead of the actual nonce, and call this nonce function at the last possible moment (i.e., when sending the built transaction) to ensure nonce bookkeeping isn't incrementing prematurely.