From 3569b0de784439403a8fbdddf00dc5a59090dc87 Mon Sep 17 00:00:00 2001 From: tmohay <37158202+rain-on@users.noreply.github.com> Date: Fri, 26 Oct 2018 16:51:59 +1100 Subject: [PATCH] Add MiningCoordinator interface (#168) --- .../dsl/node/ThreadPantheonNodeRunner.java | 2 +- .../AbstractMiningCoordinator.java | 13 ++++- .../blockcreation/MiningCoordinator.java | 47 +++++++++++++++++++ .../jsonrpc/JsonRpcMethodsFactory.java | 14 +++--- .../jsonrpc/internal/methods/EthCoinbase.java | 6 +-- .../jsonrpc/internal/methods/EthGasPrice.java | 11 ++--- .../jsonrpc/internal/methods/EthGetWork.java | 6 +-- .../jsonrpc/internal/methods/EthMining.java | 11 ++--- .../methods/miner/MinerSetCoinbase.java | 6 +-- .../internal/methods/miner/MinerStart.java | 11 ++--- .../internal/methods/miner/MinerStop.java | 11 ++--- .../internal/methods/EthCoinbaseTest.java | 4 +- .../internal/methods/EthGasPriceTest.java | 5 +- .../internal/methods/EthMiningTest.java | 5 +- .../methods/miner/MinerSetCoinbaseTest.java | 4 +- .../methods/miner/MinerStartTest.java | 5 +- .../internal/methods/miner/MinerStopTest.java | 5 +- .../java/tech/pegasys/pantheon/Runner.java | 4 +- .../tech/pegasys/pantheon/RunnerBuilder.java | 11 ++--- .../cli/ExportPublicKeySubCommand.java | 2 +- .../pegasys/pantheon/cli/PantheonCommand.java | 4 +- .../cli/PantheonControllerBuilder.java | 2 +- .../controller/CliquePantheonController.java | 14 +++--- .../controller/IbftPantheonController.java | 9 ++-- .../controller/MainnetPantheonController.java | 15 +++--- .../controller/PantheonController.java | 11 ++--- .../pegasys/pantheon/util/BlockImporter.java | 2 +- .../pantheon/util/BlockchainImporter.java | 46 ++++++++---------- .../tech/pegasys/pantheon/RunnerTest.java | 7 ++- .../pantheon/cli/CommandTestAbstract.java | 2 +- .../pantheon/util/BlockImporterTest.java | 2 +- .../pantheon/util/BlockchainImporterTest.java | 3 +- 32 files changed, 163 insertions(+), 137 deletions(-) create mode 100644 ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/MiningCoordinator.java diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java index f1b79285f7..844a517054 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java @@ -50,7 +50,7 @@ public class ThreadPantheonNodeRunner implements PantheonNodeRunner { final PantheonControllerBuilder builder = new PantheonControllerBuilder(); final EthNetworkConfig ethNetworkConfig = new EthNetworkConfig.Builder(mainnet()).setNetworkId(NETWORK_ID).build(); - final PantheonController pantheonController; + final PantheonController pantheonController; try { pantheonController = builder.build( diff --git a/ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/AbstractMiningCoordinator.java b/ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/AbstractMiningCoordinator.java index b1029f2bfd..b0eb03cdc1 100644 --- a/ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/AbstractMiningCoordinator.java +++ b/ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/AbstractMiningCoordinator.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.Logger; public abstract class AbstractMiningCoordinator< C, M extends BlockMiner>> - implements BlockAddedObserver { + implements BlockAddedObserver, MiningCoordinator { private static final Logger LOG = getLogger(); protected boolean isEnabled = false; protected volatile Optional currentRunningMiner = Optional.empty(); @@ -54,6 +54,7 @@ public abstract class AbstractMiningCoordinator< syncState.addInSyncListener(this::inSyncChanged); } + @Override public void enable() { synchronized (this) { if (isEnabled) { @@ -66,6 +67,7 @@ public abstract class AbstractMiningCoordinator< } } + @Override public void disable() { synchronized (this) { if (!isEnabled) { @@ -76,6 +78,7 @@ public abstract class AbstractMiningCoordinator< } } + @Override public boolean isRunning() { synchronized (this) { return currentRunningMiner.isPresent(); @@ -121,38 +124,46 @@ public abstract class AbstractMiningCoordinator< } // Required for JSON RPC, and are deemed to be valid for all mining mechanisms + @Override public void setMinTransactionGasPrice(final Wei minGasPrice) { executor.setMinTransactionGasPrice(minGasPrice); } + @Override public Wei getMinTransactionGasPrice() { return executor.getMinTransactionGasPrice(); } + @Override public void setExtraData(final BytesValue extraData) { executor.setExtraData(extraData); } + @Override public void setCoinbase(final Address coinbase) { throw new UnsupportedOperationException( "Current consensus mechanism prevents setting coinbase."); } + @Override public Optional
getCoinbase() { throw new UnsupportedOperationException( "Current consensus mechanism prevents querying of coinbase."); } + @Override public Optional hashesPerSecond() { throw new UnsupportedOperationException( "Current consensus mechanism prevents querying of hashrate."); } + @Override public Optional getWorkDefinition() { throw new UnsupportedOperationException( "Current consensus mechanism prevents querying work definition."); } + @Override public boolean submitWork(final EthHashSolution solution) { throw new UnsupportedOperationException( "Current consensus mechanism prevents submission of work solutions."); diff --git a/ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/MiningCoordinator.java b/ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/MiningCoordinator.java new file mode 100644 index 0000000000..8c88e4307c --- /dev/null +++ b/ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/MiningCoordinator.java @@ -0,0 +1,47 @@ +/* + * Copyright 2018 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.blockcreation; + +import tech.pegasys.pantheon.ethereum.core.Address; +import tech.pegasys.pantheon.ethereum.core.Wei; +import tech.pegasys.pantheon.ethereum.mainnet.EthHashSolution; +import tech.pegasys.pantheon.ethereum.mainnet.EthHashSolverInputs; +import tech.pegasys.pantheon.util.bytes.BytesValue; + +import java.util.Optional; + +public interface MiningCoordinator { + + void enable(); + + void disable(); + + boolean isRunning(); + + // Required for JSON RPC, and are deemed to be valid for all mining mechanisms + void setMinTransactionGasPrice(Wei minGasPrice); + + Wei getMinTransactionGasPrice(); + + void setExtraData(BytesValue extraData); + + void setCoinbase(Address coinbase); + + Optional
getCoinbase(); + + Optional hashesPerSecond(); + + Optional getWorkDefinition(); + + boolean submitWork(EthHashSolution solution); +} diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java index c74a27072c..c2e9031ac6 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.ethereum.jsonrpc; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.chain.Blockchain; import tech.pegasys.pantheon.ethereum.core.Synchronizer; import tech.pegasys.pantheon.ethereum.core.TransactionPool; @@ -94,7 +94,7 @@ public class JsonRpcMethodsFactory { final Synchronizer synchronizer, final TransactionPool transactionPool, final ProtocolSchedule protocolSchedule, - final AbstractMiningCoordinator miningCoordinator, + final MiningCoordinator miningCoordinator, final Set supportedCapabilities, final Collection rpcApis, final FilterManager filterManager) { @@ -123,7 +123,7 @@ public class JsonRpcMethodsFactory { final ProtocolSchedule protocolSchedule, final FilterManager filterManager, final TransactionPool transactionPool, - final AbstractMiningCoordinator miningCoordinator, + final MiningCoordinator miningCoordinator, final Set supportedCapabilities, final Collection rpcApis) { final Map enabledMethods = new HashMap<>(); @@ -174,10 +174,10 @@ public class JsonRpcMethodsFactory { blockchainQueries.getWorldStateArchive(), protocolSchedule), parameter), - new EthMining<>(miningCoordinator), + new EthMining(miningCoordinator), new EthCoinbase(miningCoordinator), new EthProtocolVersion(supportedCapabilities), - new EthGasPrice<>(miningCoordinator), + new EthGasPrice(miningCoordinator), new EthGetWork(miningCoordinator)); } if (rpcApis.contains(RpcApis.DEBUG)) { @@ -207,8 +207,8 @@ public class JsonRpcMethodsFactory { final MinerSetCoinbase minerSetCoinbase = new MinerSetCoinbase(miningCoordinator, parameter); addMethods( enabledMethods, - new MinerStart<>(miningCoordinator), - new MinerStop<>(miningCoordinator), + new MinerStart(miningCoordinator), + new MinerStop(miningCoordinator), minerSetCoinbase, new MinerSetEtherbase(minerSetCoinbase)); } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbase.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbase.java index 070efc28a1..465e17e222 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbase.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbase.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; @@ -24,9 +24,9 @@ import java.util.Optional; public class EthCoinbase implements JsonRpcMethod { - private final AbstractMiningCoordinator miningCoordinator; + private final MiningCoordinator miningCoordinator; - public EthCoinbase(final AbstractMiningCoordinator miningCoordinator) { + public EthCoinbase(final MiningCoordinator miningCoordinator) { this.miningCoordinator = miningCoordinator; } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPrice.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPrice.java index f15be34146..7667d1120a 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPrice.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPrice.java @@ -12,21 +12,18 @@ */ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractBlockCreator; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; -import tech.pegasys.pantheon.ethereum.blockcreation.BlockMiner; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.core.Wei; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.results.Quantity; -public class EthGasPrice>> - implements JsonRpcMethod { +public class EthGasPrice implements JsonRpcMethod { - private final AbstractMiningCoordinator miningCoordinator; + private final MiningCoordinator miningCoordinator; - public EthGasPrice(final AbstractMiningCoordinator miningCoordinator) { + public EthGasPrice(final MiningCoordinator miningCoordinator) { this.miningCoordinator = miningCoordinator; } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGetWork.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGetWork.java index 4f525e0bef..a719a98379 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGetWork.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGetWork.java @@ -14,7 +14,7 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods; import static org.apache.logging.log4j.LogManager.getLogger; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; @@ -30,10 +30,10 @@ import org.apache.logging.log4j.Logger; public class EthGetWork implements JsonRpcMethod { - private final AbstractMiningCoordinator miner; + private final MiningCoordinator miner; private static final Logger LOG = getLogger(); - public EthGetWork(final AbstractMiningCoordinator miner) { + public EthGetWork(final MiningCoordinator miner) { this.miner = miner; } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthMining.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthMining.java index 2b2c22a563..f3fdbe7089 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthMining.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthMining.java @@ -12,19 +12,16 @@ */ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractBlockCreator; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; -import tech.pegasys.pantheon.ethereum.blockcreation.BlockMiner; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -public class EthMining>> - implements JsonRpcMethod { +public class EthMining implements JsonRpcMethod { - private final AbstractMiningCoordinator miningCoordinator; + private final MiningCoordinator miningCoordinator; - public EthMining(final AbstractMiningCoordinator miningCoordinator) { + public EthMining(final MiningCoordinator miningCoordinator) { this.miningCoordinator = miningCoordinator; } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbase.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbase.java index 3d3056be89..6782683c03 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbase.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbase.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.miner; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod; @@ -24,11 +24,11 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessRe public class MinerSetCoinbase implements JsonRpcMethod { - private final AbstractMiningCoordinator miningCoordinator; + private final MiningCoordinator miningCoordinator; private final JsonRpcParameter parameters; public MinerSetCoinbase( - final AbstractMiningCoordinator miningCoordinator, final JsonRpcParameter parameters) { + final MiningCoordinator miningCoordinator, final JsonRpcParameter parameters) { this.miningCoordinator = miningCoordinator; this.parameters = parameters; } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStart.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStart.java index 3c44046062..2d3031a930 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStart.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStart.java @@ -12,10 +12,8 @@ */ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.miner; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractBlockCreator; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; -import tech.pegasys.pantheon.ethereum.blockcreation.BlockMiner; import tech.pegasys.pantheon.ethereum.blockcreation.CoinbaseNotSetException; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; @@ -23,12 +21,11 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResp import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -public class MinerStart>> - implements JsonRpcMethod { +public class MinerStart implements JsonRpcMethod { - private final AbstractMiningCoordinator miningCoordinator; + private final MiningCoordinator miningCoordinator; - public MinerStart(final AbstractMiningCoordinator miningCoordinator) { + public MinerStart(final MiningCoordinator miningCoordinator) { this.miningCoordinator = miningCoordinator; } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStop.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStop.java index cefe6392c2..f984ec84a9 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStop.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStop.java @@ -12,20 +12,17 @@ */ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.miner; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractBlockCreator; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; -import tech.pegasys.pantheon.ethereum.blockcreation.BlockMiner; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -public class MinerStop>> - implements JsonRpcMethod { +public class MinerStop implements JsonRpcMethod { - private final AbstractMiningCoordinator miningCoordinator; + private final MiningCoordinator miningCoordinator; - public MinerStop(final AbstractMiningCoordinator miningCoordinator) { + public MinerStop(final MiningCoordinator miningCoordinator) { this.miningCoordinator = miningCoordinator; } diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbaseTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbaseTest.java index 99f2612adc..457c6dc916 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbaseTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbaseTest.java @@ -17,7 +17,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; @@ -36,7 +36,7 @@ import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class EthCoinbaseTest { - @Mock private AbstractMiningCoordinator miningCoordinator; + @Mock private MiningCoordinator miningCoordinator; private EthCoinbase method; private final String JSON_RPC_VERSION = "2.0"; private final String ETH_METHOD = "eth_coinbase"; diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPriceTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPriceTest.java index 5d09e6c61e..70cbacac4d 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPriceTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPriceTest.java @@ -17,7 +17,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import tech.pegasys.pantheon.ethereum.blockcreation.EthHashBlockMiner; import tech.pegasys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import tech.pegasys.pantheon.ethereum.core.Wei; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; @@ -34,13 +33,13 @@ import org.mockito.junit.MockitoJUnitRunner; public class EthGasPriceTest { @Mock private EthHashMiningCoordinator miningCoordinator; - private EthGasPrice method; + private EthGasPrice method; private final String JSON_RPC_VERSION = "2.0"; private final String ETH_METHOD = "eth_gasPrice"; @Before public void setUp() { - method = new EthGasPrice<>(miningCoordinator); + method = new EthGasPrice(miningCoordinator); } @Test diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthMiningTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthMiningTest.java index f2348d26c8..140628722b 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthMiningTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthMiningTest.java @@ -17,7 +17,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import tech.pegasys.pantheon.ethereum.blockcreation.EthHashBlockMiner; import tech.pegasys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; @@ -33,13 +32,13 @@ import org.mockito.junit.MockitoJUnitRunner; public class EthMiningTest { @Mock private EthHashMiningCoordinator miningCoordinator; - private EthMining method; + private EthMining method; private final String JSON_RPC_VERSION = "2.0"; private final String ETH_METHOD = "eth_mining"; @Before public void setUp() { - method = new EthMining<>(miningCoordinator); + method = new EthMining(miningCoordinator); } @Test diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbaseTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbaseTest.java index d7b3903f58..cbe4e1183f 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbaseTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbaseTest.java @@ -19,7 +19,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.verify; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.exception.InvalidJsonRpcParameters; @@ -40,7 +40,7 @@ public class MinerSetCoinbaseTest { private MinerSetCoinbase method; - @Mock private AbstractMiningCoordinator miningCoordinator; + @Mock private MiningCoordinator miningCoordinator; @Before public void before() { diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStartTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStartTest.java index 7d815659c1..9f08f05dbe 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStartTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStartTest.java @@ -16,7 +16,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doThrow; import tech.pegasys.pantheon.ethereum.blockcreation.CoinbaseNotSetException; -import tech.pegasys.pantheon.ethereum.blockcreation.EthHashBlockMiner; import tech.pegasys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; @@ -33,13 +32,13 @@ import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class MinerStartTest { - private MinerStart method; + private MinerStart method; @Mock private EthHashMiningCoordinator miningCoordinator; @Before public void before() { - method = new MinerStart<>(miningCoordinator); + method = new MinerStart(miningCoordinator); } @Test diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStopTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStopTest.java index 0dc769fd81..51a302df03 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStopTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStopTest.java @@ -14,7 +14,6 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.miner; import static org.assertj.core.api.Assertions.assertThat; -import tech.pegasys.pantheon.ethereum.blockcreation.EthHashBlockMiner; import tech.pegasys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; @@ -29,13 +28,13 @@ import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class MinerStopTest { - private MinerStop method; + private MinerStop method; @Mock private EthHashMiningCoordinator miningCoordinator; @Before public void before() { - method = new MinerStop<>(miningCoordinator); + method = new MinerStop(miningCoordinator); } @Test diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/Runner.java b/pantheon/src/main/java/tech/pegasys/pantheon/Runner.java index ec47b5ec38..fde1acb538 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/Runner.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/Runner.java @@ -45,7 +45,7 @@ public class Runner implements AutoCloseable { private final Optional jsonRpc; private final Optional websocketRpc; - private final PantheonController pantheonController; + private final PantheonController pantheonController; private final Path dataDir; Runner( @@ -53,7 +53,7 @@ public class Runner implements AutoCloseable { final NetworkRunner networkRunner, final Optional jsonRpc, final Optional websocketRpc, - final PantheonController pantheonController, + final PantheonController pantheonController, final Path dataDir) { this.vertx = vertx; this.networkRunner = networkRunner; diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java b/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java index 4fb2bfc222..b81ede3c6e 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java @@ -19,7 +19,7 @@ import tech.pegasys.pantheon.consensus.ibft.jsonrpc.IbftJsonRpcMethodsFactory; import tech.pegasys.pantheon.controller.PantheonController; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.ethereum.ProtocolContext; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.chain.Blockchain; import tech.pegasys.pantheon.ethereum.core.Synchronizer; import tech.pegasys.pantheon.ethereum.core.TransactionPool; @@ -70,7 +70,7 @@ public class RunnerBuilder { public Runner build( final Vertx vertx, - final PantheonController pantheonController, + final PantheonController pantheonController, final boolean discovery, final Collection bootstrapPeers, final String discoveryHost, @@ -139,8 +139,7 @@ public class RunnerBuilder { final Synchronizer synchronizer = pantheonController.getSynchronizer(); final TransactionPool transactionPool = pantheonController.getTransactionPool(); - final AbstractMiningCoordinator miningCoordinator = - pantheonController.getMiningCoordinator(); + final MiningCoordinator miningCoordinator = pantheonController.getMiningCoordinator(); final FilterManager filterManager = createFilterManager(vertx, context, transactionPool); @@ -213,11 +212,11 @@ public class RunnerBuilder { private Map jsonRpcMethods( final ProtocolContext context, final ProtocolSchedule protocolSchedule, - final PantheonController pantheonController, + final PantheonController pantheonController, final NetworkRunner networkRunner, final Synchronizer synchronizer, final TransactionPool transactionPool, - final AbstractMiningCoordinator miningCoordinator, + final MiningCoordinator miningCoordinator, final Set supportedCapabilities, final Collection jsonRpcApis, final FilterManager filterManager) { diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/ExportPublicKeySubCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/ExportPublicKeySubCommand.java index a26059dc9f..9329875eda 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/ExportPublicKeySubCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/ExportPublicKeySubCommand.java @@ -51,7 +51,7 @@ class ExportPublicKeySubCommand implements Runnable { @Override public void run() { - final PantheonController controller = parentCommand.buildController(); + final PantheonController controller = parentCommand.buildController(); final KeyPair keyPair = controller.getLocalNodeKeyPair(); // this publicKeyExportFile can never be null because of Picocli arity requirement diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java index e76bfa8d2a..3c5f7dd69a 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java @@ -421,7 +421,7 @@ public class PantheonCommand implements Runnable { webSocketConfiguration()); } - PantheonController buildController() { + PantheonController buildController() { try { return controllerBuilder.build( buildSyncConfig(syncMode), @@ -465,7 +465,7 @@ public class PantheonCommand implements Runnable { // Blockchain synchronisation from peers. private void synchronize( - final PantheonController controller, + final PantheonController controller, final boolean noPeerDiscovery, final Collection bootstrapNodes, final int maxPeers, diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonControllerBuilder.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonControllerBuilder.java index ea81a01bc3..d4c56ff1c0 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonControllerBuilder.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonControllerBuilder.java @@ -29,7 +29,7 @@ import com.google.common.io.Resources; public class PantheonControllerBuilder { - public PantheonController build( + public PantheonController build( final SynchronizerConfiguration synchronizerConfiguration, final Path homePath, final EthNetworkConfig ethNetworkConfig, 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 bd385fb38c..baccca9fe6 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/controller/CliquePantheonController.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/controller/CliquePantheonController.java @@ -17,7 +17,6 @@ import static org.apache.logging.log4j.LogManager.getLogger; import tech.pegasys.pantheon.consensus.clique.CliqueContext; import tech.pegasys.pantheon.consensus.clique.CliqueVoteTallyUpdater; import tech.pegasys.pantheon.consensus.clique.VoteTallyCache; -import tech.pegasys.pantheon.consensus.clique.blockcreation.CliqueBlockMiner; import tech.pegasys.pantheon.consensus.clique.blockcreation.CliqueBlockScheduler; import tech.pegasys.pantheon.consensus.clique.blockcreation.CliqueMinerExecutor; import tech.pegasys.pantheon.consensus.clique.blockcreation.CliqueMiningCoordinator; @@ -25,7 +24,7 @@ import tech.pegasys.pantheon.consensus.common.EpochManager; import tech.pegasys.pantheon.consensus.common.VoteProposer; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.ethereum.ProtocolContext; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.chain.GenesisConfig; import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain; import tech.pegasys.pantheon.ethereum.core.BlockHashFunction; @@ -61,8 +60,7 @@ import java.util.concurrent.TimeUnit; import io.vertx.core.json.JsonObject; import org.apache.logging.log4j.Logger; -public class CliquePantheonController - implements PantheonController { +public class CliquePantheonController implements PantheonController { public static int RINKEBY_NETWORK_ID = 4; private static final Logger LOG = getLogger(); private final GenesisConfig genesisConfig; @@ -75,7 +73,7 @@ public class CliquePantheonController private static final long EPOCH_LENGTH_DEFAULT = 30_000L; private static final long SECONDS_BETWEEN_BLOCKS_DEFAULT = 15L; - private final CliqueMiningCoordinator miningCoordinator; + private final MiningCoordinator miningCoordinator; CliquePantheonController( final GenesisConfig genesisConfig, @@ -84,7 +82,7 @@ public class CliquePantheonController final Synchronizer synchronizer, final KeyPair keyPair, final TransactionPool transactionPool, - final CliqueMiningCoordinator miningCoordinator, + final MiningCoordinator miningCoordinator, final Runnable closer) { this.genesisConfig = genesisConfig; @@ -97,7 +95,7 @@ public class CliquePantheonController this.miningCoordinator = miningCoordinator; } - public static PantheonController init( + public static PantheonController init( final Path home, final GenesisConfig genesisConfig, final SynchronizerConfiguration taintedSyncConfig, @@ -229,7 +227,7 @@ public class CliquePantheonController } @Override - public AbstractMiningCoordinator getMiningCoordinator() { + public MiningCoordinator getMiningCoordinator() { return miningCoordinator; } 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 b1c64c5e36..9dbc8e15ed 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftPantheonController.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftPantheonController.java @@ -22,7 +22,6 @@ import tech.pegasys.pantheon.consensus.ibft.IbftContext; import tech.pegasys.pantheon.consensus.ibft.IbftEventQueue; import tech.pegasys.pantheon.consensus.ibft.IbftProcessor; import tech.pegasys.pantheon.consensus.ibft.IbftStateMachine; -import tech.pegasys.pantheon.consensus.ibft.blockcreation.IbftBlockMiner; import tech.pegasys.pantheon.consensus.ibft.network.IbftNetworkPeers; import tech.pegasys.pantheon.consensus.ibft.protocol.IbftProtocolManager; import tech.pegasys.pantheon.consensus.ibft.protocol.IbftSubProtocol; @@ -32,7 +31,7 @@ import tech.pegasys.pantheon.consensus.ibftlegacy.protocol.Istanbul64Protocol; import tech.pegasys.pantheon.consensus.ibftlegacy.protocol.Istanbul64ProtocolManager; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.ethereum.ProtocolContext; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.chain.GenesisConfig; import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain; import tech.pegasys.pantheon.ethereum.core.BlockHashFunction; @@ -67,7 +66,7 @@ import java.util.concurrent.TimeUnit; import io.vertx.core.json.JsonObject; import org.apache.logging.log4j.Logger; -public class IbftPantheonController implements PantheonController { +public class IbftPantheonController implements PantheonController { private static final int DEFAULT_ROUND_EXPIRY_MILLISECONDS = 10000; private static final Logger LOG = getLogger(); @@ -106,7 +105,7 @@ public class IbftPantheonController implements PantheonController init( + public static PantheonController init( final Path home, final GenesisConfig genesisConfig, final SynchronizerConfiguration taintedSyncConfig, @@ -243,7 +242,7 @@ public class IbftPantheonController implements PantheonController getMiningCoordinator() { + public MiningCoordinator getMiningCoordinator() { return null; } 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 5eb207ab37..fbfd18bb66 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java @@ -17,9 +17,9 @@ import static tech.pegasys.pantheon.controller.KeyPairUtil.loadKeyPair; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.ethereum.ProtocolContext; import tech.pegasys.pantheon.ethereum.blockcreation.DefaultBlockScheduler; -import tech.pegasys.pantheon.ethereum.blockcreation.EthHashBlockMiner; import tech.pegasys.pantheon.ethereum.blockcreation.EthHashMinerExecutor; import tech.pegasys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; +import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator; import tech.pegasys.pantheon.ethereum.chain.GenesisConfig; import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain; import tech.pegasys.pantheon.ethereum.core.BlockHashFunction; @@ -55,7 +55,7 @@ import java.util.concurrent.TimeUnit; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public class MainnetPantheonController implements PantheonController { +public class MainnetPantheonController implements PantheonController { private static final Logger LOG = LogManager.getLogger(); public static final int MAINNET_NETWORK_ID = 1; @@ -67,7 +67,7 @@ public class MainnetPantheonController implements PantheonController mainnet(final Path home) - throws IOException { + public static PantheonController mainnet(final Path home) throws IOException { final MiningParameters miningParams = new MiningParameters(null, null, null, false); final KeyPair nodeKeys = loadKeyPair(home); return init( @@ -101,7 +100,7 @@ public class MainnetPantheonController implements PantheonController init( + public static PantheonController init( final Path home, final GenesisConfig genesisConfig, final SynchronizerConfiguration taintedSyncConfig, @@ -216,7 +215,7 @@ public class MainnetPantheonController implements PantheonController>> - extends Closeable { +public interface PantheonController extends Closeable { String DATABASE_PATH = "database"; - static PantheonController fromConfig( + static PantheonController fromConfig( final SynchronizerConfiguration syncConfig, final String configContents, final Path pantheonHome, @@ -98,5 +95,5 @@ public interface PantheonController getMiningCoordinator(); + MiningCoordinator getMiningCoordinator(); } diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/util/BlockImporter.java b/pantheon/src/main/java/tech/pegasys/pantheon/util/BlockImporter.java index 44467a851f..74c3181af0 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/util/BlockImporter.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/util/BlockImporter.java @@ -52,7 +52,7 @@ public class BlockImporter { */ public >> BlockImporter.ImportResult importBlockchain( - final Path blocks, final PantheonController pantheonController) throws IOException { + final Path blocks, final PantheonController pantheonController) throws IOException { final ProtocolSchedule protocolSchedule = pantheonController.getProtocolSchedule(); final ProtocolContext context = pantheonController.getProtocolContext(); final GenesisConfig genesis = pantheonController.getGenesisConfig(); diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/util/BlockchainImporter.java b/pantheon/src/main/java/tech/pegasys/pantheon/util/BlockchainImporter.java index b3b728e005..ff939cadd9 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/util/BlockchainImporter.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/util/BlockchainImporter.java @@ -17,8 +17,6 @@ import static java.lang.String.format; import tech.pegasys.pantheon.controller.PantheonController; import tech.pegasys.pantheon.ethereum.ProtocolContext; -import tech.pegasys.pantheon.ethereum.blockcreation.AbstractBlockCreator; -import tech.pegasys.pantheon.ethereum.blockcreation.BlockMiner; import tech.pegasys.pantheon.ethereum.chain.GenesisConfig; import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain; import tech.pegasys.pantheon.ethereum.core.Address; @@ -91,7 +89,6 @@ public class BlockchainImporter extends BlockImporter { * Imports blockchain from file as concatenated RLP sections * * @param the consensus context type - * @param the type of miner being used within the executing pantheon * @param dataFilePath Path to the file containing the dataFilePath * @param pantheonController the PantheonController that defines blockchain behavior * @param isSkipHeaderValidation if true, header validation is skipped. This must only be used @@ -105,17 +102,16 @@ public class BlockchainImporter extends BlockImporter { * @return the import result * @throws IOException On Failure */ - public >> - BlockImporter.ImportResult importBlockchain( - final Path dataFilePath, - final PantheonController pantheonController, - final boolean isSkipHeaderValidation, - final int metricsIntervalSec, - final int accountCommitInterval, - final boolean isSkipBlocks, - final boolean isSkipAccounts, - final Long worldStateOffset) - throws IOException { + public BlockImporter.ImportResult importBlockchain( + final Path dataFilePath, + final PantheonController pantheonController, + final boolean isSkipHeaderValidation, + final int metricsIntervalSec, + final int accountCommitInterval, + final boolean isSkipBlocks, + final boolean isSkipAccounts, + final Long worldStateOffset) + throws IOException { checkNotNull(dataFilePath); checkNotNull(pantheonController); this.isSkipHeaderValidation = isSkipHeaderValidation; @@ -168,13 +164,12 @@ public class BlockchainImporter extends BlockImporter { * combination with isSkipBlocks * @return the import result */ - private >> - BlockImporter.ImportResult importBlockchain( - final PantheonController pantheonController, - final FileRLPInput rlp, - final Boolean isSkipBlocks, - final int metricsIntervalSec, - final Long worldStateOffset) { + private BlockImporter.ImportResult importBlockchain( + final PantheonController pantheonController, + final FileRLPInput rlp, + final Boolean isSkipBlocks, + final int metricsIntervalSec, + final Long worldStateOffset) { final ProtocolSchedule protocolSchedule = pantheonController.getProtocolSchedule(); final ProtocolContext context = pantheonController.getProtocolContext(); final GenesisConfig genesis = pantheonController.getGenesisConfig(); @@ -328,8 +323,8 @@ public class BlockchainImporter extends BlockImporter { * @param the consensus context type * @return root hash of the world state */ - private >> Hash importWorldState( - final PantheonController pantheonController, + private Hash importWorldState( + final PantheonController pantheonController, final FileRLPInput rlp, final int metricsIntervalSec, final int accountCommitInterval) { @@ -487,9 +482,8 @@ public class BlockchainImporter extends BlockImporter { * @param worldStateRootHash calculated world state's root hash * @param the consensus context type */ - private >> - void validateWorldStateRootHash( - final PantheonController pantheonController, final Hash worldStateRootHash) { + private void validateWorldStateRootHash( + final PantheonController pantheonController, final Hash worldStateRootHash) { final ProtocolContext context = pantheonController.getProtocolContext(); final MutableBlockchain blockchain = context.getBlockchain(); final Optional header = blockchain.getBlockHeader(blockchain.getChainHeadHash()); diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/RunnerTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/RunnerTest.java index f1e70dde51..0cd9ace49a 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/RunnerTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/RunnerTest.java @@ -19,7 +19,6 @@ import tech.pegasys.pantheon.controller.MainnetPantheonController; import tech.pegasys.pantheon.controller.PantheonController; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.ethereum.ProtocolContext; -import tech.pegasys.pantheon.ethereum.blockcreation.EthHashBlockMiner; import tech.pegasys.pantheon.ethereum.chain.GenesisConfig; import tech.pegasys.pantheon.ethereum.core.Block; import tech.pegasys.pantheon.ethereum.core.BlockImporter; @@ -91,7 +90,7 @@ public final class RunnerTest { .build(); // Setup state with block data - try (final PantheonController controller = + try (final PantheonController controller = MainnetPantheonController.init( dbAhead, GenesisConfig.mainnet(), @@ -102,7 +101,7 @@ public final class RunnerTest { } // Setup Runner with blocks - final PantheonController controllerAhead = + final PantheonController controllerAhead = MainnetPantheonController.init( dbAhead, GenesisConfig.mainnet(), @@ -135,7 +134,7 @@ public final class RunnerTest { // Setup runner with no block data final Path dbBehind = temp.newFolder().toPath(); final KeyPair behindDbNodeKeys = loadKeyPair(dbBehind); - final PantheonController controllerBehind = + final PantheonController controllerBehind = MainnetPantheonController.init( temp.newFolder().toPath(), GenesisConfig.mainnet(), diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandTestAbstract.java b/pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandTestAbstract.java index 3b2bf744ca..cf84247907 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandTestAbstract.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandTestAbstract.java @@ -60,7 +60,7 @@ public abstract class CommandTestAbstract { @Mock PantheonControllerBuilder mockControllerBuilder; @Mock SynchronizerConfiguration.Builder mockSyncConfBuilder; @Mock SynchronizerConfiguration mockSyncConf; - @Mock PantheonController mockController; + @Mock PantheonController mockController; @Mock BlockImporter mockBlockImporter; @Captor ArgumentCaptor> stringListArgumentCaptor; diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/util/BlockImporterTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/util/BlockImporterTest.java index d79f7231e3..6483b4266b 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/util/BlockImporterTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/util/BlockImporterTest.java @@ -67,7 +67,7 @@ public final class BlockImporterTest { throw new IllegalStateException(ex); } - final PantheonController controller = + final PantheonController controller = PantheonController.fromConfig( SynchronizerConfiguration.builder().build(), config, diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/util/BlockchainImporterTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/util/BlockchainImporterTest.java index bd8917865b..f90d2cd0a7 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/util/BlockchainImporterTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/util/BlockchainImporterTest.java @@ -18,7 +18,6 @@ import static tech.pegasys.pantheon.controller.KeyPairUtil.loadKeyPair; import tech.pegasys.pantheon.controller.MainnetPantheonController; import tech.pegasys.pantheon.controller.PantheonController; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; -import tech.pegasys.pantheon.ethereum.blockcreation.EthHashBlockMiner; import tech.pegasys.pantheon.ethereum.chain.GenesisConfig; import tech.pegasys.pantheon.ethereum.core.MiningParameters; import tech.pegasys.pantheon.ethereum.core.MiningParametersTestBuilder; @@ -66,7 +65,7 @@ public final class BlockchainImporterTest { final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.create(); final MiningParameters miningParams = new MiningParametersTestBuilder().enabled(false).build(); final GenesisConfig genesisConfig = GenesisConfig.fromJson(genesisJson, protocolSchedule); - final PantheonController ctrl = + final PantheonController ctrl = MainnetPantheonController.init( target, genesisConfig,