From ebc8a5ca982c0fabdb2efb8ab7902860c0b3ddca Mon Sep 17 00:00:00 2001 From: Marcin Sobczak <77129288+marcindsobczak@users.noreply.github.com> Date: Wed, 17 Aug 2022 10:07:46 +0100 Subject: [PATCH] The Merge configs (#4427) * The Merge configs * fix strange error 'Integral constant is too large' * cosmetic * more configs * fix tests * cosmetic * fix mainnet_aa.cfg * add SnapSync as default to AA and MEV * fix test --- src/Nethermind/Chains/foundation.json | 5 +++-- .../PoSSwitcherTests.cs | 2 +- .../Nethermind.Runner.Test/ConfigFilesTests.cs | 7 ++++--- .../Nethermind.Runner/configs/mainnet.cfg | 17 +++++++++++++++-- .../Nethermind.Runner/configs/mainnet_aa.cfg | 12 ++++++++++-- .../configs/mainnet_archive.cfg | 14 +++++++++++++- .../Nethermind.Runner/configs/mainnet_mev.cfg | 18 ++++++++++++++++-- .../ChainSpecBasedSpecProviderTests.cs | 1 + .../Nethermind.Specs/MainNetSpecProvider.cs | 11 ++++++----- .../Nethermind.Specs/TestSpecProvider.cs | 12 ++++++++---- 10 files changed, 77 insertions(+), 22 deletions(-) diff --git a/src/Nethermind/Chains/foundation.json b/src/Nethermind/Chains/foundation.json index c935cf0f60a..663ec40d383 100644 --- a/src/Nethermind/Chains/foundation.json +++ b/src/Nethermind/Chains/foundation.json @@ -180,7 +180,8 @@ "eip1559Transition": "0xC5D488", "eip3198Transition": "0xC5D488", "eip3529Transition": "0xC5D488", - "eip3541Transition": "0xC5D488" + "eip3541Transition": "0xC5D488", + "terminalTotalDifficulty": "C70D808A128D7380000" }, "genesis": { "seal": { @@ -30658,4 +30659,4 @@ "balance": "0xad78ebc5ac6200000" } } -} \ No newline at end of file +} diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/PoSSwitcherTests.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/PoSSwitcherTests.cs index 505a6ff2793..b130ec92719 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/PoSSwitcherTests.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/PoSSwitcherTests.cs @@ -47,7 +47,7 @@ public void Initial_TTD_should_be_null() { UInt256? expectedTtd = null; IBlockTree blockTree = Substitute.For(); - PoSSwitcher poSSwitcher = new(new MergeConfig(), new SyncConfig(), new MemDb(), blockTree, MainnetSpecProvider.Instance, LimboLogs.Instance); + PoSSwitcher poSSwitcher = new(new MergeConfig(), new SyncConfig(), new MemDb(), blockTree, TestSpecProvider.Instance, LimboLogs.Instance); Assert.AreEqual(expectedTtd, poSSwitcher.TerminalTotalDifficulty); } diff --git a/src/Nethermind/Nethermind.Runner.Test/ConfigFilesTests.cs b/src/Nethermind/Nethermind.Runner.Test/ConfigFilesTests.cs index 187874cc8ce..02258ddae14 100644 --- a/src/Nethermind/Nethermind.Runner.Test/ConfigFilesTests.cs +++ b/src/Nethermind/Nethermind.Runner.Test/ConfigFilesTests.cs @@ -262,7 +262,8 @@ public void Tx_pool_defaults_are_correct(string configWildcard, int poolSize) [TestCase("spaceneth", true)] [TestCase("ropsten", true)] [TestCase("goerli", true)] - [TestCase("^spaceneth ^baseline ^ropsten ^goerli", false)] + [TestCase("mainnet", true)] + [TestCase("^spaceneth ^baseline ^ropsten ^goerli ^mainnet", false)] public void Json_defaults_are_correct(string configWildcard, bool jsonEnabled) { Test(configWildcard, c => c.Enabled, jsonEnabled); @@ -301,8 +302,8 @@ public void Snap_sync_settings_as_expected(string configWildcard, bool enabled) Test(configWildcard, c => c.SnapSync, enabled); } - [TestCase("^aura ^ropsten ^sepolia ^goerli", false)] - [TestCase("aura ^archive ropsten sepolia goerli", true)] + [TestCase("^aura ^ropsten ^sepolia ^goerli ^mainnet", false)] + [TestCase("aura ^archive ropsten sepolia goerli mainnet", true)] public void Stays_on_full_sync(string configWildcard, bool stickToFullSyncAfterFastSync) { Test(configWildcard, c => c.FastSyncCatchUpHeightDelta, stickToFullSyncAfterFastSync ? 10_000_000_000 : 8192); diff --git a/src/Nethermind/Nethermind.Runner/configs/mainnet.cfg b/src/Nethermind/Nethermind.Runner/configs/mainnet.cfg index f2b4345f322..d80d6881865 100644 --- a/src/Nethermind/Nethermind.Runner/configs/mainnet.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/mainnet.cfg @@ -18,12 +18,25 @@ "FastBlocks": true, "AncientBodiesBarrier": 11052984, "AncientReceiptsBarrier": 11052984, - "WitnessProtocolEnabled": true + "WitnessProtocolEnabled": true, + "FastSyncCatchUpHeightDelta": "10000000000" }, "EthStats": { "Server": "wss://ethstats.net/api" }, "Metrics": { "NodeName": "Mainnet" + }, + "JsonRpc": { + "Enabled": true, + "Timeout": 20000, + "Host": "127.0.0.1", + "Port": 8545, + "AdditionalRpcUrls": [ + "http://localhost:8551|http;ws|net;eth;subscribe;engine;web3;client" + ] + }, + "Merge": { + "Enabled": true } -} \ No newline at end of file +} diff --git a/src/Nethermind/Nethermind.Runner/configs/mainnet_aa.cfg b/src/Nethermind/Nethermind.Runner/configs/mainnet_aa.cfg index cd36a5447d1..1ab28bc91a8 100644 --- a/src/Nethermind/Nethermind.Runner/configs/mainnet_aa.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/mainnet_aa.cfg @@ -14,6 +14,9 @@ "EnabledModules": [ "Eth", "AccountAbstraction" + ], + "AdditionalRpcUrls": [ + "http://localhost:8551|http;ws|net;eth;subscribe;engine;web3;client" ] }, "AccountAbstraction": { @@ -25,18 +28,23 @@ }, "Sync": { "FastSync": true, + "SnapSync": true, "PivotNumber": 15335000, "PivotHash": "0xde3bca488cce75bee9aabbfab6fc15aa56bc04e715f3197537a1d411af7b9708", "PivotTotalDifficulty": "56285312641338818488948", "FastBlocks": true, "AncientBodiesBarrier": 11052984, "AncientReceiptsBarrier": 11052984, - "WitnessProtocolEnabled": true + "WitnessProtocolEnabled": true, + "FastSyncCatchUpHeightDelta": "10000000000" }, "EthStats": { "Server": "wss://ethstats.net/api" }, "Metrics": { "NodeName": "Mainnet" + }, + "Merge": { + "Enabled": true } -} \ No newline at end of file +} diff --git a/src/Nethermind/Nethermind.Runner/configs/mainnet_archive.cfg b/src/Nethermind/Nethermind.Runner/configs/mainnet_archive.cfg index 8718a6bb9bb..79f7dd847b1 100644 --- a/src/Nethermind/Nethermind.Runner/configs/mainnet_archive.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/mainnet_archive.cfg @@ -21,5 +21,17 @@ }, "Pruning": { "Mode": "None" + }, + "JsonRpc": { + "Enabled": true, + "Timeout": 20000, + "Host": "127.0.0.1", + "Port": 8545, + "AdditionalRpcUrls": [ + "http://localhost:8551|http;ws|net;eth;subscribe;engine;web3;client" + ] + }, + "Merge": { + "Enabled": true } -} \ No newline at end of file +} diff --git a/src/Nethermind/Nethermind.Runner/configs/mainnet_mev.cfg b/src/Nethermind/Nethermind.Runner/configs/mainnet_mev.cfg index 2feb05f1270..9f9931644b9 100644 --- a/src/Nethermind/Nethermind.Runner/configs/mainnet_mev.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/mainnet_mev.cfg @@ -8,13 +8,15 @@ }, "Sync": { "FastSync": true, + "SnapSync": true, "PivotNumber": 15335000, "PivotHash": "0xde3bca488cce75bee9aabbfab6fc15aa56bc04e715f3197537a1d411af7b9708", "PivotTotalDifficulty": "56285312641338818488948", "FastBlocks": true, "AncientBodiesBarrier": 11052984, "AncientReceiptsBarrier": 11052984, - "WitnessProtocolEnabled": true + "WitnessProtocolEnabled": true, + "FastSyncCatchUpHeightDelta": "10000000000" }, "EthStats": { "Server": "wss://ethstats.net/api" @@ -25,5 +27,17 @@ "Mev": { "Enabled": true, "MaxMergedBundles": 3 + }, + "JsonRpc": { + "Enabled": true, + "Timeout": 20000, + "Host": "127.0.0.1", + "Port": 8545, + "AdditionalRpcUrls": [ + "http://localhost:8551|http;ws|net;eth;subscribe;engine;web3;client" + ] + }, + "Merge": { + "Enabled": true } -} \ No newline at end of file +} diff --git a/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs b/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs index 4f1e76e1c80..05929210f61 100644 --- a/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs +++ b/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs @@ -173,6 +173,7 @@ public void Mainnet_loads_properly() Assert.AreEqual(10_700_000, provider.GetSpec(15_049_999).DifficultyBombDelay); Assert.AreEqual(11_400_000, provider.GetSpec(15_050_000).DifficultyBombDelay); Assert.AreEqual(11_400_000, provider.GetSpec(99_414_000).DifficultyBombDelay); + Assert.AreEqual(MainnetSpecProvider.Instance.TerminalTotalDifficulty, provider.TerminalTotalDifficulty); } private static void CompareSpecProviders( diff --git a/src/Nethermind/Nethermind.Specs/MainNetSpecProvider.cs b/src/Nethermind/Nethermind.Specs/MainNetSpecProvider.cs index bc1752d4107..83ffd158bc5 100644 --- a/src/Nethermind/Nethermind.Specs/MainNetSpecProvider.cs +++ b/src/Nethermind/Nethermind.Specs/MainNetSpecProvider.cs @@ -1,16 +1,16 @@ // Copyright (c) 2021 Demerzel Solutions Limited // This file is part of the Nethermind library. -// +// // The Nethermind library is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // The Nethermind library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. -// +// // You should have received a copy of the GNU Lesser General Public License // along with the Nethermind. If not, see . @@ -23,17 +23,18 @@ namespace Nethermind.Specs public class MainnetSpecProvider : ISpecProvider { private long? _theMergeBlock = null; + private UInt256? _terminalTotalDifficulty = UInt256.Parse("58750000000000000000000"); public void UpdateMergeTransitionInfo(long? blockNumber, UInt256? terminalTotalDifficulty = null) { if (blockNumber != null) _theMergeBlock = blockNumber; if (terminalTotalDifficulty != null) - TerminalTotalDifficulty = terminalTotalDifficulty; + _terminalTotalDifficulty = terminalTotalDifficulty; } public long? MergeBlockNumber => _theMergeBlock; - public UInt256? TerminalTotalDifficulty { get; private set; } + public UInt256? TerminalTotalDifficulty => _terminalTotalDifficulty; public IReleaseSpec GenesisSpec => Frontier.Instance; public IReleaseSpec GetSpec(long blockNumber) => diff --git a/src/Nethermind/Nethermind.Specs/TestSpecProvider.cs b/src/Nethermind/Nethermind.Specs/TestSpecProvider.cs index e0478198b53..7648b5c4877 100644 --- a/src/Nethermind/Nethermind.Specs/TestSpecProvider.cs +++ b/src/Nethermind/Nethermind.Specs/TestSpecProvider.cs @@ -1,16 +1,16 @@ // Copyright (c) 2021 Demerzel Solutions Limited // This file is part of the Nethermind library. -// +// // The Nethermind library is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // The Nethermind library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. -// +// // You should have received a copy of the GNU Lesser General Public License // along with the Nethermind. If not, see . @@ -28,7 +28,7 @@ public TestSpecProvider(IReleaseSpec initialSpecToReturn) SpecToReturn = initialSpecToReturn; GenesisSpec = initialSpecToReturn; } - + public void UpdateMergeTransitionInfo(long? blockNumber, UInt256? terminalTotalDifficulty = null) { if (blockNumber != null) @@ -50,5 +50,9 @@ public void UpdateMergeTransitionInfo(long? blockNumber, UInt256? terminalTotalD public ulong ChainId { get; set; } public long[] TransitionBlocks { get; set; } = new long[] {0}; public bool AllowTestChainOverride { get; set; } = true; + + private TestSpecProvider() { } + + public static readonly TestSpecProvider Instance = new(); } }