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

more efExample tests and eof exceptions #550

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

more efExample tests and eof exceptions #550

wants to merge 5 commits into from

Conversation

winsvega
Copy link
Collaborator

@winsvega winsvega commented May 9, 2024

πŸ—’οΈ Description

add more eof exceptions and tests from efExample by Ori

πŸ”— Related Issues

βœ… Checklist

  • All: Set appropriate labels for the changes.
  • All: Considered squashing commits to improve commit history.
  • All: Added an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • Tests: All converted JSON/YML tests from ethereum/tests have been added to converted-ethereum-tests.txt.
  • Tests: Included the type and version of evm t8n tool used to locally execute test cases: e.g., ref with commit hash or geth 1.13.1-stable-3f40e65.
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.

@winsvega winsvega marked this pull request as draft May 9, 2024 10:52
@winsvega winsvega added the scope:tests Scope: Test cases label May 14, 2024
@winsvega winsvega force-pushed the efExample branch 2 times, most recently from 2c68f7c to 5b4320f Compare May 15, 2024 11:53
@winsvega winsvega marked this pull request as ready for review May 15, 2024 11:54
@@ -209,6 +209,9 @@ def list_header(sections: List["Section"]) -> bytes:
Creates the single code header for all code sections contained in
the list.
"""
if sections[0].skip_header_listing:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is to allow types section to use skip_header_listing flag

@winsvega winsvega requested a review from marioevz May 16, 2024 10:06
@@ -384,6 +391,874 @@
EOFException.UNDEFINED_INSTRUCTION,
id="jump_jumpdest_fails",
),
pytest.param(
Copy link
Contributor

Choose a reason for hiding this comment

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

We discussed with @marioevz and @danceratopz that this array with tests is not great. I don't mind some much the array but maybe it should be a separate test?

But what is bad that we add a ton of sophisticated tests to "example" category.

You should also add test cases to the EOF tracker file.

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 personally find it confusing when such an array is stored in another file, but here it is quite transparent

Copy link
Member

@marioevz marioevz May 30, 2024

Choose a reason for hiding this comment

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

I think the problem is that tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_example_valid_invalid.py contains too many unrelated test cases.

For example it tries to cover many of the deprecated opcodes but not all of them.

We need to break up test_example_valid_invalid into different coherent test functions testing similar things, it's too big, and it makes it difficult to find a specific test case (also no longer an "example", it contains multiple valid tests).

Copy link
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

Some comments on the readability. I think we should make test cases easier to find in general, with better categorization, and splitting them in files where it makes sense, instead of having everything in one file/function.

@@ -247,6 +247,10 @@ class EOFException(ExceptionBase):
"""
EOF container missing code section
"""
MISSING_DATA_SECTION = auto()
Copy link
Member

Choose a reason for hiding this comment

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

I think this is already in the main branch, so rebasing should remove this.

name="EOF1I0015",
sections=[
Section.Code(
code=Op.SELFDESTRUCT(1) + Op.STOP,
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the reason why we have two SELFDESTRUCT opcode tests here.

"ef000102000100030400010000800001305000ef",
EOFException.MISSING_TYPE_HEADER,
id="bad_type_section_order_3",
),
],
)
def test_example_valid_invalid(
Copy link
Member

Choose a reason for hiding this comment

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

I think we should break this function up into different ones to make it easier to find implemented tests, and we can create different functions that really test similar things. E.g. we could make a test_deprecated_opcodes functions and parameterize it to each opcode that is deprecated in EOF (see V1_EOF_DEPRECATED_OPCODES in tests/prague/eip7692_eof_v1/eip3540_eof_v1/opcodes.py, which actually needs an update), and another one for header failures, etc.

Also, I think there's definitely duplicates between this file and file tests/prague/eip7692_eof_v1/eip3540_eof_v1/container.py, which also should be cleaned up, but perhaps in a follow up PR.

)
from ethereum_test_tools.eof.v1.constants import NON_RETURNING_SECTION

from .spec import EOF_FORK_NAME
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
from .spec import EOF_FORK_NAME
from .. import EOF_FORK_NAME

On latest commit in main, this is where the EOF_FORK_NAME is actually defined.

@@ -287,6 +291,10 @@ class EOFException(ExceptionBase):
"""
EOF container header does not have types section first
"""
INVALID_CODE_SECTION_INDEX = auto()
Copy link
Member

Choose a reason for hiding this comment

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

This is ok, but I think that now some tests in the tests/prague/eip7692_eof_v1/eip6206_jumpf/test_jumpf_execution.py should be updated because they no longer fit the EOFException.UNDEFINED_EXCEPTION definition (because their exception is now defined with this change).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:tests Scope: Test cases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants