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?

eth
  • 85,679
  • 53
  • 285
  • 406

2 Answers2

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

Matthieu
  • 246
  • 1
  • 2
  • For Geth, are you using debug.traceTransaction or something else where a new answer to http://ethereum.stackexchange.com/questions/6007/how-can-the-transaction-status-from-a-thrown-error-be-detected-when-gas-can-be-e would help? – eth Aug 17 '16 at 11:26
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.

eth
  • 85,679
  • 53
  • 285
  • 406
  • 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? – Robert Oschler Nov 15 '18 at 13:50