Synchronization#

ErbieChain data synchronization utilizes nodes (peers) as data carriers for storing and transmitting data that chiefly consist of the Header, Body, and Receipt. This process manages data synchronization transactions through a P2P communication protocol, eventually delegating the task of downloading data to the executor. Active synchronization tasks are passed to the Downloader, while passive synchronization tasks are transferred to the Fetcher.

Data Synchronization Strategy#

  • Archive: This strategy involves synchronization in archive mode.

  • FullSync: In full node mode synchronization, the data to be filled includes the block header (Header) and the block body (Body), but not the transaction receipt (Receipt). The data is assembled into a result set (Result), which is then input into the importBlockResults function to insert the data from the result set into the main chain. FullSync differs from lightSync in that the latter does not have a block body and therefore does not execute and verify transactions. Conversely, FullSync executes and verifies transactions while inserting data, contributing to its slower synchronization speed. Afterward, transaction receipts (Receipts) are automatically generated, eliminating the need for Receipts in data filling and assembly.

  • FastSync: In fast synchronization, the Header, Body, and Receipt are all filled. Subsequently, these three data points are assembled, and data insertion is executed. This process differs substantially from FullSync and lightSync; it calls upon the commitFastSyncData function instead of the importBlockResults function used in FullSync. Rather than executing transactions, it merely submits synchronization data. To ensure safety, verification of the acquired transaction receipts is necessary. This step only forms a part of fast synchronization. To further ensure data security, the above method is employed to synchronize older blocks, whereas the FullSync synchronization mode is utilized for relatively newer blocks time-wise. In essence, FastSync synchronizes the majority of data rapidly, while a minor portion still follows the FullSync synchronization mode.