Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Right now, in testnet1, the network behaves in a single-producer many-follower consensus mode. While the block DAG correctly determines the heaviest chain from a history of blocks, the sync algorithm does not yet search divergent branch histories (ie forks) from nodes.
Sync is implemented as a greedy search, which starts from a base tip and requests windows of 2048 blocks. The tip we start at is our local headers tip:
https://github.com/tinychainorg/tinychain/blob/main/core/nakamoto/sync.go#L301
As such, the node when it hears of a block on an alternative branch does not download it. And so testnet1 can support proper nakamoto POW branching, once it starts downloading alternative branches too.
The improvement proposed in this PR is to search on divergent branches and download history.
The way this will work:
a. First check this remote tip has more accumulated work than the current local tip.