diff --git a/src/Nethermind/Nethermind.Blockchain/Synchronization/SyncConfig.cs b/src/Nethermind/Nethermind.Blockchain/Synchronization/SyncConfig.cs index 6b73d06296da..8e3cc5c125bf 100644 --- a/src/Nethermind/Nethermind.Blockchain/Synchronization/SyncConfig.cs +++ b/src/Nethermind/Nethermind.Blockchain/Synchronization/SyncConfig.cs @@ -70,8 +70,8 @@ public string? PivotHash public bool NeedToWaitForHeader { get; set; } public bool VerifyTrieOnStateSyncFinished { get; set; } public bool TrieHealing { get; set; } = true; - public int StateMaxDistanceFromHead { get; set; } = 96; - public int StateMinDistanceFromHead { get; set; } = 0; // TODO: Don't forget tto acccount for fastsynclag + public int StateMaxDistanceFromHead { get; set; } = 128; + public int StateMinDistanceFromHead { get; set; } = 32; public override string ToString() { diff --git a/src/Nethermind/Nethermind.Synchronization/FastSync/StateSyncPivot.cs b/src/Nethermind/Nethermind.Synchronization/FastSync/StateSyncPivot.cs index 7604df3e8525..ddd233c4f2e1 100644 --- a/src/Nethermind/Nethermind.Synchronization/FastSync/StateSyncPivot.cs +++ b/src/Nethermind/Nethermind.Synchronization/FastSync/StateSyncPivot.cs @@ -9,6 +9,7 @@ using Nethermind.Core; using Nethermind.Core.Crypto; using Nethermind.Logging; +using Nethermind.Synchronization.ParallelSync; namespace Nethermind.Synchronization.FastSync { @@ -36,7 +37,7 @@ public StateSyncPivot(IBlockTree blockTree, ISyncConfig syncConfig, ILogManager public BlockHeader GetPivotHeader() { - if (_bestHeader is null || _blockTree.BestSuggestedHeader?.Number - _bestHeader.Number >= _syncConfig.StateMaxDistanceFromHead) + if (_bestHeader is null || _blockTree.BestSuggestedHeader?.Number - _bestHeader.Number >= _syncConfig.StateMaxDistanceFromHead - MultiSyncModeSelector.FastSyncLag) { TrySetNewBestHeader($"distance from HEAD:{Diff}"); } @@ -67,7 +68,7 @@ public void UpdateHeaderForcefully() private void TrySetNewBestHeader(string msg) { BlockHeader bestSuggestedHeader = _blockTree.BestSuggestedHeader; - long targetBlockNumber = Math.Max(bestSuggestedHeader.Number - _syncConfig.StateMinDistanceFromHead, 0); + long targetBlockNumber = Math.Max(bestSuggestedHeader.Number - (_syncConfig.StateMinDistanceFromHead - MultiSyncModeSelector.FastSyncLag), 0); BlockHeader bestHeader = _blockTree.FindHeader(targetBlockNumber); if (bestHeader is not null) {