-
-
Notifications
You must be signed in to change notification settings - Fork 405
test: fix broken spec tests for merkle proofs #8469
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
base: unstable
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @nazarhussain, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on enhancing the reliability and correctness of Merkle proof spec tests. It addresses issues related to integer precision during deserialization by introducing BigInt handling for large values and refines the test assertions for more thorough verification. Additionally, it improves documentation around Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request fixes broken Merkle proof spec tests by addressing issues with large integer deserialization. The approach involves conditionally replacing uint types with bigint for specific test cases that are known to exceed JavaScript's safe integer limit. The test logic is also updated to correctly calculate and verify Merkle proofs for different fork versions. My main feedback is to make the condition for using bigints more robust to improve test maintainability.
testCaseName.includes("random") || testCaseName.includes("max_blobs") || testCaseName.includes("multiple_blobs") | ||
? replaceUintTypeWithUintBigintType(sszTypesFor(fork).BeaconBlockBody) | ||
: sszTypesFor(fork).BeaconBlockBody; |
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 condition for switching to bigint
types relies on testCaseName.includes(...)
. This approach is a bit brittle and might lead to issues in the future:
- It could lead to false positives. For example, a test case named
not_random
would matchincludes("random")
. - If new test cases requiring
bigint
are added with names that don't match these substrings, the tests will fail unexpectedly.
Consider making this check more robust. For example, you could use a Set
of exact test suite names or more specific regular expressions to avoid ambiguity and make the test suite easier to maintain.
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.
If we have some future cases we will be aware of their failure can add those exact tests.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #8469 +/- ##
============================================
+ Coverage 52.22% 52.25% +0.03%
============================================
Files 853 852 -1
Lines 64898 64977 +79
Branches 4768 4771 +3
============================================
+ Hits 33893 33956 +63
- Misses 30935 30952 +17
+ Partials 70 69 -1 🚀 New features to boost your workflow:
|
Performance Report✔️ no performance regression detected Full benchmark results
|
? replaceUintTypeWithUintBigintType(sszTypesFor(fork).BeaconBlockBody) | ||
: sszTypesFor(fork).BeaconBlockBody; |
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.
any reason why we can't always replace values?
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.
We would change our types only for the cases we explicitly been aware of have issues with the 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.
I tend to think we should always replace uint values here. Reason is less code and less brittle as tests update. The comment is helpful still.
* If you are not fully sure about the limit of a certain value where you use this type, particularly | ||
* types related to network interaction, then we would encourage to use `UintBn64` instead. |
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.
hmm, this doesnt read very convincing, using UintNum64
in the wrong place could lead to a consensus failure so we need to make sure ot not get this wrong
"you are not fully sure"
then research how the value is used and make sure to not get this wrong, I don't think encouraging use of UintBn64
is good (due to it's perf impact), we should only do it if it's necessary
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.
That's what is been mentioned in here. That use UintBn64
when you are fully sure of the range of values. Having performance impact is not as crucial as consensus failure.
Feel free to suggest how you want to phrase it.
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 would just remove the last paragraph
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.
Let's see what other feels about it.
? replaceUintTypeWithUintBigintType(sszTypesFor(fork).BeaconBlockBody) | ||
: sszTypesFor(fork).BeaconBlockBody; |
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 tend to think we should always replace uint values here. Reason is less code and less brittle as tests update. The comment is helpful still.
Co-authored-by: Cayman <[email protected]>
The question will pop up should we do it for So I think it's much easier to reason about and only do conditional replace for the individual test cases we found have such random data. |
This is what your added comment helps illuminate. |
Motivation
Make sure all specs passes.
Description
Closes #7839
Steps to test or reproduce
Run all tests