-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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
Does Geth guarantee consistent snapshot of state in a RPC batch? #2736
Comments
This is indeed a hard problem. In theory the node cannot give you all required information to determine the correct nonce since it might not have all pending/queued transactions in its transaction pool. Batched RPC calls are just an optimization to reduce the number of separate RPC calls. Your assumption is correct. The requests are still executed one by one and and affected by state changes. @Arachnid, if I recall it correct you did some work on adding Ethereum support for trezor. Maybe you can share your thoughts? |
It seems to me the most straightforward approach would be calling |
Trezor support was naive, and just fetches the transaction count, on the theory that you're not going to be signing transactions by hand that fast. :) |
The correct way is indeed to use |
System information
Geth version:
1.4.7-stable-667a386d
OS & Version: OSX
Expected behaviour
Using
sendRawTransaction
reliably requires computing the proper nonce. This requires knowing previous transaction count of the from address, as well as checking pending and queued transactions of the from address.AFAIK, this means that we need to call
getTransactionCount(tx.from)
andtxpool_content
to compute the final nonce (nonce = tx_count + pending_count + queued_count
).Since we need to use two calls, it's possible the state gets mutated in between the calls and thus we compute the wrong nonce:
Batched RPC call of [getTransactionCount, txpool_content] ---> Geth
getTransactionCount(tx.from)
returns 0txpool_content
is now empty and returns 0 pending/queued transactions. Application computes the final nonce oftx_count (0) + tx_pool_count (0) = 0
and the tx gets rejected (the nonce should have been 1).If the state isn't guaranteed (which is what I suspect, since it would seem silly to halt all processing because of RPC calls), then how on earth are we able to consistently produce the proper nonce?
Actual behaviour
Unknown.
The text was updated successfully, but these errors were encountered: