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

eth_getTransactionReceipt doesn't return a block number while a token transfer call #10623

Closed
vanzay opened this issue May 1, 2019 · 9 comments
Labels
Z1-question 🙋‍♀️ Issue is a question. Closer should answer.

Comments

@vanzay
Copy link

vanzay commented May 1, 2019

  • Parity Ethereum version: 2.4.5
  • Operating system: Linux
  • Installation: one-line installer
  • Fully synchronized: yes
  • Network: ropsten
  • Restarted: yes

Steps to reproduce

Send tokens using web3 library

const Web3 = require('web3');
const abi = require('human-standard-token-abi');

async function testSend() {
  let url = 'http://127.0.0.1:8545';
  let contractAddress = '0x6031ab93c5e436dfc6f4db819bf50f67e7b1289d';
  let from = '0x76b4514ceb23475be392e1305877a834401bdde8';
  let secret = 'secret';
  let to = '0xe63fb07be1bbc1d84c7e41554faf5457a1c4327e';
  let amount = 5 * 10 ** 18;
  let gas = 100000;

  let web3 = new Web3(new Web3.providers.HttpProvider(url));
  let contract = new web3.eth.Contract(abi, contractAddress);
  let gasPrice = await web3.eth.getGasPrice();
  await web3.eth.personal.unlockAccount(from, secret, null);
  let tx = await contract.methods.transfer(to, `${amount}`).send({from, gas, gasPrice});
  console.log(tx);
}

It throws an error "Invalid params: invalid type: null, expected a block number or 'latest', 'earliest' or 'pending'." because eth_getTransactionReceipt doesn't return a block number (see RPC calls below).

RPC calls traces

  1. eth_gasPrice
{ jsonrpc: '2.0', id: 0, method: 'eth_gasPrice', params: [] }
{ jsonrpc: '2.0', result: '0x3b9aca00', id: 0 }
  1. personal_unlockAccount
{ jsonrpc: '2.0',
  id: 1,
  method: 'personal_unlockAccount',
  params:
   [ '0x76b4514ceb23475be392e1305877a834401bdde8',
     '734873kjn873',
     null ] }
{ jsonrpc: '2.0', result: true, id: 1 }
  1. eth_sendTransaction
{ jsonrpc: '2.0',
  id: 2,
  method: 'eth_sendTransaction',
  params:
   [ { from: '0x76b4514ceb23475be392e1305877a834401bdde8',
       gas: '0x186a0',
       gasPrice: '0x3b9aca00',
       data:
        '0xa9059cbb000000000000000000000000e63fb07be1bbc1d84c7e41554faf5457a1c4327e0000000000000000000000000000000000000000000000004563918244f40000',
       to: '0x6031ab93c5e436dfc6f4db819bf50f67e7b1289d' } ] }
{ jsonrpc: '2.0',
  result:
   '0xd1e0cf24bb077418b1836470b2d225c37568b373490b1b2087987c2ec8c06545',
  id: 2 }
  1. eth_getTransactionReceipt
{ jsonrpc: '2.0',
  id: 3,                                                                                                                                                                                                      15:40
  method: 'eth_getTransactionReceipt',
  params:
   [ '0xd1e0cf24bb077418b1836470b2d225c37568b373490b1b2087987c2ec8c06545' ] }
{ jsonrpc: '2.0',
  result:
   { blockHash: null,
     blockNumber: null,
     contractAddress: null,
     cumulativeGasUsed: '0x96b9',
     from: null,
     gasUsed: '0x96b9',
     logs: [ [Object] ],
     logsBloom:
      '0x0000000000100000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000800000000000000000000000000000000010000000000000000
0000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000002000000000000000000100000000000000000000000000000000000000000010000000000000000000000000000002000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000002',
     root: null,
     status: '0x1',
     to: null,
     transactionHash:
      '0xd1e0cf24bb077418b1836470b2d225c37568b373490b1b2087987c2ec8c06545',
     transactionIndex: '0x0' },
  id: 3 }
  1. eth_getBlockByNumber
{ jsonrpc: '2.0',
  id: 4,
  method: 'eth_getBlockByNumber',
  params: [ null, false ] }
{ jsonrpc: '2.0',
  error:
   { code: -32602,
     message:
      'Invalid params: invalid type: null, expected a block number or \'latest\', \'earliest\' or \'pending\'.' },
  id: 4 }
@jam10o-new
Copy link
Contributor

jam10o-new commented May 1, 2019

eth_getTransactionReceipt returns a null blocknumber if the transaction is not mined yet.
Reference: https://wiki.parity.io/JSONRPC-eth-module#eth_gettransactionreceipt

This behaviour diverges from geth, which return null instead of any receipt - parity-ethereum returns a receipt if it is aware of the requested transaction but it is unconfirmed.

@jam10o-new jam10o-new added the Z1-question 🙋‍♀️ Issue is a question. Closer should answer. label May 1, 2019
@nivida
Copy link

nivida commented May 1, 2019

From the documentation:

A transaction receipt object, or null when no receipt was found:

@jam10o-new
Copy link
Contributor

From geth's documentation. This divergence has been present for a long while (since 2016, see #3482)

@nivida
Copy link

nivida commented May 1, 2019

Thanks for referencing the issue. Is there any effort from the node developers to have the JSON-RPC API in sync? @gavofyork @joshua-mir
(Btw.: I've copied it from the parity documentation)

@jam10o-new
Copy link
Contributor

jam10o-new commented May 1, 2019

@nivida there is a draft-stage EIP open to standardise the specification between clients ethereum/EIPs#1474
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md

Sorry, you're right, but in this case the reciept is found but it is in the transaction pool/pending block.

@nivida
Copy link

nivida commented May 1, 2019

Thanks for referencing the EIP-1474 but it's also there not documented as Parity has implemented it.

@jam10o-new
Copy link
Contributor

It's a draft-stage EIP, at this stage copied directly from the Ethereum wiki. In the PR comments, you can see some discussion around the discrepancies between geth and parity.

@jam10o-new
Copy link
Contributor

If you want to see even more discussion around this, we also have #10550 with some additional explanation on why the difference exists.

@adria0
Copy link

adria0 commented Jul 27, 2020

Closing issue due to its stale state.

@adria0 adria0 closed this as completed Jul 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Z1-question 🙋‍♀️ Issue is a question. Closer should answer.
Projects
None yet
Development

No branches or pull requests

5 participants
@nivida @adria0 @vanzay @jam10o-new and others