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

Implement EOF #972

Open
wants to merge 89 commits into
base: forks/prague
Choose a base branch
from
Open

Implement EOF #972

wants to merge 89 commits into from

Conversation

gurukamath
Copy link
Collaborator

What was wrong?

The current specs do not support EOF

Related to Issue #971

How was it fixed?

Implement the 11 EOF EIPs

Cute Animal Picture

Cute Animals - 1 of 1

@gurukamath gurukamath changed the base branch from forks/prague to master July 6, 2024 10:46
Copy link
Contributor

@SamWilsn SamWilsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review.

src/ethereum/prague/vm/__init__.py Outdated Show resolved Hide resolved
src/ethereum/prague/vm/__init__.py Outdated Show resolved Hide resolved
@@ -95,6 +111,7 @@ class Evm:
error: Optional[Exception]
accessed_addresses: Set[Address]
accessed_storage_keys: Set[Tuple[Address, Bytes32]]
eof: EOF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a descriptive field name. How about:

Suggested change
eof: EOF
container_format: Eof

src/ethereum/prague/vm/__init__.py Outdated Show resolved Hide resolved
src/ethereum/prague/vm/__init__.py Outdated Show resolved Hide resolved
header_end_index: Uint


def get_opcode(opcode: int, eof: EOF) -> Ops:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should name this more descriptively. Some (bad) ideas:

  • integer_to_op
  • parse_op
  • validate_op

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as map_int_to_op

src/ethereum/prague/vm/eof.py Outdated Show resolved Hide resolved
pc: Uint
stack: List[U256]
memory: bytearray
code: Bytes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we create NewType for code vs. container vs. whatever other types of sections there are?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am interpreting this as the code being implemented. If it is legacy, then it's just the code. If EOF, it is the code in the section being currently implemented.

)


def validate_header(container: bytes) -> EOFMetadata:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this separate from meta_from_valid_eof1_container?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combined into one function with a flag to validate

raise InvalidEOF("Invalid input/output for first section")


def get_valid_instructions(code: bytes) -> Set[int]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have a better name for this. From just the signature, it looks like it returns a uniqued list of all the opcodes used in code, but I think it returns offsets instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has now been integrated into the validate_code_section function.

@gurukamath gurukamath marked this pull request as ready for review August 13, 2024 09:07
@gurukamath gurukamath changed the base branch from master to forks/prague August 15, 2024 14:13
This commit updates to the latest test releases and fixes some minor bugs exposed by the increased coverage.
In particular, the bugs related to faulty return flag in the type section are fixed. Any code section that has
RETF instruction or has a JUMPF to a returning section is considered a returning section. Otherwise, the code section
is considered non-returning. The output in the type section should reflect this behaviour. If not, the container is
invalid
@gurukamath gurukamath deleted the branch forks/prague January 25, 2025 16:51
@gurukamath gurukamath closed this Jan 25, 2025
@gurukamath gurukamath reopened this Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants