-
Notifications
You must be signed in to change notification settings - Fork 477
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
Make pivot update attempts infinite #5988
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<bool> 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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. attempts left was pretty nice but if we keep int.max approach it does not have sense indeed. If You would plan to add some value like -1 to make it infinite instead of this approach, please rollback this change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it will be infinite, then it will have even less sense, because infinite number of attempt will be always left. We can add one more variable and just increment it - it will be something like: And for users WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks nice! :) |
||
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<bool> 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; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marcindsobczak Why not some value like -1? I guess this is because setting Int.Max is quicker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just have logic which is checking if
attemts left > 0
in few places, making support for -1 will be nice, but requires bigger refactoring and it is always some risk. If we are not planning to use values between disabled and infinite, we could make it bool as well. But doing it extremely high (int.Max = 68 years) works the same as infinite, is quick and safest, as doesn't require any changes in the code, just config valueThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that is what I expected to hear - we can go safe way but would be nice to leave some issue to refactor this in future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created low priority good first issue for refactoring it to be infinite instead of ~68 years: #5992