Skip to content

Commit

Permalink
Add GenesisTimeoutMs to BlocksConfig (#7457)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaszRozmej authored Sep 18, 2024
1 parent 875a4de commit ec4a833
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Nethermind/Nethermind.Config/BlocksConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public class BlocksConfig : IBlocksConfig

public bool PreWarmStateOnBlockProcessing { get; set; } = true;

public int BlockProductionTimeoutMs { get; set; } = 4000;
public int BlockProductionTimeoutMs { get; set; } = 4_000;

public int GenesisTimeoutMs { get; set; } = 40_000;

public string ExtraData
{
Expand Down
3 changes: 3 additions & 0 deletions src/Nethermind/Nethermind.Config/IBlocksConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ public interface IBlocksConfig : IConfig
[ConfigItem(Description = "Block Production timeout, in milliseconds.", DefaultValue = "4000")]
int BlockProductionTimeoutMs { get; set; }

[ConfigItem(Description = "Genesis block load timeout, in milliseconds.", DefaultValue = "40000")]
int GenesisTimeoutMs { get; set; }

byte[] GetExtraDataBytes();
}
7 changes: 4 additions & 3 deletions src/Nethermind/Nethermind.Init/Steps/LoadGenesisBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using Nethermind.Api;
using Nethermind.Blockchain;
using Nethermind.Config;
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Logging;
Expand All @@ -19,13 +20,13 @@ public class LoadGenesisBlock : IStep
private readonly IApiWithBlockchain _api;
private readonly ILogger _logger;
private IInitConfig? _initConfig;

readonly TimeSpan _genesisProcessedTimeout = TimeSpan.FromSeconds(40);
private readonly TimeSpan _genesisProcessedTimeout;

public LoadGenesisBlock(INethermindApi api)
{
_api = api;
_logger = _api.LogManager.GetClassLogger();
_genesisProcessedTimeout = TimeSpan.FromMilliseconds(_api.Config<IBlocksConfig>().GenesisTimeoutMs);
}

public async Task Execute(CancellationToken _)
Expand Down Expand Up @@ -85,7 +86,7 @@ void GenesisProcessed(object? sender, BlockEventArgs args)

if (!genesisLoaded)
{
throw new TimeoutException($"Genesis block was not processed after {_genesisProcessedTimeout.TotalSeconds} seconds");
throw new TimeoutException($"Genesis block was not processed after {_genesisProcessedTimeout.TotalSeconds} seconds. If you are running custom chain with very big genesis file consider increasing {nameof(BlocksConfig)}.{nameof(IBlocksConfig.GenesisTimeoutMs)}.");
}
}

Expand Down

0 comments on commit ec4a833

Please sign in to comment.