-
Notifications
You must be signed in to change notification settings - Fork 100
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
eth/nodeclient: Set contract nonces manually. #1482
Conversation
The v0 contract will reuse account nonces if the tx is not yet confirmed. To avoid that get the next nonce from the light eth node pool api while holding the nodeClient nonceSendMtx and set manually. Hold the mutex until the tx has been sent or errors on sending.
Tested with low fee txn and concurrent sends. Seems to always set the next nonce correctly. This runs the risk of a tx getting stuck ofc if the fee it too low, which is a bigger problem than with utxo based coins, and one that should be considered more, imo. |
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.
This LGTM. The code could go into a helper function though to avoid repeating it.
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.
Why not just put this code into txOpts
?
I think the mtx needs to be held until after the tx has either made it into the pool or not, so after attempting to send. I'm not sure of the actual behavior, but if it will give you the next nonce before a tx is sent, then if one fails you would be skipping the nonce and no longer be able to send. If it will give you the same nonce until it has a tx in the pool using it, then you would be grabbing the same nonce for multiple txn until one is in the pool. |
I don't think the helper would be much shorter if I want to hold that mutex outside of the sending function. |
Yeah let's run with it as is. The key is holding the nonce mutex until the tx hits txpool. |
closes #1467