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

Nonce error at personal_sendTransaction - multiple nonces, skipped nonces #10174

Closed
DaWe35 opened this issue Jan 13, 2019 · 4 comments
Closed
Labels
F3-annoyance 💩 The client behaves within expectations, however this “expected behaviour” itself is at issue. M4-core ⛓ Core client code / Rust.
Milestone

Comments

@DaWe35
Copy link

DaWe35 commented Jan 13, 2019

  • Parity Ethereum version: 2.1.10
  • Operating system: Linux
  • Installation: one-line installer
  • Fully synchronized: yes
  • Network: ethereum & ropsten & kovan.
  • Restarted: yes

I found an issue what happenes then I'm sending a tx which is more than my balance.
I wrote a script which prints the account balance, the nextNonce, sends a tx, and prints the real nonce used in this tx. The script content (it is not important, just if you need):

balance=$(curl -s --data '{"method":"eth_getBalance","params":["0x9de7e5d5066b2b06beebbf9e379e9d0a6a232041"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545)
balance=$(echo "$balance" | jq '.result')
echo -n "Balance: "
echo "${balance//\"}"

nexnon=$(curl -s --data '{"method":"parity_nextNonce","params":["0x9de7e5d5066b2b06beebbf9e379e9d0a6a232041"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545)
nexnon=$(echo "$nexnon" | jq '.result')
echo -n "parity_nextNonce: "
echo "${nexnon//\"}"

hash=$(curl -s --data '{"method":"personal_sendTransaction","params": [{ "from": "0x9de7e5d5066b2b06beebbf9e379e9d0a6a232041", "to": "0x34A6E41B8B23853a4A44e0e9D49D13BE6FFb33Cf", "gas": "0xBB80", "value": "0x16345785D8A0000"}, "pass"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545)
hash=$(echo "$hash" | jq '.result')
hash=$(echo "${hash//\"}")
echo -n "TX hash: "
echo $hash

txdata=$(curl -s --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["'"$hash"'"],"id":1}' -H "Content-Type: application/json" -X POST localhost:8545)
echo -n "Used nonce: "
nonce=$(echo $txdata | jq '.result.nonce')
echo "${nonce//\"}"

Starting balance: ~0.2 ETH. Each script run sends 0.1 ETH to another address.

user@machine:~$ ./debug-parity.sh
Balance: 0x2c99c545c3b0000
parity_nextNonce: 0x5a
TX hash: 0x48f40fc3e624e123f51a3a24018ec9d908049d0c025b33c91df93145100f1ee2
Used nonce: 0x5a

user@machine:~$ ./debug-parity.sh
Balance: 0x16643c28d26b000
parity_nextNonce: 0x5b
TX hash: 0xf34ffed7a9d8a5500fd2ecaa88c2eb027a50bc47105601b6369e2b1b26178b37
Used nonce: 0x5b

so here my balance is ~0, but the latest 2 tx isn't confirmed, so I can create new txes

user@machine:~$ ./debug-parity.sh
Balance: 0x16643c28d26b000
parity_nextNonce: 0x5c
TX hash: 0xe2dee6abb397d719332b0ba6f201f5722b16626e4e8eb9bd13ae42be5f52df0e
Used nonce: null

I don't know why "used nonce" is null, so a ran getTransactionByHash: {"jsonrpc":"2.0","result":null,"id":1}. So this tx doesn't exist, but personal_sendTransaction returned a valid txid and the nonce increased.

user@machine:~$ ./debug-parity.sh
Balance: 0x16643c28d26b000
parity_nextNonce: 0x5c
TX hash: 0xd89c9904b2004068ef01c69a82efacaf35c27e676fd3371dd13625895e09cd83
Used nonce: 0x5d
---0.5 ETH deposit---
user@machine:~$ ./debug-parity.sh
Balance: 0x6f3468a91c46000
parity_nextNonce: 0x5c
TX hash: 0x065849afa5b631e5532e86e0b6a449c7adacd1438126829a1e05557d4f133856
Used nonce: 0x5e

As you can see, a nonce slipped, "parity_nextNonce" != "Used nonce".

@DaWe35 DaWe35 changed the title Auto nonce error at personal_sendTransaction - multiple nonces, skipped nonces Nonce error at personal_sendTransaction - multiple nonces, skipped nonces Jan 13, 2019
@jam10o-new jam10o-new added F3-annoyance 💩 The client behaves within expectations, however this “expected behaviour” itself is at issue. M4-core ⛓ Core client code / Rust. labels Jan 13, 2019
@jam10o-new jam10o-new added this to the 2.4 milestone Jan 13, 2019
@jam10o-new
Copy link
Contributor

Would you say a good tl;dr is that "nonce remains incremented even if an invalid pending transaction is culled"?

@DaWe35
Copy link
Author

DaWe35 commented Jan 13, 2019

Would you say a good tl;dr is that "nonce remains incremented even if an invalid pending transaction is culled"?

I don't know, because getTransactionByHash response was null, not a culled tx. Or is getTransactionByHash response null for a culled tx?

@DaWe35
Copy link
Author

DaWe35 commented Jan 14, 2019

Maybe using the same "nextNonce generator" at personal_sendTransaction can solve a part of the problem, because nextNonce alwais returns good value. But I don't understand, why the 3rd tx was culled, and the 4th why not?

@jam10o-new
Copy link
Contributor

@DaWe35 #10051 should resolve this issue once it's merged and released, so I'll close this issue as a duplicate as its already known.

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.
Projects
None yet
Development

No branches or pull requests

2 participants