Verbatim contracts #16027
Labels
EOF
high impact
Changes are very prominent and affect users or the project in a major way.
medium effort
Default level of effort
must have
Something we consider an essential part of Solidity 1.0.
Abstract
Introduce syntax for defining EOF initcontainers produced from a verbatim string of bytecode rather than a contract definition. Allow
eofcreate()
to refer to them and deploy them that way.Motivation
Due to the ban on code introspection,
eofcreate()
, unlikecreate()
orcreate2()
does not allow the user to provide arbitrary bytecode to be deployed. While this is intentional, there are use cases that are not in conflict with the ban but can no longer be expressed in the language due to this. For example libraries implementing ERC-1167 depend on the ability to deploy a piece of hand-crafted bytecode that is known at compilation time. We need a language construct to express that.The solution is to make the compiler aware that the hard-coded bytecode is not just a random string of bytes, but is instead meant to represent a valid initcontainer. Currently the subcontainers produced from Solidity source always correspond to contracts (either the runtime part of the current contract or other contracts it has a bytecode dependency on), but this mechanism can be extended to allow hand-crafted containers.
Note that this does not have the same negative implications as allowing embedding of pieces of verbatim bytecode inside contracts (#12067). The container would be expected to be a self-contained contract and would not undergo any optimization.
Specification
contract X = <bytecode>;
syntax, where<bytecode>
is a string literal.new
(we don't know the constructor signature), but can be used as any other type. In particular, most properties oftype(X)
are available and it can be cast to an interface.<name>.object
.eofcreate
inline assembly #15981 already introduces for referring to contracts ineofcreate()
.verbatim()
, and would be treated as distinct form other literal strings.eofcreate()
.object
s as literal bytecodedata
is currently defined inside objects:The feature is primarily meant for EOF and at least the initial implementation should focus on that. It would technically also be possible to extend it to the legacy EVM, but this would require introducing additional inline assembly builtins corresponding to
create()
andcreate2()
that would accept verbatim bytecode corresponding to a contract.Backwards Compatibility
Fully backwards compatible outside of Yul/inline assembly. Changes to
eofcreate()
would be incompatible, but EOF is an experimental feature and we don't guarantee compatibility for those until they become stable.The text was updated successfully, but these errors were encountered: