Skip to content
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

Merged
merged 9 commits into from
Jul 15, 2024
Merged

Conversation

slundqui
Copy link
Contributor

@slundqui slundqui commented Jul 15, 2024

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.

Copy link
Member

@dpaiton dpaiton left a 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!

Copy link

codecov bot commented Jul 15, 2024

Codecov Report

Attention: Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 81.48%. Comparing base (a7f0e94) to head (b5e6c0c).

Files Patch % Lines
src/agent0/ethpy/base/transactions.py 86.66% 2 Missing ⚠️
...e/hyperdrive/interactive/local_hyperdrive_agent.py 50.00% 1 Missing ⚠️
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     
Flag Coverage Δ
unittests 81.48% <85.00%> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@slundqui slundqui enabled auto-merge (squash) July 15, 2024 20:22
@slundqui slundqui disabled auto-merge July 15, 2024 20:23
@slundqui slundqui merged commit 1258bae into delvtech:main Jul 15, 2024
5 checks passed
@slundqui slundqui deleted the better-nonce-handling branch July 15, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants