Skip to content

Commit

Permalink
Refactor enums docs (NethermindEth#7610)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubo authored Oct 25, 2024
1 parent 3198623 commit f005e26
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 148 deletions.
16 changes: 9 additions & 7 deletions src/Nethermind/Nethermind.Api/IInitConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Nethermind.Config;
using Nethermind.Consensus.Processing;
using System.ComponentModel;

namespace Nethermind.Api;

Expand Down Expand Up @@ -65,7 +66,7 @@ public interface IInitConfig : IConfig
[ConfigItem(Description = "The diagnostic mode.", DefaultValue = "None")]
DiagnosticMode DiagnosticMode { get; set; }

[ConfigItem(Description = "Auto-dump on bad blocks for diagnostics. `Default` combines `Receipts` and `Rlp`.", DefaultValue = "Default")]
[ConfigItem(Description = "Auto-dump on bad blocks for diagnostics.", DefaultValue = nameof(DumpOptions.Default))]
DumpOptions AutoDump { get; set; }

[ConfigItem(Description = $"The URL of the remote node used as a database source when `{nameof(DiagnosticMode)}` is set to `RpcDb`.", DefaultValue = "")]
Expand Down Expand Up @@ -95,23 +96,24 @@ public interface IInitConfig : IConfig

public enum DiagnosticMode
{
[Description("None.")]
None,

[ConfigItem(Description = "Diagnostics mode which uses an in-memory DB")]
[Description("Uses an in-memory DB.")]
MemDb,

[ConfigItem(Description = "Diagnostics mode which uses a remote DB")]
[Description("Uses a remote DB.")]
RpcDb,

[ConfigItem(Description = "Diagnostics mode which uses a read-only DB")]
[Description("Uses a read-only DB.")]
ReadOnlyDb,

[ConfigItem(Description = "Just scan rewards for blocks + genesis")]
[Description("Scans rewards for blocks and genesis.")]
VerifyRewards,

[ConfigItem(Description = "Just scan and sum supply on all accounts")]
[Description("Scans and sums supply on all accounts.")]
VerifySupply,

[ConfigItem(Description = "Verifies if full state is stored")]
[Description("Verifies if full state trie is stored.")]
VerifyTrie
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ public interface ISyncConfig : IConfig
[ConfigItem(Description = $"Whether to operate as a non-validator. If `true`, the `{nameof(DownloadReceiptsInFastSync)}` and `{nameof(DownloadBodiesInFastSync)}` can be set to `false`.", DefaultValue = "false")]
public bool NonValidatorNode { get; set; }

[ConfigItem(Description = "Configure the database for write optimizations during sync. Significantly reduces the total number of writes and sync time if you are not network limited.", DefaultValue = "HeavyWrite")]
[ConfigItem(Description = "Configure the database for write optimizations during sync. Significantly reduces the total number of writes and sync time if you are not network limited.", DefaultValue = nameof(ITunableDb.TuneType.HeavyWrite), HiddenFromDocs = true)]
public ITunableDb.TuneType TuneDbMode { get; set; }

[ConfigItem(Description = "Configure the blocks database for write optimizations during sync.", DefaultValue = "EnableBlobFiles")]
[ConfigItem(Description = "Configure the blocks database for write optimizations during sync.", DefaultValue = nameof(ITunableDb.TuneType.EnableBlobFiles), HiddenFromDocs = true)]
ITunableDb.TuneType BlocksDbTuneDbMode { get; set; }

[ConfigItem(Description = "The max number of threads used for syncing. `0` to use the number of logical processors.", DefaultValue = "0")]
Expand Down
34 changes: 21 additions & 13 deletions src/Nethermind/Nethermind.Consensus/Processing/DumpOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.ComponentModel;

namespace Nethermind.Consensus.Processing
namespace Nethermind.Consensus.Processing;

[Flags]
public enum DumpOptions
{
[Flags]
public enum DumpOptions
{
None = 0,
Receipts = 1,
Parity = 2,
Geth = 4,
Rlp = 8,
RlpLog = 16,
Default = Receipts | Rlp,
All = Receipts | Parity | Geth | Rlp
}
[Description("None.")]
None = 0,
[Description("Dumps block receipts traces.")]
Receipts = 1,
[Description("Dumps Parity-like traces.")]
Parity = 2,
[Description("Dumps Geth-like traces.")]
Geth = 4,
[Description("Dumps RLP data to a `.rlp` file with the block hash in the file name.")]
Rlp = 8,
[Description("Dumps RLP data to the log output.")]
RlpLog = 16,
[Description($"Combines the `{nameof(Receipts)}` `{nameof(Rlp)}` options.")]
Default = Receipts | Rlp,
[Description($"Combines the `{nameof(Geth)}` `{nameof(Parity)}` `{nameof(Receipts)}` `{nameof(Rlp)}` options.")]
All = Receipts | Parity | Geth | Rlp
}
38 changes: 21 additions & 17 deletions src/Nethermind/Nethermind.Db/FullPruningCompletionBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

namespace Nethermind.Db
using System.ComponentModel;

namespace Nethermind.Db;

/// <summary>
/// Defines what to do when a full prune completes.
/// </summary>
public enum FullPruningCompletionBehavior
{
[Description("No action.")]
/// <summary>
/// Defines what to do when a full prune completes.
/// Do nothing once pruning is completed.
/// </summary>
public enum FullPruningCompletionBehavior
{
/// <summary>
/// Do nothing once pruning is completed.
/// </summary>
None,
None,

/// <summary>
/// Shut Nethermind down gracefully if pruning was successful, but leave it running if it failed.
/// </summary>
ShutdownOnSuccess,
[Description("Shuts Nethermind down when pruning succeeds but leaves it running when fails.")]
/// <summary>
/// Shut Nethermind down gracefully if pruning was successful, but leave it running if it failed.
/// </summary>
ShutdownOnSuccess,

/// <summary>
/// Shut Nethermind down gracefully when pruning completes, regardless of whether or not it succeeded.
/// </summary>
AlwaysShutdown
}
[Description("Shuts Nethermind down when pruning completes, regardless of its status.")]
/// <summary>
/// Shut Nethermind down gracefully when pruning completes, regardless of whether or not it succeeded.
/// </summary>
AlwaysShutdown
}
38 changes: 21 additions & 17 deletions src/Nethermind/Nethermind.Db/FullPruningTrigger.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

namespace Nethermind.Db
using System.ComponentModel;

namespace Nethermind.Db;

/// <summary>
/// Triggers for Full Pruning.
/// </summary>
public enum FullPruningTrigger
{
[Description("Does not trigger. Pruning can be triggered manually.")]
/// <summary>
/// Triggers for Full Pruning.
/// Only Manual trigger is supported.
/// </summary>
public enum FullPruningTrigger
{
/// <summary>
/// Only Manual trigger is supported.
/// </summary>
Manual,
Manual,

/// <summary>
/// Automatically triggers on State DB size.
/// </summary>
StateDbSize,
[Description("Triggers when the state DB size is above the specified threshold.")]
/// <summary>
/// Automatically triggers on State DB size.
/// </summary>
StateDbSize,

/// <summary>
/// Automatically triggers on Volume free space on volume with State DB.
/// </summary>
VolumeFreeSpace
}
[Description("Triggers when the free disk space where the state DB is stored is below the specified threshold.")]
/// <summary>
/// Automatically triggers on Volume free space on volume with State DB.
/// </summary>
VolumeFreeSpace
}
36 changes: 7 additions & 29 deletions src/Nethermind/Nethermind.Db/IPruningConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@ public interface IPruningConfig : IConfig
[Obsolete]
public bool Enabled { get; set; }

[ConfigItem(
Description = """
The pruning mode:
- `None`: No pruning (full archive)
- `Memory`: In-memory pruning
- `Full`: Full pruning
- `Hybrid`: Combined in-memory and full pruning
""", DefaultValue = "Hybrid")]
[ConfigItem(Description = "The pruning mode.", DefaultValue = "Hybrid")]
PruningMode Mode { get; set; }

[ConfigItem(Description = "The in-memory cache size, in MB. The bigger the cache size, the bigger the disk space savings.", DefaultValue = "1024")]
Expand All @@ -38,25 +30,18 @@ public interface IPruningConfig : IConfig
long FullPruningThresholdMb { get; set; }

[ConfigItem(
Description = """
The full pruning trigger:
- `Manual`: Triggered manually.
- `StateDbSize`: Trigger when the state DB size is above the threshold.
- `VolumeFreeSpace`: Trigger when the free disk space where the state DB is stored is below the threshold.
""",
DefaultValue = "Manual")]
Description = "The full pruning trigger.", DefaultValue = "Manual")]
FullPruningTrigger FullPruningTrigger { get; set; }

[ConfigItem(
Description = """
The max number of parallel tasks that can be used by full pruning:
The max number of parallel tasks that can be used by full pruning.
Allowed values:
- `-1` to use the number of logical processors
- `0` to use 25% of logical processors
- `1` to run on single thread
- `-1`: Uses the number of logical processors.
- `0`: Uses 25% of logical processors.
- `1`: Runs on a single thread.
The recommended value depends on the type of the node:
Expand All @@ -80,14 +65,7 @@ public interface IPruningConfig : IConfig
[ConfigItem(Description = "The minimum delay, in hours, between full pruning operations not to exhaust disk writes.", DefaultValue = "240")]
int FullPruningMinimumDelayHours { get; set; }

[ConfigItem(Description = """
The behavior after pruning completion:
- `None`: Do nothing.
- `ShutdownOnSuccess`: Shut Nethermind down if pruning has succeeded but leave it running if failed.
- `AlwaysShutdown`: Shut Nethermind down when pruning completes, regardless of its status.
""",
DefaultValue = "None")]
[ConfigItem(Description = "The action to take on pruning completion.", DefaultValue = "None")]
FullPruningCompletionBehavior FullPruningCompletionBehavior { get; set; }

[ConfigItem(Description = "Whether to enables available disk space check.", DefaultValue = "true")]
Expand Down
58 changes: 31 additions & 27 deletions src/Nethermind/Nethermind.Db/PruningMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,43 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.ComponentModel;

namespace Nethermind.Db
namespace Nethermind.Db;

/// <summary>
/// Defines pruning mode.
/// </summary>
[Flags]
public enum PruningMode
{
[Description("No pruning (archive).")]
/// <summary>
/// Defines pruning mode.
/// No pruning - full archive.
/// </summary>
[Flags]
public enum PruningMode
{
/// <summary>
/// No pruning - full archive.
/// </summary>
None = 0,
None = 0,

/// <summary>
/// In memory pruning.
/// </summary>
Memory = 1,
[Description("In-memory pruning.")]
/// <summary>
/// In memory pruning.
/// </summary>
Memory = 1,

/// <summary>
/// Full pruning.
/// </summary>
Full = 2,
[Description("Full pruning.")]
/// <summary>
/// Full pruning.
/// </summary>
Full = 2,

/// <summary>
/// Both in memory and full pruning.
/// </summary>
Hybrid = Memory | Full
}
[Description("Combined in-memory and full pruning.")]
/// <summary>
/// Both in memory and full pruning.
/// </summary>
Hybrid = Memory | Full
}

public static class PruningModeExtensions
{
public static bool IsMemory(this PruningMode mode) => (mode & PruningMode.Memory) == PruningMode.Memory;
public static bool IsFull(this PruningMode mode) => (mode & PruningMode.Full) == PruningMode.Full;
}
public static class PruningModeExtensions
{
public static bool IsMemory(this PruningMode mode) => (mode & PruningMode.Memory) == PruningMode.Memory;
public static bool IsFull(this PruningMode mode) => (mode & PruningMode.Full) == PruningMode.Full;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.ComponentModel;

namespace Nethermind.Evm.Tracing.ParityStyle
namespace Nethermind.Evm.Tracing.ParityStyle;

[Flags]
public enum ParityTraceTypes
{
[Flags]
public enum ParityTraceTypes
{
None = 0,
VmTrace = 1,
StateDiff = 2,
Trace = 4,
Rewards = 8,
All = 15,
}
[Description("None.")]
None = 0,
[Description("Provides a full trace of the EVM state throughout the execution of transactions at each op-code, including subcalls.")]
VmTrace = 1,
[Description("Provides Ethereum state difference detailing all altered portions of the state made due to the execution of transactions.")]
StateDiff = 2,
[Description("Provides transaction trace, including subcalls.")]
Trace = 4,
[Description("Includes block rewards in the trace when tracing full blocks.")]
Rewards = 8,
[Description($"Combines the `{nameof(Rewards)}` `{nameof(StateDiff)}` `{nameof(Trace)}` `{nameof(VmTrace)}` options.")]
All = VmTrace | StateDiff | Trace | Rewards,
}
22 changes: 13 additions & 9 deletions src/Nethermind/Nethermind.JsonRpc/RpcRecorderState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.ComponentModel;

namespace Nethermind.JsonRpc
namespace Nethermind.JsonRpc;

[Flags]
public enum RpcRecorderState
{
[Flags]
public enum RpcRecorderState
{
None = 0,
Request = 1,
Response = 2,
All = Request | Response
}
[Description("None.")]
None = 0,
[Description("Records requests.")]
Request = 1,
[Description("Records responses.")]
Response = 2,
[Description("Records both requests and responses.")]
All = Request | Response
}
Loading

0 comments on commit f005e26

Please sign in to comment.