[EOF] In-language construct to check for EOF

As a part of EOF implementation we’re considering adding a mechanism for checking whether the contract is being compiled to EOF or not. Before we do this, however, we’d like to gauge interest in it, because the solutions we see are not pretty. Our main question is whether library authors would be interested in using such a mechanism in the first place during some transition period or whether they’d favor switching to EOF wholesale as soon as it’s viable. We’d hope for the latter, since EOF is expected to be an improvement across the board, with little incentive to keep using the legacy codegen and keep dealing with problems like StackToDeep. Also, assuming we do want this mechanism - what form it should take.


What we were primarily thinking of was some kind of isEOF() or eofVersion() global helper that could be used in conditionals. The value would be a compile-time constant so the irrelevant branch would be completely eliminated by the optimizer. There are, however, some potential issues:

  • Some syntax elements like the {gas: } call option of <address>.code member will not be available on EOF. Some elements may also become mandatory, like salt for new. For the EOF check to be of any use, the compiler would still have to accept the old syntax on EOF, which is problematic. We could restrict it only to areas inside the check but this would only work in very simple cases (it would basically have to be hard-coded for a particular form of if) and we’d rather avoid such magic constructs.
  • The problem is even bigger with inline assembly. Making it portable may boil down to basically having to provide two versions of an assembly block.

As an aside, our prototype implementation is almost complete and will become generally available as an experimental feature in the next release. It can already be tried out on nightly builds.

1 Like