-
Notifications
You must be signed in to change notification settings - Fork 1k
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
The new mechanism of block synchronization using Index. #1378
Comments
I'll share what I implemented for I have split Node management and Sync management into 2 separate classes. Node manager
In the unlikely event that all nodes fail and there are no more new addresses to connect to, the node manager will recycle all addresses that it historically was able to connect to. Sync manager The sync manager depends on NodeManager for providing it with healthy nodes to request data from. It does 3 things on an interval
If you have questions let me know. |
@ixje Thank you for your introduction to the python implementation. Through your sharing, I think the following mechanism can be added in NEO3.
|
@ShawnYun you're welcome. I believe a mechanism equal to point |
Background
Thanks to @ixje @erikzhang @vncoelho @jsolman @shargon for the discussion in #522, #1138, #781, and added a new p2p message for
GetBlockData
.Now, we will discuss the new mechanism of block synchronization using Index.
Do you have any solution you want to propose?
We recommend creating a new
SyncManager
class that manages synchronization, whileTaskManager
handlesInv
messages. The overall mechanism process is as follows:Process:
Get the latest block height of remotenode through
PingPong
messages.Calculate the block segments to be synchronized based on the current local block height and remotenode block height. According to the task interval rule (for example, each task can synchronize a maximum of 50 blocks), the block segment is divided into several synchronous tasks. Select a suitable node according to the task assignment rule and assign synchronous task to it. Save the startIndex, endIndex, task time and other information of the synchronization task. Send the GetBlockdata request.
Each task maintains a
BitArray
to record the received blocks’ index. Find the corresponding task for each received block, and set the bit corresponding to the index of the received block to true. Then, tell the received block to Blockchain.Blockchain
verifies the block and persists it, then tell the index of the persisted block toSyncManager
.SyncManager
checks the index of the persisted block. If the index reaches theendIndex
of a task, check the list of all tasks, delete the corresponding completed task, and assign a new task to the node.Task assignment rule:
Assign task to the node with the lowest number of tasks.
Task interval rule:
startIndex
is theendIndex
of the previous task + 1;EndIndex
is the height that is greater than and nearest tostartIndex
and divisible by 50.Exception handling:
The Timer will check the task timeout, and if the task is timed out, the corresponding task will be re-assigned to other nodes.
If blockchain receives a invalid block, tell to
SyncManager
and reassign the task to other node.(the node sending the invalid block can be marked as a bad node)Neo Version
Where in the software does this update applies to?
The text was updated successfully, but these errors were encountered: