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

Update request-resolve mechanism for full archive network #5347

Conversation

sstanculeanu
Copy link
Contributor

@sstanculeanu sstanculeanu commented Jun 14, 2023

Reasoning behind the pull request

  • request-resolve mechanism should be updated for the full archive network

Proposed changes

  • updated resolvers and requesters
  • added integration test on peers ratings

Testing procedure

  • will be tested with feat branch

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

added separate preferred peers holder for the new network
sstanculeanu and others added 6 commits June 14, 2023 16:51
…//github.com/multiversx/mx-chain-go into requesters_resolvers_full_archive_network

# Conflicts:
#	factory/processing/processComponents.go
#	factory/processing/processComponentsHandler_test.go
#	integrationTests/multiShard/hardFork/hardFork_test.go
#	update/factory/exportHandlerFactory.go
Base automatically changed from process_components_for_fullarchive_messenger to feat/multiple_p2p_messengers June 16, 2023 09:21
@sstanculeanu sstanculeanu marked this pull request as ready for review June 16, 2023 09:21
@codecov
Copy link

codecov bot commented Jun 16, 2023

Codecov Report

Patch coverage: 98.07% and project coverage change: -0.01 ⚠️

Comparison is base (cbeb97d) 80.34% compared to head (9d48c22) 80.33%.

❗ Current head 9d48c22 differs from pull request most recent head 8618e38. Consider uploading reports for the commit 8618e38 to get more accurate results

Additional details and impacted files
@@                       Coverage Diff                        @@
##           feat/multiple_p2p_messengers    #5347      +/-   ##
================================================================
- Coverage                         80.34%   80.33%   -0.01%     
================================================================
  Files                               695      695              
  Lines                             90370    90497     +127     
================================================================
+ Hits                              72604    72698      +94     
- Misses                            12599    12630      +31     
- Partials                           5167     5169       +2     
Impacted Files Coverage Δ
...esolverscontainer/metaResolversContainerFactory.go 78.08% <92.00%> (-0.12%) ⬇️
...solverscontainer/shardResolversContainerFactory.go 82.65% <92.00%> (-0.38%) ⬇️
...esolverscontainer/baseResolversContainerFactory.go 82.75% <94.28%> (+0.76%) ⬆️
factory/network/networkComponents.go 88.09% <96.77%> (+0.14%) ⬆️
...uestersContainer/baseRequestersContainerFactory.go 80.95% <100.00%> (+0.95%) ⬆️
...uestersContainer/metaRequestersContainerFactory.go 81.45% <100.00%> (+0.37%) ⬆️
...estersContainer/shardRequestersContainerFactory.go 79.81% <100.00%> (+0.57%) ⬆️
dataRetriever/topicSender/baseTopicSender.go 100.00% <100.00%> (ø)
dataRetriever/topicSender/topicRequestSender.go 100.00% <100.00%> (+1.47%) ⬆️
dataRetriever/topicSender/topicResolverSender.go 100.00% <100.00%> (ø)
... and 4 more

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines 23 to 26
// Get does nothing as it is disabled
func (holder *preferredPeersHolder) Get() map[uint32][]core.PeerID {
return make(map[uint32][]core.PeerID)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Get does nothing as it is disabled
func (holder *preferredPeersHolder) Get() map[uint32][]core.PeerID {
return make(map[uint32][]core.PeerID)
}
// Get returns empty map as it is disabled
func (holder *preferredPeersHolder) Get() map[uint32][]core.PeerID {
return make(map[uint32][]core.PeerID)
}

?

Comment on lines 263 to 271
func (mnc *managedNetworkComponents) FullArchivePreferredPeersHolderHandler() factory.PreferredPeersHolderHandler {
mnc.mutNetworkComponents.RLock()
defer mnc.mutNetworkComponents.RUnlock()

if mnc.networkComponents == nil {
return nil
}

return mnc.mainNetworkHolder.preferredPeersHolder
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (mnc *managedNetworkComponents) FullArchivePreferredPeersHolderHandler() factory.PreferredPeersHolderHandler {
mnc.mutNetworkComponents.RLock()
defer mnc.mutNetworkComponents.RUnlock()
if mnc.networkComponents == nil {
return nil
}
return mnc.mainNetworkHolder.preferredPeersHolder
func (mnc *managedNetworkComponents) FullArchivePreferredPeersHolderHandler() factory.PreferredPeersHolderHandler {
mnc.mutNetworkComponents.RLock()
defer mnc.mutNetworkComponents.RUnlock()
if mnc.networkComponents == nil {
return nil
}
return mnc.fullArchiveNetworkHolder.preferredPeersHolder

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, good catch

# "127.0.0.10",
# "16Uiu2HAm6yvbp1oZ6zjnWsn9FdRqBSaQkbhELyaThuq48ybdorrr"
# ]
PreferredFullArchiveConnections = []
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can use the same PreferredConnections list for all network messengers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed and reused the old one

@@ -31,7 +31,11 @@ func NewTopicResolverSender(arg ArgTopicResolverSender) (*topicResolverSender, e
// Send is used to send an array buffer to a connected peer
// It is used when replying to a request
func (trs *topicResolverSender) Send(buff []byte, peer core.PeerID) error {
return trs.sendToConnectedPeer(trs.topicName, buff, peer)
if trs.fullArchiveMessenger.IsConnected(peer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

so this is how we manage to send on the "correct" network
The other possibility was to provide the dataretriever.MessageHandler instance on this function. This variant will ensure that performance degradation will not occur.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added TODO and will be fixed in the next PR, as discussed

@@ -259,6 +259,18 @@ func (mnc *managedNetworkComponents) FullArchivePeersRatingMonitor() p2p.PeersRa
return mnc.fullArchiveNetworkHolder.peersRatingMonitor
}

// FullArchivePreferredPeersHolderHandler returns the preferred peers holder of the full archive network
func (mnc *managedNetworkComponents) FullArchivePreferredPeersHolderHandler() factory.PreferredPeersHolderHandler {
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not think this is required

@@ -111,12 +113,103 @@ func TestPeersRatingAndResponsiveness(t *testing.T) {
assert.Equal(t, finalMaliciousExpectedRating, maliciousRating)
}

func createNodeWithPeersRatingHandler(shardID uint32, numShards uint32) *integrationTests.TestProcessorNode {
func TestPeersRatingAndResponsivenessOnFullArchive(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍
very good test for ensuring that the feature works

@sstanculeanu sstanculeanu merged commit 8134b82 into feat/multiple_p2p_messengers Jun 21, 2023
4 checks passed
@sstanculeanu sstanculeanu deleted the requesters_resolvers_full_archive_network branch June 21, 2023 11:36
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.

None yet

3 participants