From f1cb78e581574ff8aae1cb2d0d6e3c062e539f85 Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta Date: Fri, 5 Apr 2019 15:56:44 +0200 Subject: [PATCH 01/11] [PIE-1224] Different request limits for different request types - create `EthLimits` with max size of response according to geth (https://github.com/ethereum/go-ethereum/blob/master/eth/downloader/downloader.go) - update `EthServer` to use those constants limits instead of the default one - remove requestLimit from EthServer and EthProtocolManager constructor fix PIE-1224 --- .../pantheon/ethereum/eth/EthLimits.java | 26 +++++++++++++++++ .../eth/manager/EthProtocolManager.java | 28 ++----------------- .../ethereum/eth/manager/EthServer.java | 16 +++++------ 3 files changed, 36 insertions(+), 34 deletions(-) create mode 100644 ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/EthLimits.java diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/EthLimits.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/EthLimits.java new file mode 100644 index 0000000000..2e20fa7ec4 --- /dev/null +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/EthLimits.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.ethereum.eth; + +/** Constants related to Ethereum Wire Protocol (ETH) response limits */ +public class EthLimits { + + public static final int MAX_GET_BLOCK_HEADERS = 192; + public static final int MAX_GET_BLOCK_BODIES = 128; + public static final int MAX_GET_RECEIPTS = 256; + public static final int MAX_GET_NODE_DATA = 384; + + private EthLimits() { + // Holder for constants only + } +} diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java index 2877a68a38..8772e66836 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java @@ -70,7 +70,6 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { final WorldStateArchive worldStateArchive, final int networkId, final boolean fastSyncEnabled, - final int requestLimit, final EthScheduler scheduler) { this.networkId = networkId; this.scheduler = scheduler; @@ -87,26 +86,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { this.blockBroadcaster = new BlockBroadcaster(ethContext); // Set up request handlers - new EthServer(blockchain, worldStateArchive, ethMessages, requestLimit); - } - - EthProtocolManager( - final Blockchain blockchain, - final WorldStateArchive worldStateArchive, - final int networkId, - final boolean fastSyncEnabled, - final int syncWorkers, - final int txWorkers, - final int computationWorkers, - final int requestLimit, - final MetricsSystem metricsSystem) { - this( - blockchain, - worldStateArchive, - networkId, - fastSyncEnabled, - requestLimit, - new EthScheduler(syncWorkers, txWorkers, computationWorkers, metricsSystem)); + new EthServer(blockchain, worldStateArchive, ethMessages); } public EthProtocolManager( @@ -123,11 +103,7 @@ public EthProtocolManager( worldStateArchive, networkId, fastSyncEnabled, - syncWorkers, - txWorkers, - computationWorkers, - DEFAULT_REQUEST_LIMIT, - metricsSystem); + new EthScheduler(syncWorkers, txWorkers, computationWorkers, metricsSystem)); } public EthContext ethContext() { diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java index d631a13d17..0443e07b06 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java @@ -17,6 +17,7 @@ import tech.pegasys.pantheon.ethereum.core.BlockHeader; import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.ethereum.core.TransactionReceipt; +import tech.pegasys.pantheon.ethereum.eth.EthLimits; import tech.pegasys.pantheon.ethereum.eth.messages.BlockBodiesMessage; import tech.pegasys.pantheon.ethereum.eth.messages.BlockHeadersMessage; import tech.pegasys.pantheon.ethereum.eth.messages.EthPV62; @@ -50,17 +51,14 @@ class EthServer { private final Blockchain blockchain; private final WorldStateArchive worldStateArchive; private final EthMessages ethMessages; - private final int requestLimit; EthServer( final Blockchain blockchain, final WorldStateArchive worldStateArchive, - final EthMessages ethMessages, - final int requestLimit) { + final EthMessages ethMessages) { this.blockchain = blockchain; this.worldStateArchive = worldStateArchive; this.ethMessages = ethMessages; - this.requestLimit = requestLimit; this.setupListeners(); } @@ -75,7 +73,8 @@ private void handleGetBlockHeaders(final EthMessage message) { LOG.trace("Responding to GET_BLOCK_HEADERS request"); try { final MessageData response = - constructGetHeadersResponse(blockchain, message.getData(), requestLimit); + constructGetHeadersResponse( + blockchain, message.getData(), EthLimits.MAX_GET_BLOCK_HEADERS); message.getPeer().send(response); } catch (final RLPException e) { message.getPeer().disconnect(DisconnectReason.BREACH_OF_PROTOCOL); @@ -88,7 +87,7 @@ private void handleGetBlockBodies(final EthMessage message) { LOG.trace("Responding to GET_BLOCK_BODIES request"); try { final MessageData response = - constructGetBodiesResponse(blockchain, message.getData(), requestLimit); + constructGetBodiesResponse(blockchain, message.getData(), EthLimits.MAX_GET_BLOCK_BODIES); message.getPeer().send(response); } catch (final RLPException e) { message.getPeer().disconnect(DisconnectReason.BREACH_OF_PROTOCOL); @@ -101,7 +100,7 @@ private void handleGetReceipts(final EthMessage message) { LOG.trace("Responding to GET_RECEIPTS request"); try { final MessageData response = - constructGetReceiptsResponse(blockchain, message.getData(), requestLimit); + constructGetReceiptsResponse(blockchain, message.getData(), EthLimits.MAX_GET_RECEIPTS); message.getPeer().send(response); } catch (final RLPException e) { message.getPeer().disconnect(DisconnectReason.BREACH_OF_PROTOCOL); @@ -114,7 +113,8 @@ private void handleGetNodeData(final EthMessage message) { LOG.trace("Responding to GET_NODE_DATA request"); try { final MessageData response = - constructGetNodeDataResponse(worldStateArchive, message.getData(), requestLimit); + constructGetNodeDataResponse( + worldStateArchive, message.getData(), EthLimits.MAX_GET_NODE_DATA); message.getPeer().send(response); } catch (final RLPException e) { message.getPeer().disconnect(DisconnectReason.BREACH_OF_PROTOCOL); From 2d9f42c024c33c2a6bddf98a34134c3ad00f7d53 Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta Date: Mon, 8 Apr 2019 09:32:52 +0200 Subject: [PATCH 02/11] eth wire protocol request limits - add fields in `SynchronizerConfiguration` to configure per type request limit - update `EthServer` constructor to add new fields - update `EthProtocolManager` and subclasses to support new fields - update unit tests accordingly --- .../protocol/Istanbul64ProtocolManager.java | 12 +- .../pantheon/ethereum/eth/EthLimits.java | 26 ---- .../eth/manager/EthProtocolManager.java | 28 +++- .../ethereum/eth/manager/EthServer.java | 26 +++- .../eth/sync/SynchronizerConfiguration.java | 66 +++++++- .../eth/manager/EthProtocolManagerTest.java | 142 +++++++++++++++--- .../manager/EthProtocolManagerTestUtil.java | 8 +- .../ethereum/eth/manager/EthServerTest.java | 2 +- .../ethereum/eth/transactions/TestNode.java | 13 +- .../controller/CliquePantheonController.java | 6 +- .../IbftLegacyPantheonController.java | 6 +- .../controller/IbftPantheonController.java | 6 +- .../controller/MainnetPantheonController.java | 6 +- 13 files changed, 268 insertions(+), 79 deletions(-) delete mode 100644 ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/EthLimits.java diff --git a/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/protocol/Istanbul64ProtocolManager.java b/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/protocol/Istanbul64ProtocolManager.java index 7727bcaa1c..f7cd286eb9 100644 --- a/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/protocol/Istanbul64ProtocolManager.java +++ b/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/protocol/Istanbul64ProtocolManager.java @@ -33,7 +33,11 @@ public Istanbul64ProtocolManager( final int syncWorkers, final int txWorkers, final int computationWorkers, - final MetricsSystem metricsSystem) { + final MetricsSystem metricsSystem, + final int maxGetBlockHeaders, + final int maxGetBlockBodies, + final int maxGetReceipts, + final int maxGetNodeData) { super( blockchain, worldStateArchive, @@ -42,7 +46,11 @@ public Istanbul64ProtocolManager( syncWorkers, txWorkers, computationWorkers, - metricsSystem); + metricsSystem, + maxGetBlockHeaders, + maxGetBlockBodies, + maxGetReceipts, + maxGetNodeData); } @Override diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/EthLimits.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/EthLimits.java deleted file mode 100644 index 2e20fa7ec4..0000000000 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/EthLimits.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2019 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package tech.pegasys.pantheon.ethereum.eth; - -/** Constants related to Ethereum Wire Protocol (ETH) response limits */ -public class EthLimits { - - public static final int MAX_GET_BLOCK_HEADERS = 192; - public static final int MAX_GET_BLOCK_BODIES = 128; - public static final int MAX_GET_RECEIPTS = 256; - public static final int MAX_GET_NODE_DATA = 384; - - private EthLimits() { - // Holder for constants only - } -} diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java index 8772e66836..a9770d9671 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java @@ -44,7 +44,6 @@ import org.apache.logging.log4j.Logger; public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { - static final int DEFAULT_REQUEST_LIMIT = 200; private static final Logger LOG = LogManager.getLogger(); private static final List FAST_SYNC_CAPS = Collections.singletonList(EthProtocol.ETH63); @@ -70,7 +69,11 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { final WorldStateArchive worldStateArchive, final int networkId, final boolean fastSyncEnabled, - final EthScheduler scheduler) { + final EthScheduler scheduler, + final int maxGetBlockHeaders, + final int maxGetBlockBodies, + final int maxGetReceipts, + final int maxGetNodeData) { this.networkId = networkId; this.scheduler = scheduler; this.blockchain = blockchain; @@ -86,7 +89,14 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { this.blockBroadcaster = new BlockBroadcaster(ethContext); // Set up request handlers - new EthServer(blockchain, worldStateArchive, ethMessages); + new EthServer( + blockchain, + worldStateArchive, + ethMessages, + maxGetBlockHeaders, + maxGetBlockBodies, + maxGetReceipts, + maxGetNodeData); } public EthProtocolManager( @@ -97,13 +107,21 @@ public EthProtocolManager( final int syncWorkers, final int txWorkers, final int computationWorkers, - final MetricsSystem metricsSystem) { + final MetricsSystem metricsSystem, + final int maxGetBlockHeaders, + final int maxGetBlockBodies, + final int maxGetReceipts, + final int maxGetNodeData) { this( blockchain, worldStateArchive, networkId, fastSyncEnabled, - new EthScheduler(syncWorkers, txWorkers, computationWorkers, metricsSystem)); + new EthScheduler(syncWorkers, txWorkers, computationWorkers, metricsSystem), + maxGetBlockHeaders, + maxGetBlockBodies, + maxGetReceipts, + maxGetNodeData); } public EthContext ethContext() { diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java index 0443e07b06..aeae03a607 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java @@ -17,7 +17,6 @@ import tech.pegasys.pantheon.ethereum.core.BlockHeader; import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.ethereum.core.TransactionReceipt; -import tech.pegasys.pantheon.ethereum.eth.EthLimits; import tech.pegasys.pantheon.ethereum.eth.messages.BlockBodiesMessage; import tech.pegasys.pantheon.ethereum.eth.messages.BlockHeadersMessage; import tech.pegasys.pantheon.ethereum.eth.messages.EthPV62; @@ -48,17 +47,30 @@ class EthServer { private static final Logger LOG = LogManager.getLogger(); + static final int DEFAULT_REQUEST_LIMIT = 200; private final Blockchain blockchain; private final WorldStateArchive worldStateArchive; private final EthMessages ethMessages; + private final int maxGetBlockHeaders; + private final int maxGetBlockBodies; + private final int maxGetReceipts; + private final int maxGetNodeData; EthServer( final Blockchain blockchain, final WorldStateArchive worldStateArchive, - final EthMessages ethMessages) { + final EthMessages ethMessages, + final int maxGetBlockHeaders, + final int maxGetBlockBodies, + final int maxGetReceipts, + final int maxGetNodeData) { this.blockchain = blockchain; this.worldStateArchive = worldStateArchive; this.ethMessages = ethMessages; + this.maxGetBlockHeaders = maxGetBlockHeaders; + this.maxGetBlockBodies = maxGetBlockBodies; + this.maxGetReceipts = maxGetReceipts; + this.maxGetNodeData = maxGetNodeData; this.setupListeners(); } @@ -73,8 +85,7 @@ private void handleGetBlockHeaders(final EthMessage message) { LOG.trace("Responding to GET_BLOCK_HEADERS request"); try { final MessageData response = - constructGetHeadersResponse( - blockchain, message.getData(), EthLimits.MAX_GET_BLOCK_HEADERS); + constructGetHeadersResponse(blockchain, message.getData(), maxGetBlockHeaders); message.getPeer().send(response); } catch (final RLPException e) { message.getPeer().disconnect(DisconnectReason.BREACH_OF_PROTOCOL); @@ -87,7 +98,7 @@ private void handleGetBlockBodies(final EthMessage message) { LOG.trace("Responding to GET_BLOCK_BODIES request"); try { final MessageData response = - constructGetBodiesResponse(blockchain, message.getData(), EthLimits.MAX_GET_BLOCK_BODIES); + constructGetBodiesResponse(blockchain, message.getData(), maxGetBlockBodies); message.getPeer().send(response); } catch (final RLPException e) { message.getPeer().disconnect(DisconnectReason.BREACH_OF_PROTOCOL); @@ -100,7 +111,7 @@ private void handleGetReceipts(final EthMessage message) { LOG.trace("Responding to GET_RECEIPTS request"); try { final MessageData response = - constructGetReceiptsResponse(blockchain, message.getData(), EthLimits.MAX_GET_RECEIPTS); + constructGetReceiptsResponse(blockchain, message.getData(), maxGetReceipts); message.getPeer().send(response); } catch (final RLPException e) { message.getPeer().disconnect(DisconnectReason.BREACH_OF_PROTOCOL); @@ -113,8 +124,7 @@ private void handleGetNodeData(final EthMessage message) { LOG.trace("Responding to GET_NODE_DATA request"); try { final MessageData response = - constructGetNodeDataResponse( - worldStateArchive, message.getData(), EthLimits.MAX_GET_NODE_DATA); + constructGetNodeDataResponse(worldStateArchive, message.getData(), maxGetNodeData); message.getPeer().send(response); } catch (final RLPException e) { message.getPeer().disconnect(DisconnectReason.BREACH_OF_PROTOCOL); diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/SynchronizerConfiguration.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/SynchronizerConfiguration.java index 497d838f4c..d2b5326b73 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/SynchronizerConfiguration.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/SynchronizerConfiguration.java @@ -33,6 +33,10 @@ public class SynchronizerConfiguration { private static final int DEFAULT_WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS = 1000; private static final long DEFAULT_WORLD_STATE_MIN_MILLIS_BEFORE_STALLING = TimeUnit.MINUTES.toMillis(5); + private static final int DEFAULT_MAX_GET_BLOCK_HEADERS = 192; + private static final int DEFAULT_MAX_GET_BLOCK_BODIES = 128; + private static final int DEFAULT_MAX_GET_RECEIPTS = 256; + private static final int DEFAULT_MAX_GET_NODE_DATA = 384; // Fast sync config private final int fastSyncPivotDistance; @@ -62,6 +66,12 @@ public class SynchronizerConfiguration { private final int maxTrailingPeers; private final long worldStateMinMillisBeforeStalling; + // Ethereum Wire Protocol config + private final int maxGetBlockHeaders; + private final int maxGetBlockBodies; + private final int maxGetReceipts; + private final int maxGetNodeData; + private SynchronizerConfiguration( final int fastSyncPivotDistance, final float fastSyncFullValidationRate, @@ -82,7 +92,11 @@ private SynchronizerConfiguration( final int downloaderParallelism, final int transactionsParallelism, final int computationParallelism, - final int maxTrailingPeers) { + final int maxTrailingPeers, + final int maxGetBlockHeaders, + final int maxGetBlockBodies, + final int maxGetReceipts, + final int maxGetNodeData) { this.fastSyncPivotDistance = fastSyncPivotDistance; this.fastSyncFullValidationRate = fastSyncFullValidationRate; this.fastSyncMinimumPeerCount = fastSyncMinimumPeerCount; @@ -103,6 +117,10 @@ private SynchronizerConfiguration( this.transactionsParallelism = transactionsParallelism; this.computationParallelism = computationParallelism; this.maxTrailingPeers = maxTrailingPeers; + this.maxGetBlockHeaders = maxGetBlockHeaders; + this.maxGetBlockBodies = maxGetBlockBodies; + this.maxGetReceipts = maxGetReceipts; + this.maxGetNodeData = maxGetNodeData; } public static Builder builder() { @@ -213,6 +231,22 @@ public int getMaxTrailingPeers() { return maxTrailingPeers; } + public int getMaxGetBlockHeaders() { + return maxGetBlockHeaders; + } + + public int getMaxGetBlockBodies() { + return maxGetBlockBodies; + } + + public int getMaxGetReceipts() { + return maxGetReceipts; + } + + public int getMaxGetNodeData() { + return maxGetNodeData; + } + public static class Builder { private SyncMode syncMode = SyncMode.FULL; private Range blockPropagationRange = Range.closed(-10L, 30L); @@ -235,6 +269,10 @@ public static class Builder { private long worldStateMinMillisBeforeStalling = DEFAULT_WORLD_STATE_MIN_MILLIS_BEFORE_STALLING; private Duration fastSyncMaximumPeerWaitTime = DEFAULT_FAST_SYNC_MAXIMUM_PEER_WAIT_TIME; private int maxTrailingPeers = Integer.MAX_VALUE; + private int maxGetBlockHeaders = DEFAULT_MAX_GET_BLOCK_HEADERS; + private int maxGetBlockBodies = DEFAULT_MAX_GET_BLOCK_BODIES; + private int maxGetReceipts = DEFAULT_MAX_GET_RECEIPTS; + private int maxGetNodeData = DEFAULT_MAX_GET_NODE_DATA; public Builder fastSyncPivotDistance(final int distance) { fastSyncPivotDistance = distance; @@ -337,6 +375,26 @@ public Builder maxTrailingPeers(final int maxTailingPeers) { return this; } + public Builder maxGetBlockHeaders(final int maxGetBlockHeaders) { + this.maxGetBlockHeaders = maxGetBlockHeaders; + return this; + } + + public Builder maxGetBlockBodies(final int maxGetBlockBodies) { + this.maxGetBlockBodies = maxGetBlockBodies; + return this; + } + + public Builder maxGetReceipts(final int maxGetReceipts) { + this.maxGetReceipts = maxGetReceipts; + return this; + } + + public Builder maxGetNodeData(final int maxGetNodeData) { + this.maxGetNodeData = maxGetNodeData; + return this; + } + public SynchronizerConfiguration build() { return new SynchronizerConfiguration( fastSyncPivotDistance, @@ -358,7 +416,11 @@ public SynchronizerConfiguration build() { downloaderParallelism, transactionsParallelism, computationParallelism, - maxTrailingPeers); + maxTrailingPeers, + maxGetBlockHeaders, + maxGetBlockBodies, + maxGetReceipts, + maxGetNodeData); } } } diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTest.java index 07174154fb..5cb54982a8 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTest.java @@ -116,7 +116,11 @@ public void disconnectOnUnsolicitedMessage() { 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { final MessageData messageData = BlockHeadersMessage.create(Collections.singletonList(blockchain.getBlockHeader(1).get())); final MockPeerConnection peer = setupPeer(ethManager, (cap, msg, conn) -> {}); @@ -136,7 +140,11 @@ public void disconnectOnFailureToSendStatusMessage() { 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { final MessageData messageData = BlockHeadersMessage.create(Collections.singletonList(blockchain.getBlockHeader(1).get())); final MockPeerConnection peer = @@ -157,7 +165,11 @@ public void disconnectOnWrongChainId() { 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { final MessageData messageData = BlockHeadersMessage.create(Collections.singletonList(blockchain.getBlockHeader(1).get())); final MockPeerConnection peer = @@ -189,7 +201,11 @@ public void disconnectOnWrongGenesisHash() { 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { final MessageData messageData = BlockHeadersMessage.create(Collections.singletonList(blockchain.getBlockHeader(1).get())); final MockPeerConnection peer = @@ -221,7 +237,11 @@ public void doNotDisconnectOnValidMessage() { 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { final MessageData messageData = GetBlockBodiesMessage.create(Collections.singletonList(gen.hash())); final MockPeerConnection peer = setupPeer(ethManager, (cap, msg, conn) -> {}); @@ -245,7 +265,11 @@ public void respondToGetHeaders() throws ExecutionException, InterruptedExceptio 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { final long startBlock = 5L; final int blockCount = 5; final MessageData messageData = @@ -285,8 +309,11 @@ public void respondToGetHeadersWithinLimits() throws ExecutionException, Interru 1, 1, 1, + new NoOpMetricsSystem(), limit, - new NoOpMetricsSystem())) { + limit, + limit, + limit)) { final long startBlock = 5L; final int blockCount = 10; final MessageData messageData = @@ -325,7 +352,11 @@ public void respondToGetHeadersReversed() throws ExecutionException, Interrupted 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { final long endBlock = 10L; final int blockCount = 5; final MessageData messageData = GetBlockHeadersMessage.create(endBlock, blockCount, 0, true); @@ -363,7 +394,11 @@ public void respondToGetHeadersWithSkip() throws ExecutionException, Interrupted 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { final long startBlock = 5L; final int blockCount = 5; final int skip = 1; @@ -404,7 +439,11 @@ public void respondToGetHeadersReversedWithSkip() 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { final long endBlock = 10L; final int blockCount = 5; final int skip = 1; @@ -466,7 +505,11 @@ public void respondToGetHeadersPartial() throws ExecutionException, InterruptedE 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { final long startBlock = blockchain.getChainHeadBlockNumber() - 1L; final int blockCount = 5; final MessageData messageData = @@ -505,7 +548,11 @@ public void respondToGetHeadersEmpty() throws ExecutionException, InterruptedExc 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { final long startBlock = blockchain.getChainHeadBlockNumber() + 1; final int blockCount = 5; final MessageData messageData = @@ -541,7 +588,11 @@ public void respondToGetBodies() throws ExecutionException, InterruptedException 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { // Setup blocks query final long startBlock = blockchain.getChainHeadBlockNumber() - 5; final int blockCount = 2; @@ -593,8 +644,11 @@ public void respondToGetBodiesWithinLimits() throws ExecutionException, Interrup 1, 1, 1, + new NoOpMetricsSystem(), + limit, + limit, limit, - new NoOpMetricsSystem())) { + limit)) { // Setup blocks query final int blockCount = 10; final long startBlock = blockchain.getChainHeadBlockNumber() - blockCount; @@ -645,7 +699,11 @@ public void respondToGetBodiesPartial() throws ExecutionException, InterruptedEx 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { // Setup blocks query final long expectedBlockNumber = blockchain.getChainHeadBlockNumber() - 1; final BlockHeader header = blockchain.getBlockHeader(expectedBlockNumber).get(); @@ -690,7 +748,11 @@ public void respondToGetReceipts() throws ExecutionException, InterruptedExcepti 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { // Setup blocks query final long startBlock = blockchain.getChainHeadBlockNumber() - 5; final int blockCount = 2; @@ -741,8 +803,11 @@ public void respondToGetReceiptsWithinLimits() throws ExecutionException, Interr 1, 1, 1, - limit, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { // Setup blocks query final int blockCount = 10; final long startBlock = blockchain.getChainHeadBlockNumber() - blockCount; @@ -792,7 +857,11 @@ public void respondToGetReceiptsPartial() throws ExecutionException, Interrupted 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { // Setup blocks query final long blockNumber = blockchain.getChainHeadBlockNumber() - 5; final BlockHeader header = blockchain.getBlockHeader(blockNumber).get(); @@ -832,7 +901,18 @@ public void respondToGetNodeData() throws Exception { try (final EthProtocolManager ethManager = new EthProtocolManager( - blockchain, worldStateArchive, 1, true, 1, 1, 1, new NoOpMetricsSystem())) { + blockchain, + worldStateArchive, + 1, + true, + 1, + 1, + 1, + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { // Setup node data query final List expectedResults = new ArrayList<>(); @@ -882,7 +962,11 @@ public void newBlockMinedSendsNewBlockMessageToAllPeers() { 1, 1, 1, - new NoOpMetricsSystem()); + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200); // Define handler to validate response final PeerSendHandler onSend = mock(PeerSendHandler.class); @@ -953,7 +1037,11 @@ public void shouldSuccessfullyRespondToGetHeadersRequestLessThanZero() 1, 1, 1, - new NoOpMetricsSystem())) { + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200)) { final long startBlock = 1L; final int requestedBlockCount = 13; final int receivedBlockCount = 2; @@ -1013,7 +1101,15 @@ public void transactionMessagesGoToTheCorrectExecutor() { try (final EthProtocolManager ethManager = new EthProtocolManager( - blockchain, protocolContext.getWorldStateArchive(), 1, true, 1, ethScheduler)) { + blockchain, + protocolContext.getWorldStateArchive(), + 1, + true, + ethScheduler, + 200, + 200, + 200, + 200)) { // Create a transaction pool. This has a side effect of registring a listener for the // transactions message. diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java index f3ee454239..987266b735 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java @@ -43,13 +43,7 @@ public static EthProtocolManager create( final WorldStateArchive worldStateArchive, final EthScheduler ethScheduler) { final int networkId = 1; - return new EthProtocolManager( - blockchain, - worldStateArchive, - networkId, - false, - EthProtocolManager.DEFAULT_REQUEST_LIMIT, - ethScheduler); + return new EthProtocolManager(blockchain, worldStateArchive, networkId, false, ethScheduler); } public static EthProtocolManager create( diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java index 43eddf2397..12213ef78d 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java @@ -45,7 +45,7 @@ public class EthServerTest { @Before public void setUp() { - new EthServer(blockchain, worldStateArchive, ethMessages, 2); + new EthServer(blockchain, worldStateArchive, ethMessages); } @Test diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TestNode.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TestNode.java index d79d859ea5..26170eef89 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TestNode.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TestNode.java @@ -109,7 +109,18 @@ public TestNode( new ProtocolContext<>(blockchain, worldStateArchive, null); final EthProtocolManager ethProtocolManager = new EthProtocolManager( - blockchain, worldStateArchive, 1, false, 1, 1, 1, new NoOpMetricsSystem()); + blockchain, + worldStateArchive, + 1, + false, + 1, + 1, + 1, + new NoOpMetricsSystem(), + 200, + 200, + 200, + 200); final NetworkRunner networkRunner = NetworkRunner.builder() diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/controller/CliquePantheonController.java b/pantheon/src/main/java/tech/pegasys/pantheon/controller/CliquePantheonController.java index adbd4c3fb3..2adf37a5bf 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/controller/CliquePantheonController.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/controller/CliquePantheonController.java @@ -156,7 +156,11 @@ static PantheonController init( syncConfig.downloaderParallelism(), syncConfig.transactionsParallelism(), syncConfig.computationParallelism(), - metricsSystem); + metricsSystem, + syncConfig.getMaxGetBlockHeaders(), + syncConfig.getMaxGetBlockBodies(), + syncConfig.getMaxGetReceipts(), + syncConfig.getMaxGetNodeData()); final SyncState syncState = new SyncState(blockchain, ethProtocolManager.ethContext().getEthPeers()); final Synchronizer synchronizer = diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftLegacyPantheonController.java b/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftLegacyPantheonController.java index ee95b5791a..89b6a31c36 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftLegacyPantheonController.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftLegacyPantheonController.java @@ -147,7 +147,11 @@ static PantheonController init( syncConfig.downloaderParallelism(), syncConfig.transactionsParallelism(), syncConfig.computationParallelism(), - metricsSystem); + metricsSystem, + syncConfig.getMaxGetBlockHeaders(), + syncConfig.getMaxGetBlockBodies(), + syncConfig.getMaxGetReceipts(), + syncConfig.getMaxGetNodeData()); final SyncState syncState = new SyncState(blockchain, istanbul64ProtocolManager.ethContext().getEthPeers()); diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftPantheonController.java b/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftPantheonController.java index 30fe91c62d..f6117161cd 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftPantheonController.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftPantheonController.java @@ -181,7 +181,11 @@ static PantheonController init( syncConfig.downloaderParallelism(), syncConfig.transactionsParallelism(), syncConfig.computationParallelism(), - metricsSystem); + metricsSystem, + syncConfig.getMaxGetBlockHeaders(), + syncConfig.getMaxGetBlockBodies(), + syncConfig.getMaxGetReceipts(), + syncConfig.getMaxGetNodeData()); final SubProtocol ethSubProtocol = EthProtocol.get(); final EthContext ethContext = ethProtocolManager.ethContext(); diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java b/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java index e86c1e097d..6c77a70e63 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java @@ -123,7 +123,11 @@ public static PantheonController init( syncConfig.downloaderParallelism(), syncConfig.transactionsParallelism(), syncConfig.computationParallelism(), - metricsSystem); + metricsSystem, + syncConfig.getMaxGetBlockHeaders(), + syncConfig.getMaxGetBlockBodies(), + syncConfig.getMaxGetReceipts(), + syncConfig.getMaxGetNodeData()); final SyncState syncState = new SyncState(blockchain, ethProtocolManager.ethContext().getEthPeers()); final Synchronizer synchronizer = From 07c154a30ecc59265746a26bbe8db9e299856fc6 Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta Date: Mon, 8 Apr 2019 09:50:00 +0200 Subject: [PATCH 03/11] Update SynchronizerConfiguration.java --- .../pantheon/ethereum/eth/sync/SynchronizerConfiguration.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/SynchronizerConfiguration.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/SynchronizerConfiguration.java index c4da93b5a3..968ecb5f39 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/SynchronizerConfiguration.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/SynchronizerConfiguration.java @@ -407,8 +407,7 @@ public void parseBlockPropagationRange(final String arg) { description = "Minimum time in ms without progress before considering a world state download as stalled (default: ${DEFAULT-VALUE})") private long worldStateMinMillisBeforeStalling = DEFAULT_WORLD_STATE_MIN_MILLIS_BEFORE_STALLING; - private Duration fastSyncMaximumPeerWaitTime = DEFAULT_FAST_SYNC_MAXIMUM_PEER_WAIT_TIME; - private int maxTrailingPeers = Integer.MAX_VALUE; + private int maxGetBlockHeaders = DEFAULT_MAX_GET_BLOCK_HEADERS; private int maxGetBlockBodies = DEFAULT_MAX_GET_BLOCK_BODIES; private int maxGetReceipts = DEFAULT_MAX_GET_RECEIPTS; From 891ec1b87c34df7ac253c5477142f8b85c891cd3 Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta Date: Mon, 8 Apr 2019 10:01:38 +0200 Subject: [PATCH 04/11] Update EthProtocolManagerTestUtil.java --- .../eth/manager/EthProtocolManagerTestUtil.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java index 987266b735..f552d74f64 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java @@ -43,7 +43,16 @@ public static EthProtocolManager create( final WorldStateArchive worldStateArchive, final EthScheduler ethScheduler) { final int networkId = 1; - return new EthProtocolManager(blockchain, worldStateArchive, networkId, false, ethScheduler); + return new EthProtocolManager( + blockchain, + worldStateArchive, + networkId, + false, + ethScheduler, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT); } public static EthProtocolManager create( From cbae014e86cebc33b62968fe17353525f2d670b7 Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta Date: Mon, 8 Apr 2019 10:07:49 +0200 Subject: [PATCH 05/11] Update EthServerTest.java --- .../pantheon/ethereum/eth/manager/EthServerTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java index 12213ef78d..5dd7939d1d 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java @@ -45,7 +45,14 @@ public class EthServerTest { @Before public void setUp() { - new EthServer(blockchain, worldStateArchive, ethMessages); + new EthServer( + blockchain, + worldStateArchive, + ethMessages, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT); } @Test From ab3e72b1f93922d2f624fe8ce2ec0333bcec046d Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta Date: Mon, 8 Apr 2019 10:39:49 +0200 Subject: [PATCH 06/11] Update EthProtocolManagerTest.java --- .../ethereum/eth/manager/EthProtocolManagerTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTest.java index 5cb54982a8..b235bea4c3 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTest.java @@ -804,10 +804,10 @@ public void respondToGetReceiptsWithinLimits() throws ExecutionException, Interr 1, 1, new NoOpMetricsSystem(), - 200, - 200, - 200, - 200)) { + limit, + limit, + limit, + limit)) { // Setup blocks query final int blockCount = 10; final long startBlock = blockchain.getChainHeadBlockNumber() - blockCount; From f0117e71b2cc930249146f3613c08979f168fd0b Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta Date: Mon, 8 Apr 2019 11:06:23 +0200 Subject: [PATCH 07/11] Update EthServerTest.java --- .../ethereum/eth/manager/EthServerTest.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java index 5dd7939d1d..b995355e68 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java @@ -27,7 +27,6 @@ import java.util.Optional; -import org.junit.Before; import org.junit.Test; public class EthServerTest { @@ -43,8 +42,8 @@ public class EthServerTest { private final EthPeer ethPeer = mock(EthPeer.class); private final EthMessages ethMessages = new EthMessages(); - @Before - public void setUp() { + @Test + public void shouldRespondToNodeDataRequests() throws Exception { new EthServer( blockchain, worldStateArchive, @@ -53,10 +52,6 @@ public void setUp() { EthServer.DEFAULT_REQUEST_LIMIT, EthServer.DEFAULT_REQUEST_LIMIT, EthServer.DEFAULT_REQUEST_LIMIT); - } - - @Test - public void shouldRespondToNodeDataRequests() throws Exception { when(worldStateArchive.getNodeData(HASH1)).thenReturn(Optional.of(VALUE1)); when(worldStateArchive.getNodeData(HASH2)).thenReturn(Optional.of(VALUE2)); ethMessages.dispatch(new EthMessage(ethPeer, GetNodeDataMessage.create(asList(HASH1, HASH2)))); @@ -66,6 +61,14 @@ public void shouldRespondToNodeDataRequests() throws Exception { @Test public void shouldHandleDataBeingUnavailableWhenRespondingToNodeDataRequests() throws Exception { + new EthServer( + blockchain, + worldStateArchive, + ethMessages, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT); when(worldStateArchive.getNodeData(HASH1)).thenReturn(Optional.of(VALUE1)); when(worldStateArchive.getNodeData(HASH2)).thenReturn(Optional.empty()); ethMessages.dispatch(new EthMessage(ethPeer, GetNodeDataMessage.create(asList(HASH1, HASH2)))); @@ -75,6 +78,14 @@ public void shouldHandleDataBeingUnavailableWhenRespondingToNodeDataRequests() t @Test public void shouldLimitNumberOfResponsesToNodeDataRequests() throws Exception { + new EthServer( + blockchain, + worldStateArchive, + ethMessages, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT); when(worldStateArchive.getNodeData(HASH1)).thenReturn(Optional.of(VALUE1)); when(worldStateArchive.getNodeData(HASH2)).thenReturn(Optional.of(VALUE2)); ethMessages.dispatch( @@ -86,6 +97,14 @@ public void shouldLimitNumberOfResponsesToNodeDataRequests() throws Exception { @Test public void shouldLimitTheNumberOfNodeDataResponsesLookedUpNotTheNumberReturned() throws Exception { + new EthServer( + blockchain, + worldStateArchive, + ethMessages, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT, + EthServer.DEFAULT_REQUEST_LIMIT, + 1); when(worldStateArchive.getNodeData(HASH1)).thenReturn(Optional.of(VALUE1)); when(worldStateArchive.getNodeData(HASH2)).thenReturn(Optional.empty()); when(worldStateArchive.getNodeData(HASH3)).thenReturn(Optional.of(VALUE3)); From 463e66bb1a50a1697f0d6c55ae6897636eb182c4 Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta Date: Mon, 8 Apr 2019 17:09:05 +0200 Subject: [PATCH 08/11] fix after review discussion - remove per type request limit configuration from `SynchronizerConfiguration`. - add `EthServer` constructor without new fields that use default values. - update unit tests accordingly - update instanciation of different `PantheonController` accordingly --- .../protocol/Istanbul64ProtocolManager.java | 12 +--- .../eth/manager/EthProtocolManager.java | 21 ++++++ .../ethereum/eth/manager/EthServer.java | 20 ++++++ .../eth/sync/SynchronizerConfiguration.java | 67 +------------------ .../ethereum/eth/manager/EthServerTest.java | 27 +------- .../controller/CliquePantheonController.java | 6 +- .../IbftLegacyPantheonController.java | 6 +- .../controller/IbftPantheonController.java | 6 +- .../controller/MainnetPantheonController.java | 6 +- 9 files changed, 52 insertions(+), 119 deletions(-) diff --git a/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/protocol/Istanbul64ProtocolManager.java b/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/protocol/Istanbul64ProtocolManager.java index f7cd286eb9..7727bcaa1c 100644 --- a/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/protocol/Istanbul64ProtocolManager.java +++ b/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/protocol/Istanbul64ProtocolManager.java @@ -33,11 +33,7 @@ public Istanbul64ProtocolManager( final int syncWorkers, final int txWorkers, final int computationWorkers, - final MetricsSystem metricsSystem, - final int maxGetBlockHeaders, - final int maxGetBlockBodies, - final int maxGetReceipts, - final int maxGetNodeData) { + final MetricsSystem metricsSystem) { super( blockchain, worldStateArchive, @@ -46,11 +42,7 @@ public Istanbul64ProtocolManager( syncWorkers, txWorkers, computationWorkers, - metricsSystem, - maxGetBlockHeaders, - maxGetBlockBodies, - maxGetReceipts, - maxGetNodeData); + metricsSystem); } @Override diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java index a9770d9671..d7d20bb5ca 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java @@ -99,6 +99,27 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { maxGetNodeData); } + public EthProtocolManager( + final Blockchain blockchain, + final WorldStateArchive worldStateArchive, + final int networkId, + final boolean fastSyncEnabled, + final int syncWorkers, + final int txWorkers, + final int computationWorkers, + final MetricsSystem metricsSystem) { + this( + blockchain, + worldStateArchive, + networkId, + fastSyncEnabled, + new EthScheduler(syncWorkers, txWorkers, computationWorkers, metricsSystem), + EthServer.DEFAULT_MAX_GET_BLOCK_HEADERS, + EthServer.DEFAULT_MAX_GET_BLOCK_BODIES, + EthServer.DEFAULT_MAX_GET_RECEIPTS, + EthServer.DEFAULT_MAX_GET_NODE_DATA); + } + public EthProtocolManager( final Blockchain blockchain, final WorldStateArchive worldStateArchive, diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java index aeae03a607..2ad94954c0 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java @@ -48,6 +48,12 @@ class EthServer { private static final Logger LOG = LogManager.getLogger(); static final int DEFAULT_REQUEST_LIMIT = 200; + + public static final int DEFAULT_MAX_GET_BLOCK_HEADERS = 192; + public static final int DEFAULT_MAX_GET_BLOCK_BODIES = 128; + public static final int DEFAULT_MAX_GET_RECEIPTS = 256; + public static final int DEFAULT_MAX_GET_NODE_DATA = 384; + private final Blockchain blockchain; private final WorldStateArchive worldStateArchive; private final EthMessages ethMessages; @@ -74,6 +80,20 @@ class EthServer { this.setupListeners(); } + EthServer( + final Blockchain blockchain, + final WorldStateArchive worldStateArchive, + final EthMessages ethMessages) { + this( + blockchain, + worldStateArchive, + ethMessages, + DEFAULT_MAX_GET_BLOCK_HEADERS, + DEFAULT_MAX_GET_BLOCK_BODIES, + DEFAULT_MAX_GET_RECEIPTS, + DEFAULT_MAX_GET_NODE_DATA); + } + private void setupListeners() { ethMessages.subscribe(EthPV62.GET_BLOCK_HEADERS, this::handleGetBlockHeaders); ethMessages.subscribe(EthPV62.GET_BLOCK_BODIES, this::handleGetBlockBodies); diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/SynchronizerConfiguration.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/SynchronizerConfiguration.java index 968ecb5f39..ac3f1d53cf 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/SynchronizerConfiguration.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/SynchronizerConfiguration.java @@ -36,10 +36,6 @@ public class SynchronizerConfiguration { private static final int DEFAULT_WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS = 1000; private static final long DEFAULT_WORLD_STATE_MIN_MILLIS_BEFORE_STALLING = TimeUnit.MINUTES.toMillis(5); - private static final int DEFAULT_MAX_GET_BLOCK_HEADERS = 192; - private static final int DEFAULT_MAX_GET_BLOCK_BODIES = 128; - private static final int DEFAULT_MAX_GET_RECEIPTS = 256; - private static final int DEFAULT_MAX_GET_NODE_DATA = 384; // Fast sync config private final int fastSyncPivotDistance; @@ -69,12 +65,6 @@ public class SynchronizerConfiguration { private final int maxTrailingPeers; private final long worldStateMinMillisBeforeStalling; - // Ethereum Wire Protocol config - private final int maxGetBlockHeaders; - private final int maxGetBlockBodies; - private final int maxGetReceipts; - private final int maxGetNodeData; - private SynchronizerConfiguration( final int fastSyncPivotDistance, final float fastSyncFullValidationRate, @@ -95,11 +85,7 @@ private SynchronizerConfiguration( final int downloaderParallelism, final int transactionsParallelism, final int computationParallelism, - final int maxTrailingPeers, - final int maxGetBlockHeaders, - final int maxGetBlockBodies, - final int maxGetReceipts, - final int maxGetNodeData) { + final int maxTrailingPeers) { this.fastSyncPivotDistance = fastSyncPivotDistance; this.fastSyncFullValidationRate = fastSyncFullValidationRate; this.fastSyncMinimumPeerCount = fastSyncMinimumPeerCount; @@ -120,10 +106,6 @@ private SynchronizerConfiguration( this.transactionsParallelism = transactionsParallelism; this.computationParallelism = computationParallelism; this.maxTrailingPeers = maxTrailingPeers; - this.maxGetBlockHeaders = maxGetBlockHeaders; - this.maxGetBlockBodies = maxGetBlockBodies; - this.maxGetReceipts = maxGetReceipts; - this.maxGetNodeData = maxGetNodeData; } public static Builder builder() { @@ -234,22 +216,6 @@ public int getMaxTrailingPeers() { return maxTrailingPeers; } - public int getMaxGetBlockHeaders() { - return maxGetBlockHeaders; - } - - public int getMaxGetBlockBodies() { - return maxGetBlockBodies; - } - - public int getMaxGetReceipts() { - return maxGetReceipts; - } - - public int getMaxGetNodeData() { - return maxGetNodeData; - } - public static class Builder { private SyncMode syncMode = SyncMode.FULL; private int fastSyncMinimumPeerCount = DEFAULT_FAST_SYNC_MINIMUM_PEERS; @@ -408,11 +374,6 @@ public void parseBlockPropagationRange(final String arg) { "Minimum time in ms without progress before considering a world state download as stalled (default: ${DEFAULT-VALUE})") private long worldStateMinMillisBeforeStalling = DEFAULT_WORLD_STATE_MIN_MILLIS_BEFORE_STALLING; - private int maxGetBlockHeaders = DEFAULT_MAX_GET_BLOCK_HEADERS; - private int maxGetBlockBodies = DEFAULT_MAX_GET_BLOCK_BODIES; - private int maxGetReceipts = DEFAULT_MAX_GET_RECEIPTS; - private int maxGetNodeData = DEFAULT_MAX_GET_NODE_DATA; - public Builder fastSyncPivotDistance(final int distance) { fastSyncPivotDistance = distance; return this; @@ -519,26 +480,6 @@ public Builder maxTrailingPeers(final int maxTailingPeers) { return this; } - public Builder maxGetBlockHeaders(final int maxGetBlockHeaders) { - this.maxGetBlockHeaders = maxGetBlockHeaders; - return this; - } - - public Builder maxGetBlockBodies(final int maxGetBlockBodies) { - this.maxGetBlockBodies = maxGetBlockBodies; - return this; - } - - public Builder maxGetReceipts(final int maxGetReceipts) { - this.maxGetReceipts = maxGetReceipts; - return this; - } - - public Builder maxGetNodeData(final int maxGetNodeData) { - this.maxGetNodeData = maxGetNodeData; - return this; - } - public SynchronizerConfiguration build() { return new SynchronizerConfiguration( fastSyncPivotDistance, @@ -560,11 +501,7 @@ public SynchronizerConfiguration build() { downloaderParallelism, transactionsParallelism, computationParallelism, - maxTrailingPeers, - maxGetBlockHeaders, - maxGetBlockBodies, - maxGetReceipts, - maxGetNodeData); + maxTrailingPeers); } } } diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java index b995355e68..8124d3db0a 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java @@ -44,14 +44,7 @@ public class EthServerTest { @Test public void shouldRespondToNodeDataRequests() throws Exception { - new EthServer( - blockchain, - worldStateArchive, - ethMessages, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT); + new EthServer(blockchain, worldStateArchive, ethMessages); when(worldStateArchive.getNodeData(HASH1)).thenReturn(Optional.of(VALUE1)); when(worldStateArchive.getNodeData(HASH2)).thenReturn(Optional.of(VALUE2)); ethMessages.dispatch(new EthMessage(ethPeer, GetNodeDataMessage.create(asList(HASH1, HASH2)))); @@ -61,14 +54,7 @@ public void shouldRespondToNodeDataRequests() throws Exception { @Test public void shouldHandleDataBeingUnavailableWhenRespondingToNodeDataRequests() throws Exception { - new EthServer( - blockchain, - worldStateArchive, - ethMessages, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT); + new EthServer(blockchain, worldStateArchive, ethMessages); when(worldStateArchive.getNodeData(HASH1)).thenReturn(Optional.of(VALUE1)); when(worldStateArchive.getNodeData(HASH2)).thenReturn(Optional.empty()); ethMessages.dispatch(new EthMessage(ethPeer, GetNodeDataMessage.create(asList(HASH1, HASH2)))); @@ -78,14 +64,7 @@ public void shouldHandleDataBeingUnavailableWhenRespondingToNodeDataRequests() t @Test public void shouldLimitNumberOfResponsesToNodeDataRequests() throws Exception { - new EthServer( - blockchain, - worldStateArchive, - ethMessages, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT); + new EthServer(blockchain, worldStateArchive, ethMessages); when(worldStateArchive.getNodeData(HASH1)).thenReturn(Optional.of(VALUE1)); when(worldStateArchive.getNodeData(HASH2)).thenReturn(Optional.of(VALUE2)); ethMessages.dispatch( diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/controller/CliquePantheonController.java b/pantheon/src/main/java/tech/pegasys/pantheon/controller/CliquePantheonController.java index 2adf37a5bf..adbd4c3fb3 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/controller/CliquePantheonController.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/controller/CliquePantheonController.java @@ -156,11 +156,7 @@ static PantheonController init( syncConfig.downloaderParallelism(), syncConfig.transactionsParallelism(), syncConfig.computationParallelism(), - metricsSystem, - syncConfig.getMaxGetBlockHeaders(), - syncConfig.getMaxGetBlockBodies(), - syncConfig.getMaxGetReceipts(), - syncConfig.getMaxGetNodeData()); + metricsSystem); final SyncState syncState = new SyncState(blockchain, ethProtocolManager.ethContext().getEthPeers()); final Synchronizer synchronizer = diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftLegacyPantheonController.java b/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftLegacyPantheonController.java index 89b6a31c36..ee95b5791a 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftLegacyPantheonController.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftLegacyPantheonController.java @@ -147,11 +147,7 @@ static PantheonController init( syncConfig.downloaderParallelism(), syncConfig.transactionsParallelism(), syncConfig.computationParallelism(), - metricsSystem, - syncConfig.getMaxGetBlockHeaders(), - syncConfig.getMaxGetBlockBodies(), - syncConfig.getMaxGetReceipts(), - syncConfig.getMaxGetNodeData()); + metricsSystem); final SyncState syncState = new SyncState(blockchain, istanbul64ProtocolManager.ethContext().getEthPeers()); diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftPantheonController.java b/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftPantheonController.java index f6117161cd..30fe91c62d 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftPantheonController.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftPantheonController.java @@ -181,11 +181,7 @@ static PantheonController init( syncConfig.downloaderParallelism(), syncConfig.transactionsParallelism(), syncConfig.computationParallelism(), - metricsSystem, - syncConfig.getMaxGetBlockHeaders(), - syncConfig.getMaxGetBlockBodies(), - syncConfig.getMaxGetReceipts(), - syncConfig.getMaxGetNodeData()); + metricsSystem); final SubProtocol ethSubProtocol = EthProtocol.get(); final EthContext ethContext = ethProtocolManager.ethContext(); diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java b/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java index 6c77a70e63..e86c1e097d 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java @@ -123,11 +123,7 @@ public static PantheonController init( syncConfig.downloaderParallelism(), syncConfig.transactionsParallelism(), syncConfig.computationParallelism(), - metricsSystem, - syncConfig.getMaxGetBlockHeaders(), - syncConfig.getMaxGetBlockBodies(), - syncConfig.getMaxGetReceipts(), - syncConfig.getMaxGetNodeData()); + metricsSystem); final SyncState syncState = new SyncState(blockchain, ethProtocolManager.ethContext().getEthPeers()); final Synchronizer synchronizer = From be500e5cbb917abeeeab1c28ee7061c22b66b65f Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta Date: Mon, 8 Apr 2019 17:25:34 +0200 Subject: [PATCH 09/11] Update EthServerTest.java --- .../ethereum/eth/manager/EthServerTest.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java index 8124d3db0a..2ea4839f34 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java @@ -18,6 +18,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import org.junit.Before; import tech.pegasys.pantheon.ethereum.chain.Blockchain; import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.ethereum.eth.messages.GetNodeDataMessage; @@ -42,9 +43,13 @@ public class EthServerTest { private final EthPeer ethPeer = mock(EthPeer.class); private final EthMessages ethMessages = new EthMessages(); + @Before + public void setUp() { + new EthServer(blockchain, worldStateArchive, ethMessages, 2, 2, 2, 2); + } + @Test public void shouldRespondToNodeDataRequests() throws Exception { - new EthServer(blockchain, worldStateArchive, ethMessages); when(worldStateArchive.getNodeData(HASH1)).thenReturn(Optional.of(VALUE1)); when(worldStateArchive.getNodeData(HASH2)).thenReturn(Optional.of(VALUE2)); ethMessages.dispatch(new EthMessage(ethPeer, GetNodeDataMessage.create(asList(HASH1, HASH2)))); @@ -54,7 +59,6 @@ public void shouldRespondToNodeDataRequests() throws Exception { @Test public void shouldHandleDataBeingUnavailableWhenRespondingToNodeDataRequests() throws Exception { - new EthServer(blockchain, worldStateArchive, ethMessages); when(worldStateArchive.getNodeData(HASH1)).thenReturn(Optional.of(VALUE1)); when(worldStateArchive.getNodeData(HASH2)).thenReturn(Optional.empty()); ethMessages.dispatch(new EthMessage(ethPeer, GetNodeDataMessage.create(asList(HASH1, HASH2)))); @@ -64,7 +68,6 @@ public void shouldHandleDataBeingUnavailableWhenRespondingToNodeDataRequests() t @Test public void shouldLimitNumberOfResponsesToNodeDataRequests() throws Exception { - new EthServer(blockchain, worldStateArchive, ethMessages); when(worldStateArchive.getNodeData(HASH1)).thenReturn(Optional.of(VALUE1)); when(worldStateArchive.getNodeData(HASH2)).thenReturn(Optional.of(VALUE2)); ethMessages.dispatch( @@ -76,14 +79,6 @@ public void shouldLimitNumberOfResponsesToNodeDataRequests() throws Exception { @Test public void shouldLimitTheNumberOfNodeDataResponsesLookedUpNotTheNumberReturned() throws Exception { - new EthServer( - blockchain, - worldStateArchive, - ethMessages, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT, - 1); when(worldStateArchive.getNodeData(HASH1)).thenReturn(Optional.of(VALUE1)); when(worldStateArchive.getNodeData(HASH2)).thenReturn(Optional.empty()); when(worldStateArchive.getNodeData(HASH3)).thenReturn(Optional.of(VALUE3)); From af3f496423de7e2bec73ba5263840144c152a33e Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta Date: Mon, 8 Apr 2019 17:35:19 +0200 Subject: [PATCH 10/11] fix review - spotless - fix clean up review comment --- .../pegasys/pantheon/ethereum/eth/manager/EthServer.java | 4 +--- .../ethereum/eth/manager/EthProtocolManagerTestUtil.java | 8 ++++---- .../pantheon/ethereum/eth/manager/EthServerTest.java | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java index 2ad94954c0..20dbde7fdf 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java @@ -46,9 +46,7 @@ class EthServer { private static final Logger LOG = LogManager.getLogger(); - - static final int DEFAULT_REQUEST_LIMIT = 200; - + public static final int DEFAULT_MAX_GET_BLOCK_HEADERS = 192; public static final int DEFAULT_MAX_GET_BLOCK_BODIES = 128; public static final int DEFAULT_MAX_GET_RECEIPTS = 256; diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java index f552d74f64..15bc4e9582 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java @@ -49,10 +49,10 @@ public static EthProtocolManager create( networkId, false, ethScheduler, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT, - EthServer.DEFAULT_REQUEST_LIMIT); + 200, + 200, + 200, + 200); } public static EthProtocolManager create( diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java index 2ea4839f34..d4218ef36f 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServerTest.java @@ -18,7 +18,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.junit.Before; import tech.pegasys.pantheon.ethereum.chain.Blockchain; import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.ethereum.eth.messages.GetNodeDataMessage; @@ -28,6 +27,7 @@ import java.util.Optional; +import org.junit.Before; import org.junit.Test; public class EthServerTest { From 24e68f0811f719f7708a4f8254efbc8b2e977fcd Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta Date: Mon, 8 Apr 2019 17:48:20 +0200 Subject: [PATCH 11/11] spotlessApply --- .../pantheon/ethereum/eth/manager/EthServer.java | 2 +- .../eth/manager/EthProtocolManagerTestUtil.java | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java index 20dbde7fdf..43ae502e6f 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java @@ -46,7 +46,7 @@ class EthServer { private static final Logger LOG = LogManager.getLogger(); - + public static final int DEFAULT_MAX_GET_BLOCK_HEADERS = 192; public static final int DEFAULT_MAX_GET_BLOCK_BODIES = 128; public static final int DEFAULT_MAX_GET_RECEIPTS = 256; diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java index 15bc4e9582..3481f8961c 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManagerTestUtil.java @@ -44,15 +44,7 @@ public static EthProtocolManager create( final EthScheduler ethScheduler) { final int networkId = 1; return new EthProtocolManager( - blockchain, - worldStateArchive, - networkId, - false, - ethScheduler, - 200, - 200, - 200, - 200); + blockchain, worldStateArchive, networkId, false, ethScheduler, 200, 200, 200, 200); } public static EthProtocolManager create(