Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set MaxAttemptsToUpdatePivot to -1 for infinite pivot update trials #8107

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public interface ISyncConfig : IConfig
[ConfigItem(DisabledForCli = true, HiddenFromDocs = true)]
Hash256? PivotHashParsed => PivotHash is null ? null : new Hash256(Bytes.FromHexString(PivotHash));

[ConfigItem(Description = "The max number of attempts to update the pivot block based on the FCU message from the consensus client.", DefaultValue = "2147483647")]
[ConfigItem(Description = "The max number of attempts to update the pivot block based on the FCU message from the consensus client.", DefaultValue = "-1")]
int MaxAttemptsToUpdatePivot { get; set; }

[ConfigItem(Description = $$"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private async void OnSyncModeChanged(object? sender, SyncModeChangedEventArgs sy
{
_syncModeSelector.Changed -= OnSyncModeChanged;
}
else if (_attemptsLeft-- > 0)
else if (_syncConfig.MaxAttemptsToUpdatePivot == -1 || _attemptsLeft-- > 0)
{
Interlocked.CompareExchange(ref _updateInProgress, 0, 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public ScenarioBuilder IfThisNodeJustFinishedStateSyncButBehindHeader(FastBlocks
{
SyncProgressResolver.FindBestHeader().Returns(currentBlock);
SyncProgressResolver.FindBestFullBlock().Returns(0); //no full blocks available
SyncProgressResolver.FindBestFullState().Returns(currentBlock - 4); //pivot is set to header, but then header follows the head of the chain
SyncProgressResolver.FindBestFullState().Returns(currentBlock - 4); //pivot is set to header, but then header follows the head of the chain
SyncProgressResolver.FindBestProcessedBlock().Returns(0);
SyncProgressResolver.IsFastBlocksFinished().Returns(fastBlocksState);
SyncProgressResolver.ChainDifficulty.Returns((UInt256)currentBlock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private bool ShouldBeInBeaconHeaders(bool shouldBeInUpdatingPivot)

private bool ShouldBeInUpdatingPivot()
{
bool updateRequestedAndNotFinished = _syncConfig.MaxAttemptsToUpdatePivot > 0;
bool updateRequestedAndNotFinished = _syncConfig.MaxAttemptsToUpdatePivot != 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct. We should be updating pivot with a matching condition to logic in PivotUpdator, that's when -1 or > 0. Could simplify it to >= -1, but probably have to test.

bool isPostMerge = _beaconSyncStrategy.MergeTransitionFinished;
bool stateSyncNotFinished = _syncProgressResolver.FindBestFullState() == 0;

Expand Down