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

ledger: use single SP verification hash/data query for catchpoint tracking & generation #5579

Merged
merged 5 commits into from Jul 20, 2023

Conversation

cce
Copy link
Contributor

@cce cce commented Jul 18, 2023

From #5574:

Summary

  1. stateproof verification snapshot logic does not handle CatchpointTracking=1 properly - its hash calculation is a side effect of writing spver data chunk into catchpoint file. Fixed that by calculating hash similarly to balance hash on demand.

Test Plan

  1. Modified unit test TestCatchpointReproducibleLabels for CatchpointTracking=1
  2. Tested locally

@cce cce added the Bug-Fix label Jul 18, 2023
@cce cce changed the title ledger: use single SP verification hash/data lookup for catchpoint tracking & generation ledger: use single SP verification hash/data query for catchpoint tracking & generation Jul 18, 2023
@codecov
Copy link

codecov bot commented Jul 18, 2023

Codecov Report

Merging #5579 (cf96bbe) into master (d316914) will increase coverage by 0.04%.
The diff coverage is 65.38%.

@@            Coverage Diff             @@
##           master    #5579      +/-   ##
==========================================
+ Coverage   55.79%   55.83%   +0.04%     
==========================================
  Files         446      446              
  Lines       63418    63428      +10     
==========================================
+ Hits        35381    35417      +36     
+ Misses      25668    25642      -26     
  Partials     2369     2369              
Impacted Files Coverage Δ
ledger/catchpointwriter.go 62.42% <60.00%> (+0.07%) ⬆️
ledger/catchpointtracker.go 59.69% <66.66%> (+<0.01%) ⬆️

... and 7 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Co-authored-by: Pavel Zbitskiy <65323360+algorandskiy@users.noreply.github.com>
@cce cce marked this pull request as ready for review July 18, 2023 18:54
@@ -201,6 +201,23 @@ func (ct *catchpointTracker) GetLastCatchpointLabel() string {
return ct.lastCatchpointLabel
}

func (ct *catchpointTracker) getSPVerificationData() (encodedData []byte, spVerificationHash crypto.Digest, err error) {
err = ct.dbs.Transaction(func(ctx context.Context, tx trackerdb.TransactionScope) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need a Transaction scope if you're just reading?

Copy link
Contributor Author

@cce cce Jul 20, 2023

Choose a reason for hiding this comment

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

Oh, good point, the place I pulled this out of was inside a Transaction, but now it is read only

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in #5592

b.StopTimer()
b.ReportMetric(float64(accountsNumber), "accounts")
}

func TestCatchpointReproducibleLabels(t *testing.T) {
partitiontest.PartitionTest(t)

if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems not related to the PR so just curious what the purpose of the chang eis.

Comment on lines +601 to +604
// every other iteration modify CatchpointTracking to ensure labels generation does not depends on catchpoint file creation
if rnd%2 == 0 {
cfg2.CatchpointTracking = int64(crypto.RandUint63())%2 + 1 //values 1 or 2
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not guaranteed to modify the tracking value, for what looks like 2 reasons:

  1. the 50% chance assignment, depending on the duration of this loop, might fail to modify the value (rare but flakey behavior)

  2. the loop modifies this rnd value by rnd -= cfg.CatchpointInterval, which in this test appears to be 50. So I would expect rnd%2 to always be true/false for a given test

why not just unconditionally set CatchpointTracking = (CatchpointTracking % 2) + 1 on every loop?

Copy link
Contributor

@algonautshant algonautshant left a comment

Choose a reason for hiding this comment

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

I agree this is nicer.
Great!

@algorandskiy algorandskiy merged commit 0e0b26d into algorand:master Jul 20, 2023
24 checks passed
cce added a commit to cce/go-algorand that referenced this pull request Jul 21, 2023
cce added a commit to cce/go-algorand that referenced this pull request Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants