-
Notifications
You must be signed in to change notification settings - Fork 84
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
Conversation
Lines of code reportTotal lines added: Detailed view
|
There was a problem hiding this 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.
Suggestion, leave in PR description the necessary steps for running the tests |
Parsing test files... |
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 |
@JereSalo your suggestions where added here:
The comment about repeated runs I consider better to leave for another PR. What do you think? |
There was a problem hiding this 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.
// Remove previous report if it exists. | ||
let _ = fs::remove_file("./runner_v2/runner_report.txt").await; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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), | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
95eec0f
to
aa1431b
Compare
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. |
I removed a lot of custom errors for situations external to VM problems in this commit, replacing with I added the report file to Also, I added some comments on the functions purposes here. |
There was a problem hiding this 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
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/
runmake 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 runmake download-evm-ef-tests
previously.Considerations
The main changes are:
Test
andTestCase
structures in types.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.