ethermint-archive icon indicating copy to clipboard operation
ethermint-archive copied to clipboard

Contract transaction couldn't be found after 50 blocks

Open jaekwon opened this issue 9 years ago • 5 comments

Raised by Dan Turner.

This bug appears with a single ethermint node deployment. There are two machines using node.js making requests to geth, one 'local' and one 'Travis' machine. They are both attempting to deploy a contract using the same account. The node.js app is using this library to submit the transaction: https://github.com/ConsenSys/hooked-web3-provider/blob/master/app/hooked-web3-provider.es6#L81

What we've seen is that the same tx will fail sometimes, but restarting ethermint will allow it to succeed.

[17:09:54] Starting 'concat'...
[17:09:54] Finished 'concat' after 47 ms
[17:09:54] Starting 'compile'...
Using Geth @ 'http://node-1.<snipped>:8545'
[17:10:01] Finished 'compile' after 7.11 s
[17:10:01] Starting 'deploy'...
Redeploy contracts: true
Deploy: DateTime
DateTime: doesn't exist
Nonce: 0x436
Contract "DateTime" transaction sent: TransactionHash: 0x118df26e014ff76da1db09967ac7082c392c48038e5b4f87fbc330aa83a13938 waiting to be mined...
Error: Contract transaction couldn't be found after 50 blocks

Then restart ethermint, and...

[17:12:38] Using gulpfile ~/code/canchain-api/gulpfile.js
[17:12:38] Starting 'concat'...
[17:12:38] Finished 'concat' after 41 ms
[17:12:38] Starting 'compile'...
Using Geth @ 'http://node-1.<snipped>:8545'
[17:12:45] Finished 'compile' after 7.08 s
[17:12:45] Starting 'deploy'...
Redeploy contracts: true
Deploy: DateTime
DateTime: doesn't exist
Nonce: 0x436
Contract "DateTime" transaction sent: TransactionHash: 0x118df26e014ff76da1db09967ac7082c392c48038e5b4f87fbc330aa83a13938 waiting to be mined...
DateTime mined! Address: 0x7507cd7f730da66a2d326ed41f838f26af41082f
Saved contract

Notice that the tx hash is identical.

jaekwon avatar Jan 23 '17 07:01 jaekwon

Since there is only 1 node, and according to Dan only geth was used to submit transactions, it's probably unrelated to #10.

jaekwon avatar Jan 23 '17 07:01 jaekwon

is that still valid ?

illya13 avatar Feb 18 '17 07:02 illya13

Still reproduced. Will add details later

ramilexe avatar May 01 '17 16:05 ramilexe

The cause of this issue:

  1. go-ethereum has flag homestead. It affect to gas price of operation in EVM. When homestead is true cost of EVM command is increased.
  2. By default go-ethereum started with homestead=false.
  3. You want to deploy big smart contract you need to know gas for it. You use web3.eth.estimateGas function to calc it. But when you call this function your go-ethereum works with homestead=false and calc gas cheaper.
  4. web3.eth.estimateGas returns your some value and you pass this value as gas limit for smart contract deploy transaction.
  5. but in app.validateTx ethermint calc gas as homestead = true (https://github.com/tendermint/ethermint/blob/master/app/app.go#L223) and it require more gas for it transaction than you passed.
  6. app.validateTx -> app.CheckTx returns error and smart contract never deployed

ramilexe avatar May 10 '17 23:05 ramilexe

Fixed :-)

adrianbrink avatar May 15 '17 18:05 adrianbrink