diff --git a/src/Nethermind/Nethermind.Blockchain/Synchronization/ISyncConfig.cs b/src/Nethermind/Nethermind.Blockchain/Synchronization/ISyncConfig.cs index 4610dad14e4..12323a34736 100644 --- a/src/Nethermind/Nethermind.Blockchain/Synchronization/ISyncConfig.cs +++ b/src/Nethermind/Nethermind.Blockchain/Synchronization/ISyncConfig.cs @@ -61,7 +61,7 @@ public interface ISyncConfig : IConfig [ConfigItem(DisabledForCli = true, HiddenFromDocs = true)] Keccak? PivotHashParsed => PivotHash is null ? null : new Keccak(Bytes.FromHexString(PivotHash)); - [ConfigItem(Description = "Max number of attempts (seconds) to update pivot block basing on Forkchoice message from Consensus Layer. Only for PoS chains.", DefaultValue = "900")] + [ConfigItem(Description = "Max number of attempts (seconds) to update pivot block basing on Forkchoice message from Consensus Layer. Only for PoS chains. Infinite by default.", DefaultValue = "2147483647")] int MaxAttemptsToUpdatePivot { get; set; } [ConfigItem(Description = "[EXPERIMENTAL] Defines the earliest body downloaded in fast sync when DownloadBodiesInFastSync is enabled. Actual values used will be Math.Max(1, Math.Min(PivotNumber, AncientBodiesBarrier))", DefaultValue = "0")] diff --git a/src/Nethermind/Nethermind.Blockchain/Synchronization/SyncConfig.cs b/src/Nethermind/Nethermind.Blockchain/Synchronization/SyncConfig.cs index 8734473a792..a73a8d4c16c 100644 --- a/src/Nethermind/Nethermind.Blockchain/Synchronization/SyncConfig.cs +++ b/src/Nethermind/Nethermind.Blockchain/Synchronization/SyncConfig.cs @@ -49,7 +49,7 @@ public string? PivotHash get => FastSync || SnapSync ? _pivotHash : null; set => _pivotHash = value; } - public int MaxAttemptsToUpdatePivot { get; set; } = 900; + public int MaxAttemptsToUpdatePivot { get; set; } = int.MaxValue; public bool WitnessProtocolEnabled { get; set; } = false; public bool SnapSync { get; set; } = false; public int SnapSyncAccountRangePartitionCount { get; set; } = 8; diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Synchronization/PivotUpdator.cs b/src/Nethermind/Nethermind.Merge.Plugin/Synchronization/PivotUpdator.cs index ba763a4ee92..415c9c2e45b 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Synchronization/PivotUpdator.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Synchronization/PivotUpdator.cs @@ -33,6 +33,7 @@ public class PivotUpdator private readonly CancellationTokenSource _cancellation = new(); + private static int _maxAttempts; private int _attemptsLeft; private int _updateInProgress; private Keccak _alreadyAnnouncedNewPivotHash = Keccak.Zero; @@ -55,6 +56,7 @@ public PivotUpdator(IBlockTree blockTree, _metadataDb = metadataDb ?? throw new ArgumentNullException(nameof(metadataDb)); _logger = logManager.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); + _maxAttempts = syncConfig.MaxAttemptsToUpdatePivot; _attemptsLeft = syncConfig.MaxAttemptsToUpdatePivot; if (!TryUpdateSyncConfigUsingDataFromDb()) @@ -141,7 +143,7 @@ private async Task TrySetFreshPivot(CancellationToken cancellationToken) if (finalizedBlockHash is null || finalizedBlockHash == Keccak.Zero) { - if (_logger.IsInfo && _attemptsLeft % 10 == 0) _logger.Info($"Waiting for Forkchoice message from Consensus Layer to set fresh pivot block. {_attemptsLeft} attempts left"); + if (_logger.IsInfo && (_maxAttempts - _attemptsLeft) % 10 == 0) _logger.Info($"Waiting for Forkchoice message from Consensus Layer to set fresh pivot block [{_maxAttempts - _attemptsLeft}s]"); return null; } @@ -217,7 +219,7 @@ private async Task TrySetFreshPivot(CancellationToken cancellationToken) } } - if (_logger.IsInfo && _attemptsLeft % 10 == 0) _logger.Info($"Potential new pivot block hash: {finalizedBlockHash}. Waiting for pivot block header. {_attemptsLeft} attempts left"); + if (_logger.IsInfo && (_maxAttempts - _attemptsLeft) % 10 == 0) _logger.Info($"Potential new pivot block hash: {finalizedBlockHash}. Waiting for pivot block header [{_maxAttempts - _attemptsLeft}s]"); return null; }