feat: optimize epoch chain sync with specialized staged sync pipeline and improve performance for crosslinks processing #4943
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.
This pull request introduces a specialized synchronization pipeline for epoch chains to reduce resource overhead. The changes create a clear separation between regular shard chain synchronization and epoch chain synchronization, ensuring that epoch chains only run the minimal stages necessary for their operation.
The main improvement comes from the new
CreateStagedEpochSync
function that automatically detects when a node is running an epoch chain and configures a lightweight sync pipeline. Instead of running all the standard stages like bodies, states, and receipts synchronization, epoch chains now only execute the essentialSyncEpoch
and Finish stages. This optimization significantly reduces memory usage and processing overhead since epoch chains don't need to store or process full block data.The downloader now intelligently chooses between the full staged sync pipeline for regular shard chains and the specialized epoch sync pipeline for epoch chains. This automatic detection ensures that nodes running on the beacon chain shard get the appropriate sync behavior without requiring manual configuration. The changes maintain full backward compatibility while providing better performance for crosslinks processing, which relies heavily on keeping epoch chains synchronized with minimal latency.
These optimizations directly address the crosslinks processing requirements by ensuring that epoch chains stay synchronized efficiently, preventing resource conflicts between different sync types, and maintaining a clean architectural separation between beacon chain epoch blocks and regular shard chain operations.