diff --git a/src/Nethermind/Nethermind.Init/Steps/RegisterRpcModules.cs b/src/Nethermind/Nethermind.Init/Steps/RegisterRpcModules.cs index 5bc4f2ffc9a..570ec346d9b 100644 --- a/src/Nethermind/Nethermind.Init/Steps/RegisterRpcModules.cs +++ b/src/Nethermind/Nethermind.Init/Steps/RegisterRpcModules.cs @@ -132,6 +132,7 @@ public virtual async Task Execute(CancellationToken cancellationToken) ManualPruningTrigger pruningTrigger = new(); _api.PruningTrigger.Add(pruningTrigger); + (IApiWithStores getFromApi, IApiWithBlockchain setInApi) = _api.ForInit; AdminRpcModule adminRpcModule = new( _api.BlockTree, networkConfig, @@ -139,7 +140,8 @@ public virtual async Task Execute(CancellationToken cancellationToken) _api.StaticNodesManager, _api.Enode, initConfig.BaseDbPath, - pruningTrigger); + pruningTrigger, + getFromApi.ChainSpec.Parameters); rpcModuleProvider.RegisterSingle(adminRpcModule); StepDependencyException.ThrowIfNull(_api.TxPoolInfoProvider); diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/AdminModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/AdminModuleTests.cs index dc40547d637..c4af338d7fb 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/AdminModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/AdminModuleTests.cs @@ -15,6 +15,7 @@ using Nethermind.Network; using Nethermind.Network.Config; using Nethermind.Serialization.Json; +using Nethermind.Specs.ChainSpecStyle; using Nethermind.Stats.Model; using NSubstitute; using NUnit.Framework; @@ -44,6 +45,11 @@ public void Setup() IStaticNodesManager staticNodesManager = Substitute.For(); Enode enode = new(_enodeString); + ChainSpec chainSpec = new() + { + Parameters = new ChainParameters() + }; + _adminRpcModule = new AdminRpcModule( _blockTree, _networkConfig, @@ -51,7 +57,8 @@ public void Setup() staticNodesManager, enode, _exampleDataDir, - new ManualPruningTrigger()); + new ManualPruningTrigger(), + chainSpec.Parameters); _serializer = new EthereumJsonSerializer(); } diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Admin/AdminRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Admin/AdminRpcModule.cs index 86f5fb7cedb..25da270be2a 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Admin/AdminRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Admin/AdminRpcModule.cs @@ -11,12 +11,14 @@ using Nethermind.Core.Crypto; using Nethermind.Network; using Nethermind.Network.Config; +using Nethermind.Specs.ChainSpecStyle; using Nethermind.Stats.Model; namespace Nethermind.JsonRpc.Modules.Admin; public class AdminRpcModule : IAdminRpcModule { + private readonly ChainParameters _parameters; private readonly IBlockTree _blockTree; private readonly INetworkConfig _networkConfig; private readonly IPeerPool _peerPool; @@ -33,7 +35,8 @@ public AdminRpcModule( IStaticNodesManager staticNodesManager, IEnode enode, string dataDir, - ManualPruningTrigger pruningTrigger) + ManualPruningTrigger pruningTrigger, + ChainParameters parameters) { _enode = enode ?? throw new ArgumentNullException(nameof(enode)); _dataDir = dataDir ?? throw new ArgumentNullException(nameof(dataDir)); @@ -42,6 +45,7 @@ public AdminRpcModule( _networkConfig = networkConfig ?? throw new ArgumentNullException(nameof(networkConfig)); _staticNodesManager = staticNodesManager ?? throw new ArgumentNullException(nameof(staticNodesManager)); _pruningTrigger = pruningTrigger; + _parameters = parameters ?? throw new ArgumentNullException(nameof(parameters)); BuildNodeInfo(); } @@ -71,6 +75,7 @@ private void UpdateEthProtocolInfo() _nodeInfo.Protocols["eth"].NewtorkId = _blockTree.ChainId; _nodeInfo.Protocols["eth"].HeadHash = _blockTree.HeadHash; _nodeInfo.Protocols["eth"].GenesisHash = _blockTree.GenesisHash; + _nodeInfo.Protocols["eth"].Config = _parameters; } public async Task> admin_addPeer(string enode, bool addToStaticNodes = false) diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Admin/EthProtocolInfo.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Admin/EthProtocolInfo.cs index 87024cede4c..228f91c7dda 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Admin/EthProtocolInfo.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Admin/EthProtocolInfo.cs @@ -3,6 +3,7 @@ using Nethermind.Core.Crypto; using Nethermind.Int256; +using Nethermind.Specs.ChainSpecStyle; using System.Text.Json.Serialization; namespace Nethermind.JsonRpc.Modules.Admin @@ -17,5 +18,7 @@ public class EthProtocolInfo public Hash256 HeadHash { get; set; } [JsonPropertyName("network")] public ulong NewtorkId { get; set; } + [JsonPropertyName("config")] + public ChainParameters Config { get; set; } } } diff --git a/src/Nethermind/Nethermind.Runner.Test/Ethereum/ContextWithMocks.cs b/src/Nethermind/Nethermind.Runner.Test/Ethereum/ContextWithMocks.cs index 190f5cfb667..2cbc5284269 100644 --- a/src/Nethermind/Nethermind.Runner.Test/Ethereum/ContextWithMocks.cs +++ b/src/Nethermind/Nethermind.Runner.Test/Ethereum/ContextWithMocks.cs @@ -56,7 +56,7 @@ public static class Build public static NethermindApi ContextWithMocks() { var api = new NethermindApi(Substitute.For(), Substitute.For(), LimboLogs.Instance, - new ChainSpec()) + new ChainSpec { Parameters = new ChainParameters(), }) { Enode = Substitute.For(), TxPool = Substitute.For(),