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

Safety check for full pruning #5550

Merged
merged 18 commits into from
Jun 12, 2023
Merged

Conversation

deffrian
Copy link
Contributor

@deffrian deffrian commented Apr 10, 2023

Fixes Closes Resolves #
#5495

Adds available memory check before execution full pruning
Size estimations ready only for mainnet and sepolia. Will add other networks in few weeks.

Changes

  • Check itself
  • A bit refactoring

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

@deffrian deffrian linked an issue Apr 10, 2023 that may be closed by this pull request
…or-full-pruning

# Conflicts:
#	src/Nethermind/Nethermind.Blockchain.Test/FullPruning/FullPrunerTests.cs
# Conflicts:
#	src/Nethermind/Nethermind.Blockchain.Test/FullPruning/FullPrunerTests.cs
#	src/Nethermind/Nethermind.Blockchain.Test/FullPruning/FullPruningDiskTest.cs
#	src/Nethermind/Nethermind.Blockchain/FullPruning/FullPruner.cs
#	src/Nethermind/Nethermind.Init/Steps/InitializeBlockchain.cs
# Conflicts:
#	src/Nethermind/Nethermind.Init/Steps/InitializeBlockchain.cs
@deffrian deffrian marked this pull request as ready for review May 2, 2023 07:48
@deffrian deffrian changed the title [Draft] Safety check for full pruning Safety check for full pruning May 2, 2023
@kamilchodola
Copy link
Contributor

@deffrian @MarekM25
Thinking out loud now - is there any chance to put some kind of logs which will inform user that space is running out and full pruning or resync is advised? Somewhere around 250-300GB for mainnet (and respectively less for other chains). This may be configurable by Pruning options and fully disabled if somebody doesn't want to have this (or threshold can be adjusted).
This also may be pushed to health module as well since node which is close to this threshold is already put under risk.

src/Nethermind/Nethermind.Db/IPruningConfig.cs Outdated Show resolved Hide resolved
@benaadams
Copy link
Member

is there any chance to put some kind of logs which will inform user that space is running out and full pruning or resync is advised?

Warn level?

deffrian and others added 2 commits May 9, 2023 01:16
Co-authored-by: Ben Adams <thundercat@illyriad.co.uk>
@@ -158,6 +170,28 @@ private void SetCurrentPruning(IPruningContext pruningContext)

private bool CanStartNewPruning() => _fullPruningDb.CanStartPruning;

private const double ChainSizeThresholdFactor = 1.3;
Copy link
Member

Choose a reason for hiding this comment

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

Would make this a long and make it in %, set it to 130, then when using it first multiply by it, then divide by 100. You keep everything integer and avoid floats.

long? currentChainSize = _chainEstimations.PruningSize;
if (currentChainSize is null)
{
if (_logger.IsWarn) _logger.Warn("Full Pruning: Chain size estimation is unavailable.");
Copy link
Member

Choose a reason for hiding this comment

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

Is this user problem?

/// <summary>
/// Pruning failed because of low disk space
/// </summary>
NotEnoughDiskSpace,
Copy link
Member

Choose a reason for hiding this comment

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

very minor - thinking if we shoulnd't keep this enum in some order, so this would go after Disabled

@@ -63,5 +63,8 @@ public interface IPruningConfig : IConfig
"'AlwaysShutdown': shuts Nethermind down once the prune completes, whether it succeeded or failed.",
DefaultValue = "None")]
FullPruningCompletionBehavior FullPruningCompletionBehavior { get; set; }

[ConfigItem(Description = "Enables available disk space check.", DefaultValue = "true", HiddenFromDocs = true)]
Copy link
Member

Choose a reason for hiding this comment

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

We want this to be hidden from docs?

@@ -314,7 +315,10 @@ private Task InitBlockchain()
api.PruningTrigger.Add(pruningTrigger);
}

FullPruner pruner = new(fullPruningDb, api.PruningTrigger, pruningConfig, api.BlockTree!, stateReader, api.ProcessExit!, api.LogManager);
IDriveInfo drive = api.FileSystem.GetDriveInfos(fullPruningDb.GetPath(initConfig.BaseDbPath))[0];
Copy link
Member

Choose a reason for hiding this comment

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

StateDb Path should be used, this can be mapped to different drive.

Comment on lines 71 to 93
BlockchainIds.Goerli => new ChainEstimations(
new LinearExtrapolation(8490.MB(), 15.MB(), new DateTime(2021, 12, 7))),
BlockchainIds.Rinkeby => new ChainEstimations(
new LinearExtrapolation(34700.MB(), 20.MB(), new DateTime(2021, 12, 7))),
BlockchainIds.Ropsten => new ChainEstimations(
new LinearExtrapolation(35900.MB(), 25.MB(), new DateTime(2021, 12, 7))),
BlockchainIds.Mainnet => new ChainEstimations(
new LinearExtrapolation(90000.MB(), 70.MB(), new DateTime(2022, 04, 7)),
new LinearExtrapolation(163.GB(), new DateTime(2023, 4, 11, 19, 49, 0),
177653453177, new DateTime(2023, 04, 29, 00, 50, 0))),
BlockchainIds.Gnosis => new ChainEstimations(
new LinearExtrapolation(18000.MB(), 48.MB(), new DateTime(2021, 12, 7))),
BlockchainIds.EnergyWeb => new ChainEstimations(
new LinearExtrapolation(15300.MB(), 15.MB(), new DateTime(2021, 12, 7))),
BlockchainIds.Volta => new ChainEstimations(
new LinearExtrapolation(17500.MB(), 10.MB(), new DateTime(2021, 11, 7))),
BlockchainIds.PoaCore => new ChainEstimations(
new LinearExtrapolation(13900.MB(), 4.MB(), new DateTime(2021, 12, 7))),
BlockchainIds.Sepolia => new ChainEstimations(null,
new LinearExtrapolation(2457.MB(), new DateTime(2023, 04, 9, 21, 11, 0),
3699505976, new DateTime(2023, 04, 28, 20, 18, 0))),
_ => UnknownChain.Instance
};
Copy link
Member

Choose a reason for hiding this comment

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

@kamilchodola can you update chain sizes post newest tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have problems with chain sizes, they are very unstable. I'm working on it right now

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we should do that a bit in similar way as we had with Pivots.
Tests will store data about chain size and then action will fetch them and apply in code.
Would be worth to read it from json file rather than hardcoding

@LukaszRozmej
Copy link
Member

is there any chance to put some kind of logs which will inform user that space is running out and full pruning or resync is advised?

Warn level?

This could be checked and written in healthchecks

@deffrian
Copy link
Contributor Author

@kamilchodola I will create new pr with progress logger and any other logging you want

Nikita Mescheryakov added 4 commits May 18, 2023 00:14
@deffrian deffrian merged commit ca09576 into master Jun 12, 2023
@deffrian deffrian deleted the 5495-safety-check-for-full-pruning branch June 12, 2023 15:24
marcindsobczak added a commit that referenced this pull request Jun 14, 2023
marcindsobczak added a commit that referenced this pull request Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Safety check for full pruning
5 participants