tari-project / tari

The Tari protocol
https://tari.com
BSD 3-Clause "New" or "Revised" License
345 stars 212 forks source link

chore: refactor checksum mask initialization #6337

Closed AaronFeickert closed 3 months ago

AaronFeickert commented 3 months ago

Description

Makes checksums more efficient by using lazy initialization.

Motivation and Context

Checksum computation requires a mask whose value is fixed. Currently, this mask is computed each time a checksum is computed or validated. This is inefficient. Additionally, if the underlying coefficient parameters were later changed in an invalid way, this computation could overflow.

This PR refactors mask computation to use lazy initialization. It also checks for overflow during initialization, adds a test for this, and cleans up documentation and comments.

How Has This Been Tested?

Existing tests pass. A new test passes.

What process can a PR reviewer use to test or verify this change?

Check that mask computation is still correct, properly implemented using lazy initialization, and tested.

github-actions[bot] commented 3 months ago

Test Results (CI)

    3 files    113 suites   38m 6s :stopwatch: 1 280 tests 1 279 :white_check_mark: 0 :zzz: 1 :x: 3 717 runs  3 716 :white_check_mark: 0 :zzz: 1 :x:

For more details on these failures, see this check.

Results for commit 83ead201.

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 3 months ago

Test Results (Integration tests)

 2 files  11 suites   15m 12s :stopwatch: 33 tests 32 :white_check_mark: 0 :zzz: 1 :x: 35 runs  33 :white_check_mark: 0 :zzz: 2 :x:

For more details on these failures, see this check.

Results for commit 83ead201.

:recycle: This comment has been updated with latest results.