Add MiningCoordinator interface (#168)

tmohay 6 years ago committed by GitHub
parent 2f5f829c1d
commit 3569b0de78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java
  2. 13
      ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/AbstractMiningCoordinator.java
  3. 47
      ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/MiningCoordinator.java
  4. 14
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java
  5. 6
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbase.java
  6. 11
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPrice.java
  7. 6
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGetWork.java
  8. 11
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthMining.java
  9. 6
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbase.java
  10. 11
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStart.java
  11. 11
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStop.java
  12. 4
      ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbaseTest.java
  13. 5
      ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPriceTest.java
  14. 5
      ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthMiningTest.java
  15. 4
      ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbaseTest.java
  16. 5
      ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStartTest.java
  17. 5
      ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStopTest.java
  18. 4
      pantheon/src/main/java/tech/pegasys/pantheon/Runner.java
  19. 11
      pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java
  20. 2
      pantheon/src/main/java/tech/pegasys/pantheon/cli/ExportPublicKeySubCommand.java
  21. 4
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java
  22. 2
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonControllerBuilder.java
  23. 14
      pantheon/src/main/java/tech/pegasys/pantheon/controller/CliquePantheonController.java
  24. 9
      pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftPantheonController.java
  25. 15
      pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java
  26. 11
      pantheon/src/main/java/tech/pegasys/pantheon/controller/PantheonController.java
  27. 2
      pantheon/src/main/java/tech/pegasys/pantheon/util/BlockImporter.java
  28. 46
      pantheon/src/main/java/tech/pegasys/pantheon/util/BlockchainImporter.java
  29. 7
      pantheon/src/test/java/tech/pegasys/pantheon/RunnerTest.java
  30. 2
      pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandTestAbstract.java
  31. 2
      pantheon/src/test/java/tech/pegasys/pantheon/util/BlockImporterTest.java
  32. 3
      pantheon/src/test/java/tech/pegasys/pantheon/util/BlockchainImporterTest.java

@ -50,7 +50,7 @@ public class ThreadPantheonNodeRunner implements PantheonNodeRunner {
final PantheonControllerBuilder builder = new PantheonControllerBuilder(); final PantheonControllerBuilder builder = new PantheonControllerBuilder();
final EthNetworkConfig ethNetworkConfig = final EthNetworkConfig ethNetworkConfig =
new EthNetworkConfig.Builder(mainnet()).setNetworkId(NETWORK_ID).build(); new EthNetworkConfig.Builder(mainnet()).setNetworkId(NETWORK_ID).build();
final PantheonController<?, ?> pantheonController; final PantheonController<?> pantheonController;
try { try {
pantheonController = pantheonController =
builder.build( builder.build(

@ -33,7 +33,7 @@ import org.apache.logging.log4j.Logger;
public abstract class AbstractMiningCoordinator< public abstract class AbstractMiningCoordinator<
C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>> C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>>
implements BlockAddedObserver { implements BlockAddedObserver, MiningCoordinator {
private static final Logger LOG = getLogger(); private static final Logger LOG = getLogger();
protected boolean isEnabled = false; protected boolean isEnabled = false;
protected volatile Optional<M> currentRunningMiner = Optional.empty(); protected volatile Optional<M> currentRunningMiner = Optional.empty();
@ -54,6 +54,7 @@ public abstract class AbstractMiningCoordinator<
syncState.addInSyncListener(this::inSyncChanged); syncState.addInSyncListener(this::inSyncChanged);
} }
@Override
public void enable() { public void enable() {
synchronized (this) { synchronized (this) {
if (isEnabled) { if (isEnabled) {
@ -66,6 +67,7 @@ public abstract class AbstractMiningCoordinator<
} }
} }
@Override
public void disable() { public void disable() {
synchronized (this) { synchronized (this) {
if (!isEnabled) { if (!isEnabled) {
@ -76,6 +78,7 @@ public abstract class AbstractMiningCoordinator<
} }
} }
@Override
public boolean isRunning() { public boolean isRunning() {
synchronized (this) { synchronized (this) {
return currentRunningMiner.isPresent(); 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 // Required for JSON RPC, and are deemed to be valid for all mining mechanisms
@Override
public void setMinTransactionGasPrice(final Wei minGasPrice) { public void setMinTransactionGasPrice(final Wei minGasPrice) {
executor.setMinTransactionGasPrice(minGasPrice); executor.setMinTransactionGasPrice(minGasPrice);
} }
@Override
public Wei getMinTransactionGasPrice() { public Wei getMinTransactionGasPrice() {
return executor.getMinTransactionGasPrice(); return executor.getMinTransactionGasPrice();
} }
@Override
public void setExtraData(final BytesValue extraData) { public void setExtraData(final BytesValue extraData) {
executor.setExtraData(extraData); executor.setExtraData(extraData);
} }
@Override
public void setCoinbase(final Address coinbase) { public void setCoinbase(final Address coinbase) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Current consensus mechanism prevents setting coinbase."); "Current consensus mechanism prevents setting coinbase.");
} }
@Override
public Optional<Address> getCoinbase() { public Optional<Address> getCoinbase() {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Current consensus mechanism prevents querying of coinbase."); "Current consensus mechanism prevents querying of coinbase.");
} }
@Override
public Optional<Long> hashesPerSecond() { public Optional<Long> hashesPerSecond() {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Current consensus mechanism prevents querying of hashrate."); "Current consensus mechanism prevents querying of hashrate.");
} }
@Override
public Optional<EthHashSolverInputs> getWorkDefinition() { public Optional<EthHashSolverInputs> getWorkDefinition() {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Current consensus mechanism prevents querying work definition."); "Current consensus mechanism prevents querying work definition.");
} }
@Override
public boolean submitWork(final EthHashSolution solution) { public boolean submitWork(final EthHashSolution solution) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Current consensus mechanism prevents submission of work solutions."); "Current consensus mechanism prevents submission of work solutions.");

@ -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<Address> getCoinbase();
Optional<Long> hashesPerSecond();
Optional<EthHashSolverInputs> getWorkDefinition();
boolean submitWork(EthHashSolution solution);
}

@ -12,7 +12,7 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc; 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.chain.Blockchain;
import tech.pegasys.pantheon.ethereum.core.Synchronizer; import tech.pegasys.pantheon.ethereum.core.Synchronizer;
import tech.pegasys.pantheon.ethereum.core.TransactionPool; import tech.pegasys.pantheon.ethereum.core.TransactionPool;
@ -94,7 +94,7 @@ public class JsonRpcMethodsFactory {
final Synchronizer synchronizer, final Synchronizer synchronizer,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final ProtocolSchedule<?> protocolSchedule, final ProtocolSchedule<?> protocolSchedule,
final AbstractMiningCoordinator<?, ?> miningCoordinator, final MiningCoordinator miningCoordinator,
final Set<Capability> supportedCapabilities, final Set<Capability> supportedCapabilities,
final Collection<RpcApi> rpcApis, final Collection<RpcApi> rpcApis,
final FilterManager filterManager) { final FilterManager filterManager) {
@ -123,7 +123,7 @@ public class JsonRpcMethodsFactory {
final ProtocolSchedule<?> protocolSchedule, final ProtocolSchedule<?> protocolSchedule,
final FilterManager filterManager, final FilterManager filterManager,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final AbstractMiningCoordinator<?, ?> miningCoordinator, final MiningCoordinator miningCoordinator,
final Set<Capability> supportedCapabilities, final Set<Capability> supportedCapabilities,
final Collection<RpcApi> rpcApis) { final Collection<RpcApi> rpcApis) {
final Map<String, JsonRpcMethod> enabledMethods = new HashMap<>(); final Map<String, JsonRpcMethod> enabledMethods = new HashMap<>();
@ -174,10 +174,10 @@ public class JsonRpcMethodsFactory {
blockchainQueries.getWorldStateArchive(), blockchainQueries.getWorldStateArchive(),
protocolSchedule), protocolSchedule),
parameter), parameter),
new EthMining<>(miningCoordinator), new EthMining(miningCoordinator),
new EthCoinbase(miningCoordinator), new EthCoinbase(miningCoordinator),
new EthProtocolVersion(supportedCapabilities), new EthProtocolVersion(supportedCapabilities),
new EthGasPrice<>(miningCoordinator), new EthGasPrice(miningCoordinator),
new EthGetWork(miningCoordinator)); new EthGetWork(miningCoordinator));
} }
if (rpcApis.contains(RpcApis.DEBUG)) { if (rpcApis.contains(RpcApis.DEBUG)) {
@ -207,8 +207,8 @@ public class JsonRpcMethodsFactory {
final MinerSetCoinbase minerSetCoinbase = new MinerSetCoinbase(miningCoordinator, parameter); final MinerSetCoinbase minerSetCoinbase = new MinerSetCoinbase(miningCoordinator, parameter);
addMethods( addMethods(
enabledMethods, enabledMethods,
new MinerStart<>(miningCoordinator), new MinerStart(miningCoordinator),
new MinerStop<>(miningCoordinator), new MinerStop(miningCoordinator),
minerSetCoinbase, minerSetCoinbase,
new MinerSetEtherbase(minerSetCoinbase)); new MinerSetEtherbase(minerSetCoinbase));
} }

@ -12,7 +12,7 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods; 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.core.Address;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; 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.JsonRpcError;
@ -24,9 +24,9 @@ import java.util.Optional;
public class EthCoinbase implements JsonRpcMethod { 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; this.miningCoordinator = miningCoordinator;
} }

@ -12,21 +12,18 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods; package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods;
import tech.pegasys.pantheon.ethereum.blockcreation.AbstractBlockCreator; import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator;
import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator;
import tech.pegasys.pantheon.ethereum.blockcreation.BlockMiner;
import tech.pegasys.pantheon.ethereum.core.Wei; import tech.pegasys.pantheon.ethereum.core.Wei;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; 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.JsonRpcResponse;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.results.Quantity; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.results.Quantity;
public class EthGasPrice<C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>> public class EthGasPrice implements JsonRpcMethod {
implements JsonRpcMethod {
private final AbstractMiningCoordinator<C, M> miningCoordinator; private final MiningCoordinator miningCoordinator;
public EthGasPrice(final AbstractMiningCoordinator<C, M> miningCoordinator) { public EthGasPrice(final MiningCoordinator miningCoordinator) {
this.miningCoordinator = miningCoordinator; this.miningCoordinator = miningCoordinator;
} }

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods;
import static org.apache.logging.log4j.LogManager.getLogger; 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.JsonRpcRequest;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse;
@ -30,10 +30,10 @@ import org.apache.logging.log4j.Logger;
public class EthGetWork implements JsonRpcMethod { public class EthGetWork implements JsonRpcMethod {
private final AbstractMiningCoordinator<?, ?> miner; private final MiningCoordinator miner;
private static final Logger LOG = getLogger(); private static final Logger LOG = getLogger();
public EthGetWork(final AbstractMiningCoordinator<?, ?> miner) { public EthGetWork(final MiningCoordinator miner) {
this.miner = miner; this.miner = miner;
} }

@ -12,19 +12,16 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods; package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods;
import tech.pegasys.pantheon.ethereum.blockcreation.AbstractBlockCreator; import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator;
import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator;
import tech.pegasys.pantheon.ethereum.blockcreation.BlockMiner;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; 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.JsonRpcResponse;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse;
public class EthMining<C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>> public class EthMining implements JsonRpcMethod {
implements JsonRpcMethod {
private final AbstractMiningCoordinator<C, M> miningCoordinator; private final MiningCoordinator miningCoordinator;
public EthMining(final AbstractMiningCoordinator<C, M> miningCoordinator) { public EthMining(final MiningCoordinator miningCoordinator) {
this.miningCoordinator = miningCoordinator; this.miningCoordinator = miningCoordinator;
} }

@ -12,7 +12,7 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.miner; 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.core.Address;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod; 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 { public class MinerSetCoinbase implements JsonRpcMethod {
private final AbstractMiningCoordinator<?, ?> miningCoordinator; private final MiningCoordinator miningCoordinator;
private final JsonRpcParameter parameters; private final JsonRpcParameter parameters;
public MinerSetCoinbase( public MinerSetCoinbase(
final AbstractMiningCoordinator<?, ?> miningCoordinator, final JsonRpcParameter parameters) { final MiningCoordinator miningCoordinator, final JsonRpcParameter parameters) {
this.miningCoordinator = miningCoordinator; this.miningCoordinator = miningCoordinator;
this.parameters = parameters; this.parameters = parameters;
} }

@ -12,10 +12,8 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.miner; 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.CoinbaseNotSetException;
import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; 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.JsonRpcResponse;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse;
public class MinerStart<C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>> public class MinerStart implements JsonRpcMethod {
implements JsonRpcMethod {
private final AbstractMiningCoordinator<C, M> miningCoordinator; private final MiningCoordinator miningCoordinator;
public MinerStart(final AbstractMiningCoordinator<C, M> miningCoordinator) { public MinerStart(final MiningCoordinator miningCoordinator) {
this.miningCoordinator = miningCoordinator; this.miningCoordinator = miningCoordinator;
} }

@ -12,20 +12,17 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.miner; package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.miner;
import tech.pegasys.pantheon.ethereum.blockcreation.AbstractBlockCreator; import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator;
import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator;
import tech.pegasys.pantheon.ethereum.blockcreation.BlockMiner;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod; 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.JsonRpcResponse;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse;
public class MinerStop<C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>> public class MinerStop implements JsonRpcMethod {
implements JsonRpcMethod {
private final AbstractMiningCoordinator<C, M> miningCoordinator; private final MiningCoordinator miningCoordinator;
public MinerStop(final AbstractMiningCoordinator<C, M> miningCoordinator) { public MinerStop(final MiningCoordinator miningCoordinator) {
this.miningCoordinator = miningCoordinator; this.miningCoordinator = miningCoordinator;
} }

@ -17,7 +17,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when; 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.core.Address;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; 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.JsonRpcError;
@ -36,7 +36,7 @@ import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class EthCoinbaseTest { public class EthCoinbaseTest {
@Mock private AbstractMiningCoordinator<?, ?> miningCoordinator; @Mock private MiningCoordinator miningCoordinator;
private EthCoinbase method; private EthCoinbase method;
private final String JSON_RPC_VERSION = "2.0"; private final String JSON_RPC_VERSION = "2.0";
private final String ETH_METHOD = "eth_coinbase"; private final String ETH_METHOD = "eth_coinbase";

@ -17,7 +17,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when; 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.blockcreation.EthHashMiningCoordinator;
import tech.pegasys.pantheon.ethereum.core.Wei; import tech.pegasys.pantheon.ethereum.core.Wei;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
@ -34,13 +33,13 @@ import org.mockito.junit.MockitoJUnitRunner;
public class EthGasPriceTest { public class EthGasPriceTest {
@Mock private EthHashMiningCoordinator miningCoordinator; @Mock private EthHashMiningCoordinator miningCoordinator;
private EthGasPrice<Void, EthHashBlockMiner> method; private EthGasPrice method;
private final String JSON_RPC_VERSION = "2.0"; private final String JSON_RPC_VERSION = "2.0";
private final String ETH_METHOD = "eth_gasPrice"; private final String ETH_METHOD = "eth_gasPrice";
@Before @Before
public void setUp() { public void setUp() {
method = new EthGasPrice<>(miningCoordinator); method = new EthGasPrice(miningCoordinator);
} }
@Test @Test

@ -17,7 +17,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when; 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.blockcreation.EthHashMiningCoordinator;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; 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.JsonRpcResponse;
@ -33,13 +32,13 @@ import org.mockito.junit.MockitoJUnitRunner;
public class EthMiningTest { public class EthMiningTest {
@Mock private EthHashMiningCoordinator miningCoordinator; @Mock private EthHashMiningCoordinator miningCoordinator;
private EthMining<Void, EthHashBlockMiner> method; private EthMining method;
private final String JSON_RPC_VERSION = "2.0"; private final String JSON_RPC_VERSION = "2.0";
private final String ETH_METHOD = "eth_mining"; private final String ETH_METHOD = "eth_mining";
@Before @Before
public void setUp() { public void setUp() {
method = new EthMining<>(miningCoordinator); method = new EthMining(miningCoordinator);
} }
@Test @Test

@ -19,7 +19,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.verify; 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.core.Address;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.exception.InvalidJsonRpcParameters; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.exception.InvalidJsonRpcParameters;
@ -40,7 +40,7 @@ public class MinerSetCoinbaseTest {
private MinerSetCoinbase method; private MinerSetCoinbase method;
@Mock private AbstractMiningCoordinator<?, ?> miningCoordinator; @Mock private MiningCoordinator miningCoordinator;
@Before @Before
public void before() { public void before() {

@ -16,7 +16,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.doThrow;
import tech.pegasys.pantheon.ethereum.blockcreation.CoinbaseNotSetException; 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.blockcreation.EthHashMiningCoordinator;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; 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.JsonRpcError;
@ -33,13 +32,13 @@ import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class MinerStartTest { public class MinerStartTest {
private MinerStart<Void, EthHashBlockMiner> method; private MinerStart method;
@Mock private EthHashMiningCoordinator miningCoordinator; @Mock private EthHashMiningCoordinator miningCoordinator;
@Before @Before
public void before() { public void before() {
method = new MinerStart<>(miningCoordinator); method = new MinerStart(miningCoordinator);
} }
@Test @Test

@ -14,7 +14,6 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.miner;
import static org.assertj.core.api.Assertions.assertThat; 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.blockcreation.EthHashMiningCoordinator;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; 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.JsonRpcResponse;
@ -29,13 +28,13 @@ import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class MinerStopTest { public class MinerStopTest {
private MinerStop<Void, EthHashBlockMiner> method; private MinerStop method;
@Mock private EthHashMiningCoordinator miningCoordinator; @Mock private EthHashMiningCoordinator miningCoordinator;
@Before @Before
public void before() { public void before() {
method = new MinerStop<>(miningCoordinator); method = new MinerStop(miningCoordinator);
} }
@Test @Test

@ -45,7 +45,7 @@ public class Runner implements AutoCloseable {
private final Optional<JsonRpcHttpService> jsonRpc; private final Optional<JsonRpcHttpService> jsonRpc;
private final Optional<WebSocketService> websocketRpc; private final Optional<WebSocketService> websocketRpc;
private final PantheonController<?, ?> pantheonController; private final PantheonController<?> pantheonController;
private final Path dataDir; private final Path dataDir;
Runner( Runner(
@ -53,7 +53,7 @@ public class Runner implements AutoCloseable {
final NetworkRunner networkRunner, final NetworkRunner networkRunner,
final Optional<JsonRpcHttpService> jsonRpc, final Optional<JsonRpcHttpService> jsonRpc,
final Optional<WebSocketService> websocketRpc, final Optional<WebSocketService> websocketRpc,
final PantheonController<?, ?> pantheonController, final PantheonController<?> pantheonController,
final Path dataDir) { final Path dataDir) {
this.vertx = vertx; this.vertx = vertx;
this.networkRunner = networkRunner; this.networkRunner = networkRunner;

@ -19,7 +19,7 @@ import tech.pegasys.pantheon.consensus.ibft.jsonrpc.IbftJsonRpcMethodsFactory;
import tech.pegasys.pantheon.controller.PantheonController; import tech.pegasys.pantheon.controller.PantheonController;
import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair;
import tech.pegasys.pantheon.ethereum.ProtocolContext; 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.chain.Blockchain;
import tech.pegasys.pantheon.ethereum.core.Synchronizer; import tech.pegasys.pantheon.ethereum.core.Synchronizer;
import tech.pegasys.pantheon.ethereum.core.TransactionPool; import tech.pegasys.pantheon.ethereum.core.TransactionPool;
@ -70,7 +70,7 @@ public class RunnerBuilder {
public Runner build( public Runner build(
final Vertx vertx, final Vertx vertx,
final PantheonController<?, ?> pantheonController, final PantheonController<?> pantheonController,
final boolean discovery, final boolean discovery,
final Collection<?> bootstrapPeers, final Collection<?> bootstrapPeers,
final String discoveryHost, final String discoveryHost,
@ -139,8 +139,7 @@ public class RunnerBuilder {
final Synchronizer synchronizer = pantheonController.getSynchronizer(); final Synchronizer synchronizer = pantheonController.getSynchronizer();
final TransactionPool transactionPool = pantheonController.getTransactionPool(); final TransactionPool transactionPool = pantheonController.getTransactionPool();
final AbstractMiningCoordinator<?, ?> miningCoordinator = final MiningCoordinator miningCoordinator = pantheonController.getMiningCoordinator();
pantheonController.getMiningCoordinator();
final FilterManager filterManager = createFilterManager(vertx, context, transactionPool); final FilterManager filterManager = createFilterManager(vertx, context, transactionPool);
@ -213,11 +212,11 @@ public class RunnerBuilder {
private Map<String, JsonRpcMethod> jsonRpcMethods( private Map<String, JsonRpcMethod> jsonRpcMethods(
final ProtocolContext<?> context, final ProtocolContext<?> context,
final ProtocolSchedule<?> protocolSchedule, final ProtocolSchedule<?> protocolSchedule,
final PantheonController<?, ?> pantheonController, final PantheonController<?> pantheonController,
final NetworkRunner networkRunner, final NetworkRunner networkRunner,
final Synchronizer synchronizer, final Synchronizer synchronizer,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final AbstractMiningCoordinator<?, ?> miningCoordinator, final MiningCoordinator miningCoordinator,
final Set<Capability> supportedCapabilities, final Set<Capability> supportedCapabilities,
final Collection<RpcApi> jsonRpcApis, final Collection<RpcApi> jsonRpcApis,
final FilterManager filterManager) { final FilterManager filterManager) {

@ -51,7 +51,7 @@ class ExportPublicKeySubCommand implements Runnable {
@Override @Override
public void run() { public void run() {
final PantheonController<?, ?> controller = parentCommand.buildController(); final PantheonController<?> controller = parentCommand.buildController();
final KeyPair keyPair = controller.getLocalNodeKeyPair(); final KeyPair keyPair = controller.getLocalNodeKeyPair();
// this publicKeyExportFile can never be null because of Picocli arity requirement // this publicKeyExportFile can never be null because of Picocli arity requirement

@ -421,7 +421,7 @@ public class PantheonCommand implements Runnable {
webSocketConfiguration()); webSocketConfiguration());
} }
PantheonController<?, ?> buildController() { PantheonController<?> buildController() {
try { try {
return controllerBuilder.build( return controllerBuilder.build(
buildSyncConfig(syncMode), buildSyncConfig(syncMode),
@ -465,7 +465,7 @@ public class PantheonCommand implements Runnable {
// Blockchain synchronisation from peers. // Blockchain synchronisation from peers.
private void synchronize( private void synchronize(
final PantheonController<?, ?> controller, final PantheonController<?> controller,
final boolean noPeerDiscovery, final boolean noPeerDiscovery,
final Collection<?> bootstrapNodes, final Collection<?> bootstrapNodes,
final int maxPeers, final int maxPeers,

@ -29,7 +29,7 @@ import com.google.common.io.Resources;
public class PantheonControllerBuilder { public class PantheonControllerBuilder {
public PantheonController<?, ?> build( public PantheonController<?> build(
final SynchronizerConfiguration synchronizerConfiguration, final SynchronizerConfiguration synchronizerConfiguration,
final Path homePath, final Path homePath,
final EthNetworkConfig ethNetworkConfig, final EthNetworkConfig ethNetworkConfig,

@ -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.CliqueContext;
import tech.pegasys.pantheon.consensus.clique.CliqueVoteTallyUpdater; import tech.pegasys.pantheon.consensus.clique.CliqueVoteTallyUpdater;
import tech.pegasys.pantheon.consensus.clique.VoteTallyCache; 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.CliqueBlockScheduler;
import tech.pegasys.pantheon.consensus.clique.blockcreation.CliqueMinerExecutor; import tech.pegasys.pantheon.consensus.clique.blockcreation.CliqueMinerExecutor;
import tech.pegasys.pantheon.consensus.clique.blockcreation.CliqueMiningCoordinator; 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.consensus.common.VoteProposer;
import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair;
import tech.pegasys.pantheon.ethereum.ProtocolContext; 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.GenesisConfig;
import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain; import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain;
import tech.pegasys.pantheon.ethereum.core.BlockHashFunction; import tech.pegasys.pantheon.ethereum.core.BlockHashFunction;
@ -61,8 +60,7 @@ import java.util.concurrent.TimeUnit;
import io.vertx.core.json.JsonObject; import io.vertx.core.json.JsonObject;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
public class CliquePantheonController public class CliquePantheonController implements PantheonController<CliqueContext> {
implements PantheonController<CliqueContext, CliqueBlockMiner> {
public static int RINKEBY_NETWORK_ID = 4; public static int RINKEBY_NETWORK_ID = 4;
private static final Logger LOG = getLogger(); private static final Logger LOG = getLogger();
private final GenesisConfig<CliqueContext> genesisConfig; private final GenesisConfig<CliqueContext> genesisConfig;
@ -75,7 +73,7 @@ public class CliquePantheonController
private static final long EPOCH_LENGTH_DEFAULT = 30_000L; private static final long EPOCH_LENGTH_DEFAULT = 30_000L;
private static final long SECONDS_BETWEEN_BLOCKS_DEFAULT = 15L; private static final long SECONDS_BETWEEN_BLOCKS_DEFAULT = 15L;
private final CliqueMiningCoordinator miningCoordinator; private final MiningCoordinator miningCoordinator;
CliquePantheonController( CliquePantheonController(
final GenesisConfig<CliqueContext> genesisConfig, final GenesisConfig<CliqueContext> genesisConfig,
@ -84,7 +82,7 @@ public class CliquePantheonController
final Synchronizer synchronizer, final Synchronizer synchronizer,
final KeyPair keyPair, final KeyPair keyPair,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final CliqueMiningCoordinator miningCoordinator, final MiningCoordinator miningCoordinator,
final Runnable closer) { final Runnable closer) {
this.genesisConfig = genesisConfig; this.genesisConfig = genesisConfig;
@ -97,7 +95,7 @@ public class CliquePantheonController
this.miningCoordinator = miningCoordinator; this.miningCoordinator = miningCoordinator;
} }
public static PantheonController<CliqueContext, CliqueBlockMiner> init( public static PantheonController<CliqueContext> init(
final Path home, final Path home,
final GenesisConfig<CliqueContext> genesisConfig, final GenesisConfig<CliqueContext> genesisConfig,
final SynchronizerConfiguration taintedSyncConfig, final SynchronizerConfiguration taintedSyncConfig,
@ -229,7 +227,7 @@ public class CliquePantheonController
} }
@Override @Override
public AbstractMiningCoordinator<CliqueContext, CliqueBlockMiner> getMiningCoordinator() { public MiningCoordinator getMiningCoordinator() {
return miningCoordinator; return miningCoordinator;
} }

@ -22,7 +22,6 @@ import tech.pegasys.pantheon.consensus.ibft.IbftContext;
import tech.pegasys.pantheon.consensus.ibft.IbftEventQueue; import tech.pegasys.pantheon.consensus.ibft.IbftEventQueue;
import tech.pegasys.pantheon.consensus.ibft.IbftProcessor; import tech.pegasys.pantheon.consensus.ibft.IbftProcessor;
import tech.pegasys.pantheon.consensus.ibft.IbftStateMachine; 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.network.IbftNetworkPeers;
import tech.pegasys.pantheon.consensus.ibft.protocol.IbftProtocolManager; import tech.pegasys.pantheon.consensus.ibft.protocol.IbftProtocolManager;
import tech.pegasys.pantheon.consensus.ibft.protocol.IbftSubProtocol; 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.consensus.ibftlegacy.protocol.Istanbul64ProtocolManager;
import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair;
import tech.pegasys.pantheon.ethereum.ProtocolContext; 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.GenesisConfig;
import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain; import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain;
import tech.pegasys.pantheon.ethereum.core.BlockHashFunction; import tech.pegasys.pantheon.ethereum.core.BlockHashFunction;
@ -67,7 +66,7 @@ import java.util.concurrent.TimeUnit;
import io.vertx.core.json.JsonObject; import io.vertx.core.json.JsonObject;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
public class IbftPantheonController implements PantheonController<IbftContext, IbftBlockMiner> { public class IbftPantheonController implements PantheonController<IbftContext> {
private static final int DEFAULT_ROUND_EXPIRY_MILLISECONDS = 10000; private static final int DEFAULT_ROUND_EXPIRY_MILLISECONDS = 10000;
private static final Logger LOG = getLogger(); private static final Logger LOG = getLogger();
@ -106,7 +105,7 @@ public class IbftPantheonController implements PantheonController<IbftContext, I
this.closer = closer; this.closer = closer;
} }
public static PantheonController<IbftContext, IbftBlockMiner> init( public static PantheonController<IbftContext> init(
final Path home, final Path home,
final GenesisConfig<IbftContext> genesisConfig, final GenesisConfig<IbftContext> genesisConfig,
final SynchronizerConfiguration taintedSyncConfig, final SynchronizerConfiguration taintedSyncConfig,
@ -243,7 +242,7 @@ public class IbftPantheonController implements PantheonController<IbftContext, I
} }
@Override @Override
public AbstractMiningCoordinator<IbftContext, IbftBlockMiner> getMiningCoordinator() { public MiningCoordinator getMiningCoordinator() {
return null; return null;
} }

@ -17,9 +17,9 @@ import static tech.pegasys.pantheon.controller.KeyPairUtil.loadKeyPair;
import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair;
import tech.pegasys.pantheon.ethereum.ProtocolContext; import tech.pegasys.pantheon.ethereum.ProtocolContext;
import tech.pegasys.pantheon.ethereum.blockcreation.DefaultBlockScheduler; 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.EthHashMinerExecutor;
import tech.pegasys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; 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.GenesisConfig;
import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain; import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain;
import tech.pegasys.pantheon.ethereum.core.BlockHashFunction; 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.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
public class MainnetPantheonController implements PantheonController<Void, EthHashBlockMiner> { public class MainnetPantheonController implements PantheonController<Void> {
private static final Logger LOG = LogManager.getLogger(); private static final Logger LOG = LogManager.getLogger();
public static final int MAINNET_NETWORK_ID = 1; public static final int MAINNET_NETWORK_ID = 1;
@ -67,7 +67,7 @@ public class MainnetPantheonController implements PantheonController<Void, EthHa
private final Synchronizer synchronizer; private final Synchronizer synchronizer;
private final TransactionPool transactionPool; private final TransactionPool transactionPool;
private final EthHashMiningCoordinator miningCoordinator; private final MiningCoordinator miningCoordinator;
private final Runnable close; private final Runnable close;
public MainnetPantheonController( public MainnetPantheonController(
@ -77,7 +77,7 @@ public class MainnetPantheonController implements PantheonController<Void, EthHa
final Synchronizer synchronizer, final Synchronizer synchronizer,
final KeyPair keyPair, final KeyPair keyPair,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final EthHashMiningCoordinator miningCoordinator, final MiningCoordinator miningCoordinator,
final Runnable close) { final Runnable close) {
this.genesisConfig = genesisConfig; this.genesisConfig = genesisConfig;
this.protocolContext = protocolContext; this.protocolContext = protocolContext;
@ -89,8 +89,7 @@ public class MainnetPantheonController implements PantheonController<Void, EthHa
this.close = close; this.close = close;
} }
public static PantheonController<Void, EthHashBlockMiner> mainnet(final Path home) public static PantheonController<Void> mainnet(final Path home) throws IOException {
throws IOException {
final MiningParameters miningParams = new MiningParameters(null, null, null, false); final MiningParameters miningParams = new MiningParameters(null, null, null, false);
final KeyPair nodeKeys = loadKeyPair(home); final KeyPair nodeKeys = loadKeyPair(home);
return init( return init(
@ -101,7 +100,7 @@ public class MainnetPantheonController implements PantheonController<Void, EthHa
nodeKeys); nodeKeys);
} }
public static PantheonController<Void, EthHashBlockMiner> init( public static PantheonController<Void> init(
final Path home, final Path home,
final GenesisConfig<Void> genesisConfig, final GenesisConfig<Void> genesisConfig,
final SynchronizerConfiguration taintedSyncConfig, final SynchronizerConfiguration taintedSyncConfig,
@ -216,7 +215,7 @@ public class MainnetPantheonController implements PantheonController<Void, EthHa
} }
@Override @Override
public EthHashMiningCoordinator getMiningCoordinator() { public MiningCoordinator getMiningCoordinator() {
return miningCoordinator; return miningCoordinator;
} }

@ -16,9 +16,7 @@ import tech.pegasys.pantheon.consensus.clique.CliqueProtocolSchedule;
import tech.pegasys.pantheon.consensus.ibftlegacy.IbftProtocolSchedule; import tech.pegasys.pantheon.consensus.ibftlegacy.IbftProtocolSchedule;
import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair;
import tech.pegasys.pantheon.ethereum.ProtocolContext; import tech.pegasys.pantheon.ethereum.ProtocolContext;
import tech.pegasys.pantheon.ethereum.blockcreation.AbstractBlockCreator; import tech.pegasys.pantheon.ethereum.blockcreation.MiningCoordinator;
import tech.pegasys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator;
import tech.pegasys.pantheon.ethereum.blockcreation.BlockMiner;
import tech.pegasys.pantheon.ethereum.chain.GenesisConfig; import tech.pegasys.pantheon.ethereum.chain.GenesisConfig;
import tech.pegasys.pantheon.ethereum.core.MiningParameters; import tech.pegasys.pantheon.ethereum.core.MiningParameters;
import tech.pegasys.pantheon.ethereum.core.Synchronizer; import tech.pegasys.pantheon.ethereum.core.Synchronizer;
@ -34,12 +32,11 @@ import java.nio.file.Path;
import io.vertx.core.json.JsonObject; import io.vertx.core.json.JsonObject;
public interface PantheonController<C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>> public interface PantheonController<C> extends Closeable {
extends Closeable {
String DATABASE_PATH = "database"; String DATABASE_PATH = "database";
static PantheonController<?, ?> fromConfig( static PantheonController<?> fromConfig(
final SynchronizerConfiguration syncConfig, final SynchronizerConfiguration syncConfig,
final String configContents, final String configContents,
final Path pantheonHome, final Path pantheonHome,
@ -98,5 +95,5 @@ public interface PantheonController<C, M extends BlockMiner<C, ? extends Abstrac
TransactionPool getTransactionPool(); TransactionPool getTransactionPool();
AbstractMiningCoordinator<C, M> getMiningCoordinator(); MiningCoordinator getMiningCoordinator();
} }

@ -52,7 +52,7 @@ public class BlockImporter {
*/ */
public <C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>> public <C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>>
BlockImporter.ImportResult importBlockchain( BlockImporter.ImportResult importBlockchain(
final Path blocks, final PantheonController<C, M> pantheonController) throws IOException { final Path blocks, final PantheonController<C> pantheonController) throws IOException {
final ProtocolSchedule<C> protocolSchedule = pantheonController.getProtocolSchedule(); final ProtocolSchedule<C> protocolSchedule = pantheonController.getProtocolSchedule();
final ProtocolContext<C> context = pantheonController.getProtocolContext(); final ProtocolContext<C> context = pantheonController.getProtocolContext();
final GenesisConfig<C> genesis = pantheonController.getGenesisConfig(); final GenesisConfig<C> genesis = pantheonController.getGenesisConfig();

@ -17,8 +17,6 @@ import static java.lang.String.format;
import tech.pegasys.pantheon.controller.PantheonController; import tech.pegasys.pantheon.controller.PantheonController;
import tech.pegasys.pantheon.ethereum.ProtocolContext; 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.GenesisConfig;
import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain; import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain;
import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.Address;
@ -91,7 +89,6 @@ public class BlockchainImporter extends BlockImporter {
* Imports blockchain from file as concatenated RLP sections * Imports blockchain from file as concatenated RLP sections
* *
* @param <C> the consensus context type * @param <C> the consensus context type
* @param <M> the type of miner being used within the executing pantheon
* @param dataFilePath Path to the file containing the dataFilePath * @param dataFilePath Path to the file containing the dataFilePath
* @param pantheonController the PantheonController that defines blockchain behavior * @param pantheonController the PantheonController that defines blockchain behavior
* @param isSkipHeaderValidation if true, header validation is skipped. This must only be used * @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 * @return the import result
* @throws IOException On Failure * @throws IOException On Failure
*/ */
public <C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>> public <C> BlockImporter.ImportResult importBlockchain(
BlockImporter.ImportResult importBlockchain( final Path dataFilePath,
final Path dataFilePath, final PantheonController<C> pantheonController,
final PantheonController<C, M> pantheonController, final boolean isSkipHeaderValidation,
final boolean isSkipHeaderValidation, final int metricsIntervalSec,
final int metricsIntervalSec, final int accountCommitInterval,
final int accountCommitInterval, final boolean isSkipBlocks,
final boolean isSkipBlocks, final boolean isSkipAccounts,
final boolean isSkipAccounts, final Long worldStateOffset)
final Long worldStateOffset) throws IOException {
throws IOException {
checkNotNull(dataFilePath); checkNotNull(dataFilePath);
checkNotNull(pantheonController); checkNotNull(pantheonController);
this.isSkipHeaderValidation = isSkipHeaderValidation; this.isSkipHeaderValidation = isSkipHeaderValidation;
@ -168,13 +164,12 @@ public class BlockchainImporter extends BlockImporter {
* combination with isSkipBlocks * combination with isSkipBlocks
* @return the import result * @return the import result
*/ */
private <C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>> private <C> BlockImporter.ImportResult importBlockchain(
BlockImporter.ImportResult importBlockchain( final PantheonController<C> pantheonController,
final PantheonController<C, M> pantheonController, final FileRLPInput rlp,
final FileRLPInput rlp, final Boolean isSkipBlocks,
final Boolean isSkipBlocks, final int metricsIntervalSec,
final int metricsIntervalSec, final Long worldStateOffset) {
final Long worldStateOffset) {
final ProtocolSchedule<C> protocolSchedule = pantheonController.getProtocolSchedule(); final ProtocolSchedule<C> protocolSchedule = pantheonController.getProtocolSchedule();
final ProtocolContext<C> context = pantheonController.getProtocolContext(); final ProtocolContext<C> context = pantheonController.getProtocolContext();
final GenesisConfig<C> genesis = pantheonController.getGenesisConfig(); final GenesisConfig<C> genesis = pantheonController.getGenesisConfig();
@ -328,8 +323,8 @@ public class BlockchainImporter extends BlockImporter {
* @param <C> the consensus context type * @param <C> the consensus context type
* @return root hash of the world state * @return root hash of the world state
*/ */
private <C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>> Hash importWorldState( private <C> Hash importWorldState(
final PantheonController<C, M> pantheonController, final PantheonController<C> pantheonController,
final FileRLPInput rlp, final FileRLPInput rlp,
final int metricsIntervalSec, final int metricsIntervalSec,
final int accountCommitInterval) { final int accountCommitInterval) {
@ -487,9 +482,8 @@ public class BlockchainImporter extends BlockImporter {
* @param worldStateRootHash calculated world state's root hash * @param worldStateRootHash calculated world state's root hash
* @param <C> the consensus context type * @param <C> the consensus context type
*/ */
private <C, M extends BlockMiner<C, ? extends AbstractBlockCreator<C>>> private <C> void validateWorldStateRootHash(
void validateWorldStateRootHash( final PantheonController<C> pantheonController, final Hash worldStateRootHash) {
final PantheonController<C, M> pantheonController, final Hash worldStateRootHash) {
final ProtocolContext<C> context = pantheonController.getProtocolContext(); final ProtocolContext<C> context = pantheonController.getProtocolContext();
final MutableBlockchain blockchain = context.getBlockchain(); final MutableBlockchain blockchain = context.getBlockchain();
final Optional<BlockHeader> header = blockchain.getBlockHeader(blockchain.getChainHeadHash()); final Optional<BlockHeader> header = blockchain.getBlockHeader(blockchain.getChainHeadHash());

@ -19,7 +19,6 @@ import tech.pegasys.pantheon.controller.MainnetPantheonController;
import tech.pegasys.pantheon.controller.PantheonController; import tech.pegasys.pantheon.controller.PantheonController;
import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair;
import tech.pegasys.pantheon.ethereum.ProtocolContext; 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.chain.GenesisConfig;
import tech.pegasys.pantheon.ethereum.core.Block; import tech.pegasys.pantheon.ethereum.core.Block;
import tech.pegasys.pantheon.ethereum.core.BlockImporter; import tech.pegasys.pantheon.ethereum.core.BlockImporter;
@ -91,7 +90,7 @@ public final class RunnerTest {
.build(); .build();
// Setup state with block data // Setup state with block data
try (final PantheonController<Void, EthHashBlockMiner> controller = try (final PantheonController<Void> controller =
MainnetPantheonController.init( MainnetPantheonController.init(
dbAhead, dbAhead,
GenesisConfig.mainnet(), GenesisConfig.mainnet(),
@ -102,7 +101,7 @@ public final class RunnerTest {
} }
// Setup Runner with blocks // Setup Runner with blocks
final PantheonController<Void, EthHashBlockMiner> controllerAhead = final PantheonController<Void> controllerAhead =
MainnetPantheonController.init( MainnetPantheonController.init(
dbAhead, dbAhead,
GenesisConfig.mainnet(), GenesisConfig.mainnet(),
@ -135,7 +134,7 @@ public final class RunnerTest {
// Setup runner with no block data // Setup runner with no block data
final Path dbBehind = temp.newFolder().toPath(); final Path dbBehind = temp.newFolder().toPath();
final KeyPair behindDbNodeKeys = loadKeyPair(dbBehind); final KeyPair behindDbNodeKeys = loadKeyPair(dbBehind);
final PantheonController<Void, EthHashBlockMiner> controllerBehind = final PantheonController<Void> controllerBehind =
MainnetPantheonController.init( MainnetPantheonController.init(
temp.newFolder().toPath(), temp.newFolder().toPath(),
GenesisConfig.mainnet(), GenesisConfig.mainnet(),

@ -60,7 +60,7 @@ public abstract class CommandTestAbstract {
@Mock PantheonControllerBuilder mockControllerBuilder; @Mock PantheonControllerBuilder mockControllerBuilder;
@Mock SynchronizerConfiguration.Builder mockSyncConfBuilder; @Mock SynchronizerConfiguration.Builder mockSyncConfBuilder;
@Mock SynchronizerConfiguration mockSyncConf; @Mock SynchronizerConfiguration mockSyncConf;
@Mock PantheonController<?, ?> mockController; @Mock PantheonController<?> mockController;
@Mock BlockImporter mockBlockImporter; @Mock BlockImporter mockBlockImporter;
@Captor ArgumentCaptor<Collection<String>> stringListArgumentCaptor; @Captor ArgumentCaptor<Collection<String>> stringListArgumentCaptor;

@ -67,7 +67,7 @@ public final class BlockImporterTest {
throw new IllegalStateException(ex); throw new IllegalStateException(ex);
} }
final PantheonController<?, ?> controller = final PantheonController<?> controller =
PantheonController.fromConfig( PantheonController.fromConfig(
SynchronizerConfiguration.builder().build(), SynchronizerConfiguration.builder().build(),
config, config,

@ -18,7 +18,6 @@ import static tech.pegasys.pantheon.controller.KeyPairUtil.loadKeyPair;
import tech.pegasys.pantheon.controller.MainnetPantheonController; import tech.pegasys.pantheon.controller.MainnetPantheonController;
import tech.pegasys.pantheon.controller.PantheonController; import tech.pegasys.pantheon.controller.PantheonController;
import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; 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.chain.GenesisConfig;
import tech.pegasys.pantheon.ethereum.core.MiningParameters; import tech.pegasys.pantheon.ethereum.core.MiningParameters;
import tech.pegasys.pantheon.ethereum.core.MiningParametersTestBuilder; import tech.pegasys.pantheon.ethereum.core.MiningParametersTestBuilder;
@ -66,7 +65,7 @@ public final class BlockchainImporterTest {
final ProtocolSchedule<Void> protocolSchedule = MainnetProtocolSchedule.create(); final ProtocolSchedule<Void> protocolSchedule = MainnetProtocolSchedule.create();
final MiningParameters miningParams = new MiningParametersTestBuilder().enabled(false).build(); final MiningParameters miningParams = new MiningParametersTestBuilder().enabled(false).build();
final GenesisConfig<Void> genesisConfig = GenesisConfig.fromJson(genesisJson, protocolSchedule); final GenesisConfig<Void> genesisConfig = GenesisConfig.fromJson(genesisJson, protocolSchedule);
final PantheonController<Void, EthHashBlockMiner> ctrl = final PantheonController<Void> ctrl =
MainnetPantheonController.init( MainnetPantheonController.init(
target, target,
genesisConfig, genesisConfig,

Loading…
Cancel
Save