-
Notifications
You must be signed in to change notification settings - Fork 670
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
Add tests for race conditions in merkledb #1256
Conversation
Awesome contribution, @kyl27 ❤️ . We'll take a look at this tomorrow. In the meantime, I enabled unit tests on the PR! |
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.
@kyl27 Thank you for contributing tests. I added a couple comments.
We can also consider adding parallelism to the tests that use randTestStep
here @dboehm-avalabs.
That is a good idea, though I'd probably like to make it a controllable parameter so that the reproducibility of the existing tests is preserved. |
Added an additional test for GetRangeProof() |
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.
LGTM, @dboehm-avalabs would you have a look too?
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
Why this should be merged
These tests perform concurrent reads/writes in x/merkledb to ensure there are no race conditions. Given that merkledb is under active development and will be used as a fundamental component in upcoming features such as HyperSDK, we should ensure that it has as many diverse tests as possible, covering all aspects of correctness and performance.
How this works
The golang testing framework provides the -race parameter, which allows it to perform analysis at runtime to test check for data races between go routines. These tests create multiple go routines that perform concurrent data read/writes in x/merkledb.
How this was tested
These new tests pass. Although these tests do not exhaustively check for data races between all combinations of concurrent calls to merkledb/trieView, they do check for several common access patterns.