Skip to content

Commit a9bcdbf

Browse files
marcindsobczakrubobenaadams
authored
Add NetworkId flag to InitConfig (#9476)
* add flag with networkId * cosmetic * Update src/Nethermind/Nethermind.Api/IInitConfig.cs Co-authored-by: Ruben Buniatyan <[email protected]> * fix * # Conflicts: # src/Nethermind/Nethermind.Api/IInitConfig.cs # src/Nethermind/Nethermind.Api/InitConfig.cs * Revert "# Conflicts:" This reverts commit 7f25638. * postmerge fix * Apply suggestion from @benaadams --------- Co-authored-by: Ruben Buniatyan <[email protected]> Co-authored-by: Ben {chmark} Adams <[email protected]>
1 parent 9e2afef commit a9bcdbf

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/Nethermind/Nethermind.Api/IInitConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public interface IInitConfig : IConfig
3939
[ConfigItem(Description = "The hash of the genesis block. If not specified, the genesis block validity is not checked which is useful in the case of ad hoc test/private networks.", DefaultValue = "null")]
4040
string? GenesisHash { get; set; }
4141

42+
[ConfigItem(Description = "The network id. If not specified, taken from the chain spec file.", DefaultValue = "null", HiddenFromDocs = true)]
43+
ulong? NetworkId { get; set; }
44+
4245
[ConfigItem(Description = "The path to the static nodes file.", DefaultValue = "static-nodes.json")]
4346
string StaticNodesPath { get; set; }
4447

src/Nethermind/Nethermind.Api/InitConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class InitConfig : IInitConfig
1818
public string BaseDbPath { get; set; } = "db";
1919
public string LogFileName { get; set; } = "log.txt";
2020
public string? GenesisHash { get; set; }
21+
public ulong? NetworkId { get; set; }
2122
public string StaticNodesPath { get; set; } = "static-nodes.json";
2223
public string TrustedNodesPath { get; set; } = "trusted-nodes.json";
2324
public string? KzgSetupPath { get; set; } = null;

src/Nethermind/Nethermind.Runner/Ethereum/Api/ApiBuilder.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ private ChainSpec LoadChainSpec(IJsonSerializer ethereumJsonSerializer)
7272

7373
var loader = new ChainSpecFileLoader(ethereumJsonSerializer, _logger);
7474
ChainSpec chainSpec = loader.LoadEmbeddedOrFromFile(_initConfig.ChainSpecPath);
75+
76+
//overwriting NetworkId which is useful for some devnets (like bloatnet)
77+
if (_initConfig.NetworkId is not null)
78+
{
79+
chainSpec.NetworkId = (ulong)_initConfig.NetworkId;
80+
}
81+
7582
return chainSpec;
7683
}
7784

0 commit comments

Comments
 (0)