Skip to content

Commit

Permalink
fix(pkg/da): ensure DAH.hash is always calculated during ValidateBasic (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
Wondertan authored Oct 10, 2022
1 parent 5885894 commit 7ca6eca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/da/data_availability_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (dah *DataAvailabilityHeader) ValidateBasic() error {
len(dah.ColumnRoots),
)
}
if err := validateHash(dah.hash); err != nil {
if err := validateHash(dah.Hash()); err != nil {
return fmt.Errorf("wrong hash: %v", err)
}

Expand Down

0 comments on commit 7ca6eca

Please sign in to comment.