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 1 commit
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 (_attemptsLeft-- < 0)
{
Interlocked.CompareExchange(ref _updateInProgress, 0, 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ public ScenarioBuilder WhenMergeSyncPivotNotResolvedYet()
_syncProgressSetups.Add(
() =>
{
SyncConfig.MaxAttemptsToUpdatePivot = 3;
SyncConfig.MaxAttemptsToUpdatePivot = -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

With tests, I'd be cautious to use any settings potentially causing infinite work

Choose a reason for hiding this comment

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

I've reverted back the test to set MaxAttemptsToUpdatePivot = 3, so it can test by retrying pivot updates for exactly 3 number of times.

BeaconSyncStrategy = Substitute.For<IBeaconSyncStrategy>();
BeaconSyncStrategy.MergeTransitionFinished.Returns(true);
return "merge sync pivot not resolved yet";
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 == -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic needs to work not only with value of -1 - any value can be specified through config. With this logic, any positive value will most likely break syncing.

Choose a reason for hiding this comment

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

Hi @damian-orzechowski , sorry I didn't consider the possibility of any value coming from the config, and the logic shall hold true given any value for MaxAttemptsToUpdatePivot from config. I have now updated the logic where retires happen infinite number of times if MaxAttemptsToUpdatePivot = -1 and finite number of times if MaxAttemptsToUpdatePivot = N, N being a positive number.

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

Expand Down
Loading