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

catchup: cleanup pipelinedFetch #5662

Merged
merged 9 commits into from
Aug 16, 2023

Conversation

zeldovich
Copy link
Contributor

This PR simplifies the catchup code for managing a pipeline of block-fetching workers. Catchup should work in more-or-less the same way as before, but the code itself should be easier to read and modify.

New ledger code checks partkeys, and buildTestLedger() was creating
Online accounts without any valid partkeys.
Waits for round r to appear in memory, without waiting for it to be
committed to disk.  Implemented by instantiating another copy of the
notifier tracker, which notifies when newBlock() is called.
More streamlined code for catchup, which avoids the carefully
orchestrated chain of channels, each of which was getting read twice,
between each round's fetchAndWrite invocation, the nested closure
created by pipelineCallback(), and the one-off implementation of task
queues in taskCh.  This should make the catchup code easier to modify
when adding state-proof-based block validation.
@codecov
Copy link

codecov bot commented Aug 14, 2023

Codecov Report

Merging #5662 (0f50241) into master (4ff2bf3) will decrease coverage by 0.03%.
Report is 7 commits behind head on master.
The diff coverage is 65.30%.

@@            Coverage Diff             @@
##           master    #5662      +/-   ##
==========================================
- Coverage   55.13%   55.11%   -0.03%     
==========================================
  Files         465      465              
  Lines       65022    64993      -29     
==========================================
- Hits        35852    35823      -29     
+ Misses      26780    26779       -1     
- Partials     2390     2391       +1     
Files Changed Coverage Δ
ledger/ledger.go 69.09% <42.85%> (-0.63%) ⬇️
catchup/service.go 71.02% <64.70%> (+0.64%) ⬆️
ledger/bulletin.go 94.23% <100.00%> (+0.48%) ⬆️

... and 6 files with indirect coverage changes

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

@zeldovich zeldovich requested a review from yossigi August 15, 2023 15:05
algorandskiy
algorandskiy previously approved these changes Aug 15, 2023
Copy link
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

I like the refactoring. Please fix the linter issue and consider returning the comment.

@algorandskiy algorandskiy requested a review from cce August 15, 2023 21:47
@zeldovich zeldovich changed the title Catchup cleanup catchup: cleanup Aug 16, 2023
Pass context.Context as the first argument to fetchAndWrite
algorandskiy
algorandskiy previously approved these changes Aug 16, 2023
algonautshant
algonautshant previously approved these changes Aug 16, 2023
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.

Looks great!

One possible improvement suggestion and correction of the comment.

@zeldovich zeldovich dismissed stale reviews from algonautshant and algorandskiy via d4f29ee August 16, 2023 11:57
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.

Thanks for the updates!

@algorandskiy algorandskiy changed the title catchup: cleanup catchup: cleanup pipelinedFetch Aug 16, 2023
@algorandskiy algorandskiy merged commit 78460a9 into algorand:master Aug 16, 2023
@algorandskiy
Copy link
Contributor

catchup test TestOnSwitchToUnSupportedProtocol2 failed after merging this

@algorandskiy
Copy link
Contributor

@zeldovich it is reproducible - hangs after adding block 10

go test ./catchup -run TestOnSwitchToUnSupportedProtocol2 -count=1 -v

@zeldovich
Copy link
Contributor Author

Huh, will take a look now; thanks for pointing this out.

@algonautshant
Copy link
Contributor

Most likely this test is no longer needed. It is for "the rest" loop, but it has been eliminated.

@zeldovich
Copy link
Contributor Author

There's a bit of a race condition in the new loop. The test might not be quite so important, and I think the race is fairly benign, but still it seems like a good idea to make the test pass. The tests did pass for me on my machine at some point, but I didn't realize what test partitioning was doing, and I thought CI kept running all of the tests on each run, but apparently not. Oops.

In any case, I'll make this more deterministic and submit another PR shortly.

@zeldovich
Copy link
Contributor Author

(The fix is #5673)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants