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

Sending signed tx returns an error while tx was successfull #2587

Closed
AlexeyKhmelev opened this issue Mar 27, 2019 · 8 comments · Fixed by #2594
Closed

Sending signed tx returns an error while tx was successfull #2587

AlexeyKhmelev opened this issue Mar 27, 2019 · 8 comments · Fixed by #2594
Labels
Bug Addressing a bug

Comments

@AlexeyKhmelev
Copy link

Description

I have a simple code that sends signed transaction:

    const promiseEvent = ethProvider.sendSignedTransaction('0x' + serializedTx.toString('hex'));
    return promiseEvent.once('transactionHash', callback)
        .on('confirmation', (confirmNumber, receipt) =>
            console.log({ CONFIRMATION: { confirmNumber, receipt } })
        )
        .on('error', (error => {
                console.log({ ERROR: error });
            })
        );

That emit error event:

Transaction has been reverted by the EVM: :{
  "blockHash": "0xded395d97b26b7e43a2f09a6a72e804dac3e579f8e41c068f4bf2822e4f94c93",
  "blockNumber": 5285527,
  "contractAddress": null,
  "cumulativeGasUsed": 636536,
  "from": "0x0b30df42e49d3906f0c50916d6e99727b58a8650",
  "gasUsed": 65455,
  "logs": [
    {
      "address": "0x9e2A802e608A3C046860c2039792DCF0876c4799",
      "blockHash": "0xded395d97b26b7e43a2f09a6a72e804dac3e579f8e41c068f4bf2822e4f94c93",
      "blockNumber": 5285527,
      "data": "0x0000000000000000000000000000000000000000000000008ac72c1cd85aa000",
      "logIndex": 6,
      "removed": false,
      "topics": [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
        "0x0000000000000000000000007e23a7f3d51826650da4f515fbc499238f4d79e1",
        "0x0000000000000000000000000b30df42e49d3906f0c50916d6e99727b58a8650"
      ],
      "transactionHash": "0xa0e7c70064e7c80bc7534b40f951b434fc9e88a8547a4d88edd06e1e61ce7967",
      "transactionIndex": 8,
      "id": "log_0x0bd512a82042db1f3eda33ba6863b999ff916617b5a93a784960cd3710532fe9"
    },
    {
      "address": "0xa1c332933F9F4AAb72f128bb294B0CA22dAcb19D",
      "blockHash": "0xded395d97b26b7e43a2f09a6a72e804dac3e579f8e41c068f4bf2822e4f94c93",
      "blockNumber": 5285527,
      "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "logIndex": 7,
      "removed": false,
      "topics": [
        "0x624288b64c6c3f645691554ea1a84c4d17e0753059f967b43653768fbfcb5afb",
        "0x0000000000000000000000000000000000000000000000000000000000000000",
        "0x0000000000000000000000000b30df42e49d3906f0c50916d6e99727b58a8650"
      ],
      "transactionHash": "0xa0e7c70064e7c80bc7534b40f951b434fc9e88a8547a4d88edd06e1e61ce7967",
      "transactionIndex": 8,
      "id": "log_0xf22050ce849b7c4513378d55afa2d33ece66a7773a3ae2ef8e7915102c0f29b2"
    },
    {
      "address": "0x7e23A7f3D51826650dA4f515fBc499238f4D79e1",
      "blockHash": "0xded395d97b26b7e43a2f09a6a72e804dac3e579f8e41c068f4bf2822e4f94c93",
      "blockNumber": 5285527,
      "data": "0x0000000000000000000000000000000000000000000000008ac72c1cd85aa000",
      "logIndex": 8,
      "removed": false,
      "topics": [
        "0x09bd3894cb7ab22415416dac0fecc519855a4b0842f1c9115e562ef557ab577b",
        "0x0000000000000000000000000b30df42e49d3906f0c50916d6e99727b58a8650"
      ],
      "transactionHash": "0xa0e7c70064e7c80bc7534b40f951b434fc9e88a8547a4d88edd06e1e61ce7967",
      "transactionIndex": 8,
      "id": "log_0x5f06e1efe77a7b8260055839863c5bb06ff2b328f58661cc1c137e30b0194a02"
    }
  ],
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000100000000000000000000080000000000100000000000000000000000000000000000000000000000000008000000000000000800000400008000000000000000000000020000000800000000000800000000000000000000000010000000000000000000000000000000000000000000000000008001000000010000080000000000000000000001000000000000200000000000000000080000000000000004000002000000000000000000000020100000000000000000000020000020004000000000000000000000040000000000000001000000000000000000000000",
  "status": true,
  "to": "0x7e23a7f3d51826650da4f515fbc499238f4d79e1",
  "transactionHash": "0xa0e7c70064e7c80bc7534b40f951b434fc9e88a8547a4d88edd06e1e61ce7967",
  "transactionIndex": 8
}

at SafeSubscriber._next (/node_modules/web3-core-method/dist/web3-core-method.cjs.js:1017:32)
at SafeSubscriber.__tryOrUnsub (/node_modules/rxjs/internal/Subscriber.js:207:16)
at SafeSubscriber.next (/node_modules/rxjs/internal/Subscriber.js:145:22)
at Subscriber._next (/node_modules/rxjs/internal/Subscriber.js:89:26)
at Subscriber.next (/node_modules/rxjs/internal/Subscriber.js:66:18)
at TransactionObserver.emitNext (/node_modules/web3-core-method/dist/web3-core-method.cjs.js:438:16)
at _callee2$ (/node_modules/web3-core-method/dist/web3-core-method.cjs.js:408:24)
at tryCatch (/node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.(anonymous function) [as next] (/node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7) }

while the transaction was successful:
https://ropsten.etherscan.io/tx/0xa0e7c70064e7c80bc7534b40f951b434fc9e88a8547a4d88edd06e1e61ce7967

Probably the status field format was changed and the method hasRevertReceiptStatus doesn't work as expected:

  hasRevertReceiptStatus(receipt) {
    return Boolean(parseInt(receipt.status)) === false && receipt.status !== undefined && receipt.status !== null;
  }

Versions

  • web3.js: ^1.0.0-beta.50
  • nodejs: 8.11.1
  • ethereum node: ropsten

Details:
image

Could you please give any comments? Is it a bug or the specific of testnet or whatever? Thanks a lot!

@nivida
Copy link
Contributor

nivida commented Mar 27, 2019

Could you add some more details about the connected node and for example add the responses you see in the network tab of your browser?

@AlexeyKhmelev
Copy link
Author

@nivida it's a server side. I use infura:

    httpEthereumProvider: 'https://ropsten.infura.io/v3/***',
    wsEthereumProvider: 'wss://ropsten.infura.io/ws',

and same for mainnet.

@nivida
Copy link
Contributor

nivida commented Mar 27, 2019

I've checked it closer and it's an issue of infura because they return a boolean instead of hex value which is representing the boolean.

Current behavior:

"status": true

Expected behavior:

"status": "0x1"

It's also documented to return a hex value here and here.

@nivida nivida closed this as completed Mar 27, 2019
@Robsonsjre
Copy link

Same problem, using infura too.

@Fang-
Copy link

Fang- commented Mar 27, 2019

Experiencing the same error when using ganache-cli, which seems to exhibit identical behavior to Infura.

Noteworthy these also produces integers for blockNumber, gasUsed, etc, rather than hex-encoded values (QUANTITYs as per the RPC spec). From a quick glance at ganache-core's revision history, it seems it's been doing this for some time. Web3 previously worked fine with that. Perhaps it should continue to be accepting of "decoded" RPC results?

@mesirendon
Copy link

I'm running into this problem as well. I thought the problem was ganache so I deployed into Ropsten and tried to test my API against it, but I'm getting the same behavior. So I don't think it's something related to Infura or Ganache, simply because the transactions are actually on chain.

What I'm doing now is testing my API with mocha and chai. I'm signing the transaction manually and then sending it signed

post: (functionName, ...params) => new Promise((resolve, reject) => {
    const contractFunction = Tru.contract.methods[functionName](...params);
    const functionAbi = contractFunction.encodeABI();
    contractFunction.estimateGas(from)
      .then(gas => sign(functionAbi, gas))
      .then(Tru.web3.eth.sendSignedTransaction)
      .then((tx) => {
        resolve(tx.transactionHash)
      })
      .catch((e) => {
        console.error(`Post(${functionName}): ${e}`);
        reject(e);
      });
  }),

What I get in my tests is this:

  1) Repository: SmartContract
       Tru
         should allow to register a candidates list:
     Error: Transaction has been reverted by the EVM:
{
  "transactionHash": "0x326a2971c3215a740c0104db0f0d372c90947dba04628224448f3690cbbe1fc9",
  "transactionIndex": 0,
  "blockHash": "0x89f543b36a673ee953f6d38f33be6217448d8e916b9ef556a059142e4c430902",
  "blockNumber": 13,
  "from": "0xdc1fb6c03c9cc8235a2f9cf35c94dd1d112ef45d",
  "to": "0x04b5f46f401fa4f421a19f69efa0a29b1ae53270",
  "gasUsed": 77149,
  "cumulativeGasUsed": 77149,
  "contractAddress": null,
  "logs": [],
  "status": true,
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000",
  "v": "0x1b",
  "r": "0x79c7a2a4a183f2f575dd939d8ea6bd546d91f3ca080401b414bec5dbbc989f1b",
  "s": "0x1e13dfff69eade930c41f6ff204bdb28303abf881823743fe7d21abe68d830eb"
}
      at SafeSubscriber._next (node_modules/web3-core-method/dist/web3-core-method.cjs.js:1017:32)
      at SafeSubscriber.__tryOrUnsub (node_modules/rxjs/src/internal/Subscriber.ts:267:10)
      at SafeSubscriber.next (node_modules/rxjs/src/internal/Subscriber.ts:209:14)
      at Subscriber._next (node_modules/rxjs/src/internal/Subscriber.ts:139:22)
      at Subscriber.next (node_modules/rxjs/src/internal/Subscriber.ts:99:12)
      at TransactionObserver.emitNext (node_modules/web3-core-method/dist/web3-core-method.cjs.js:438:16)
      at _callee2$ (node_modules/web3-core-method/dist/web3-core-method.cjs.js:408:24)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
      at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
      at process._tickCallback (internal/process/next_tick.js:68:7)

But if I go to the truffle console, and check for the specified tx, I get everything good. I can even retrieve data right away from my contract's internal structure.

@ryanschneider
Copy link

I'm pretty sure the transformation from hex to bool is happening at a higher layer in your code, as the raw result from Infura is clearly still a "0x1":

$ curl https://ropsten.infura.io/v3/${PROJECT_ID} -X POST -d '{"id":1, "jsonrpc": "2.0", "method": "eth_getTransactionReceipt", "params": ["0xa0e7c70064e7c80bc7534b40f951b434fc9e88a8547a4d88edd06e1e61ce7967"]}' -H 'Content-Type: application/json' | jq .result.status

"0x1"

@SwissArmyBud
Copy link

@mesirendon and @ryanschneider see reference discussion about #2542

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants