Skip to content

Commit

Permalink
Additional logging for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
damian-orzechowski committed Dec 13, 2024
1 parent 7809cac commit 6a22ed7
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,14 @@ private bool ShouldBeInFastSyncMode(Snapshot best)
notHasJustStartedFullSync &&
notNeedToWaitForHeaders;

if (_logger.IsInfo && _syncProgressResolver.IsSnapGetRangesFinished())
{
LogDetailedSyncModeChecks("FAST",
(nameof(notReachedFullSyncTransition), notReachedFullSyncTransition),
(nameof(notInAStickyFullSync), notInAStickyFullSync),
(nameof(notHasJustStartedFullSync), notHasJustStartedFullSync));
}

if (_logger.IsTrace)
{
LogDetailedSyncModeChecks("FAST",
Expand Down Expand Up @@ -460,6 +468,17 @@ private bool ShouldBeInFullSyncMode(Snapshot best)
stateSyncFinished &&
notNeedToWaitForHeaders;

if (_logger.IsInfo && _syncProgressResolver.IsSnapGetRangesFinished())
{
LogDetailedSyncModeChecks("FULL",
(nameof(postPivotPeerAvailable), postPivotPeerAvailable),
(nameof(hasFastSyncBeenActive), hasFastSyncBeenActive),
(nameof(notInFastSync), notInFastSync),
(nameof(notInStateSync), notInStateSync),
(nameof(stateSyncFinished), stateSyncFinished));
}


if (_logger.IsTrace)
{
LogDetailedSyncModeChecks("FULL",
Expand Down Expand Up @@ -607,6 +626,15 @@ private bool ShouldBeInStateSyncMode(Snapshot best)
notInAStickyFullSync &&
notNeedToWaitForHeaders;

if (_logger.IsInfo && _syncProgressResolver.IsSnapGetRangesFinished())
{
LogDetailedSyncModeChecks("STATE",
($"{nameof(notInFastSync)}||{nameof(stickyStateNodes)}", notInFastSync || stickyStateNodes),
(nameof(stateNotDownloadedYet), stateNotDownloadedYet),
(nameof(notInAStickyFullSync), notInAStickyFullSync),
(nameof(notHasJustStartedFullSync), notHasJustStartedFullSync));
}

if (_logger.IsTrace)
{
LogDetailedSyncModeChecks("STATE",
Expand All @@ -632,6 +660,13 @@ private bool ShouldBeInStateNodesMode(Snapshot best)

bool result = isInStateSync && (snapSyncDisabled || snapRangesFinished);

if (_logger.IsInfo && _syncProgressResolver.IsSnapGetRangesFinished())
{
LogDetailedSyncModeChecks("STATE_NODES",
(nameof(isInStateSync), isInStateSync),
($"{nameof(snapSyncDisabled)}||{nameof(snapRangesFinished)}", snapSyncDisabled || snapRangesFinished));
}

if (_logger.IsTrace)
{
LogDetailedSyncModeChecks("STATE_NODES",
Expand Down Expand Up @@ -780,7 +815,7 @@ private void LogDetailedSyncModeChecks(string syncType, params (string Name, boo

bool result = checks.All(c => c.IsSatisfied);
string text = $"{(result ? " * " : " ")}{syncType,-20}: yes({string.Join(", ", matched)}), no({string.Join(", ", failed)})";
_logger.Trace(text);
_logger.Info(text);
}

private ref struct Snapshot
Expand Down

0 comments on commit 6a22ed7

Please sign in to comment.