Check call depth in create (#1089)

This commit is contained in:
wborgeaud 2023-06-08 12:59:38 +02:00 committed by GitHub
parent e51c4d0d21
commit 9838a367ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,7 +70,11 @@ global create_common:
// stack: address, value, code_offset, code_len, kexit_info
DUP1 %insert_accessed_addresses_no_return
// TODO: Check call stack depth.
// Check call depth
%call_depth
%gt_const(@CALL_STACK_LIMIT)
%jumpi(create_too_deep)
// stack: address, value, code_offset, code_len, kexit_info
DUP2 %selfbalance LT %jumpi(create_insufficient_balance)
// Increment the sender's nonce.
@ -220,6 +224,12 @@ create_oog:
%stack (code_size_cost, leftover_gas, success, address, kexit_info) -> (kexit_info, 0)
EXIT_KERNEL
create_too_deep:
%mstore_context_metadata(@CTX_METADATA_RETURNDATA_SIZE, 0)
%stack (address, value, code_offset, code_len, kexit_info) -> (kexit_info, 0)
// stack: kexit_info, 0
EXIT_KERNEL
%macro set_codehash
%stack (addr, codehash) -> (addr, codehash, %%after)
%jump(set_codehash)