Perf/parallel block downloader#8255
Conversation
b3fc46a to
0ff8706
Compare
0ff8706 to
c24a4b9
Compare
|
Needs rebasing |
There was a problem hiding this comment.
Pull Request Overview
This PR improves forward sync performance by enabling parallel block and receipt downloads. Key changes include:
- Adding a padded hash conversion method in Hash256.
- Introducing a new blockchain ID ("Hoodi") and corresponding name mapping.
- Extending ITxSource implementations with a new SupportsBlobs property and updating related transaction sources.
Reviewed Changes
Copilot reviewed 211 out of 213 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Nethermind/Nethermind.Core/Crypto/Hash256.cs | Added FromBytesWithPadding method to pad hash bytes for non-32-byte inputs |
| src/Nethermind/Nethermind.Core/BlockchainIds.cs | Added a new blockchain ID (Hoodi) and its name mapping |
| src/Nethermind/Nethermind.Consensus/Transactions/* | Added SupportsBlobs property to various ITxSource implementations |
| src/Nethermind/Nethermind.Blockchain/Blocks/BlockhashStore.cs | Updated to use the new padded hash conversion method |
| src/Nethermind/Nethermind.Blockchain.Test/BlockhashProviderTests.cs | Introduced a new test to validate trimmed hash behavior |
| scripts/superchain.py | Adjusted log file name formatting |
Files not reviewed (2)
- scripts/private-networking/clique-validators.sh: Language not supported
- scripts/systemd-utils/tail.sh: Language not supported
|
|
||
| public static Hash256 FromBytesWithPadding(ReadOnlySpan<byte> bytes) | ||
| { | ||
| if (bytes.Length != 32) |
There was a problem hiding this comment.
The FromBytesWithPadding method does not handle the case when bytes.Length > 32, which may result in a negative slice index. Consider changing the condition to 'if (bytes.Length < 32)' and adding appropriate handling or error reporting for inputs longer than 32 bytes.
| if (bytes.Length != 32) | |
| if (bytes.Length < 32) |
f1c07fa to
8db4564
Compare
|
Request size adjustment is a bit flaky. Need to find a solution first or batch size is going to be limited by the slowest node. |
There was a problem hiding this comment.
Pull Request Overview
This PR improves forward synchronization performance by introducing parallel block and receipt downloading while refactoring related tests and dependency registration. Key changes include:
- Implementation of a MultiBlockDownloader to download blocks and receipts concurrently.
- Refactoring of synchronization feeds and tests to use a new SyncBatchSize constant.
- Updates to dependency injection lifetimes in merge-related components.
Reviewed Changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| MultiBlockDownloader.cs | Adds parallel download logic for block bodies and receipts. |
| IForwardSyncController.cs | Introduces a shared interface for forward sync handling. |
| FullSyncFeed.cs and FastSyncFeed.cs | Refactors feeds to use the forward sync controller and updates multi-feed status. |
| BlocksSyncPeerSelectionStrategy.cs | Adjusts peer selection logic using a temporary difficulty variable. |
| BlockDownloadRequest.cs | Changes BlocksRequest to implement IDisposable and manage pooled resources. |
| BlockDownloadContext.cs | Removes obsolete download context logic. |
| SynchronizerTests.cs, OldStyleFullSynchronizerTests.cs, ForwardHeaderProviderTests*.cs, BlockDownloaderTests.Merge.cs | Updates tests to use the new SyncBatchSizeMax constant and revised sync methods. |
| OwnedBlockBodies.cs | Revises enumerator implementation for owned block bodies. |
| MergeSynchronizer.cs | Updates dependency lifetimes for BlockDownloader and IForwardHeaderProvider to Singleton. |
| MergeBlockDownloader.cs, ChainLevelHelper.cs, BlockTreeTests.cs, SyncConfig.cs, ISyncConfig.cs | Minor adjustments and additions to support the new sync behavior. |
Comments suppressed due to low confidence (1)
src/Nethermind/Nethermind.Merge.Plugin/Synchronization/MergeSynchronizer.cs:84
- Changing the registration of BlockDownloader (and IForwardHeaderProvider) to Singleton may introduce thread-safety or state management issues if these services are not fully stateless and thread-safe. Please verify that the services are intended for a Singleton lifetime.
.AddSingleton<BlockDownloader, MergeBlockDownloader>()
| { | ||
| yield return blockBody; | ||
| } | ||
| return GetEnumerator(); |
There was a problem hiding this comment.
The implementation of IEnumerable.GetEnumerator() calls GetEnumerator() recursively. Replace it with a call to _rawBodies.GetEnumerator() to correctly iterate over the collection.
LukaszRozmej
left a comment
There was a problem hiding this comment.
Looks good, few things to clarify before merging.
You probably don't want to update submodule!
…er.cs Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>
…er.cs Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>
…er.cs Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>
…er.cs Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>
…er.cs Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>
…er.cs Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>
…er.cs Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>
…rSelectionStrategy.cs Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>
This reverts commit 8403a08.
Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing