Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Nonce increment when transaction failed #9040

Closed
gituser opened this issue Jul 4, 2018 · 10 comments
Closed

Nonce increment when transaction failed #9040

gituser opened this issue Jul 4, 2018 · 10 comments
Assignees
Labels
F3-annoyance 💩 The client behaves within expectations, however this “expected behaviour” itself is at issue. M4-core ⛓ Core client code / Rust. Z0-unconfirmed 🤔 Issue might be valid, but it’s not yet known.
Milestone

Comments

@gituser
Copy link

gituser commented Jul 4, 2018

I'm running:

  • Which Parity version?: 1.10.8
  • Which operating system?: Linux
  • How installed?: from source
  • Are you fully synchronized?: yes
  • Which network are you connected to?: ethereum
  • Did you try to restart the node?: yes

Summary
When you try to send a transaction with gas less than 21000 or (if you specify amount of the transaction bigger than your actual address balance) it fails, but nonce still increments, thus all future transactions will be forever in the queue, until someone fills the nonce gap between that last successful transaction and the one in the queue or restarts the parity.

Here is how to reproduce:

  1. create some transaction without nonce (thus nonce will be picked up, let's say nonce is 10)
  2. next, create a transaction with gas=20000, you'll get this error:
Error: Transaction gas is too low. There is not enough gas to cover minimal cost of the transaction (minimal: 21000, got: 20000). Try increasing supplied gas.
  1. now try creating another transaction without specifying the nonce, nonce will be 12 and thus transaction will stay in the pool, until you send transaction with nonce=11

I think nonce shouldn't be incremented if transaction has failed due to low gas or any other error when there is no resulting hash.

@Tbaut
Copy link
Contributor

Tbaut commented Jul 4, 2018

If you specify a gas, you should know what you do. Just use estimateGas for that. Just like specifying a gas price too low... the transaction will never be broadcasted, still, the nonce is incremented.

If you wish to have a better nonce handling, you should manage it in your Dapp.

@Tbaut Tbaut closed this as completed Jul 4, 2018
@Tbaut Tbaut added the Z1-question 🙋‍♀️ Issue is a question. Closer should answer. label Jul 4, 2018
@gituser
Copy link
Author

gituser commented Jul 4, 2018

The issue here is not about gas amount, but rather about nonce increment. Why parity does increment the nonce when in fact there was no previous transaction?

Also it can be not only gas issue but another issue when transaction has been failed for some reason and not posted.

@gituser
Copy link
Author

gituser commented Oct 8, 2018

Also, nonce is being incremented if you try to send transaction which exceeds your current account balance. That means that after that all future transactions will be stuck as well.

@Tbaut Tbaut added P5-sometimesoon 🌲 Issue is worth doing soon. F3-annoyance 💩 The client behaves within expectations, however this “expected behaviour” itself is at issue. and removed Z1-question 🙋‍♀️ Issue is a question. Closer should answer. labels Oct 9, 2018
@5chdn 5chdn modified the milestones: 2.2, 2.3 Oct 29, 2018
@seunlanlege seunlanlege self-assigned this Nov 21, 2018
@seunlanlege
Copy link
Member

can't replicate this on kovan.

@Tbaut Tbaut added Z6-unreproducible 🤷 Issue could not be reproduced and removed P5-sometimesoon 🌲 Issue is worth doing soon. labels Nov 29, 2018
@Tbaut
Copy link
Contributor

Tbaut commented Nov 29, 2018

@gituser Could you please provide a concrete example (with rpc or a web3 script) that could allow us to reproduce the behavior? Happy to reopen then.

@Tbaut Tbaut closed this as completed Nov 29, 2018
@gituser
Copy link
Author

gituser commented Nov 29, 2018

You want me to provide you with RPC call how to send transaction? It's all described in the issue description, re-read it.

Or you just want to get rid of another issue on github's tracker?

Simply try to send transaction with gas=20000 or specify value bigger than your current balance and then try to create another transaction with good value, it will never be picked up, because there will be a gap in nonce.

Why close the issue without trying to reproduce it? I've written exact steps how to reproduce the issue.

First with low gas value:

curl --data '{"method":"personal_sendTransaction","params":[{"from":"XXX","to":"YYY","value":"0x186a0","gas":"0x4e20},"password"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545

if account has balance of 1 ETH try to send 2 ETH:

curl --data '{"method":"personal_sendTransaction","params":[{"from":"XXX","to":"YYY","value":"0x1BC16D674EC80000"},"password"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545

After any of these actions above try to send another legitimate transaction and it will be stuck because of the gap in nonce.

@gituser
Copy link
Author

gituser commented Nov 29, 2018

Also, I've just tested on newest parity release and the bug is still there on Ropsten, I'm pretty sure on Kovan it should be there too.

@Tbaut
Copy link
Contributor

Tbaut commented Nov 29, 2018

The reason I ask is not to bother you :) Sometimes users introduce mistake in their RPC/script and call it a bug. Since @seunlanlege gave it a try and couldn't reproduce, that's a good enough reason to ask you some more info ;) Thanks for providing them, we'll check on Ropsten.

@Tbaut Tbaut reopened this Nov 29, 2018
@gituser
Copy link
Author

gituser commented Nov 29, 2018

Sure, it's non-standard behavior, but software should be able to handle such use-cases and not break, don't you think?
And for example not everyone knows that minimum gas amount for transaction is 21000.

@5chdn 5chdn added Z0-unconfirmed 🤔 Issue might be valid, but it’s not yet known. and removed Z6-unreproducible 🤷 Issue could not be reproduced labels Nov 29, 2018
@5chdn 5chdn modified the milestones: 2.3, 2.4 Jan 10, 2019
@seunlanlege
Copy link
Member

closed via #10051

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
F3-annoyance 💩 The client behaves within expectations, however this “expected behaviour” itself is at issue. M4-core ⛓ Core client code / Rust. Z0-unconfirmed 🤔 Issue might be valid, but it’s not yet known.
Projects
None yet
Development

No branches or pull requests

5 participants
@gituser @5chdn @seunlanlege @Tbaut and others