Skip to content

Commit

Permalink
clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
gurukamath committed Aug 13, 2024
1 parent 89d8fea commit 5869072
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/ethereum/prague/vm/eof/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ def validate_code_section(validator: Validator) -> None:
if op_metadata.stack_height is None:
raise InvalidEof("Stack height not set")

stack_implementation = get_stack_validation(op)
stack_implementation(validator)
stack_validation = get_stack_validation(op)
stack_validation(validator)

update_successor_stack_height(validator)
if op_metadata.stack_height.max > computed_maximum_stack_height:
Expand Down
8 changes: 4 additions & 4 deletions src/ethereum/prague/vm/instructions/control_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
charge_gas,
)
from .. import Evm
from ..exceptions import ExceptionalHalt, InvalidJumpDestError
from ..exceptions import InvalidJumpDestError, StackOverflowError
from ..stack import pop, push


Expand Down Expand Up @@ -311,9 +311,9 @@ def callf(evm: Evm) -> None:
target_max_stack_height = Uint.from_be_bytes(target_section[2:])

if len(evm.stack) > 1024 - target_max_stack_height + target_inputs:
raise ExceptionalHalt
raise StackOverflowError
if len(evm.return_stack) == 1024:
raise ExceptionalHalt
raise StackOverflowError("Return stack overflow")

evm.return_stack.append(
ReturnStackItem(
Expand Down Expand Up @@ -383,7 +383,7 @@ def jumpf(evm: Evm) -> None:
target_max_stack_height = Uint.from_be_bytes(target_section[2:])

if len(evm.stack) > 1024 - target_max_stack_height + target_inputs:
raise ExceptionalHalt
raise StackOverflowError

# PROGRAM COUNTER
evm.current_section_index = target_section_index
Expand Down
12 changes: 6 additions & 6 deletions src/ethereum/prague/vm/instructions/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def extcodesize(evm: Evm) -> None:
The current EVM frame.
"""
from ..eof import EofVersion, get_eof_version
from ..eof import EOF_MAGIC, EofVersion, get_eof_version

# STACK
address = to_address(pop(evm.stack))
Expand All @@ -356,7 +356,7 @@ def extcodesize(evm: Evm) -> None:
code = get_account(evm.env.state, address).code
target_eof_version = get_eof_version(code)
if target_eof_version == EofVersion.EOF1:
codesize = U256(2)
codesize = U256(len(EOF_MAGIC))
else:
codesize = U256(len(code))

Expand All @@ -376,7 +376,7 @@ def extcodecopy(evm: Evm) -> None:
The current EVM frame.
"""
from ..eof import EofVersion, get_eof_version
from ..eof import EOF_MAGIC, EofVersion, get_eof_version

# STACK
address = to_address(pop(evm.stack))
Expand Down Expand Up @@ -404,7 +404,7 @@ def extcodecopy(evm: Evm) -> None:
code = get_account(evm.env.state, address).code
eof_version = get_eof_version(code)
if eof_version == EofVersion.EOF1:
value = b"\xEF\x00"
value = EOF_MAGIC
else:
value = buffer_read(code, code_start_index, size)
memory_write(evm.memory, memory_start_index, value)
Expand Down Expand Up @@ -479,7 +479,7 @@ def extcodehash(evm: Evm) -> None:
evm :
The current EVM frame.
"""
from ..eof import EofVersion, get_eof_version
from ..eof import EOF_MAGIC, EofVersion, get_eof_version

# STACK
address = to_address(pop(evm.stack))
Expand All @@ -497,7 +497,7 @@ def extcodehash(evm: Evm) -> None:
if account == EMPTY_ACCOUNT:
codehash = U256(0)
elif get_eof_version(account.code) == EofVersion.EOF1:
codehash = U256.from_be_bytes(keccak256(b"\xEF\x00"))
codehash = U256.from_be_bytes(keccak256(EOF_MAGIC))
else:
codehash = U256.from_be_bytes(keccak256(account.code))

Expand Down

0 comments on commit 5869072

Please sign in to comment.