Skip to content
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

No response for contract method (send) invocation in 1.0.0-beta.52 via HttpProvider #2674

Closed
mmshihov opened this issue Apr 12, 2019 · 1 comment

Comments

@mmshihov
Copy link

Description

I got web3 instance for http provider:

   var web3 = new Web3(new Web3.providers.HttpProvider(NODE_URL));

Then contract method sending:

    let paramObj = {  from: <addr>,  gas:   20000, gasPrice: 0  };
    var contract = new web3.eth.Contract(<abi>, <address>);
    var invokeTx = contract.methods[methodName](...methodParams);

    invokeTx.send(paramObj)
        .on('transactionHash', (hash) => { 
            console.log("ON transactionHash:", hash);  })
        .on('confirmation', (confirmationNumber, receipt) => {
            console.log("ON confirmation:", confirmationNumber, receipt);  })
        .then(response => {
              // NEVER GET HERE !!!
        })
        .catch(err => { 
             console.log(err); 
             // GOT error after some period of time: 
             // Timeout exceeded during the transaction confirmation process. Be aware the transaction could still get confirmed!
        }) ;

Expected behavior

Contract method invocation and getting the response in Web3js client code.

Actual behavior

Just one "ON confirmation" emit, web3.eth.transactionPollingTimeout delay and error:

 Timeout exceeded during the transaction confirmation process. Be aware the transaction could still get confirmed!

Assumptions

In web3.js/packages/web3-core-method/src/observers/TransactionObserver.js:153:

                    const block = await this.getBlockByNumber(this.increaseBlockNumber(this.lastBlock.number)); 

                    if (block && this.isValidConfirmation(block)) {
                        this.lastBlock = block;
                        this.confirmations++;
                        this.emitNext(receipt, observer);
                    }

It looks like increaseBlockNumber(blockNumber) funciton (line 283) asserts that blockNumber is a string in 16 radix

increaseBlockNumber(blockNumber) {
    return '0x' + (parseInt(blockNumber, 16) + 1).toString(16); //__WTF__ этого говна либо нету, либо в 10 сс!
}

, but it parsed to number in outputBlockFormatter (web3.js/packages/web3-core-helpers/src/Formatters.js:305):

if (block.number !== null) {
    block.number = Utils.hexToNumber(block.number);
}

Versions

  • web3.js: 1.0.0-beta.52
  • nodejs: v8.11.3
  • ethereum node: quorum geth
@nivida
Copy link
Contributor

nivida commented Apr 14, 2019

The code below will work if you configure the transactionConfirmationBlocks to one. We have an open issue regarding the block number with an Http connection here. I will fix and release it asap.

invokeTx.send(paramObj)
  .on('transactionHash', (hash) => { 
    console.log("ON transactionHash:", hash);  })
  .on('confirmation', (confirmationNumber, receipt) => {
    console.log("ON confirmation:", confirmationNumber, receipt);  })
  .on('receipt', (receipt) => {
    console.log(receipt); 
   })
  .on('error', () => { 
    console.log(err); 
  });

@nivida nivida closed this as completed Apr 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants