Skip to content
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

Merged
merged 6 commits into from
Mar 31, 2023
Merged

Add tests for race conditions in merkledb #1256

merged 6 commits into from
Mar 31, 2023

Conversation

kyl27
Copy link
Contributor

@kyl27 kyl27 commented Mar 24, 2023

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.

@patrick-ogrady
Copy link
Contributor

Awesome contribution, @kyl27 ❤️ . We'll take a look at this tomorrow.

In the meantime, I enabled unit tests on the PR!

Copy link
Contributor

@darioush darioush left a 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.

x/merkledb/trie_test.go Outdated Show resolved Hide resolved
x/merkledb/trieview.go Outdated Show resolved Hide resolved
@StephenButtolph StephenButtolph added testing This primarily focuses on testing storage This involves storage primitives labels Mar 28, 2023
@dboehm-avalabs
Copy link
Contributor

@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.

x/merkledb/trie_test.go Outdated Show resolved Hide resolved
x/merkledb/trie_test.go Outdated Show resolved Hide resolved
@kyl27
Copy link
Contributor Author

kyl27 commented Mar 29, 2023

Added an additional test for GetRangeProof()

Copy link
Contributor

@darioush darioush left a 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?

x/merkledb/trie_test.go Outdated Show resolved Hide resolved
@StephenButtolph StephenButtolph added this to the v1.10.0 (Cortina) milestone Mar 31, 2023
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
@StephenButtolph StephenButtolph merged commit e5567ec into ava-labs:dev Mar 31, 2023
@kyl27 kyl27 deleted the merkledb-tests branch March 31, 2023 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
storage This involves storage primitives testing This primarily focuses on testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants