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: NetworkFetcher service to export fetchBlock #4388

Merged
merged 14 commits into from
Aug 18, 2022

Conversation

algoganesh
Copy link
Contributor

@algoganesh algoganesh commented Aug 10, 2022

Summary

  • NetworkFetcher is the new struct used to export fetchBlock function from universalFetcher.
  • createPeerSelector has been partially exported.

@codecov
Copy link

codecov bot commented Aug 10, 2022

Codecov Report

Merging #4388 (0a11973) into master (fd488f8) will decrease coverage by 0.01%.
The diff coverage is 74.60%.

@@            Coverage Diff             @@
##           master    #4388      +/-   ##
==========================================
- Coverage   55.34%   55.33%   -0.02%     
==========================================
  Files         400      401       +1     
  Lines       50797    50852      +55     
==========================================
+ Hits        28112    28137      +25     
- Misses      20311    20335      +24     
- Partials     2374     2380       +6     
Impacted Files Coverage Δ
catchup/networkFetcher.go 70.90% <70.90%> (ø)
catchup/service.go 69.38% <100.00%> (+0.74%) ⬆️
ledger/roundlru.go 90.56% <0.00%> (-5.67%) ⬇️
network/wsPeer.go 65.47% <0.00%> (-2.20%) ⬇️
crypto/merkletrie/trie.go 66.42% <0.00%> (-2.19%) ⬇️
crypto/merkletrie/node.go 91.62% <0.00%> (-1.87%) ⬇️
ledger/blockqueue.go 85.63% <0.00%> (-1.73%) ⬇️
data/abi/abi_type.go 87.67% <0.00%> (-0.95%) ⬇️
ledger/acctonline.go 79.00% <0.00%> (+0.52%) ⬆️
... and 2 more

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

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 very good.
Some comments. The major 2 things are:

  1. The fetcher should have a retry loop
  2. There are 3 criteria for ranking the peer

catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
)

// NetworkFetcher is the interface used to export fetchBlock function from universalFetcher
type NetworkFetcher interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need it as an interface and an implementation.
Just use the implementation. You are not using the interface with a different impl.

catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
@algoganesh algoganesh changed the title Catchup: Add new interface - NetworkFetcher Catchup: NetworkFetcher service to export fetchBlock Aug 12, 2022
@algoganesh algoganesh requested a review from winder August 12, 2022 17:30
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 addressing the comments.
Getting close. A few more comments.

catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
catchup/networkFetcher.go Outdated Show resolved Hide resolved
@algoganesh algoganesh marked this pull request as ready for review August 15, 2022 16:47
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!
Will it be possible to test all or some of the error branches in the code?

@winder winder requested a review from shiqizng August 16, 2022 14:02
@algoganesh
Copy link
Contributor Author

Looks great! Will it be possible to test all or some of the error branches in the code?

I've added tests to test most of the error branches and increase codecov

@@ -52,7 +52,7 @@ func MakeNetworkFetcher(log logging.Logger, net network.GossipNode, cfg config.L
}

func (netFetcher *NetworkFetcher) getHTTPPeer() (network.HTTPPeer, *peerSelectorPeer, error) {
for retryCount := 0; retryCount < netFetcher.cfg.CatchupBlockDownloadRetryAttempts; retryCount++ {
for retryCount := 1; retryCount <= netFetcher.cfg.CatchupBlockDownloadRetryAttempts; retryCount++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this change?

@@ -79,7 +79,7 @@ func (netFetcher *NetworkFetcher) getHTTPPeer() (network.HTTPPeer, *peerSelector
func (netFetcher *NetworkFetcher) FetchBlock(ctx context.Context, round basics.Round) (*bookkeeping.Block,
*agreement.Certificate, time.Duration, error) {
// internal retry attempt to fetch the block
for retryCount := 0; retryCount < netFetcher.cfg.CatchupBlockDownloadRetryAttempts; retryCount++ {
for retryCount := 1; retryCount <= netFetcher.cfg.CatchupBlockDownloadRetryAttempts; retryCount++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why???

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to say attempt 1 out of 100 instead of 0 out of 100 while logging

Copy link
Contributor

@algonautshant algonautshant Aug 18, 2022

Choose a reason for hiding this comment

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

It is a confusing notation. All the loops start from 0 (usually). You can add +1 in the logging statement.

algonautshant
algonautshant previously approved these changes Aug 18, 2022
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.

More testing might be needed, but I am fine the the changes to the existing code and the implementation of the new interfaces.
Great job!

@algoganesh
Copy link
Contributor Author

More testing might be needed, but I am fine the the changes to the existing code and the implementation of the new interfaces. Great job!

Thank you!
I've fixed the notation in the loop

@winder winder merged commit a29e35a into master Aug 18, 2022
@winder winder deleted the catchup-networkFetch-interface branch August 18, 2022 18:25
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