EIP-615: Subroutines and Static Jumps for the EVM -- Last Call

Following is my review of EIP-615. This includes all issues past and present which apply to the current text. This includes technical problems which warrant cancelling/extending this Last Call, specific recommendations to improve the EIP (I will supply PR if invited), and arguments on theoretical and practical topics.

Dependency is missing

In the text it states

Dependencies

EIP-1702. Generalized Account Versioning Scheme. This proposal needs a versioning scheme to allow for its bytecode (and eventually eWasm bytecode) to be deployed with existing bytecode on the same blockchain.

However, such a dependency is missing in the front matter header.

EIP-1702 DRAFT is not a finalized document. Therefore I believe EIP-615 is prematurely in Last Call status. For precedent, please see ERC-721 where ERC-165 was a prerequisite and the latter was finalized before the former entered Last Call.

There will be no benefit, and much cost, in finalizing EIP-1720 if it cannot be used. The prerequisites are not met and so it can’t be used. The cost is that it cannot continue to be edited. So again, Last Call should be aborted.

Another dependency. The instruction arguments are specified to use “MSB-first, two’s-complement, two-byte positive integers”. This puts an upper bound on the non-data part (and non-JUMPDEST part) of contract sizes at 0x7fff. This depends on contract sizes being limited, which is currently specified by EIP-170 to be limited to 0x6000, so this is good. This dependency on EIP-170 can please be included in the front matter for cross reference purposes, and referenced in text.

Test cases are missing

EIP-1 states:

Test Cases - Test cases for an implementation are mandatory for EIPs that are affecting consensus changes. Other EIPs can choose to include links to test cases if applicable.

However this EIP fails to include test cases.

Backwards compatibility is incomplete

This EIP introduces a backwards compatibility against a finalized EIP, specifically EIP-1167. Requesting please that this be added as a note for cross-reference.

Formal verification is not shown to provide any practical benefit

The first line in the EIP states:

…formal specification and verification are an essential tool against loss.

However this claim is not substantiated sufficiently. Only references are made under the heading “some papers” at bottom.

I have raised this topic before, but that wasn’t Last Call, so I’ll do it again here.

Has anybody translated any deployed contract to the proposed byte code and successfully detected any actual problem using formal verification? Would EIP-615 have prevented this week’s exploit on 0x Exchange 2.0?

Notes on complexity are misleading

The paper hypothesizes a vulnerability where contract authors can evade formal analysis by introducing quadratic complexity against a static analyzer.

Otherwise, Contracts can be crafted or discovered with quadratic complexity to use as denial of service attack vectors against validations and optimizations.

This is entirely impractical because no serious projects publish using EVM, they all use a higher level language. Everybody knows that a contract which does not publish its higher-level source code is suspect. And since Solidity is advertised here to be able to target EIP-615 as easily as current EVM, now therefore all the formal analysis benefits of EIP-615 already exist today against Solidity source code.

Separately, there is a note on complexity at:

All of the instructions are O(1) with a small constant, requiring just a few machine operations each, whereas a JUMP or JUMPI typically does an O(log n) binary search of an array of JUMPDESToffsets before every jump.

This is an implementation detail. Anybody that cared to implement JUMPDEST lookup in O(1) time would simply store all bytecode in 9-bit bytes where the extra bit denotes valid jump destinations.

Dynamic jumps are rarely used

I have provided a method to analyze existing contracts to find if they are actually using dynamic jumps or if instead there is a trick to immediately (O(1)) find jump destinations.

This analysis is performed here:

It demonstrates that the vast majority of JUMPs on EVM are not actually dynamic.

This puts into question the underlying motivation of this EIP which is to remove dynamic jumps. This relevant analysis is not referenced from the EIP.

Other notes/corrections

(Negative values are reserved for extensions.)

At current, zero is also unused and could be reserved.