Skip to content

Commit

Permalink
Account for fast sync lag
Browse files Browse the repository at this point in the history
  • Loading branch information
asdacap committed Nov 25, 2024
1 parent 5544e4a commit 135022d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Logging;
using Nethermind.Synchronization.ParallelSync;

namespace Nethermind.Synchronization.FastSync
{
Expand Down Expand Up @@ -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}");
}
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 135022d

Please sign in to comment.