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

Simplify configs #3826

Merged
merged 5 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 31 additions & 88 deletions scripts/syncSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,126 +18,69 @@
# fast sync section
"mainnet": {
"url": "api.etherscan.io",
"blockReduced": 2000,
"multiplierRequirement": 2000
"blockReduced": 100,
"multiplierRequirement": 100
},
"goerli": {
"url": "api-goerli.etherscan.io",
"blockReduced": 8192,
"multiplierRequirement": 30000
"blockReduced": 1000,
"multiplierRequirement": 1000
},
"ropsten": {
"url": "api-ropsten.etherscan.io",
"blockReduced": 8192,
"multiplierRequirement": 10000
"blockReduced": 1000,
"multiplierRequirement": 1000
},
"rinkeby": {
"url": "api-rinkeby.etherscan.io",
"blockReduced": 8192,
"multiplierRequirement": 30000
},
"blockReduced": 1000,
"multiplierRequirement": 1000
},
"kovan": {
"url": "api-kovan.etherscan.io",
"blockReduced": 1000,
"multiplierRequirement": 1000
},
"poacore": {
"url": "https://core.poa.network",
"blockReduced": 8192,
"multiplierRequirement": 10000
"blockReduced": 1000,
"multiplierRequirement": 1000
},
"xdai": {
"url": "https://dai.poa.network",
"blockReduced": 8192,
"multiplierRequirement": 10000
"blockReduced": 1000,
"multiplierRequirement": 1000
},
"sokol": {
"url": "https://sokol.poa.network",
"blockReduced": 8192,
"multiplierRequirement": 10000
"blockReduced": 1000,
"multiplierRequirement": 1000
},
"energyweb": {
"url": "https://rpc.energyweb.org",
"blockReduced": 8192,
"multiplierRequirement": 10000
"blockReduced": 1000,
"multiplierRequirement": 1000
},
"volta": {
"url": "https://volta-rpc.energyweb.org",
"blockReduced": 8192,
"multiplierRequirement": 10000
},
"blockReduced": 1000,
"multiplierRequirement": 1000
},
# mev section
"mainnet_mev": {
"url": "api.etherscan.io",
"blockReduced": 2000,
"multiplierRequirement": 2000
"blockReduced": 1000,
"multiplierRequirement": 1000
},
"goerli_mev": {
"url": "api-goerli.etherscan.io",
"blockReduced": 8192,
"multiplierRequirement": 30000
"blockReduced": 1000,
"multiplierRequirement": 1000
},
"xdai_mev": {
"url": "https://dai.poa.network",
"blockReduced": 8192,
"multiplierRequirement": 10000
},
# pruned mev section
"mainnet_pruned_mev": {
"url": "api.etherscan.io",
"blockReduced": 2000,
"multiplierRequirement": 2000
},
"goerli_pruned_mev": {
"url": "api-goerli.etherscan.io",
"blockReduced": 8192,
"multiplierRequirement": 30000
},
"xdai_pruned_mev": {
"url": "https://dai.poa.network",
"blockReduced": 8192,
"multiplierRequirement": 10000
},
# pruning section
"mainnet_pruned": {
"url": "api.etherscan.io",
"blockReduced": 2000,
"multiplierRequirement": 2000
},
"goerli_pruned": {
"url": "api-goerli.etherscan.io",
"blockReduced": 8192,
"multiplierRequirement": 30000
},
"ropsten_pruned": {
"url": "api-ropsten.etherscan.io",
"blockReduced": 8192,
"multiplierRequirement": 10000
},
"rinkeby_pruned": {
"url": "api-rinkeby.etherscan.io",
"blockReduced": 8192,
"multiplierRequirement": 30000
},
"poacore_pruned": {
"url": "https://core.poa.network",
"blockReduced": 8192,
"multiplierRequirement": 10000
},
"xdai_pruned": {
"url": "https://dai.poa.network",
"blockReduced": 8192,
"multiplierRequirement": 10000
},
"sokol_pruned": {
"url": "https://sokol.poa.network",
"blockReduced": 8192,
"multiplierRequirement": 10000
},
"energyweb_pruned": {
"url": "https://rpc.energyweb.org",
"blockReduced": 8192,
"multiplierRequirement": 10000
},
"volta_pruned": {
"url": "https://volta-rpc.energyweb.org",
"blockReduced": 8192,
"multiplierRequirement": 10000
"blockReduced": 1000,
"multiplierRequirement": 1000
}
}

Expand Down
48 changes: 37 additions & 11 deletions src/Nethermind/Nethermind.Config.Test/ConfigFileTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
Expand All @@ -33,7 +34,7 @@ namespace Nethermind.Config.Test
[Parallelizable(ParallelScope.All)]
public abstract class ConfigFileTestsBase
{
private readonly IDictionary<string, ConfigProvider> _cachedProviders = new ConcurrentDictionary<string, ConfigProvider>();
private readonly IDictionary<string, TestConfigProvider> _cachedProviders = new ConcurrentDictionary<string, TestConfigProvider>();
private readonly Dictionary<string, IEnumerable<string>> _configGroups = new();

[OneTimeSetUp]
Expand All @@ -45,7 +46,7 @@ public void Setup()

Parallel.ForEach(Resolve("*"), configFile =>
{
ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
TestConfigProvider configProvider = GetConfigProviderFromFile(configFile);
foreach (Type configType in configTypes)
{
configProvider.GetConfig(configType);
Expand Down Expand Up @@ -179,26 +180,51 @@ protected void Test<T, TProperty>(string configWildcard, Expression<Func<T, TPro
}

protected void Test<T, TProperty>(string configWildcard, Expression<Func<T, TProperty>> getter, Action<string, TProperty> expectedValue) where T : IConfig
{
foreach (TestConfigProvider configProvider in GetConfigProviders(configWildcard))
{
T config = configProvider.GetConfig<T>();
expectedValue(configProvider.FileName, getter.Compile()(config));
}
}

protected IEnumerable<TestConfigProvider> GetConfigProviders(string configWildcard)
{
foreach (string configFile in Resolve(configWildcard))
{
Console.WriteLine("Testing " + configFile);
if (!_cachedProviders.TryGetValue(configFile, out ConfigProvider? configProvider))
if (!_cachedProviders.TryGetValue(configFile, out TestConfigProvider? configProvider))
{
configProvider = GetConfigProviderFromFile(configFile);
}

yield return configProvider;
}
}

T config = configProvider.GetConfig<T>();
expectedValue(configFile, getter.Compile()(config));
protected class TestConfigProvider : ConfigProvider
{
public string FileName { get; }

public TestConfigProvider(string fileName)
{
FileName = fileName;
}
}
private static ConfigProvider GetConfigProviderFromFile(string configFile)

private static TestConfigProvider GetConfigProviderFromFile(string configFile)
{
ConfigProvider configProvider = new();
string configPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "configs", configFile);
configProvider.AddSource(new JsonConfigSource(configPath));
return configProvider;
try
{
TestConfigProvider configProvider = new(configFile);
string configPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "configs", configFile);
configProvider.AddSource(new JsonConfigSource(configPath));
return configProvider;
}
catch (Exception e)
{
throw new ConfigurationErrorsException($"Cannot load config file {configFile}", e);
}
}

private Dictionary<string, IEnumerable<string>> BuildConfigGroups()
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Config/ConfigProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void Initialize()

public (string ErrorMsg, IList<(IConfigSource Source, string Category, string Name)> Errors) FindIncorrectSettings()
{
if(_instances.Count() == 0)
if(_instances.Count == 0)
{
Initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Nethermind.Consensus.AuRa.Config
{
public class AuRaConfig : IAuraConfig
{
public bool ForceSealing { get; set; }
public bool ForceSealing { get; set; } = true;

public bool AllowAuRaPrivateChains { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Nethermind.Consensus.AuRa.Config
{
public interface IAuraConfig : IConfig
{
[ConfigItem(Description = "If 'true' then Nethermind if mining will seal empty blocks.", DefaultValue = "false")]
[ConfigItem(Description = "If 'true' then Nethermind if mining will seal empty blocks.", DefaultValue = "true")]
bool ForceSealing { get; set; }

[ConfigItem(Description = "If 'true' then you can run Nethermind only private chains. Do not use with existing Parity AuRa chains.", DefaultValue = "false")]
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Db/IPruningConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public interface IPruningConfig : IConfig
[Obsolete]
public bool Enabled { get; set; }

[ConfigItem(Description = "Sets pruning mode. Possible values: 'None', 'Memory', 'Full', 'Hybrid'.", DefaultValue = "None")]
[ConfigItem(Description = "Sets pruning mode. Possible values: 'None', 'Memory', 'Full', 'Hybrid'.", DefaultValue = "Hybrid")]
PruningMode Mode { get; set; }

[ConfigItem(Description = "'Memory' pruning: Pruning cache size in MB (amount if historical nodes data to store in cache - the bigger the cache the bigger the disk space savings).", DefaultValue = "512")]
[ConfigItem(Description = "'Memory' pruning: Pruning cache size in MB (amount if historical nodes data to store in cache - the bigger the cache the bigger the disk space savings).", DefaultValue = "1024")]
long CacheMb { get; set; }

[ConfigItem(
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Db/PruningConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public bool Enabled
}
}

public PruningMode Mode { get; set; } = PruningMode.None;
public long CacheMb { get; set; } = 512;
public PruningMode Mode { get; set; } = PruningMode.Hybrid;
public long CacheMb { get; set; } = 1024;
public long PersistenceInterval { get; set; } = 8192;
public long FullPruningThresholdMb { get; set; } = 256000;
public FullPruningTrigger FullPruningTrigger { get; set; } = FullPruningTrigger.Manual;
Expand Down
8 changes: 4 additions & 4 deletions src/Nethermind/Nethermind.EthStats/Configs/EthStatsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ namespace Nethermind.EthStats.Configs
public class EthStatsConfig : IEthStatsConfig
{
public bool Enabled { get; set; }
public string? Server { get; set; }
public string? Name { get; set; }
public string? Secret { get; set; }
public string? Contact { get; set; }
public string? Server { get; set; } = "ws://localhost:3000/api";
public string? Name { get; set; } = "Nethermind";
public string? Secret { get; set; } = "secret";
public string? Contact { get; set; } = "hello@nethermind.io";
}
}
8 changes: 4 additions & 4 deletions src/Nethermind/Nethermind.EthStats/IEthStatsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ public interface IEthStatsConfig : IConfig
[ConfigItem(Description = "If 'true' then EthStats publishing gets enabled.", DefaultValue = "false")]
bool Enabled { get; }

[ConfigItem(Description = "EthStats server wss://hostname:port/api/", DefaultValue = "null")]
[ConfigItem(Description = "EthStats server wss://hostname:port/api/", DefaultValue = "ws://localhost:3000/api")]
string? Server { get; }

[ConfigItem(Description = "Node name displayed on the given ethstats server.", DefaultValue = "null")]
[ConfigItem(Description = "Node name displayed on the given ethstats server.", DefaultValue = "Nethermind")]
string? Name { get; }

[ConfigItem(Description = "Password for publishing to a given ethstats server.", DefaultValue = "null")]
[ConfigItem(Description = "Password for publishing to a given ethstats server.", DefaultValue = "secret")]
string? Secret { get; }

[ConfigItem(Description = "Node owner contact details displayed on the ethstats page.", DefaultValue = "null")]
[ConfigItem(Description = "Node owner contact details displayed on the ethstats page.", DefaultValue = "hello@nethermind.io")]
string? Contact { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"Init": {
"EnableUnsecuredDevWallet": true,
"KeepDevWalletInMemory": true,
"IsMining": false,
"KeepDevWalletInMemory": true,
"ChainSpecPath": "chainspec/clique.json",
"GenesisHash": "",
"BaseDbPath": "goerli",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"Init": {
"EnableUnsecuredDevWallet": true,
"KeepDevWalletInMemory": true,
"IsMining": false,
"KeepDevWalletInMemory": true,
"ChainSpecPath": "chainspec/goerli_test.json",
"GenesisHash": "",
"BaseDbPath": "goerli",
Expand Down
Loading