Skip to content

Commit

Permalink
Some clarifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth authored Jun 30, 2017
1 parent 793f88b commit efd2333
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions EIPS/eip-140.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@ Currently this is not possible. There are two practical ways to revert a transac

## Specification

The `REVERT` instruction is introduced at `0xfd`. Execution is aborted, considered as failed, and state changes are rolled back.
The `REVERT` instruction is introduced at `0xfd`. It expects two stack items, the top item is the `memory_offset` followed by `memory_length`. It does not return anything because it stops execution.

It expects two stack items, the top item is the `memory_offset` followed by `memory_length`. Both of these can equal to zero. The cost of the `REVERT` instruction equals to that of the `RETURN` instruction.
The semantics of `REVERT` with respect to memory and memory cost are identical to those of `RETURN`. The sequence of bytes given by `memory_offset` and `memory_length` is called "error message" in the following.

In case there is not enough gas left to cover the cost of `REVERT` or there is a stack underflow, the effect of the `REVERT` instruction will equal to that of a regular out of gas exception.
The effect of `REVERT` is that execution is aborted, considered as failed, and state changes are rolled back. The error message will be available to the caller in the returndata buffer and will also be copied to the output area, i.e. it is handled in the same way as the regular return data is handled.

The cost of the `REVERT` instruction equals to that of the `RETURN` instruction, i.e. the rollback itself does not consume all gas, the contract only has to pay for memory.

In case there is not enough gas left to cover the cost of `REVERT` or there is a stack underflow, the effect of the `REVERT` instruction will equal to that of a regular out of gas exception, i.e. it will consume all gas.

In the same way as all other failures, the calling opcode returns `1` on the stack following a `REVERT` opcode in the callee.

In case `REVERT` is used in the context of a `CREATE` or `CREATE2` call, no code is deployed, `1` is put on the stack and the error message is available in the returndata buffer.

The content of the optionally provided memory section is not defined by this EIP, but is a candidate for another Informational EIP.

Expand Down

0 comments on commit efd2333

Please sign in to comment.