9

Why doesn't the Ethereum protocol have a clear indicator for a transaction that is reverted?

There's a heuristic here as well as a workaround using Geth. But there are probably ways that the protocol could provide a clear indicator. For example, could a transaction receipt have a boolean property for outofgas?

What could the protocol do to provide an Out of Gas indicator, and why were none implemented?

3
  • I feel it could be used in an attack to make a node do extra work for free. Idk
    – user3407
    Commented Jul 15, 2016 at 14:01
  • 1
    Wouldn't it be a good idea to make an EIP ? Commented Jul 15, 2016 at 14:51
  • I think it's a very good idea to have that information in the transaction receipt. Commented Aug 11, 2016 at 2:15

2 Answers 2

3

Most of the protocol (and more particularly the transaction receipt) is consensus critical. The amount of information it handles need to be as much as possible limited and stable. An error message doesn't really fit those requirements.

On the other hand, implementations can easily bubble up that sort of information. At least both Ethereumj and Geth do so. For an example see the "execution_error" property here:

http://api.blockcypher.com/v1/eth/main/txs/0x63b904db45e52924ff37e998a5553e2c9993bb89c0922c869fb7af8139af33ad

1
1

The protocol was updated in block 4370000 (Byzantium) so that a status indicator has been added to receipts.

eth.getTransactionReceipt(transactionHash) will return a status field that has a value of 0 when a transaction has failed and 1 when the transaction has succeeded.

Here's an example showing the status field:

{ blockHash: '0xb1fcff633029ee18ab6482b58ff8b6e95dd7c82a954c852157152a7a6d32785e',
  blockNumber: 4370000,
  contractAddress: null,
  cumulativeGasUsed: 21000,
  gasUsed: 21000,
  logs: [],
  logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
  root: null,
  status: 1, // **** HERE IS THE STATUS FIELD *****
  transactionHash: '0x1421a887a02301ae127bf2cd4c006116053c9dc4a255e69ea403a2d77c346cf5',
  transactionIndex: 0 }

(Blocks before 4370000 will have a status of null.)

More details here.

1
  • What do you get back in the status field if you call eth.getTransactionReceipt(transactionHash) before the block associated with the Tx hash is mined? Commented Nov 15, 2018 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.