Skip to content

refactor(levm): rewrite of state EF tests runner first iteration #3642

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

Merged
merged 22 commits into from
Jul 22, 2025

Conversation

sofiazcoaga
Copy link
Contributor

@sofiazcoaga sofiazcoaga commented Jul 15, 2025

Motivation

Related issue: #3496.

The idea is to incrementally develop a new EF Test runner (for state tests) that can eventually replace the current one. The main goal of the new runner is to be easy to understand and as straightforward as possible, also making it possible to easily add any new requirement.

How to run
A target in the makefile was included. You can, then, from ethrex/cmd/ef_tests/state/ run make run-new-runner. If no specific path is passed, it will parse anything in the ./vectors folder. Otherwise you can do, for example:
make run-new-runner TESTS_PATH=./vectors/GeneralStateTests/Cancun to specify a path.

This command assumes you have the vectors directory downloaded, if not run make download-evm-ef-tests previously.

Considerations

The main changes are:

  • The new Test and TestCase structures in types.
  • The runner and parser simplified flows.

Files that should not be reviewed as they are full or partial copies of the original files:

  • runner_v2/deserialize.rs
  • runner_v2/utils.rs

This iteration excludes report-related code, option flags and other possible test case errors to be considered that will be included later. Checks are performed only on exceptions and root hash.

@sofiazcoaga sofiazcoaga requested a review from a team as a code owner July 15, 2025 16:41
@github-actions github-actions bot added the levm Lambda EVM implementation label Jul 15, 2025
@sofiazcoaga sofiazcoaga marked this pull request as draft July 15, 2025 16:41
Copy link

github-actions bot commented Jul 15, 2025

Lines of code report

Total lines added: 1087
Total lines removed: 0
Total lines changed: 1087

Detailed view
+-----------------------------------------------------+-------+------+
| File                                                | Lines | Diff |
+-----------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/lib.rs                    | 7     | +1   |
+-----------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/runner_v2/deserialize.rs  | 294   | +294 |
+-----------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/runner_v2/error.rs        | 11    | +11  |
+-----------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/runner_v2/mod.rs          | 7     | +7   |
+-----------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/runner_v2/parser.rs       | 48    | +48  |
+-----------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/runner_v2/result_check.rs | 166   | +166 |
+-----------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/runner_v2/run.rs          | 13    | +13  |
+-----------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/runner_v2/runner.rs       | 104   | +104 |
+-----------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/runner_v2/types.rs        | 406   | +406 |
+-----------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/runner_v2/utils.rs        | 37    | +37  |
+-----------------------------------------------------+-------+------+

@sofiazcoaga sofiazcoaga changed the title refactor(levm): refactor of state EF tests runner refactor(levm): rewrite of state EF tests runner first iteration Jul 15, 2025
@sofiazcoaga sofiazcoaga marked this pull request as ready for review July 15, 2025 17:24
Copy link
Contributor

@cdiielsi cdiielsi left a comment

Choose a reason for hiding this comment

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

Really nice work! I like how you distributed the modules, having runner separated from result_check makes things feel less crowded and easier to navigate. I made a couple of comments, one you can consider moving on (it's about writing reports) the rest are rather subjective and totally skippable.

@JereSalo
Copy link
Contributor

Suggestion, leave in PR description the necessary steps for running the tests

@JereSalo
Copy link
Contributor

Parsing test files...
Error: FailedToParseTestFile("./vectors/LegacyTests/Cancun/GeneralStateTests/Cancun/stEIP1153-transientStorage/21_tstoreCannotBeDosdOOO.json", "Failed to deserialize post field in test 21_tstoreCannotBeDosdOOO. Serde error: missing field state")

@JereSalo
Copy link
Contributor

Now that each test is one struct we can filter out repeated tests, a problem in the other runner that we have was that we were running some tests twice because some files were duplicated

@mpaulucci mpaulucci moved this to In Progress in ethrex_l1 Jul 17, 2025
@sofiazcoaga
Copy link
Contributor Author

@JereSalo your suggestions where added here:

  • The parsing error was fixed by making state field optional here
  • Include the possibility to specify a path to the tests here
  • Makefile command to run the tests here
  • How to run the tests left in the PR description

The comment about repeated runs I consider better to leave for another PR. What do you think?

@sofiazcoaga sofiazcoaga requested a review from JereSalo July 18, 2025 15:54
Copy link
Contributor

@JereSalo JereSalo left a comment

Choose a reason for hiding this comment

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

Some additional comments:

  • Leave rustdocs comments in top of functions/methods. Even the ones that are kinda self-explanatory. Usually one line is enough for some of the short functions.
  • Add runner_report.txt to .gitignore
  • Use unwrap and delete a lot of the errors, keep only the errors that are specific to the VM if possible. If something shouldn't happen (like failing to write a file) just unwrap. Abuse this as code clarity and size matters, we want to make it easier and faster to read.

Comment on lines +17 to +18
// Remove previous report if it exists.
let _ = fs::remove_file("./runner_v2/runner_report.txt").await;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we simply overwrite instead of manually removing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing is, every test report is written as soon as it finishes executing, so I have to open the file in append mode. To do that, I need to make sure that I'm appending to a file that belongs only to this run and no other.

Comment on lines 4 to 24
pub enum RunnerError {
RootMismatch,
FailedToGetAccountsUpdates,
VMExecutionError(String),
CurrentBaseFeeMissing,
MaxPriorityFeePerGasMissing,
MaxFeePerGasMissing,
TxSucceededAndExceptionWasExpected,
DifferentExceptionWasExpected,
EIP7702ShouldNotBeCreateType,
FailedToReadDirectory(PathBuf, String),
FailedToConvertPath,
FailedToGetFileType(String),
FailedToParseTestFile(PathBuf, String),
FailedToOpenFile(String),
FailedToWriteReport(String),
MissingJsonField(String),
FailedToDeserializeField(String),
FailedToCreateReportFile(String),
FailedToGetIndexValue(String),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be tidy, it's too cluttered. It's okay for this iteration to be pretty basic but it has to be the simplest it can possibly be and this enum is overwhelming.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed a lot of errors as I mention in this comment, but I will certainly keep in mind to make this file tidier in later iterations. Thank you!

@JereSalo JereSalo force-pushed the ef_tests/refactor-runner branch from 95eec0f to aa1431b Compare July 18, 2025 20:05
@JereSalo
Copy link
Contributor

@JereSalo your suggestions where added here:

  • The parsing error was fixed by making state field optional here
  • Include the possibility to specify a path to the tests here
  • Makefile command to run the tests here
  • How to run the tests left in the PR description

The comment about repeated runs I consider better to leave for another PR. What do you think?

That's fine, I just thought this was important because it's a thing that we should consider for the structure of the tests. But I agree it should be tackle in another PR, it is a priority though.

@sofiazcoaga
Copy link
Contributor Author

sofiazcoaga commented Jul 21, 2025

Some additional comments:

  • Leave rustdocs comments in top of functions/methods. Even the ones that are kinda self-explanatory. Usually one line is enough for some of the short functions.
  • Add runner_report.txt to .gitignore
  • Use unwrap and delete a lot of the errors, keep only the errors that are specific to the VM if possible. If something shouldn't happen (like failing to write a file) just unwrap. Abuse this as code clarity and size matters, we want to make it easier and faster to read.

I removed a lot of custom errors for situations external to VM problems in this commit, replacing with unwrap() as you suggested. This made the error.rs file smaller as well.

I added the report file to .gitignore here.

Also, I added some comments on the functions purposes here.

Copy link
Contributor

@JereSalo JereSalo left a comment

Choose a reason for hiding this comment

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

good job, I think the comment on the type of the transaction is wrong though but the pr is okay

@github-project-automation github-project-automation bot moved this from In Progress to In Review in ethrex_l1 Jul 21, 2025
@sofiazcoaga sofiazcoaga added this pull request to the merge queue Jul 22, 2025
Merged via the queue into main with commit 2ce46bf Jul 22, 2025
37 checks passed
@sofiazcoaga sofiazcoaga deleted the ef_tests/refactor-runner branch July 22, 2025 18:42
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
levm Lambda EVM implementation
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants