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

fix(pkg/da): ensure DAH.hash is always calculated during ValidateBasic #845

Merged
merged 1 commit into from
Oct 10, 2022

Conversation

Wondertan
Copy link
Member

@Wondertan Wondertan commented Oct 6, 2022

This is useful for headers downloaded from the network. Each such header goes through validation during which the hash should be calculated. Otherwise, the hash is calcualated at much later point, which is prone to races. In celestia-node we observed such races when the DAH.Hahs is read from multiple routines, where both end up calculating the hash and setting the it to the cache value making the race detector complain. Such precompute fixes this, similar to how Hash is precomputed in the constructor.

This is useful for headers downloaded from the network. Each such header goes through validation during which the hash should be calculated. Otherwise, the hash is calcualated at much later point, which is prone to races.
In celestia-node we observed such races when the DAH.Hahs is read from multiple routines, where both end up calculating the hash and setting the it to the cache value making the race detector complain. Such precompute fixes this.
Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice find, 👍 👍

@evan-forbes
Copy link
Member

is this needed for celestiaorg/celestia-node#1160?

@Wondertan
Copy link
Member Author

Wondertan commented Oct 7, 2022

is this needed for celestiaorg/celestia-node#1160?

I observed the described race while playing with the code there and enabling race detector for tests it was disabled before 1.19. Don't think it's needed for #1160, as it's not directly related, but still should be included in the upcoming release.

@rootulp
Copy link
Collaborator

rootulp commented Oct 10, 2022

Merging based on celestiaorg/celestia-node#1160

@rootulp rootulp merged commit 7ca6eca into celestiaorg:main Oct 10, 2022
evan-forbes pushed a commit that referenced this pull request Oct 10, 2022
#845)

This is useful for headers downloaded from the network. Each such header
goes through validation during which the hash should be calculated.
Otherwise, the hash is calcualated at much later point, which is prone
to races. In celestia-node we observed such races when the DAH.Hahs is
read from multiple routines, where both end up calculating the hash and
setting the it to the cache value making the race detector complain.
Such precompute fixes this, similar to how Hash is precomputed in the
constructor.
rach-id pushed a commit to rach-id/celestia-app that referenced this pull request Nov 16, 2022
celestiaorg#845)

This is useful for headers downloaded from the network. Each such header
goes through validation during which the hash should be calculated.
Otherwise, the hash is calcualated at much later point, which is prone
to races. In celestia-node we observed such races when the DAH.Hahs is
read from multiple routines, where both end up calculating the hash and
setting the it to the cache value making the race detector complain.
Such precompute fixes this, similar to how Hash is precomputed in the
constructor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants