diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml index 7fbc536f3a4..ec0ee3b4cf7 100644 --- a/.github/workflows/update-docs.yml +++ b/.github/workflows/update-docs.yml @@ -10,7 +10,7 @@ on: required: true default: master -jobs: +jobs: update-docs: name: Update docs runs-on: ubuntu-latest @@ -36,10 +36,14 @@ jobs: - name: Generate docs run: | mv d/docs/fundamentals/configuration.md n/docgen/configuration.md + mv d/docs/interacting/json-rpc-ns/eth_subscribe.md n/docgen/eth_subscribe.md + mv d/docs/interacting/json-rpc-ns/eth_unsubscribe.md n/docgen/eth_unsubscribe.md mv d/docs/monitoring/metrics/metrics.md n/docgen/metrics.md cd n/docgen && ./DocGen && cd ../.. mv n/docgen/configuration.md d/docs/fundamentals/configuration.md rm -f d/docs/interacting/json-rpc-ns/*.md + mv n/docgen/eth_subscribe.md d/docs/interacting/json-rpc-ns/eth_subscribe.md + mv n/docgen/eth_unsubscribe.md d/docs/interacting/json-rpc-ns/eth_unsubscribe.md mv n/docgen/json-rpc-ns/*.md d/docs/interacting/json-rpc-ns mv n/docgen/metrics.md d/docs/monitoring/metrics/metrics.md - name: Tag a new version @@ -61,5 +65,3 @@ jobs: git commit -am "Auto-update docs" git push origin $head_branch gh pr create -B main -H $head_branch -t "Auto-update docs" -b "Autogenerated docs on `${{ github.event_name }}`" -l docgen - - diff --git a/src/Nethermind/Nethermind.AccountAbstraction/IAccountAbstractionConfig.cs b/src/Nethermind/Nethermind.AccountAbstraction/IAccountAbstractionConfig.cs index 6fa02110c03..2fe4abba0d0 100644 --- a/src/Nethermind/Nethermind.AccountAbstraction/IAccountAbstractionConfig.cs +++ b/src/Nethermind/Nethermind.AccountAbstraction/IAccountAbstractionConfig.cs @@ -6,66 +6,66 @@ using Nethermind.Config; using Nethermind.Int256; -namespace Nethermind.AccountAbstraction +namespace Nethermind.AccountAbstraction; + +[ConfigCategory(HiddenFromDocs = true)] +public interface IAccountAbstractionConfig : IConfig { - public interface IAccountAbstractionConfig : IConfig - { - [ConfigItem( - Description = "Defines whether UserOperations are allowed.", - DefaultValue = "false")] - bool Enabled { get; set; } + [ConfigItem( + Description = "Defines whether UserOperations are allowed.", + DefaultValue = "false")] + bool Enabled { get; set; } - [ConfigItem( - Description = "Max number of priority AccountAbstraction peers.", - DefaultValue = "20")] - int AaPriorityPeersMaxCount { get; set; } + [ConfigItem( + Description = "Max number of priority AccountAbstraction peers.", + DefaultValue = "20")] + int AaPriorityPeersMaxCount { get; set; } - [ConfigItem( - Description = "Defines the maximum number of UserOperations that can be kept in memory by clients", - DefaultValue = "200")] - int UserOperationPoolSize { get; set; } + [ConfigItem( + Description = "Defines the maximum number of UserOperations that can be kept in memory by clients", + DefaultValue = "200")] + int UserOperationPoolSize { get; set; } - [ConfigItem( - Description = "Defines the maximum number of UserOperations that can be kept for each sender", - DefaultValue = "1")] - int MaximumUserOperationPerSender { get; set; } + [ConfigItem( + Description = "Defines the maximum number of UserOperations that can be kept for each sender", + DefaultValue = "1")] + int MaximumUserOperationPerSender { get; set; } - [ConfigItem( - Description = - "Defines the comma separated list of hex string representations of the addresses of the EntryPoint contract to which transactions can be made", - DefaultValue = "")] - string EntryPointContractAddresses { get; set; } + [ConfigItem( + Description = + "Defines the comma separated list of hex string representations of the addresses of the EntryPoint contract to which transactions can be made", + DefaultValue = "")] + string EntryPointContractAddresses { get; set; } - [ConfigItem( - Description = "Defines the minimum gas price for a user operation to be accepted", - DefaultValue = "1")] - UInt256 MinimumGasPrice { get; set; } + [ConfigItem( + Description = "Defines the minimum gas price for a user operation to be accepted", + DefaultValue = "1")] + UInt256 MinimumGasPrice { get; set; } - [ConfigItem( - Description = "Defines a comma separated list of the hex string representations of paymasters that are whitelisted by the node", - DefaultValue = "")] - string WhitelistedPaymasters { get; set; } + [ConfigItem( + Description = "Defines a comma separated list of the hex string representations of paymasters that are whitelisted by the node", + DefaultValue = "")] + string WhitelistedPaymasters { get; set; } - [ConfigItem( - Description = "Defines the string URL for the flashbots bundle reception endpoint", - DefaultValue = "https://relay.flashbots.net/")] - string FlashbotsEndpoint { get; set; } - } + [ConfigItem( + Description = "Defines the string URL for the flashbots bundle reception endpoint", + DefaultValue = "https://relay.flashbots.net/")] + string FlashbotsEndpoint { get; set; } +} - public static class AccountAbstractionConfigExtensions - { - public static IEnumerable GetEntryPointAddresses(this IAccountAbstractionConfig accountAbstractionConfig) => - accountAbstractionConfig.EntryPointContractAddresses - .Split(",") - .Where(s => !string.IsNullOrWhiteSpace(s)) - .Select(s => s.Trim()) - .Distinct(); +public static class AccountAbstractionConfigExtensions +{ + public static IEnumerable GetEntryPointAddresses(this IAccountAbstractionConfig accountAbstractionConfig) => + accountAbstractionConfig.EntryPointContractAddresses + .Split(",") + .Where(s => !string.IsNullOrWhiteSpace(s)) + .Select(s => s.Trim()) + .Distinct(); - public static IEnumerable GetWhitelistedPaymasters(this IAccountAbstractionConfig accountAbstractionConfig) => - accountAbstractionConfig.WhitelistedPaymasters - .Split(",") - .Where(s => !string.IsNullOrWhiteSpace(s)) - .Select(s => s.Trim()) - .Distinct(); - } + public static IEnumerable GetWhitelistedPaymasters(this IAccountAbstractionConfig accountAbstractionConfig) => + accountAbstractionConfig.WhitelistedPaymasters + .Split(",") + .Where(s => !string.IsNullOrWhiteSpace(s)) + .Select(s => s.Trim()) + .Distinct(); } diff --git a/src/Nethermind/Nethermind.Api/Extensions/IPluginConfig.cs b/src/Nethermind/Nethermind.Api/Extensions/IPluginConfig.cs index dec68283d66..d519e3d3b5a 100644 --- a/src/Nethermind/Nethermind.Api/Extensions/IPluginConfig.cs +++ b/src/Nethermind/Nethermind.Api/Extensions/IPluginConfig.cs @@ -5,6 +5,7 @@ namespace Nethermind.Api.Extensions; +[ConfigCategory(DisabledForCli = false, HiddenFromDocs = true)] public interface IPluginConfig : IConfig { [ConfigItem(Description = "Order of plugin initialization", DefaultValue = "[Clique, Aura, Ethash, Optimism, AuRaMerge, Merge, MEV, HealthChecks, Hive]")] diff --git a/src/Nethermind/Nethermind.Config/IBlocksConfig.cs b/src/Nethermind/Nethermind.Config/IBlocksConfig.cs index 568255d5a2a..a78820f5f56 100644 --- a/src/Nethermind/Nethermind.Config/IBlocksConfig.cs +++ b/src/Nethermind/Nethermind.Config/IBlocksConfig.cs @@ -14,12 +14,12 @@ public interface IBlocksConfig : IConfig //bool Enabled { get; set; } [ConfigItem( - Description = "The block gas limit that the block producer should try to reach in the fastest possible way based on the protocol rules. If not specified, then the miner should follow other miners.", + Description = "The block gas limit that the block producer should try to reach in the fastest possible way based on the protocol rules. If not specified, then the block producer should follow others.", DefaultValue = "null")] long? TargetBlockGasLimit { get; set; } [ConfigItem( - Description = "The minimum gas premium (price if before the London hard fork) for transactions accepted by the block producer.", + Description = "The minimum gas premium (or the gas price before the London hard fork) for transactions accepted by the block producer.", DefaultValue = "1")] UInt256 MinGasPrice { get; set; } @@ -31,7 +31,7 @@ public interface IBlocksConfig : IConfig [ConfigItem(Description = "The block header extra data up to 32 bytes in length.", DefaultValue = "Nethermind")] string ExtraData { get; set; } - [ConfigItem(Description = "Seconds per slot.", DefaultValue = "12")] + [ConfigItem(Description = "The block time slot, in seconds.", DefaultValue = "12")] ulong SecondsPerSlot { get; set; } byte[] GetExtraDataBytes(); diff --git a/src/Nethermind/Nethermind.Config/INoCategoryConfig.cs b/src/Nethermind/Nethermind.Config/INoCategoryConfig.cs index e7f2041d494..e40fa35577f 100644 --- a/src/Nethermind/Nethermind.Config/INoCategoryConfig.cs +++ b/src/Nethermind/Nethermind.Config/INoCategoryConfig.cs @@ -1,50 +1,50 @@ // SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -namespace Nethermind.Config +namespace Nethermind.Config; + +[ConfigCategory(HiddenFromDocs = true)] +public interface INoCategoryConfig : IConfig { - public interface INoCategoryConfig : IConfig - { - [ConfigItem(Description = "Parent directory or path for BaseDbPath, KeyStoreDirectory, LogDirectory configurations.")] - public string DataDir { get; set; } + [ConfigItem(Description = "Parent directory or path for BaseDbPath, KeyStoreDirectory, LogDirectory configurations.")] + public string DataDir { get; set; } - [ConfigItem(Description = "Path to the JSON configuration file.")] - public string Config { get; set; } + [ConfigItem(Description = "Path to the JSON configuration file.")] + public string Config { get; set; } - [ConfigItem(Description = "Path or directory for configuration files.", DefaultValue = "configs")] - public string ConfigsDirectory { get; set; } + [ConfigItem(Description = "Path or directory for configuration files.", DefaultValue = "configs")] + public string ConfigsDirectory { get; set; } - [ConfigItem(Description = "Path or directory for database files.", DefaultValue = "db")] - public string BaseDbPath { get; set; } + [ConfigItem(Description = "Path or directory for database files.", DefaultValue = "db")] + public string BaseDbPath { get; set; } - [ConfigItem(Description = "Log level override. Possible values: OFF|TRACE|DEBUG|INFO|WARN|ERROR")] - public string Log { get; set; } + [ConfigItem(Description = "Log level override. Possible values: OFF|TRACE|DEBUG|INFO|WARN|ERROR")] + public string Log { get; set; } - [ConfigItem(Description = "Path to the NLog config file")] - public string LoggerConfigSource { get; set; } + [ConfigItem(Description = "Path to the NLog config file")] + public string LoggerConfigSource { get; set; } - [ConfigItem(Description = "Plugins directory")] - public string PluginsDirectory { get; set; } + [ConfigItem(Description = "Plugins directory")] + public string PluginsDirectory { get; set; } - [ConfigItem(Description = "Sets the job name for metrics monitoring.", EnvironmentVariable = "NETHERMIND_MONITORING_JOB")] - public string MonitoringJob { get; set; } + [ConfigItem(Description = "Sets the job name for metrics monitoring.", EnvironmentVariable = "NETHERMIND_MONITORING_JOB")] + public string MonitoringJob { get; set; } - [ConfigItem(Description = "Sets the default group name for metrics monitoring.", EnvironmentVariable = "NETHERMIND_MONITORING_GROUP")] - public string MonitoringGroup { get; set; } + [ConfigItem(Description = "Sets the default group name for metrics monitoring.", EnvironmentVariable = "NETHERMIND_MONITORING_GROUP")] + public string MonitoringGroup { get; set; } - [ConfigItem(Description = "Sets the external IP for the node.", EnvironmentVariable = "NETHERMIND_ENODE_IPADDRESS")] - public string EnodeIpAddress { get; set; } + [ConfigItem(Description = "Sets the external IP for the node.", EnvironmentVariable = "NETHERMIND_ENODE_IPADDRESS")] + public string EnodeIpAddress { get; set; } - [ConfigItem(Description = "Enables Hive plugin used for executing Hive Ethereum Tests.", EnvironmentVariable = "NETHERMIND_HIVE_ENABLED", DefaultValue = "false")] - public bool HiveEnabled { get; set; } + [ConfigItem(Description = "Enables Hive plugin used for executing Hive Ethereum Tests.", EnvironmentVariable = "NETHERMIND_HIVE_ENABLED", DefaultValue = "false")] + public bool HiveEnabled { get; set; } - [ConfigItem(Description = "Defines default URL for JSON RPC.", EnvironmentVariable = "NETHERMIND_URL")] - public string Url { get; set; } + [ConfigItem(Description = "Defines default URL for JSON RPC.", EnvironmentVariable = "NETHERMIND_URL")] + public string Url { get; set; } - [ConfigItem(Description = "Defines CORS origins for JSON RPC.", DefaultValue = "*", EnvironmentVariable = "NETHERMIND_CORS_ORIGINS")] - public string CorsOrigins { get; set; } + [ConfigItem(Description = "Defines CORS origins for JSON RPC.", DefaultValue = "*", EnvironmentVariable = "NETHERMIND_CORS_ORIGINS")] + public string CorsOrigins { get; set; } - [ConfigItem(Description = "Defines host value for CLI function \"switchLocal\".", DefaultValue = "http://localhost", EnvironmentVariable = "NETHERMIND_CLI_SWITCH_LOCAL")] - public string CliSwitchLocal { get; set; } - } + [ConfigItem(Description = "Defines host value for CLI function \"switchLocal\".", DefaultValue = "http://localhost", EnvironmentVariable = "NETHERMIND_CLI_SWITCH_LOCAL")] + public string CliSwitchLocal { get; set; } } diff --git a/src/Nethermind/Nethermind.JsonRpc/IJsonRpcConfig.cs b/src/Nethermind/Nethermind.JsonRpc/IJsonRpcConfig.cs index 82f7da32bb9..c50477df65f 100644 --- a/src/Nethermind/Nethermind.JsonRpc/IJsonRpcConfig.cs +++ b/src/Nethermind/Nethermind.JsonRpc/IJsonRpcConfig.cs @@ -56,7 +56,7 @@ public interface IJsonRpcConfig : IConfig Description = """ An array of JSON-RPC namespaces to enable. For instance, `[debug,eth]`. - Built-in modules: + Built-in namespaces: - `admin` - `client` diff --git a/src/Nethermind/Nethermind.Merge.Plugin/IMergeConfig.cs b/src/Nethermind/Nethermind.Merge.Plugin/IMergeConfig.cs index a052b3452fe..36c3dcaaa38 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/IMergeConfig.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/IMergeConfig.cs @@ -47,21 +47,22 @@ public interface IMergeConfig : IConfig [ConfigItem(Description = "The garbage collection (GC) mode between Engine API calls.", DefaultValue = "Gen1")] public GcLevel SweepMemory { get; set; } - [ConfigItem(Description = "The memory compaction mode. When set to `Full`, compacts the large object heap (LOH) if `--Merge.SweepMemory` is set to `Gen2`.", DefaultValue = "Yes")] + [ConfigItem(Description = "The memory compaction mode. When set to `Full`, compacts the large object heap (LOH) if `SweepMemory` is set to `Gen2`.", DefaultValue = "Yes")] public GcCompaction CompactMemory { get; set; } [ConfigItem(Description = """ - Request the garbage collector (GC) to release process memory back to the OS. + Request the garbage collector (GC) to release the process memory. Allowed values: - `-1` to disable - `0` to release every time - - A positive number to realise memory after that many Engine API calls + - A positive number to release memory after that many Engine API calls + """, DefaultValue = "75")] public int CollectionsPerDecommit { get; set; } - [ConfigItem(Description = "The timeout, in seconds, for the `engine_newPayload*` methods.", DefaultValue = "7", HiddenFromDocs = true)] + [ConfigItem(Description = "The timeout, in seconds, for the `engine_newPayload` method.", DefaultValue = "7", HiddenFromDocs = true)] public int NewPayloadTimeout { get; } } diff --git a/src/Nethermind/Nethermind.Mev/IMevConfig.cs b/src/Nethermind/Nethermind.Mev/IMevConfig.cs index 4734b0f73d3..9392e77dfb3 100644 --- a/src/Nethermind/Nethermind.Mev/IMevConfig.cs +++ b/src/Nethermind/Nethermind.Mev/IMevConfig.cs @@ -7,41 +7,41 @@ using Nethermind.Core; using Nethermind.Int256; -namespace Nethermind.Mev +namespace Nethermind.Mev; + +[ConfigCategory(HiddenFromDocs = true)] +public interface IMevConfig : IConfig +{ + [ConfigItem( + Description = "Defines whether the MEV bundles are allowed.", + DefaultValue = "false")] + bool Enabled { get; set; } + + [ConfigItem( + Description = "Defines how long MEV bundles will be kept in memory by clients", + DefaultValue = "3600")] + UInt256 BundleHorizon { get; set; } + + [ConfigItem( + Description = "Defines the maximum number of MEV bundles that can be kept in memory by clients", + DefaultValue = "200")] + int BundlePoolSize { get; set; } + + [ConfigItem(Description = "Defines the maximum number of MEV bundles to be included within a single block", DefaultValue = "1")] + int MaxMergedBundles { get; set; } + + [ConfigItem(Description = "Defines the list of trusted relay addresses to receive megabundles from as a comma separated string", + DefaultValue = "")] + string TrustedRelays { get; set; } +} + +public static class MevConfigExtensions { - public interface IMevConfig : IConfig - { - [ConfigItem( - Description = "Defines whether the MEV bundles are allowed.", - DefaultValue = "false")] - bool Enabled { get; set; } - - [ConfigItem( - Description = "Defines how long MEV bundles will be kept in memory by clients", - DefaultValue = "3600")] - UInt256 BundleHorizon { get; set; } - - [ConfigItem( - Description = "Defines the maximum number of MEV bundles that can be kept in memory by clients", - DefaultValue = "200")] - int BundlePoolSize { get; set; } - - [ConfigItem(Description = "Defines the maximum number of MEV bundles to be included within a single block", DefaultValue = "1")] - int MaxMergedBundles { get; set; } - - [ConfigItem(Description = "Defines the list of trusted relay addresses to receive megabundles from as a comma separated string", - DefaultValue = "")] - string TrustedRelays { get; set; } - } - - public static class MevConfigExtensions - { - public static IEnumerable
GetTrustedRelayAddresses(this IMevConfig mevConfig) => - mevConfig.TrustedRelays - .Split(",") - .Where(s => !string.IsNullOrWhiteSpace(s)) - .Select(s => s.Trim()) - .Distinct() - .Select(s => new Address(s)); - } + public static IEnumerable
GetTrustedRelayAddresses(this IMevConfig mevConfig) => + mevConfig.TrustedRelays + .Split(",") + .Where(s => !string.IsNullOrWhiteSpace(s)) + .Select(s => s.Trim()) + .Distinct() + .Select(s => new Address(s)); } diff --git a/tools/docgen/ConfigGenerator.cs b/tools/docgen/ConfigGenerator.cs index ed087598aa3..c0d0db5347d 100644 --- a/tools/docgen/ConfigGenerator.cs +++ b/tools/docgen/ConfigGenerator.cs @@ -14,15 +14,15 @@ internal static void Generate() var startMark = ""; var endMark = ""; var fileName = "configuration.md"; - var excluded = new[] { "AccountAbstraction", "Mev", "Plugin" }; + var excluded = Enumerable.Empty(); var types = Directory .GetFiles(AppDomain.CurrentDomain.BaseDirectory, "Nethermind.*.dll") - .SelectMany(a => Assembly.LoadFile(a).GetExportedTypes()) + .SelectMany(a => Assembly.LoadFrom(a).GetExportedTypes()) .Where(t => t.IsInterface && typeof(IConfig).IsAssignableFrom(t) && !excluded.Any(x => t.FullName?.Contains(x, StringComparison.Ordinal) ?? false)) .OrderBy(t => t.Name); - + File.Delete($"~{fileName}"); using var readStream = new StreamReader(File.OpenRead(fileName)); diff --git a/tools/docgen/JsonRpcGenerator.cs b/tools/docgen/JsonRpcGenerator.cs index 1b312bc127e..ab23ecb21d2 100644 --- a/tools/docgen/JsonRpcGenerator.cs +++ b/tools/docgen/JsonRpcGenerator.cs @@ -5,6 +5,7 @@ using Nethermind.JsonRpc.Modules; using Nethermind.JsonRpc.Modules.Evm; using Nethermind.JsonRpc.Modules.Rpc; +using Nethermind.JsonRpc.Modules.Subscribe; using Nethermind.JsonRpc.Modules.Witness; using Newtonsoft.Json; @@ -17,15 +18,18 @@ internal static class JsonRpcGenerator internal static void Generate() { + var excluded = new[] { + typeof(IContextAwareRpcModule).FullName, + typeof(IEvmRpcModule).FullName, + typeof(IRpcModule).FullName, + typeof(IRpcRpcModule).FullName, + typeof(ISubscribeRpcModule).FullName, + typeof(IWitnessRpcModule).FullName + }; var types = new[] { "Nethermind.JsonRpc", "Nethermind.Consensus.Clique" } .SelectMany(a => Assembly.Load(a).GetTypes()) - .Where(t => - t.IsInterface && t != typeof(IRpcModule) && - typeof(IRpcModule).IsAssignableFrom(t) && - !typeof(IContextAwareRpcModule).IsAssignableFrom(t) && - !t.Name.Equals(nameof(IEvmRpcModule), StringComparison.Ordinal) && - !t.Name.Equals(nameof(IRpcRpcModule), StringComparison.Ordinal) && - !t.Name.Equals(nameof(IWitnessRpcModule), StringComparison.Ordinal)) + .Where(t => t.IsInterface && typeof(IRpcModule).IsAssignableFrom(t) && + !excluded.Any(x => x is not null && (t.FullName?.Contains(x, StringComparison.Ordinal) ?? false))) .OrderBy(t => t.Name); if (Directory.Exists(_directory)) @@ -58,9 +62,14 @@ private static void WriteMarkdown(Type rpcType, int sidebarIndex) """); - var methods = rpcType - .GetMethods(BindingFlags.Instance | BindingFlags.Public) - .OrderBy(m => m.Name); + IEnumerable methods = rpcType + .GetMethods(BindingFlags.Instance | BindingFlags.Public); + + // Inject the `subscribe` methods into `eth` + if (rpcName.Equals("eth", StringComparison.Ordinal)) + methods = methods.Concat(typeof(ISubscribeRpcModule).GetMethods(BindingFlags.Instance | BindingFlags.Public)); + + methods = methods.OrderBy(m => m.Name); foreach (var method in methods) { @@ -69,6 +78,14 @@ private static void WriteMarkdown(Type rpcType, int sidebarIndex) if (attr is null || !attr.IsImplemented) continue; + if (method.Name.Equals("eth_subscribe", StringComparison.Ordinal) || + method.Name.Equals("eth_unsubscribe", StringComparison.Ordinal)) + { + WriteFromFile(file, $"{method.Name}.md"); + + continue; + } + file.WriteLine($""" ### {method.Name} @@ -235,6 +252,20 @@ private static void WriteExpandedType(StreamWriter file, Type type, int indentat } } + private static void WriteFromFile(StreamWriter file, string fileName) + { + file.Flush(); + + try + { + File.OpenRead(fileName).CopyTo(file.BaseStream); + } + catch (Exception) + { + Console.WriteLine($"Failed copying from '${fileName}'"); + } + } + private static string GetJsonTypeName(Type type) { var underlyingType = Nullable.GetUnderlyingType(type); @@ -262,7 +293,7 @@ private static string GetJsonTypeName(Type type) or "Byte" or "Byte[]" => "*string* (hex data)", "Boolean" => "*boolean*", - "Keccak" => "*string* (hash)", + "Hash256" => "*string* (hash)", "String" => "*string*", "TxType" => "*string* (transaction type)", _ => _objectTypeName