EVM Transactions – Retrieve Event Log from Reverted Transaction

evm

I know there is an upcoming change to solidity which will allow the returning of require() calls with a string error message. But I'm wondering if it's possible to do something like this now. Since each node has to run the code up to the revert point to know that the code reverts, doesn't this mean that the event will get stored in the history still? And if we're operating a node couldn't we see that the event was fired off even inside of a reverted transaction? I'm not an expert on the EVM so maybe I'm missing something crucial but it seems like something like this should be possible.

Best Answer

No, when a revert occurs, the transaction state changes are thrown away, including any event logs.

This behaviour is defined in the Yellow Paper here:

enter image description here

The A0 bit when w = REVERT is the formal version of what I said above: no logs are recorded in the case of a revert.

If you are running your own node, of course you can do whatever you like. Geth, for example can provide very detailed transaction traces that you can look at and see what happened even for aborted transactions. But none of that will get stored on the main blockchain.

Related Topic