-
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
eth_getTransactionCount does not include pending transactions when 'pending' qualifier given #2880
Comments
This is critical for the upcoming Go API as well. Maybe getTransactionCount(..., "pending") should return the transaction pool's latest known nonce instead of looking at the pending block. |
Are you sure you used geth 1.4.10?
Geth will grab the nonce from the pending state if you ask for it. |
Same issue here. Looking at the code in |
stateAndBlockByNumber is called which gets the pending state from the miner. |
We will change it to look at the transaction pool because it knows about the latest nonce faster. |
@fjl that sounds very good. I'm testing out the Go bindings and in the example here there seems to be some races to be aware of due to the sleep:
I'm doing two transactions from the same account after each other and right now the nonce is the same for both which means once tx will be invalid once the other is mined. How will the concurrency work after the change to use the transaction pool? Will multiple transactions from the same account increment the nonce without any tricks with sleep etc.? Also when is this change planned to hit develop? |
I cannot give you a timeline but it will be included in the next major release. |
OK, thanks @fjl. I think the Go bindings are really cool and was also wondering a bit how they were meant to be used in various situations e.g.:
In addition, the two above could be done concurrently from e.g. different goroutines. As the underlying mechanism from the calling go code right now calls out to the backend over RPC to get the transaction count or later the tx pool nonce there is a race. Hence, I assume concurrent transactions for the same account is not supported. Right? However, for 1 & 2 it would be possible to keep track of the nonce in the client code, maybe in the TransactOpts by the underlying backend? Or something along those lines so that a caller using the same account would automatically get the nonce incremented without a need to ask over RPC. This opens of course up other points such as keeping the local value in sync. Has this been thought about? I'd be interested to understand what's been considered. |
@fjl : Just checking if this change to look at the transaction pool for the nonce was made yet as obviously this issue is still currently open here... |
I am seeing that this issue is still open. Does this mean this is not fixed? |
@fjl any update on this? Is this change still going to happen? |
Any progress on this? It seems like a critical issue for those of us attempting to generate multiple transactions with Go, and still has a milestone tag of two major releases back. |
There is a related issue in Parity (openethereum/parity-ethereum#5014) with "pending". Parity has a non-standard RPC call parity_nextNonce to get the nonce considering all pending transactions in the pool. Maybe this could be added to the standard JSONRPC API. Something like eth_nextNonce. Or the suggestion on the issue of using "pending_mining" or "pending_inclusion" could work too. Then this getTransactionCount with "pending" can remain as meaning "the currently mined block (including pending transactions)". ie. pending transactions in a block being mined. |
At the moment I'm doing some local testing with this change to
Thoughts on if this is a reasonable solution? This issue seems to still be a problem for anyone using |
@fjl (2016-08-06)
When is the next major release? It's been a year and a half and the bug is serious and still present. |
Any chance to have this fixed this year(2018) ? |
Reason: It allows a developer to calculate transaction nonce on his own. May be needed when you want to control transactions order or calculate nonce using transaction pool rather than relying on current client algorithm. Relates to: - EthWorks#35 - ethereum/go-ethereum#2880
* Include pending transactions in Client#get_nonce Reason: Submitting more than one transaction from the same account before the block is mined resulted with colliding transactions, because of the same nonce. This change takes the nonce from the pending transactions, so it's incrementes as the pool growths before block is mined. Relates to: #35 * Allow to change nonce on contract before sending transaction Reason: It allows a developer to calculate transaction nonce on his own. May be needed when you want to control transactions order or calculate nonce using transaction pool rather than relying on current client algorithm. Relates to: - #35 - ethereum/go-ethereum#2880
I wonder, how can it still open? How people deal with a need to send multiple transactions from the same account without storing the nonce (super fragile and can lead to transaction failures or overrides)? Do I miss something or this is a must have for any normal project? |
This seems like to be too serious of bug to be left hanging? Is there any possibility of a fix? This issue will cause stability problems for any general application using Ethereum smart contracts. |
Btw, for now it seems we found a workaround by accessing node's pool using txpool api, fetching pending transactions and adding the number to eth_getTransactionCount. But yeah, this is a super crappy hack since you have to do extra fetch of a massive size on any transaction. Should be fixed on a node level! |
@vernon99 just fyi, there's a potential race condition in that workaround if the node state changes between calls. (i think) |
(Finally) fixed in #15794. |
Fix raiden-network#4976 Instead use web3.eth.getTransactionCount(address, "pending") which now works as intended since ethereum/go-ethereum#2880 has been fixed
Fix #4976 Instead use web3.eth.getTransactionCount(address, "pending") which now works as intended since ethereum/go-ethereum#2880 has been fixed
This is to have the eth_getTransactionCount fix: ethereum/go-ethereum#2880
This is to have the eth_getTransactionCount fix: ethereum/go-ethereum#2880
As the title states, tx count is not getting incremented for pending transactions when giving second argument of 'pending'. It seems to be treated the same as 'latest'.
System information
Geth version:
1.4.10
OS & Version: OSX
The text was updated successfully, but these errors were encountered: