ewasm / design

Ewasm Design Overview and Specification
Apache License 2.0
1.02k stars 125 forks source link

should `unreachable` not OOG and just revert the state? #60

Closed wanderer closed 6 years ago

wanderer commented 7 years ago

Currently unreachable works just like an invalid opcode in EVM1, but it could provide a nicer way of handling reverts

axic commented 6 years ago

I think this is a good idea, but would suggest to keep the behaviour as is. Since this issue was opened, the EVM introduced the REVERT opcode.

Reasoning: revert() will mark the transaction as reverted and will not charge all the gas. unreachable then still remains as a second option to abort a transaction.

These two kinds of aborts are utilised by static analysis tools on Ethereum, where revert usually corresponds to a pre-condition and unreachable corresponds to an assertion.

chfast commented 6 years ago

I don't think there is any reason to additionally consume remaining gas in case of any kind of failure. If we accept this fact, the only matter that is left is how to report different kinds of failures.

axic commented 6 years ago

Decision: document that unreachable results in OOG.

chfast commented 6 years ago

I think it would be more correct to document that a trap results in OOG.