feat(opcodes): reject 0xEF code prefix in CREATE/CREATE2#94
Merged
Conversation
cc1637c to
e72dac8
Compare
…loses #72 EIP-3541 (London hardfork): CREATE and CREATE2 must refuse to deploy runtime code whose first byte is 0xEF. That prefix is reserved for the EVM Object Format (EOF) — future EOF contracts must be created via a dedicated EOF creation transaction, not through legacy creation opcodes. The check is inserted in execute_create_inner/6 at the correct position: after init code execution, after EIP-170 code size validation, and before code deposit. This means: - Init code gas is consumed (no refund on rejection) - Sender nonce is incremented before the attempt - Empty runtime code (<<>>) is explicitly allowed Tests cover both opcodes, the empty-runtime edge case, safe non-0xEF runtime code, and the case where 0xEF appears inside init code but the returned runtime starts with a different byte. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
e72dac8 to
e7c6807
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements EIP-3541 (London hardfork):
CREATEandCREATE2now reject deployment of runtime code whose first byte is0xEF. This prefix is reserved for the EVM Object Format (EOF) to ensure future EOF contracts cannot be deployed accidentally or maliciously using the legacy creation path.What changed
lib/eevm/opcodes/system/creation.exreject_eip_3541_runtime_code?/1predicate that checksbyte_size(runtime_code) > 0 and :binary.first(runtime_code) == 0xEFexecute_create_inner/6at the correct position: after init code execution, after EIP-170 code size check, before code deposit — so init code gas is consumed but no contract is deployed@docblock explaining the EIP, its position in the check sequence, and the empty-code exceptiontest/opcodes/system/eip_3541_test.exs(new)CREATEwith0xEFruntime prefix → pushes 0, nonce incremented, no code storedCREATE2with0xEFruntime prefix → pushes 0CREATEwith empty runtime code → succeeds (empty is not0xEF)CREATEwith0x60runtime prefix → succeeds, code stored correctly0xEFbytes (but returning non-0xEFruntime) → succeedsSpec reference