-
Notifications
You must be signed in to change notification settings - Fork 134
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
refactor: use generics for consensus test specs testing to reduce code duplication #1621
Conversation
2f5e6a1
to
b521e77
Compare
b521e77
to
d745c63
Compare
testing/ef-tests/README.md
Outdated
## Run [ethereum/consensus-spec-tests](https://github.com/ethereum/consensus-spec-tests) | ||
|
||
|
||
Run Tests this will automatically download test data |
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.
IIUC, this will also run the tests? This kind of sounds like it will only download the test data...
Clean test files | ||
```bash | ||
make clean | ||
``` |
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.
In general, I think this README could use a fair amount more useful information....
- outline of the crate structure
- what kinds of datatypes are being tested?
- how to add tests in future forks & make sure that they're tested
- any other info you think would be useful to someone who just looks at this crate, and doesn't want to go digging through the code to understand what's going on
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.
Thank you for the feedback I will update the readme 🫡
@njgheorghita ready for another look, I tried to address the feedback, let me know if there is anything else you think would need improvement |
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 think it will be better if we have a root Makefile, instead of always going inside testing/ef-test
if we want to download the test data.
testing/ef-tests/README.md
Outdated
|
||
In the future we may also test `ethereum/execution-test-specs` | ||
|
||
## how to add tests in future forks & make sure that they're tested |
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.
nit:
## how to add tests in future forks & make sure that they're tested | |
## How to add tests in future forks & make sure that they're tested |
testing/ef-tests/README.md
Outdated
@@ -0,0 +1,46 @@ | |||
## Run [ethereum/consensus-spec-tests](https://github.com/ethereum/consensus-spec-tests) | |||
|
|||
`ethereum/consensus-spec-tests` test data is important for testing our types, but the test data is very large which makes it not feasible to host it in our repository, this has lead to us under testing new types when new forks ship, and adding thousands of lines of test data and copy pasting almost identical tests with a few variables renamed. |
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.
`ethereum/consensus-spec-tests` test data is important for testing our types, but the test data is very large which makes it not feasible to host it in our repository, this has lead to us under testing new types when new forks ship, and adding thousands of lines of test data and copy pasting almost identical tests with a few variables renamed. | |
`ethereum/consensus-spec-tests` test data is important for testing our types, but the test data is very large which makes it not feasible to host it in our repository, this has led to us under testing new types when new forks ship, and adding thousands of lines of test data and copy pasting almost identical tests with a few variables renamed. |
testing/ef-tests/README.md
Outdated
### tests | ||
All the tests the `ef-tests` crates run will be located in the `tests` folder | ||
|
||
## what kinds of data types are being tested? |
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.
nit:
## what kinds of data types are being tested? | |
## What kinds of data types are being tested? |
testing/ef-tests/Makefile
Outdated
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.
@ogenev ready for another review, I believe I addressed all your concerns, let me know if I missed something or anything |
I didn't take a closer look, but I wanted to ask why use Makefile and downloading test files instead of using submodule (like we do for In general, I'm in favor of this PR. |
Both lighthouse and reth download the test files using makefiles. The test data is over 500MB's and uses git lfs, so I think using a submodule would make it less friendly to clone our project or run tests. Doing it this way git cloning is still fast, and the annoying thing of git submodules changing branches is avoided. |
Makefile
Outdated
##@ Other | ||
|
||
.PHONY: clean | ||
clean: ## Perform a `cargo` clean and remove the binary and test vectors directories. | ||
cargo clean | ||
rm -rf $(BIN_DIR) | ||
rm -rf $(EF_TESTS_DIR) | ||
rm -rf $(EF_TESTS_DIR) |
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.
nit: missed new line in EOF
@echo "Tests complete." | ||
|
||
.PHONY: test | ||
test: ## Runs workspace tests. |
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.
What do you think about having a make command like test-workspace
(or test-trin
?), where we will run cargo test --workspace -- --nocapture
and then having make test
to run all tests (ef-tests
+ test-workspace
)?
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 wouldn't want make test
to run ef-tests
as it downloads files
neither lighthouse or reth uses make test
to run ef-tests
Lighthouse puts ef-tests
behind make test-full
, I will do that as then it is more intentional you want to run the expanded test suite, which would involve downloading files.
Both lighthouse and reth use make test
for testing the workspace
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.
ok fair enough 👍 .
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.
⛵
What was wrong?
Currently every fork we must add thousands of lines of test data from ethereum/consensus-spec-tests and copy pastes tons of tests
This bloats our repo with large files, but also creates a bunch of almost duplicate tests.
This method also makes our test coverage limited as adding tests taking a lot of work to add and maintain so we often avoided adding additional test cases
This makes it very annoying and tedious to write tests for future forks
How was it fixed?
Creating a
ef-testing
crate which runs tests on data mostly generically, but manually for some cases.ethereum/consensus-spec-tests
These tests will also run in the CI which is good
Lighthouse and Reth use similar strategies for dealing with EF test data
In short
Future work
This is a big improvement, but of course we can always still improve. Anyways I want to move
ethportal-peertest
to the testing folder, and probably the test folder into it as well. What do you guys think?I also want to move
utp-testing
into the testing folder