poanetwork / token-wizard

(Discontinued) TokenWizard is an DApp to create and manage crowdsale and token contracts using a simple UI
MIT License
386 stars 215 forks source link

(Bug) Failed to check for transaction receipt #472

Closed vbaranov closed 6 years ago

vbaranov commented 6 years ago

If you are reporting a problem with ICO Wizard, please include the following information:

Which network did you use? (Mainnet, Kovan, Rinkeby, etc.)

Mainnet

If you were able to create it, what is the URL of your crowdsale?

I wasn't able to create the crowdsale. ICO Wizard failed on the 2nd transaction. But the transaction is successfully mined later: https://etherscan.io/tx/0xeceac5957cd7d57826f21e0b9f6c462617efa99363a135586f7dc46c95777341.

The same error was happening before this PR https://github.com/poanetwork/ico-wizard/pull/465 is merged too. So, it isn't provoked by it.

Do you have screenshots showing the problem?

2018-01-09 19 32 43

Root problem https://github.com/ethereum/web3.js/issues/1255 Relates to https://github.com/poanetwork/ico-wizard/issues/471

Do you see errors in the dev console? If yes, please include a screenshot

(To open the dev console in Google Chrome, press F12, or go to View -> Developer -> Developer Tools, and open the Console tab)

wizard.poa.network-1515514258309.log


rstormsf commented 6 years ago

How do u get private key from user?

This issue is not related to root problem mentined above, because in ICO-wizard there is no sendSignedTx call, as well as having direct access to raw private key. The root problem is hidden somewhere else, I don't think it's web3 problem. Lets investigate more into the root cause.

@vbaranov Can you show us where is the code reference in wizard where you actually send Tx and waiting for receipt?

rstormsf commented 6 years ago

Can it be that you are calling callback on receipt outside of IF block from CheckTxMined https://github.com/poanetwork/ico-wizard/blob/3bbf54996a463f04d685291a9f9316c910c9f016/src/utils/blockchainHelpers.js#L251

export function checkTxMined(web3, txhash, cb) {
  web3.eth.getTransactionReceipt(txhash, function(err, receipt) {
    if (receipt)
      console.log(receipt);
    cb(receipt);
  });
}

to

export function checkTxMined(web3, txhash, cb) {
  web3.eth.getTransactionReceipt(txhash, function(err, receipt) {
    if (receipt){
    console.log(receipt);
    cb(receipt);
}

  });
}

also, you are not checking for errors here:

https://github.com/poanetwork/ico-wizard/blob/3bbf54996a463f04d685291a9f9316c910c9f016/src/utils/blockchainHelpers.js#L152

you are only expecting a receipt, this is anti-pattern

vbaranov commented 6 years ago

Thank you for valuable comments! There are some ways to refactor here. I'll take a deep look. @fernandomg @fvictorio if you'll have some suggestions here, please, share too.

fernandomg commented 6 years ago

I share the idea of refactor (progressively), and I think is a must to fix all the anti-patterns in the code.

Anyway, yesterday I tested without using the checkTxMined, and listening the promiEvent receipt; but got a Gateway timeout.

So today I rolled back, and used the same code that's in master, and it failed due to intrinsic gas too low, when trying to deploy PricingStrategy contract (this is the 3rd tx).

Log: localhost-1515597586385.log

Sucessful tx: https://etherscan.io/tx/0xdb25e621f6750901de8f3ac6f3414d16621e71816e0966f16eb8bc3bddcdd491 https://etherscan.io/tx/0x1e9922ee9648ec2b50eeba0c9d11dcc1878bb44aed095837d0aee636b1cda01a