From ef7eb6e730b07748294651d8347bb02e50db4163 Mon Sep 17 00:00:00 2001 From: Lisandro Date: Thu, 15 Mar 2018 17:28:32 -0300 Subject: [PATCH] Old blocks that are not requested are ignored if block number is far enough --- .../src/main/java/co/rsk/core/RskFactory.java | 5 +- .../main/java/co/rsk/net/BlockProcessor.java | 2 + .../java/co/rsk/net/BlockSyncService.java | 9 ++ .../java/co/rsk/net/NodeBlockProcessor.java | 5 + .../java/co/rsk/net/NodeMessageHandler.java | 22 ++- .../java/co/rsk/net/BlockSyncServiceTest.java | 10 +- .../co/rsk/net/NodeBlockProcessorTest.java | 129 +++++++++++++----- .../rsk/net/NodeBlockProcessorUnclesTest.java | 4 +- .../co/rsk/net/NodeMessageHandlerTest.java | 20 +-- .../co/rsk/net/NodeMessageHandlerUtil.java | 4 +- .../java/co/rsk/net/OneAsyncNodeTest.java | 2 +- .../java/co/rsk/net/SyncProcessorTest.java | 63 ++++++--- .../java/co/rsk/net/TwoAsyncNodeTest.java | 4 +- .../src/test/java/co/rsk/net/TwoNodeTest.java | 3 +- .../co/rsk/net/simples/SimpleAsyncNode.java | 2 +- .../rsk/net/simples/SimpleBlockProcessor.java | 5 + .../src/test/java/co/rsk/test/World.java | 3 +- 17 files changed, 204 insertions(+), 88 deletions(-) diff --git a/rskj-core/src/main/java/co/rsk/core/RskFactory.java b/rskj-core/src/main/java/co/rsk/core/RskFactory.java index 8796fc7a42f..59ef3623d21 100644 --- a/rskj-core/src/main/java/co/rsk/core/RskFactory.java +++ b/rskj-core/src/main/java/co/rsk/core/RskFactory.java @@ -119,11 +119,12 @@ public SyncProcessor getSyncProcessor(RskSystemProperties config, } @Bean - public BlockSyncService getBlockSyncService(Blockchain blockchain, + public BlockSyncService getBlockSyncService(RskSystemProperties config, + Blockchain blockchain, BlockStore store, BlockNodeInformation nodeInformation, SyncConfiguration syncConfiguration) { - return new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + return new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); } @Bean diff --git a/rskj-core/src/main/java/co/rsk/net/BlockProcessor.java b/rskj-core/src/main/java/co/rsk/net/BlockProcessor.java index da732faa27f..082b8bac18e 100644 --- a/rskj-core/src/main/java/co/rsk/net/BlockProcessor.java +++ b/rskj-core/src/main/java/co/rsk/net/BlockProcessor.java @@ -64,4 +64,6 @@ public interface BlockProcessor { void processBlockHashRequest(MessageChannel sender, long requestId, long height); void processSkeletonRequest(MessageChannel sender, long requestId, long startNumber); + + boolean canBeIgnoredForUnclesRewards(long blockNumber); } diff --git a/rskj-core/src/main/java/co/rsk/net/BlockSyncService.java b/rskj-core/src/main/java/co/rsk/net/BlockSyncService.java index 1b440d26169..5f05ba8df9a 100644 --- a/rskj-core/src/main/java/co/rsk/net/BlockSyncService.java +++ b/rskj-core/src/main/java/co/rsk/net/BlockSyncService.java @@ -18,6 +18,7 @@ package co.rsk.net; +import co.rsk.config.RskSystemProperties; import co.rsk.core.bc.BlockUtils; import co.rsk.crypto.Keccak256; import co.rsk.net.messages.GetBlockMessage; @@ -52,10 +53,12 @@ public class BlockSyncService { private final Blockchain blockchain; private final SyncConfiguration syncConfiguration; private final BlockNodeInformation nodeInformation; // keep tabs on which nodes know which blocks. + private final RskSystemProperties config; // this is tightly coupled with NodeProcessorService and SyncProcessor, // and we should use the same objects everywhere to ensure consistency public BlockSyncService( + @Nonnull final RskSystemProperties config, @Nonnull final BlockStore store, @Nonnull final Blockchain blockchain, @Nonnull final BlockNodeInformation nodeInformation, @@ -65,6 +68,7 @@ public BlockSyncService( this.syncConfiguration = syncConfiguration; this.nodeInformation = nodeInformation; this.unknownBlockHashes = new HashMap<>(); + this.config = config; } public BlockProcessResult processBlock(@Nonnull Block block, MessageChannel sender, boolean ignoreMissingHashes) { @@ -134,6 +138,11 @@ public boolean hasBetterBlockToSync() { return getLastKnownBlockNumber() >= getBestBlockNumber() + blocksDistance; } + public boolean canBeIgnoredForUnclesRewards(long blockNumber) { + int blockDistance = config.getBlockchainConfig().getCommonConstants().getUncleGenerationLimit(); + return blockNumber < getBestBlockNumber() - blockDistance; + } + public long getLastKnownBlockNumber() { return this.lastKnownBlockNumber; } diff --git a/rskj-core/src/main/java/co/rsk/net/NodeBlockProcessor.java b/rskj-core/src/main/java/co/rsk/net/NodeBlockProcessor.java index 968d77427a9..2208bb87510 100644 --- a/rskj-core/src/main/java/co/rsk/net/NodeBlockProcessor.java +++ b/rskj-core/src/main/java/co/rsk/net/NodeBlockProcessor.java @@ -293,6 +293,11 @@ public void processSkeletonRequest(@Nonnull final MessageChannel sender, long re sender.sendMessage(responseMessage); } + @Override + public boolean canBeIgnoredForUnclesRewards(long blockNumber) { + return blockSyncService.canBeIgnoredForUnclesRewards(blockNumber); + } + /** * * @param skeletonBlockNumber a block number that belongs to the skeleton diff --git a/rskj-core/src/main/java/co/rsk/net/NodeMessageHandler.java b/rskj-core/src/main/java/co/rsk/net/NodeMessageHandler.java index e927e45c244..d8cec5a2d4a 100644 --- a/rskj-core/src/main/java/co/rsk/net/NodeMessageHandler.java +++ b/rskj-core/src/main/java/co/rsk/net/NodeMessageHandler.java @@ -308,20 +308,28 @@ private void processBlockMessage(@Nonnull final MessageChannel sender, @Nonnull return; } - boolean wasOrphan = !this.blockProcessor.hasBlockInSomeBlockchain(block.getHash().getBytes()); - BlockProcessResult result = this.blockProcessor.processBlock(sender, block); + if (blockProcessor.canBeIgnoredForUnclesRewards(block.getNumber())){ + logger.trace("Block ignored: too far from best block {} {}", blockNumber, block.getShortHash()); + Metrics.processBlockMessage("blockIgnored", block, sender.getPeerNodeID()); + return; + } - Metrics.processBlockMessage("blockProcessed", block, sender.getPeerNodeID()); + if (blockProcessor.hasBlockInSomeBlockchain(block.getHash().getBytes())){ + logger.trace("Block ignored: it's included in blockchain {} {}", blockNumber, block.getShortHash()); + Metrics.processBlockMessage("blockIgnored", block, sender.getPeerNodeID()); + return; + } + BlockProcessResult result = this.blockProcessor.processBlock(sender, block); + Metrics.processBlockMessage("blockProcessed", block, sender.getPeerNodeID()); + tryRelayBlock(sender, block, result); recordEvent(sender, EventType.VALID_BLOCK); - tryRelayBlock(sender, block, wasOrphan, result); - Metrics.processBlockMessage("finish", block, sender.getPeerNodeID()); } - private void tryRelayBlock(@Nonnull MessageChannel sender, Block block, boolean wasOrphan, BlockProcessResult result) { + private void tryRelayBlock(@Nonnull MessageChannel sender, Block block, BlockProcessResult result) { // is new block and it is not orphan, it is in some blockchain - if (wasOrphan && result.wasBlockAdded(block) && !this.blockProcessor.hasBetterBlockToSync()) { + if (result.wasBlockAdded(block) && !this.blockProcessor.hasBetterBlockToSync()) { relayBlock(sender, block); } } diff --git a/rskj-core/src/test/java/co/rsk/net/BlockSyncServiceTest.java b/rskj-core/src/test/java/co/rsk/net/BlockSyncServiceTest.java index 4f436fbaaa3..8945cdc9cee 100644 --- a/rskj-core/src/test/java/co/rsk/net/BlockSyncServiceTest.java +++ b/rskj-core/src/test/java/co/rsk/net/BlockSyncServiceTest.java @@ -19,6 +19,7 @@ package co.rsk.net; import co.rsk.blockchain.utils.BlockGenerator; +import co.rsk.config.RskSystemProperties; import co.rsk.net.sync.SyncConfiguration; import co.rsk.test.builders.BlockChainBuilder; import org.ethereum.core.Block; @@ -36,7 +37,8 @@ public void sendBlockMessagesAndAddThemToBlockchain() { Blockchain blockchain = BlockChainBuilder.ofSize(10 * i); BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); Assert.assertEquals(10 * i, blockchain.getBestBlock().getNumber()); List extendedChain = new BlockGenerator().getBlockChain(blockchain.getBestBlock(), i); @@ -54,7 +56,8 @@ public void sendBlockMessagesAndAddThemToBlockchainInReverseOrder() { Blockchain blockchain = BlockChainBuilder.ofSize(10 * i); BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); Assert.assertEquals(10 * i, blockchain.getBestBlock().getNumber()); Block initialBestBlock = blockchain.getBestBlock(); @@ -82,7 +85,8 @@ public void sendBlockMessageAndAddItToBlockchainWithCommonAncestors() { Blockchain blockchain = BlockChainBuilder.ofSize(10); BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); Block initialBestBlock = blockchain.getBestBlock(); Assert.assertEquals(10, initialBestBlock.getNumber()); diff --git a/rskj-core/src/test/java/co/rsk/net/NodeBlockProcessorTest.java b/rskj-core/src/test/java/co/rsk/net/NodeBlockProcessorTest.java index ad60d4740b7..00923fe6656 100644 --- a/rskj-core/src/test/java/co/rsk/net/NodeBlockProcessorTest.java +++ b/rskj-core/src/test/java/co/rsk/net/NodeBlockProcessorTest.java @@ -19,6 +19,7 @@ package co.rsk.net; import co.rsk.blockchain.utils.BlockGenerator; +import co.rsk.config.RskSystemProperties; import co.rsk.core.BlockDifficulty; import co.rsk.crypto.Keccak256; import co.rsk.net.messages.*; @@ -53,7 +54,8 @@ public void processBlockSavingInStore() throws UnknownHostException { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); processor.processBlock(sender, orphan); @@ -73,7 +75,8 @@ public void processBlockWithTooMuchHeight() throws UnknownHostException { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); processor.processBlock(sender, orphan); @@ -94,13 +97,34 @@ public void advancedBlock() throws UnknownHostException { final Blockchain blockchain = BlockChainBuilder.ofSize(0); final long advancedBlockNumber = syncConfiguration.getChunkSize() * syncConfiguration.getMaxSkeletonChunks() + blockchain.getBestBlock().getNumber() + 1; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); Assert.assertTrue(processor.isAdvancedBlock(advancedBlockNumber)); Assert.assertFalse(processor.isAdvancedBlock(advancedBlockNumber - 1)); } + @Test + public void canBeIgnoredForUncles() throws UnknownHostException { + final BlockStore store = new BlockStore(); + final MessageChannel sender = new SimpleMessageChannel(); + + final BlockNodeInformation nodeInformation = new BlockNodeInformation(); + final SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; + + final Blockchain blockchain = BlockChainBuilder.ofSize(15); + final RskSystemProperties config = new RskSystemProperties(); + int uncleGenerationLimit = config.getBlockchainConfig().getCommonConstants().getUncleGenerationLimit(); + final long blockNumberThatCanBeIgnored = blockchain.getBestBlock().getNumber() - 1 - uncleGenerationLimit; + + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); + final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); + + Assert.assertTrue(processor.canBeIgnoredForUnclesRewards(blockNumberThatCanBeIgnored)); + Assert.assertFalse(processor.canBeIgnoredForUnclesRewards(blockNumberThatCanBeIgnored + 1)); + } + @Test public void processBlockAddingToBlockchain() { Blockchain blockchain = BlockChainBuilder.ofSize(10); @@ -117,7 +141,8 @@ public void processBlockAddingToBlockchain() { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); processor.processBlock(null, block); @@ -138,7 +163,8 @@ public void processTenBlocksAddingToBlockchain() { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); processor.processBlock(null, genesis); @@ -162,7 +188,8 @@ public void processTwoBlockListsAddingToBlockchain() { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); processor.processBlock(null, genesis); @@ -189,7 +216,8 @@ public void processTwoBlockListsAddingToBlockchainWithFork() { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); processor.processBlock(null, genesis); @@ -211,7 +239,8 @@ public void noSyncingWithEmptyBlockchain() { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); Assert.assertFalse(processor.hasBetterBlockToSync()); @@ -225,7 +254,8 @@ public void noSyncingWithEmptyBlockchainAndLowBestBlock() { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); Assert.assertFalse(processor.hasBetterBlockToSync()); @@ -244,7 +274,8 @@ public void syncingWithEmptyBlockchainAndHighBestBlock() { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); Assert.assertFalse(processor.hasBetterBlockToSync()); @@ -263,7 +294,8 @@ public void syncingThenNoSyncing() { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); Assert.assertFalse(processor.hasBetterBlockToSync()); @@ -297,7 +329,8 @@ public void processTenBlocksGenesisAtLastAddingToBlockchain() { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); for (Block b : blocks) @@ -318,7 +351,8 @@ public void processTenBlocksInverseOrderAddingToBlockchain() { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); for (int k = 0; k < 10; k++) @@ -339,7 +373,8 @@ public void processTenBlocksWithHoleAddingToBlockchain() { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); for (int k = 0; k < 10; k++) @@ -369,7 +404,8 @@ public void processBlockAddingToBlockchainUsingItsParent() { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); processor.processBlock(null, block); @@ -394,7 +430,8 @@ public void processBlockRetrievingParentUsingSender() throws UnknownHostExceptio BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -427,7 +464,8 @@ public void processStatusRetrievingBestBlockUsingSender() throws UnknownHostExce BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -458,7 +496,8 @@ public void processStatusHavingBestBlockInStore() throws UnknownHostException { final Blockchain blockchain = BlockChainBuilder.ofSize(0); BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -480,7 +519,8 @@ public void processStatusHavingBestBlockAsBestBlockInBlockchain() throws Unknown final Blockchain blockchain = BlockChainBuilder.ofSize(2); BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -504,7 +544,8 @@ public void processStatusHavingBestBlockInBlockchainStore() throws UnknownHostEx final Blockchain blockchain = BlockChainBuilder.ofSize(2); BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -533,7 +574,8 @@ public void processGetBlockHeaderMessageUsingBlockInStore() throws UnknownHostEx final Blockchain blockchain = BlockChainBuilder.ofSize(0); BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -560,7 +602,8 @@ public void processGetBlockHeaderMessageUsingEmptyStore() throws UnknownHostExce BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -582,7 +625,8 @@ public void processGetBlockHeaderMessageUsingBlockInBlockchain() throws UnknownH BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -612,7 +656,8 @@ public void processGetBlockMessageUsingBlockInStore() throws UnknownHostExceptio final Blockchain blockchain = BlockChainBuilder.ofSize(0); BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -643,7 +688,8 @@ public void processGetBlockMessageUsingEmptyStore() throws UnknownHostException BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -666,7 +712,8 @@ public void processGetBlockMessageUsingBlockInBlockchain() throws UnknownHostExc BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -700,7 +747,8 @@ public void processBlockRequestMessageUsingBlockInStore() throws UnknownHostExce final Blockchain blockchain = BlockChainBuilder.ofSize(0); BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -731,7 +779,8 @@ public void processBodyRequestMessageUsingBlockInBlockchain() throws UnknownHost final BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -761,7 +810,8 @@ public void processBlockHashRequestMessageUsingEmptyStore() throws UnknownHostEx BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -784,7 +834,8 @@ public void processBlockHashRequestMessageUsingBlockInBlockchain() throws Unknow BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -814,7 +865,8 @@ public void processBlockHashRequestMessageUsingOutOfBoundsHeight() throws Unknow final BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -832,7 +884,8 @@ public void processBlockHeadersRequestMessageUsingBlockInBlockchain() throws Unk BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -863,7 +916,8 @@ public void processBlockHeadersRequestMessageUsingUnknownHash() throws UnknownHo BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -883,7 +937,8 @@ public void processSkeletonRequestWithGenesisPlusBestBlockInSkeleton() throws Un BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -918,7 +973,8 @@ public void processSkeletonRequestWithThreeResults() throws UnknownHostException BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); @@ -955,7 +1011,8 @@ public void processSkeletonRequestNotIncludingGenesis() throws UnknownHostExcept BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); diff --git a/rskj-core/src/test/java/co/rsk/net/NodeBlockProcessorUnclesTest.java b/rskj-core/src/test/java/co/rsk/net/NodeBlockProcessorUnclesTest.java index 94ea780f314..4e5cf47de71 100644 --- a/rskj-core/src/test/java/co/rsk/net/NodeBlockProcessorUnclesTest.java +++ b/rskj-core/src/test/java/co/rsk/net/NodeBlockProcessorUnclesTest.java @@ -19,6 +19,7 @@ package co.rsk.net; import co.rsk.blockchain.utils.BlockGenerator; +import co.rsk.config.RskSystemProperties; import co.rsk.core.bc.BlockChainImpl; import co.rsk.net.simples.SimpleMessageChannel; import co.rsk.net.sync.SyncConfiguration; @@ -149,7 +150,8 @@ private static NodeBlockProcessor createNodeBlockProcessor(BlockChainImpl blockC BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockChain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockChain, nodeInformation, syncConfiguration); NodeBlockProcessor processor = new NodeBlockProcessor(store, blockChain, nodeInformation, blockSyncService, syncConfiguration); return processor; diff --git a/rskj-core/src/test/java/co/rsk/net/NodeMessageHandlerTest.java b/rskj-core/src/test/java/co/rsk/net/NodeMessageHandlerTest.java index 17670e6e7aa..d2de9e9057a 100644 --- a/rskj-core/src/test/java/co/rsk/net/NodeMessageHandlerTest.java +++ b/rskj-core/src/test/java/co/rsk/net/NodeMessageHandlerTest.java @@ -274,7 +274,7 @@ public void processStatusMessageUsingNodeBlockProcessor() throws UnknownHostExce final BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor bp = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); final NodeMessageHandler handler = new NodeMessageHandler(config, bp, null, null, null, null, null, @@ -332,7 +332,7 @@ public void processStatusMessageWithKnownBestBlock() throws UnknownHostException BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor bp = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final SimpleMessageChannel sender = new SimpleMessageChannel(); final SyncProcessor syncProcessor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), RskMockFactory.getChannelManager(), syncConfiguration, new DummyBlockValidationRule(), null); @@ -363,7 +363,7 @@ public void processGetBlockMessageUsingBlockInStore() throws UnknownHostExceptio BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor bp = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final NodeMessageHandler handler = new NodeMessageHandler(config, bp, null, null, null, null, @@ -398,7 +398,7 @@ public void processGetBlockMessageUsingBlockInBlockchain() throws UnknownHostExc BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); NodeBlockProcessor bp = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); NodeMessageHandler handler = new NodeMessageHandler(config, bp, null, null, null, null, @@ -431,7 +431,7 @@ public void processGetBlockMessageUsingEmptyStore() throws UnknownHostException BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor bp = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final NodeMessageHandler handler = new NodeMessageHandler(config, bp, null, null, null, null, null, new DummyBlockValidationRule()); @@ -455,7 +455,7 @@ public void processBlockHeaderRequestMessageUsingBlockInStore() throws UnknownHo BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor bp = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final NodeMessageHandler handler = new NodeMessageHandler(config, bp, null, null, null, null, @@ -491,7 +491,7 @@ public void processBlockHeaderRequestMessageUsingBlockInBlockchain() throws Unkn BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); NodeBlockProcessor bp = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); NodeMessageHandler handler = new NodeMessageHandler(config, bp, null, null, null, null, @@ -528,7 +528,7 @@ public void processNewBlockHashesMessage() throws UnknownHostException { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor bp = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final NodeMessageHandler handler = new NodeMessageHandler(config, bp, null, null, null, null, null, new ProofOfWorkRule(config).setFallbackMiningEnabled(false)); @@ -667,7 +667,7 @@ public void processGetBlockHeadersMessage() throws UnknownHostException { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor bp = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final NodeMessageHandler handler = new NodeMessageHandler(config, bp, null, null, null, null, null, new ProofOfWorkRule(config).setFallbackMiningEnabled(false)); @@ -776,7 +776,7 @@ public void processGetBlockHeaderMessageUsingEmptyStore() throws UnknownHostExce BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); final NodeBlockProcessor bp = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); final NodeMessageHandler handler = new NodeMessageHandler(config, bp, null, null, null, null, null, new DummyBlockValidationRule()); diff --git a/rskj-core/src/test/java/co/rsk/net/NodeMessageHandlerUtil.java b/rskj-core/src/test/java/co/rsk/net/NodeMessageHandlerUtil.java index 46738643733..a9befc37b31 100644 --- a/rskj-core/src/test/java/co/rsk/net/NodeMessageHandlerUtil.java +++ b/rskj-core/src/test/java/co/rsk/net/NodeMessageHandlerUtil.java @@ -30,7 +30,7 @@ public static NodeMessageHandler createHandler(BlockValidationRule validationRul BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); SyncProcessor syncProcessor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), RskMockFactory.getChannelManager(), syncConfiguration, new DummyBlockValidationRule(), DIFFICULTY_CALCULATOR); NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); @@ -62,7 +62,7 @@ public static NodeMessageHandler createHandlerWithSyncProcessor( final BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); ProofOfWorkRule blockValidationRule = new ProofOfWorkRule(config); PeerScoringManager peerScoringManager = mock(PeerScoringManager.class); diff --git a/rskj-core/src/test/java/co/rsk/net/OneAsyncNodeTest.java b/rskj-core/src/test/java/co/rsk/net/OneAsyncNodeTest.java index b0b9f62db8e..10edeafe28d 100644 --- a/rskj-core/src/test/java/co/rsk/net/OneAsyncNodeTest.java +++ b/rskj-core/src/test/java/co/rsk/net/OneAsyncNodeTest.java @@ -48,7 +48,7 @@ private static SimpleAsyncNode createNode() { RskSystemProperties config = new RskSystemProperties(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); SimpleChannelManager channelManager = new SimpleChannelManager(); SyncProcessor syncProcessor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), channelManager, syncConfiguration, new DummyBlockValidationRule(), new DifficultyCalculator(config)); diff --git a/rskj-core/src/test/java/co/rsk/net/SyncProcessorTest.java b/rskj-core/src/test/java/co/rsk/net/SyncProcessorTest.java index f2ab8fd57ee..dc1cb849d0e 100644 --- a/rskj-core/src/test/java/co/rsk/net/SyncProcessorTest.java +++ b/rskj-core/src/test/java/co/rsk/net/SyncProcessorTest.java @@ -50,7 +50,8 @@ public void noPeers() { final BlockStore store = new BlockStore(); Blockchain blockchain = BlockChainBuilder.ofSize(0); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, getPeerScoringManager(), getChannelManager(), SyncConfiguration.IMMEDIATE_FOR_TESTING, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); @@ -70,7 +71,8 @@ public void processStatusWithAdvancedPeers() { Status status = new Status(100, hash, parentHash, blockchain.getTotalDifficulty().add(new BlockDifficulty(BigInteger.TEN))); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SimpleMessageChannel sender = new SimpleMessageChannel(new byte[]{0x01}); final ChannelManager channelManager = mock(ChannelManager.class); @@ -116,7 +118,8 @@ public void syncWithAdvancedPeerAfterTimeoutWaitingPeers() { Status status = new Status(100, hash, parentHash, blockchain.getTotalDifficulty().add(new BlockDifficulty(BigInteger.TEN))); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SyncConfiguration syncConfiguration = SyncConfiguration.DEFAULT; SimpleMessageChannel sender = new SimpleMessageChannel(new byte[]{0x01}); @@ -168,7 +171,8 @@ public void dontSyncWithoutAdvancedPeerAfterTimeoutWaitingPeers() { Status status = new Status(0, hash, parentHash, blockchain.getTotalDifficulty()); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), SyncConfiguration.DEFAULT, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); @@ -200,7 +204,8 @@ public void syncWithAdvancedStatusAnd5Peers() { Status status = new Status(100, hash, parentHash, blockchain.getTotalDifficulty().add(new BlockDifficulty(BigInteger.TEN))); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); final ChannelManager channelManager = mock(ChannelManager.class); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), channelManager, @@ -272,7 +277,8 @@ public void processStatusWithPeerWithSameDifficulty() { Status status = new Status(blockchain.getStatus().getBestBlockNumber(), hash, parentHash, blockchain.getStatus().getTotalDifficulty()); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), SyncConfiguration.IMMEDIATE_FOR_TESTING, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); @@ -373,7 +379,8 @@ public void processBlockHeadersResponseWithEmptyList() { Blockchain blockchain = BlockChainBuilder.ofSize(0); SimpleMessageChannel sender = new SimpleMessageChannel(new byte[] { 0x01 }); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(new BlockStore(), blockchain, new BlockNodeInformation(), syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, new BlockStore(), blockchain, new BlockNodeInformation(), syncConfiguration); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), syncConfiguration, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); @@ -394,7 +401,8 @@ public void processBlockHeadersResponseRejectsNonSolicitedMessages() { SimpleMessageChannel sender = new SimpleMessageChannel(new byte[] { 0x01 }); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(new BlockStore(), blockchain, new BlockNodeInformation(), syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, new BlockStore(), blockchain, new BlockNodeInformation(), syncConfiguration); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), syncConfiguration, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); processor.setSelectedPeer(sender, StatusUtils.getFakeStatus(), 0); @@ -416,7 +424,8 @@ public void processBlockHeadersResponseWithManyHeadersMissingFirstParent() { SimpleMessageChannel sender = new SimpleMessageChannel(new byte[] { 0x01 }); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(new BlockStore(), blockchain, new BlockNodeInformation(), syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, new BlockStore(), blockchain, new BlockNodeInformation(), syncConfiguration); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), syncConfiguration, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); processor.setSelectedPeer(sender, StatusUtils.getFakeStatus(), 0); @@ -441,7 +450,8 @@ public void processBlockHeadersResponseWithOneExistingHeader() { SimpleMessageChannel sender = new SimpleMessageChannel(new byte[] { 0x01 }); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(new BlockStore(), blockchain, new BlockNodeInformation(), syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, new BlockStore(), blockchain, new BlockNodeInformation(), syncConfiguration); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), syncConfiguration, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); processor.setSelectedPeer(sender, StatusUtils.getFakeStatus(), 0); @@ -462,7 +472,8 @@ public void processBodyResponseRejectsNonSolicitedMessages() { SimpleMessageChannel sender = new SimpleMessageChannel(new byte[] { 0x01 }); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(new BlockStore(), blockchain, new BlockNodeInformation(), syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, new BlockStore(), blockchain, new BlockNodeInformation(), syncConfiguration); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), syncConfiguration, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); processor.setSelectedPeer(sender, StatusUtils.getFakeStatus(), 0); @@ -489,7 +500,8 @@ public void processBodyResponseAddsToBlockchain() { Assert.assertArrayEquals(blockchain.getBestBlockHash(), block.getParentHash().getBytes()); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), SyncConfiguration.IMMEDIATE_FOR_TESTING, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); @@ -533,7 +545,8 @@ public void doesntProcessInvalidBodyResponse() { Assert.assertArrayEquals(blockchain.getBestBlockHash(), block.getParentHash().getBytes()); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), SyncConfiguration.IMMEDIATE_FOR_TESTING, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); @@ -588,7 +601,8 @@ public void doesntProcessUnexpectedBodyResponse() { Assert.assertArrayEquals(blockchain.getBestBlockHash(), block.getParentHash().getBytes()); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), SyncConfiguration.IMMEDIATE_FOR_TESTING, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); @@ -657,7 +671,8 @@ public void processBodyResponseWithTransactionAddsToBlockchain() { Assert.assertArrayEquals(blockchain.getBestBlockHash(), block.getParentHash().getBytes()); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), SyncConfiguration.IMMEDIATE_FOR_TESTING, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); @@ -701,7 +716,8 @@ public void processBlockResponseAddsToBlockchain() { Assert.assertArrayEquals(blockchain.getBestBlockHash(), block.getParentHash().getBytes()); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), SyncConfiguration.IMMEDIATE_FOR_TESTING, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); @@ -734,7 +750,8 @@ public void findConnectionPointBlockchainWithGenesisVsBlockchainWith100Blocks() BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), channelManager, SyncConfiguration.IMMEDIATE_FOR_TESTING, new DummyBlockValidationRule(), DIFFICULTY_CALCULATOR); @@ -788,7 +805,8 @@ public void findConnectionPointBlockchainWith30BlocksVsBlockchainWith100Blocks() BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), channelManager, SyncConfiguration.IMMEDIATE_FOR_TESTING, new DummyBlockValidationRule(), DIFFICULTY_CALCULATOR); @@ -829,7 +847,8 @@ public void processSkeletonResponseWithTenBlockIdentifiers() { final BlockStore store = new BlockStore(); Blockchain blockchain = BlockChainBuilder.ofSize(0); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SimpleMessageChannel sender = new SimpleMessageChannel(new byte[] { 0x01 }); final ChannelManager channelManager = mock(ChannelManager.class); @@ -879,7 +898,8 @@ public void processSkeletonResponseWithoutBlockIdentifiers() { SimpleMessageChannel sender = new SimpleMessageChannel(new byte[] { 0x01 }); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(new BlockStore(), blockchain, new BlockNodeInformation(), syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, new BlockStore(), blockchain, new BlockNodeInformation(), syncConfiguration); SyncProcessor processor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), getChannelManager(), syncConfiguration, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), DIFFICULTY_CALCULATOR); processor.setSelectedPeer(sender, StatusUtils.getFakeStatus(), 0); @@ -901,7 +921,8 @@ public void processSkeletonResponseWithConnectionPoint() { final BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING); SimpleMessageChannel sender = new SimpleMessageChannel(new byte[] { 0x01 }); final ChannelManager channelManager = mock(ChannelManager.class); diff --git a/rskj-core/src/test/java/co/rsk/net/TwoAsyncNodeTest.java b/rskj-core/src/test/java/co/rsk/net/TwoAsyncNodeTest.java index a08e1afe300..30017c3e7ff 100644 --- a/rskj-core/src/test/java/co/rsk/net/TwoAsyncNodeTest.java +++ b/rskj-core/src/test/java/co/rsk/net/TwoAsyncNodeTest.java @@ -52,7 +52,7 @@ private static SimpleAsyncNode createNode(int size) { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); NodeMessageHandler handler = new NodeMessageHandler(config, processor, null, null, null, null, null, new DummyBlockValidationRule()); @@ -71,7 +71,7 @@ private static SimpleAsyncNode createNodeWithUncles(int size) { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); NodeMessageHandler handler = new NodeMessageHandler(config, processor, null, null, null, null, null, new DummyBlockValidationRule()); diff --git a/rskj-core/src/test/java/co/rsk/net/TwoNodeTest.java b/rskj-core/src/test/java/co/rsk/net/TwoNodeTest.java index e72935ea29a..51d970a4120 100644 --- a/rskj-core/src/test/java/co/rsk/net/TwoNodeTest.java +++ b/rskj-core/src/test/java/co/rsk/net/TwoNodeTest.java @@ -49,7 +49,8 @@ private static SimpleNode createNode(int size) { BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); NodeMessageHandler handler = new NodeMessageHandler(new RskSystemProperties(), processor, null, null, null, null, null, new DummyBlockValidationRule()); diff --git a/rskj-core/src/test/java/co/rsk/net/simples/SimpleAsyncNode.java b/rskj-core/src/test/java/co/rsk/net/simples/SimpleAsyncNode.java index 59e196df4f6..e3de4e47f17 100644 --- a/rskj-core/src/test/java/co/rsk/net/simples/SimpleAsyncNode.java +++ b/rskj-core/src/test/java/co/rsk/net/simples/SimpleAsyncNode.java @@ -111,7 +111,7 @@ public static SimpleAsyncNode createNode(Blockchain blockchain, SyncConfiguratio final BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); - BlockSyncService blockSyncService = new BlockSyncService(store, blockchain, nodeInformation, syncConfiguration); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration); NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration); DummyBlockValidationRule blockValidationRule = new DummyBlockValidationRule(); PeerScoringManager peerScoringManager = RskMockFactory.getPeerScoringManager(); diff --git a/rskj-core/src/test/java/co/rsk/net/simples/SimpleBlockProcessor.java b/rskj-core/src/test/java/co/rsk/net/simples/SimpleBlockProcessor.java index 20744d53a96..74e7aaee13e 100644 --- a/rskj-core/src/test/java/co/rsk/net/simples/SimpleBlockProcessor.java +++ b/rskj-core/src/test/java/co/rsk/net/simples/SimpleBlockProcessor.java @@ -122,6 +122,11 @@ public void processSkeletonRequest(final MessageChannel sender, long requestId, } + @Override + public boolean canBeIgnoredForUnclesRewards(long blockNumber) { + return false; + } + @Override public boolean hasBlock(byte[] hash) { return false; diff --git a/rskj-core/src/test/java/co/rsk/test/World.java b/rskj-core/src/test/java/co/rsk/test/World.java index f3c60234395..445b2115dbc 100644 --- a/rskj-core/src/test/java/co/rsk/test/World.java +++ b/rskj-core/src/test/java/co/rsk/test/World.java @@ -69,7 +69,8 @@ public World(BlockChainImpl blockChain, Genesis genesis) { BlockStore store = new BlockStore(); BlockNodeInformation nodeInformation = new BlockNodeInformation(); SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING; - BlockSyncService blockSyncService = new BlockSyncService(store, blockChain, nodeInformation, syncConfiguration); + RskSystemProperties config = new RskSystemProperties(); + BlockSyncService blockSyncService = new BlockSyncService(config, store, blockChain, nodeInformation, syncConfiguration); this.blockProcessor = new NodeBlockProcessor(store, blockChain, nodeInformation, blockSyncService, syncConfiguration); }