Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Remove SyncState from SyncTargetManager #1188

Merged

Conversation

ajsutton
Copy link
Contributor

PR description

Removes the dependency on SyncState from SyncTargetManager. Every approach I've tried to fix https://pegasys1.atlassian.net/browse/PAN-1057 winds up with this change included and it makes SyncTargetManager much purer and simpler to understand. Reducing shared state generally seems like a good idea. There is some extra complexity added in ChainDownloader but this still feels like a step in the right direction.

Copy link
Contributor

@mbaxter mbaxter left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -111,6 +111,8 @@ public void start() {
public TrailingPeerRequirements calculateTrailingPeerRequirements() {
return syncState.isInSync()
? TrailingPeerRequirements.UNRESTRICTED
: new TrailingPeerRequirements(syncState.chainHeadNumber(), config.getMaxTrailingPeers());
: new TrailingPeerRequirements(
protocolContext.getBlockchain().getChainHeadBlockNumber(),
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we're loosening the requirements for trailing peers during full sync? It does look like we were being too strict ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not this just removes the indirection when getting the current blockchain head number - previously it went through SyncState which then ran protocolContext.getBlockchain().getChainHeadBlockNumber() so it's just been inlined.

The trailing peer limit during a full sync is set up so that a trailing peer is anyone behind us and at most 25% of our peers are allowed to be trailing. The main aim is to be connected to as many peers who can give us the data we need to sync as possible as few peers who will be asking us for data (which slows us down).

@ajsutton ajsutton merged commit 7acc50a into PegaSysEng:master Mar 31, 2019
@ajsutton ajsutton deleted the remove-sync-state-from-sync-target-manager branch March 31, 2019 20:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants