Skip to content

Commit

Permalink
Quick fix for FullPruner (#5809)
Browse files Browse the repository at this point in the history
* Update hive-tests.yml

* Update hive-consensus-tests.yml

* adjust workflow generator

* fix full pruner?

* Revert "adjust workflow generator"

This reverts commit 797a186.

* Revert "Update hive-consensus-tests.yml"

This reverts commit 89eeb9f.

* Revert "Update hive-tests.yml"

This reverts commit 07156b6.

* fix test

* fix test

* Revert "fix test"

This reverts commit 5639ac5.

* Revert "fix full pruner?"

This reverts commit f58fe79.

* better fix

* add nullables

(cherry picked from commit 785619b)
  • Loading branch information
marcindsobczak committed Jun 19, 2023
1 parent c8ea7cd commit e67727e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class FullPruner : IDisposable
private readonly IProcessExitSource _processExitSource;
private readonly ILogManager _logManager;
private readonly IChainEstimations _chainEstimations;
private readonly IDriveInfo _driveInfo;
private readonly IDriveInfo? _driveInfo;
private IPruningContext? _currentPruning;
private int _waitingForBlockProcessed = 0;
private int _waitingForStateReady = 0;
Expand All @@ -48,7 +48,7 @@ public FullPruner(
IStateReader stateReader,
IProcessExitSource processExitSource,
IChainEstimations chainEstimations,
IDriveInfo driveInfo,
IDriveInfo? driveInfo,
ILogManager logManager)
{
_fullPruningDb = fullPruningDb;
Expand Down Expand Up @@ -181,7 +181,7 @@ private bool HaveEnoughDiskSpaceToRun()
return true;
}

long available = _driveInfo.AvailableFreeSpace;
long available = _driveInfo?.AvailableFreeSpace ?? 0;
if (available < currentChainSize.Value * ChainSizeThresholdFactor / 100)
{
if (_logger.IsWarn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class DbDriveInfoProvider
{
public static IDriveInfo[] GetDriveInfos(this IFileSystem fileSystem, string dbPath)
{
static IDriveInfo FindDriveForDirectory(IDriveInfo[] drives, DirectoryInfo dir)
static IDriveInfo? FindDriveForDirectory(IDriveInfo[] drives, DirectoryInfo dir)
{
string dPath = dir.LinkTarget ?? dir.FullName;
IEnumerable<IDriveInfo> candidateDrives = drives.Where(drive => dPath.StartsWith(drive.RootDirectory.FullName));
Expand All @@ -27,7 +27,7 @@ static IDriveInfo FindDriveForDirectory(IDriveInfo[] drives, DirectoryInfo dir)
}
}

return result!;
return result;
}

DirectoryInfo topDir = new(dbPath);
Expand All @@ -37,7 +37,7 @@ static IDriveInfo FindDriveForDirectory(IDriveInfo[] drives, DirectoryInfo dir)
//the following processing is to overcome specific behaviour on linux where creating DriveInfo for multiple paths on same logical drive
//gives instances with these paths (and not logical drive)
IDriveInfo[] allDrives = fileSystem.DriveInfo.GetDrives();
IDriveInfo topLevelDrive = FindDriveForDirectory(allDrives, topDir);
IDriveInfo? topLevelDrive = FindDriveForDirectory(allDrives, topDir);
if (topLevelDrive is not null)
{
driveInfos.Add(topLevelDrive);
Expand All @@ -48,7 +48,7 @@ static IDriveInfo FindDriveForDirectory(IDriveInfo[] drives, DirectoryInfo dir)
//only want to handle symlinks - otherwise will be on same drive as parent
if (di.LinkTarget is not null)
{
IDriveInfo matchedDrive = FindDriveForDirectory(allDrives, topDir);
IDriveInfo? matchedDrive = FindDriveForDirectory(allDrives, topDir);
if (matchedDrive is not null)
{
driveInfos.Add(matchedDrive);
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Init/Steps/InitializeBlockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO.Abstractions;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Nethermind.Api;
Expand All @@ -26,7 +27,6 @@
using Nethermind.Db.FullPruning;
using Nethermind.Evm;
using Nethermind.Evm.TransactionProcessing;
using Nethermind.Facade.Eth;
using Nethermind.JsonRpc.Converters;
using Nethermind.JsonRpc.Modules.DebugModule;
using Nethermind.JsonRpc.Modules.Eth.GasPrice;
Expand Down Expand Up @@ -306,7 +306,7 @@ private static void InitializeFullPruning(
api.PruningTrigger.Add(pruningTrigger);
}

IDriveInfo drive = api.FileSystem.GetDriveInfos(pruningDbPath)[0];
IDriveInfo? drive = api.FileSystem.GetDriveInfos(pruningDbPath).FirstOrDefault();
FullPruner pruner = new(fullPruningDb, api.PruningTrigger, pruningConfig, api.BlockTree!,
stateReader, api.ProcessExit!, ChainSizes.CreateChainSizeInfo(api.ChainSpec.ChainId),
drive, api.LogManager);
Expand Down

0 comments on commit e67727e

Please sign in to comment.