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

Increment nonce count when populating transaction #54

Merged
merged 6 commits into from
Sep 14, 2023

Conversation

emizzle
Copy link
Contributor

@emizzle emizzle commented Sep 7, 2023

Fixes: codex-storage/nim-codex#538

Problem

Concurrently calling sendTransaction (via a contract call, for example) would call getTransactionCount multiple times without the underlying value being incremented before the next call.

Solution

Keep track of a lastSeenNonce in the signer on each call to populateTransaction. On each call, the lastSeenNonce is compared to the getTransactionCount value, and when it is greater, the lastSeenNonce is incremented, otherwise it is set to the getTransactionCount value.

Additionally, if a transaction is crated manually and sent (via sendTransaction), the lastSeenNonce is updated.

Copy link
Member

@markspanbroek markspanbroek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thanks @emizzle!

ethers/signer.nim Outdated Show resolved Hide resolved
ethers/signer.nim Outdated Show resolved Hide resolved
emizzle and others added 2 commits September 14, 2023 17:15
Co-authored-by: markspanbroek <mark@spanbroek.net>
Co-authored-by: markspanbroek <mark@spanbroek.net>
@emizzle emizzle merged commit f030347 into main Sep 14, 2023
4 checks passed
@emizzle emizzle deleted the feat/increment-nonce branch September 14, 2023 23:54
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.

[BUG] Geth errors with already known when two simultaneous sales statemachines attempt to approve tokens
2 participants