Skip to content

Commit

Permalink
post review updates 1
Browse files Browse the repository at this point in the history
  • Loading branch information
gurukamath committed Aug 5, 2024
1 parent 3cfeb2e commit 47180a1
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 297 deletions.
2 changes: 1 addition & 1 deletion src/ethereum/prague/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def apply_body(
gas=SYSTEM_TRANSACTION_GAS,
value=U256(0),
data=parent_beacon_block_root,
container=beacon_block_roots_contract_code,
code=beacon_block_roots_contract_code,
depth=Uint(0),
current_target=BEACON_ROOTS_ADDRESS,
code_address=BEACON_ROOTS_ADDRESS,
Expand Down
6 changes: 3 additions & 3 deletions src/ethereum/prague/utils/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ def prepare_message(
get_account(env.state, caller).nonce - U256(1),
)
msg_data = Bytes(b"")
container = data
code = data
elif isinstance(target, Address):
current_target = target
msg_data = data
container = get_account(env.state, target).code
code = get_account(env.state, target).code
if code_address is None:
code_address = target
else:
Expand All @@ -103,7 +103,7 @@ def prepare_message(
gas=gas,
value=value,
data=msg_data,
container=container,
code=code,
depth=Uint(0),
current_target=current_target,
code_address=code_address,
Expand Down
31 changes: 16 additions & 15 deletions src/ethereum/prague/vm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
from ..blocks import Log
from ..fork_types import Address, VersionedHash
from ..state import State, TransientStorage, account_exists_and_is_empty
from .exceptions import InvalidEOF
from .exceptions import InvalidEof
from .precompiled_contracts import RIPEMD160_ADDRESS

__all__ = ("Environment", "Evm", "Message", "EOF")
__all__ = ("Environment", "Evm", "Message", "Eof")


EOF_MAGIC = b"\xEF\x00"
EOF_MAGIC_LENGTH = 2
EOF_MAGIC_LENGTH = len(EOF_MAGIC)

MAX_CODE_SIZE = 0x6000


class EOF(enum.Enum):
class Eof(enum.Enum):
"""
Enumeration of the different kinds of EOF containers.
Legacy code is assigned zero.
Expand All @@ -46,7 +46,7 @@ class EOF(enum.Enum):


@dataclass
class EOFMetadata:
class EofMetadata:
"""
Dataclass to hold the metadata information of the
EOF container.
Expand Down Expand Up @@ -112,7 +112,7 @@ class Message:
value: U256
data: Bytes
code_address: Optional[Address]
container: Bytes
code: Bytes
depth: Uint
should_transfer_value: bool
is_static: bool
Expand Down Expand Up @@ -143,8 +143,9 @@ class Evm:
error: Optional[Exception]
accessed_addresses: Set[Address]
accessed_storage_keys: Set[Tuple[Address, Bytes32]]
eof: EOF
eof_meta: Optional[EOFMetadata]
eof_version: Eof
eof_container: Optional[Bytes]
eof_metadata: Optional[EofMetadata]
current_section_index: Uint
return_stack: List[ReturnStackItem]

Expand Down Expand Up @@ -201,9 +202,9 @@ def incorporate_child_on_error(evm: Evm, child_evm: Evm) -> None:
evm.gas_left += child_evm.gas_left


def get_eof_version(code: bytes) -> EOF:
def get_eof_version(code: bytes) -> Eof:
"""
Get the EOF version container.
Get the Eof container's version.
Parameters
----------
Expand All @@ -212,13 +213,13 @@ def get_eof_version(code: bytes) -> EOF:
Returns
-------
EOF
EOF Version of the container.
Eof
Eof Version of the container.
"""
if not code.startswith(EOF_MAGIC):
return EOF.LEGACY
return Eof.LEGACY

if code[EOF_MAGIC_LENGTH] == 1:
return EOF.EOF1
return Eof.EOF1
else:
raise InvalidEOF("Invalid EOF version")
raise InvalidEof("Invalid EOF version")
Loading

0 comments on commit 47180a1

Please sign in to comment.