Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check against 0xEF byte in contract creation. #719

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions evm_arithmetization/src/cpu/kernel/asm/core/process_txn.asm
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,15 @@ global process_contract_creation_txn_after_constructor:

ISZERO %jumpi(contract_creation_fault_3)

// EIP-3541: Reject new contract code starting with the 0xEF byte
// EIP-3541: Reject new contract code starting with the 0xEF byte, if code_size > 0
%returndatasize // size of the code
DUP1 ISZERO
// stack: code_size == 0, code_size, leftover_gas, new_ctx, address, retdest, success
%jumpi(process_contract_creation_txn_after_ef_check)
// stack: code_size, leftover_gas, new_ctx, address, retdest, success
PUSH 0 %mload_current(@SEGMENT_RETURNDATA) %eq_const(0xEF) %jumpi(contract_creation_fault_3_zero_leftover)

// stack: leftover_gas, new_ctx, address, retdest, success
%returndatasize // Size of the code.
process_contract_creation_txn_after_ef_check:
// stack: code_size, leftover_gas, new_ctx, address, retdest, success
DUP1 %gt_const(@MAX_CODE_SIZE) %jumpi(contract_creation_fault_4)
// stack: code_size, leftover_gas, new_ctx, address, retdest, success
Expand Down Expand Up @@ -487,8 +491,8 @@ contract_creation_fault_3:

contract_creation_fault_3_zero_leftover:
%revert_checkpoint
// stack: leftover_gas, new_ctx, address, retdest, success
%pop3
// stack: code_size, leftover_gas, new_ctx, address, retdest, success
%pop4
PUSH 0 // leftover gas
// stack: leftover_gas, retdest, success
%pay_coinbase_and_refund_sender
Expand Down
Loading