From 71d71fed4ca50195add76e5e341a262901475dd1 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Tue, 20 Jun 2023 09:55:52 +0100 Subject: [PATCH] Add missing peer types to limits (#5838) * Add missing peer types to limits * Add Reth * Flaky test --- .../Nethermind.Network.Stats/Model/Node.cs | 4 ++++ .../Model/NodeClientType.cs | 1 + .../SynchronizerTests.cs | 4 ++-- .../Blocks/BlockDownloaderLimits.cs | 14 +++++++++++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Nethermind/Nethermind.Network.Stats/Model/Node.cs b/src/Nethermind/Nethermind.Network.Stats/Model/Node.cs index ebca63b426d..da0bd43f521 100644 --- a/src/Nethermind/Nethermind.Network.Stats/Model/Node.cs +++ b/src/Nethermind/Nethermind.Network.Stats/Model/Node.cs @@ -186,6 +186,10 @@ public static NodeClientType RecognizeClientType(string clientId) { return NodeClientType.Erigon; } + else if (clientId.Contains(nameof(NodeClientType.Reth), StringComparison.OrdinalIgnoreCase)) + { + return NodeClientType.Reth; + } else if (clientId.Contains(nameof(NodeClientType.Parity), StringComparison.OrdinalIgnoreCase)) { return NodeClientType.Parity; diff --git a/src/Nethermind/Nethermind.Network.Stats/Model/NodeClientType.cs b/src/Nethermind/Nethermind.Network.Stats/Model/NodeClientType.cs index be5ec95ac06..fe6978df096 100644 --- a/src/Nethermind/Nethermind.Network.Stats/Model/NodeClientType.cs +++ b/src/Nethermind/Nethermind.Network.Stats/Model/NodeClientType.cs @@ -13,5 +13,6 @@ public enum NodeClientType OpenEthereum, Trinity, Erigon, + Reth, } } diff --git a/src/Nethermind/Nethermind.Synchronization.Test/SynchronizerTests.cs b/src/Nethermind/Nethermind.Synchronization.Test/SynchronizerTests.cs index dd7595df93a..9b064b4d0f3 100644 --- a/src/Nethermind/Nethermind.Synchronization.Test/SynchronizerTests.cs +++ b/src/Nethermind/Nethermind.Synchronization.Test/SynchronizerTests.cs @@ -579,7 +579,7 @@ public SyncingContext PeerCountIs(long i) public SyncingContext PeerCountEventuallyIs(long i) { - Assert.That(() => SyncPeerPool.AllPeers.Count(), Is.EqualTo(i).After(1000, 100), "peer count"); + Assert.That(() => SyncPeerPool.AllPeers.Count(), Is.EqualTo(i).After(5000, 100), "peer count"); return this; } @@ -820,7 +820,7 @@ public void Will_not_add_same_peer_twice() .BestSuggestedBlockHasNumber(1).Stop(); } - [Test, Retry(3)] + [Test, Retry(5)] public void Will_remove_peer_when_init_fails() { SyncPeerMock peerA = new("A", true, true); diff --git a/src/Nethermind/Nethermind.Synchronization/Blocks/BlockDownloaderLimits.cs b/src/Nethermind/Nethermind.Synchronization/Blocks/BlockDownloaderLimits.cs index eab7096c8ce..82290de7028 100644 --- a/src/Nethermind/Nethermind.Synchronization/Blocks/BlockDownloaderLimits.cs +++ b/src/Nethermind/Nethermind.Synchronization/Blocks/BlockDownloaderLimits.cs @@ -20,8 +20,10 @@ public static int MaxBodiesPerRequest(this PeerInfo peer) NodeClientType.Parity => ParitySyncLimits.MaxBodyFetch, NodeClientType.OpenEthereum => ParitySyncLimits.MaxBodyFetch, NodeClientType.Trinity => GethSyncLimits.MaxBodyFetch, + NodeClientType.Erigon => GethSyncLimits.MaxBodyFetch, + NodeClientType.Reth => GethSyncLimits.MaxBodyFetch, NodeClientType.Unknown => 32, - _ => throw new ArgumentOutOfRangeException() + _ => throw new ArgumentOutOfRangeException(nameof(peer.PeerClientType), peer.PeerClientType, null) }; } @@ -34,8 +36,11 @@ public static int MaxReceiptsPerRequest(this PeerInfo peer) NodeClientType.Nethermind => NethermindSyncLimits.MaxReceiptFetch, NodeClientType.Parity => ParitySyncLimits.MaxReceiptFetch, NodeClientType.OpenEthereum => ParitySyncLimits.MaxReceiptFetch, + NodeClientType.Trinity => GethSyncLimits.MaxReceiptFetch, + NodeClientType.Erigon => GethSyncLimits.MaxReceiptFetch, + NodeClientType.Reth => GethSyncLimits.MaxReceiptFetch, NodeClientType.Unknown => 128, - _ => throw new ArgumentOutOfRangeException() + _ => throw new ArgumentOutOfRangeException(nameof(peer.PeerClientType), peer.PeerClientType, null) }; } @@ -48,8 +53,11 @@ public static int MaxHeadersPerRequest(this PeerInfo peer) NodeClientType.Nethermind => NethermindSyncLimits.MaxHeaderFetch, NodeClientType.Parity => ParitySyncLimits.MaxHeaderFetch, NodeClientType.OpenEthereum => ParitySyncLimits.MaxHeaderFetch, + NodeClientType.Trinity => GethSyncLimits.MaxHeaderFetch, + NodeClientType.Erigon => GethSyncLimits.MaxHeaderFetch, + NodeClientType.Reth => GethSyncLimits.MaxHeaderFetch, NodeClientType.Unknown => 192, - _ => throw new ArgumentOutOfRangeException() + _ => throw new ArgumentOutOfRangeException(nameof(peer.PeerClientType), peer.PeerClientType, null) }; } }