diff --git a/acceptance-tests/src/test/java/net/consensys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java b/acceptance-tests/src/test/java/net/consensys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java index 4104d3316b..aca39cfc67 100644 --- a/acceptance-tests/src/test/java/net/consensys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java +++ b/acceptance-tests/src/test/java/net/consensys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java @@ -33,7 +33,7 @@ public class ThreadPantheonNodeRunner implements PantheonNodeRunner { } final PantheonControllerBuilder builder = new PantheonControllerBuilder(); - PantheonController pantheonController; + PantheonController pantheonController; try { pantheonController = builder.build( diff --git a/consensus/clique/src/main/java/net/consensys/pantheon/consensus/clique/blockcreation/CliqueBlockMiner.java b/consensus/clique/src/main/java/net/consensys/pantheon/consensus/clique/blockcreation/CliqueBlockMiner.java index ef5f3c46c2..57a0a7cc6d 100644 --- a/consensus/clique/src/main/java/net/consensys/pantheon/consensus/clique/blockcreation/CliqueBlockMiner.java +++ b/consensus/clique/src/main/java/net/consensys/pantheon/consensus/clique/blockcreation/CliqueBlockMiner.java @@ -5,8 +5,8 @@ import net.consensys.pantheon.consensus.clique.CliqueHelpers; import net.consensys.pantheon.consensus.common.ValidatorProvider; import net.consensys.pantheon.ethereum.ProtocolContext; import net.consensys.pantheon.ethereum.blockcreation.AbstractBlockScheduler; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator.MinedBlockObserver; import net.consensys.pantheon.ethereum.blockcreation.BlockMiner; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator.MinedBlockObserver; import net.consensys.pantheon.ethereum.core.Address; import net.consensys.pantheon.ethereum.core.BlockHeader; import net.consensys.pantheon.ethereum.mainnet.ProtocolSchedule; diff --git a/consensus/clique/src/main/java/net/consensys/pantheon/consensus/clique/blockcreation/CliqueMinerExecutor.java b/consensus/clique/src/main/java/net/consensys/pantheon/consensus/clique/blockcreation/CliqueMinerExecutor.java index 1f359d46d2..c85ebb9fba 100644 --- a/consensus/clique/src/main/java/net/consensys/pantheon/consensus/clique/blockcreation/CliqueMinerExecutor.java +++ b/consensus/clique/src/main/java/net/consensys/pantheon/consensus/clique/blockcreation/CliqueMinerExecutor.java @@ -8,7 +8,7 @@ import net.consensys.pantheon.crypto.SECP256K1.KeyPair; import net.consensys.pantheon.ethereum.ProtocolContext; import net.consensys.pantheon.ethereum.blockcreation.AbstractBlockScheduler; import net.consensys.pantheon.ethereum.blockcreation.AbstractMinerExecutor; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator.MinedBlockObserver; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator.MinedBlockObserver; import net.consensys.pantheon.ethereum.blockcreation.MiningParameters; import net.consensys.pantheon.ethereum.core.Address; import net.consensys.pantheon.ethereum.core.BlockHeader; diff --git a/consensus/ibft/src/main/java/net/consensys/pantheon/consensus/ibft/blockcreation/IbftBlockMiner.java b/consensus/ibft/src/main/java/net/consensys/pantheon/consensus/ibft/blockcreation/IbftBlockMiner.java new file mode 100644 index 0000000000..d104b94272 --- /dev/null +++ b/consensus/ibft/src/main/java/net/consensys/pantheon/consensus/ibft/blockcreation/IbftBlockMiner.java @@ -0,0 +1,25 @@ +package net.consensys.pantheon.consensus.ibft.blockcreation; + +import net.consensys.pantheon.consensus.ibft.IbftContext; +import net.consensys.pantheon.ethereum.ProtocolContext; +import net.consensys.pantheon.ethereum.blockcreation.AbstractBlockScheduler; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator.MinedBlockObserver; +import net.consensys.pantheon.ethereum.blockcreation.BlockMiner; +import net.consensys.pantheon.ethereum.core.BlockHeader; +import net.consensys.pantheon.ethereum.mainnet.ProtocolSchedule; +import net.consensys.pantheon.util.Subscribers; + +public class IbftBlockMiner extends BlockMiner { + + // TODO(tmm): Currently a place holder to allow infrastructure code to continue to operate + // with the advent of multiple consensus methods. + public IbftBlockMiner( + final IbftBlockCreator blockCreator, + final ProtocolSchedule protocolSchedule, + final ProtocolContext protocolContext, + final Subscribers observers, + final AbstractBlockScheduler scheduler, + final BlockHeader parentHeader) { + super(blockCreator, protocolSchedule, protocolContext, observers, scheduler, parentHeader); + } +} diff --git a/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/AbstractMinerExecutor.java b/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/AbstractMinerExecutor.java index 729dcd37c0..d245c996ef 100644 --- a/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/AbstractMinerExecutor.java +++ b/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/AbstractMinerExecutor.java @@ -1,7 +1,7 @@ package net.consensys.pantheon.ethereum.blockcreation; import net.consensys.pantheon.ethereum.ProtocolContext; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator.MinedBlockObserver; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator.MinedBlockObserver; import net.consensys.pantheon.ethereum.core.BlockHeader; import net.consensys.pantheon.ethereum.core.PendingTransactions; import net.consensys.pantheon.ethereum.core.Wei; diff --git a/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/MiningCoordinator.java b/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/AbstractMiningCoordinator.java similarity index 58% rename from ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/MiningCoordinator.java rename to ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/AbstractMiningCoordinator.java index 13872d17bc..a7d8f58541 100644 --- a/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/MiningCoordinator.java +++ b/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/AbstractMiningCoordinator.java @@ -15,61 +15,66 @@ import net.consensys.pantheon.util.bytes.BytesValue; import java.util.Optional; -/** - * Responsible for determining when a block mining operation should be started/stopped, then - * creating an appropriate miner and starting it running in a thread. - */ -public class MiningCoordinator implements BlockAddedObserver { +public abstract class AbstractMiningCoordinator< + C, M extends BlockMiner>> + implements BlockAddedObserver { - private final Subscribers minedBlockObservers = new Subscribers<>(); - - private final EthHashMinerExecutor executor; + protected boolean isEnabled = false; + protected volatile Optional currentRunningMiner = Optional.empty(); - private volatile Optional currentRunningMiner = Optional.empty(); - private volatile Optional cachedHashesPerSecond = Optional.empty(); - private boolean isEnabled = false; - private final Blockchain blockchain; + private final Subscribers minedBlockObservers = new Subscribers<>(); + private final AbstractMinerExecutor executor; + protected final Blockchain blockchain; - public MiningCoordinator(final Blockchain blockchain, final EthHashMinerExecutor executor) { + public AbstractMiningCoordinator( + final Blockchain blockchain, final AbstractMinerExecutor executor) { this.executor = executor; this.blockchain = blockchain; this.blockchain.observeBlockAdded(this); } - public void enable() { + public abstract void enable(); + + public abstract void disable(); + + public boolean isRunning() { synchronized (this) { - if (isEnabled) { - return; - } - startAsyncMiningOperation(); - isEnabled = true; + return isEnabled; } } - public void disable() { + protected void startAsyncMiningOperation() { + final BlockHeader parentHeader = blockchain.getChainHeadHeader(); + currentRunningMiner = Optional.of(executor.startAsyncMining(minedBlockObservers, parentHeader)); + } + + protected void haltCurrentMiningOperation() { + currentRunningMiner.ifPresent(M::cancel); + } + + @Override + public void onBlockAdded(final BlockAddedEvent event, final Blockchain blockchain) { synchronized (this) { - if (!isEnabled) { - return; + if (isEnabled && shouldStartNewMiner(event)) { + haltCurrentMiningOperation(); + startAsyncMiningOperation(); } - haltCurrentMiningOperation(); - isEnabled = false; } } - public boolean isRunning() { - synchronized (this) { - return isEnabled; - } + private boolean shouldStartNewMiner(final BlockAddedEvent event) { + return event.getEventType() != EventType.FORK; } - public void setCoinbase(final Address coinbase) { - executor.setCoinbase(coinbase); + public void removeMinedBlockObserver(final long id) { + minedBlockObservers.unsubscribe(id); } - public Optional
getCoinbase() { - return executor.getCoinbase(); + public long addMinedBlockObserver(final MinedBlockObserver obs) { + return minedBlockObservers.subscribe(obs); } + // Required for JSON RPC, and are deemed to be valid for all mining mechanisms public void setMinTransactionGasPrice(final Wei minGasPrice) { executor.setMinTransactionGasPrice(minGasPrice); } @@ -82,61 +87,29 @@ public class MiningCoordinator implements BlockAddedObserver { executor.setExtraData(extraData); } - public Optional hashesPerSecond() { - final Optional currentHashesPerSecond = - currentRunningMiner.flatMap(EthHashBlockMiner::getHashesPerSecond); - - if (currentHashesPerSecond.isPresent()) { - cachedHashesPerSecond = currentHashesPerSecond; - return currentHashesPerSecond; - } else { - return cachedHashesPerSecond; - } - } - - public Optional getWorkDefinition() { - return currentRunningMiner.flatMap(EthHashBlockMiner::getWorkDefinition); - } - - public boolean submitWork(final EthHashSolution solution) { - synchronized (this) { - return currentRunningMiner.map(miner -> miner.submitWork(solution)).orElse(false); - } - } - - @Override - public void onBlockAdded(final BlockAddedEvent event, final Blockchain blockchain) { - synchronized (this) { - if (isEnabled && shouldStartNewMiner(event)) { - haltCurrentMiningOperation(); - startAsyncMiningOperation(); - } - } - } - - private boolean shouldStartNewMiner(final BlockAddedEvent event) { - return event.getEventType() != EventType.FORK; + public void setCoinbase(final Address coinbase) { + throw new UnsupportedOperationException( + "Current consensus mechanism prevents" + " setting coinbase."); } - private void startAsyncMiningOperation() { - final BlockHeader parentHeader = blockchain.getChainHeadHeader(); - currentRunningMiner = Optional.of(executor.startAsyncMining(minedBlockObservers, parentHeader)); + public Optional
getCoinbase() { + throw new UnsupportedOperationException( + "Current consensus mechanism prevents" + " querying of coinbase."); } - private void haltCurrentMiningOperation() { - currentRunningMiner.ifPresent( - miner -> { - miner.cancel(); - miner.getHashesPerSecond().ifPresent(val -> cachedHashesPerSecond = Optional.of(val)); - }); + public Optional hashesPerSecond() { + throw new UnsupportedOperationException( + "Current consensus mechanism prevents querying " + "of hashrate."); } - public long addMinedBlockObserver(final MinedBlockObserver obs) { - return minedBlockObservers.subscribe(obs); + public Optional getWorkDefinition() { + throw new UnsupportedOperationException( + "Current consensus mechanism prevents querying " + "work definition."); } - public void removeMinedBlockObserver(final long id) { - minedBlockObservers.unsubscribe(id); + public boolean submitWork(final EthHashSolution solution) { + throw new UnsupportedOperationException( + "Current consensus mechanism prevents submission of work" + " solutions."); } public interface MinedBlockObserver { diff --git a/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/BlockMiner.java b/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/BlockMiner.java index 0c26dd20e7..248d5d855f 100644 --- a/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/BlockMiner.java +++ b/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/BlockMiner.java @@ -1,7 +1,7 @@ package net.consensys.pantheon.ethereum.blockcreation; import net.consensys.pantheon.ethereum.ProtocolContext; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator.MinedBlockObserver; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator.MinedBlockObserver; import net.consensys.pantheon.ethereum.core.Block; import net.consensys.pantheon.ethereum.core.BlockHeader; import net.consensys.pantheon.ethereum.core.BlockImporter; diff --git a/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/EthHashBlockMiner.java b/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/EthHashBlockMiner.java index 4eb2903cca..1003a25847 100644 --- a/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/EthHashBlockMiner.java +++ b/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/EthHashBlockMiner.java @@ -1,7 +1,7 @@ package net.consensys.pantheon.ethereum.blockcreation; import net.consensys.pantheon.ethereum.ProtocolContext; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator.MinedBlockObserver; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator.MinedBlockObserver; import net.consensys.pantheon.ethereum.core.BlockHeader; import net.consensys.pantheon.ethereum.mainnet.EthHashBlockCreator; import net.consensys.pantheon.ethereum.mainnet.EthHashSolution; diff --git a/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/EthHashMinerExecutor.java b/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/EthHashMinerExecutor.java index addce21836..0882474f8a 100644 --- a/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/EthHashMinerExecutor.java +++ b/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/EthHashMinerExecutor.java @@ -1,7 +1,7 @@ package net.consensys.pantheon.ethereum.blockcreation; import net.consensys.pantheon.ethereum.ProtocolContext; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator.MinedBlockObserver; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator.MinedBlockObserver; import net.consensys.pantheon.ethereum.core.Address; import net.consensys.pantheon.ethereum.core.BlockHeader; import net.consensys.pantheon.ethereum.core.PendingTransactions; diff --git a/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/EthHashMiningCoordinator.java b/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/EthHashMiningCoordinator.java new file mode 100644 index 0000000000..368e1adba0 --- /dev/null +++ b/ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/EthHashMiningCoordinator.java @@ -0,0 +1,83 @@ +package net.consensys.pantheon.ethereum.blockcreation; + +import net.consensys.pantheon.ethereum.chain.BlockAddedObserver; +import net.consensys.pantheon.ethereum.chain.Blockchain; +import net.consensys.pantheon.ethereum.core.Address; +import net.consensys.pantheon.ethereum.mainnet.EthHashSolution; +import net.consensys.pantheon.ethereum.mainnet.EthHashSolverInputs; + +import java.util.Optional; + +/** + * Responsible for determining when a block mining operation should be started/stopped, then + * creating an appropriate miner and starting it running in a thread. + */ +public class EthHashMiningCoordinator extends AbstractMiningCoordinator + implements BlockAddedObserver { + + private final EthHashMinerExecutor executor; + private volatile Optional cachedHashesPerSecond = Optional.empty(); + + public EthHashMiningCoordinator( + final Blockchain blockchain, final EthHashMinerExecutor executor) { + super(blockchain, executor); + this.executor = executor; + } + + @Override + public void enable() { + synchronized (this) { + if (isEnabled) { + return; + } + startAsyncMiningOperation(); + isEnabled = true; + } + } + + @Override + public void disable() { + synchronized (this) { + if (!isEnabled) { + return; + } + haltCurrentMiningOperation(); + isEnabled = false; + } + } + + @Override + public void setCoinbase(final Address coinbase) { + executor.setCoinbase(coinbase); + } + + @Override + public Optional
getCoinbase() { + return executor.getCoinbase(); + } + + @Override + public Optional hashesPerSecond() { + final Optional currentHashesPerSecond = + currentRunningMiner.flatMap(EthHashBlockMiner::getHashesPerSecond); + + if (currentHashesPerSecond.isPresent()) { + cachedHashesPerSecond = currentHashesPerSecond; + return currentHashesPerSecond; + } else { + return cachedHashesPerSecond; + } + } + + @Override + public Optional getWorkDefinition() { + return currentRunningMiner.flatMap(EthHashBlockMiner::getWorkDefinition); + } + + @Override + public boolean submitWork(final EthHashSolution solution) { + synchronized (this) { + return currentRunningMiner.map(miner -> miner.submitWork(solution)).orElse(false); + } + } +} diff --git a/ethereum/core/src/test/java/net/consensys/pantheon/ethereum/blockcreation/BlockMinerTest.java b/ethereum/core/src/test/java/net/consensys/pantheon/ethereum/blockcreation/BlockMinerTest.java index 44f16335a5..c321825e12 100644 --- a/ethereum/core/src/test/java/net/consensys/pantheon/ethereum/blockcreation/BlockMinerTest.java +++ b/ethereum/core/src/test/java/net/consensys/pantheon/ethereum/blockcreation/BlockMinerTest.java @@ -8,7 +8,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import net.consensys.pantheon.ethereum.ProtocolContext; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator.MinedBlockObserver; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator.MinedBlockObserver; import net.consensys.pantheon.ethereum.core.Block; import net.consensys.pantheon.ethereum.core.BlockBody; import net.consensys.pantheon.ethereum.core.BlockHeaderTestFixture; diff --git a/ethereum/core/src/test/java/net/consensys/pantheon/ethereum/blockcreation/MiningCoordinatorTest.java b/ethereum/core/src/test/java/net/consensys/pantheon/ethereum/blockcreation/EthHashMiningCoordinatorTest.java similarity index 86% rename from ethereum/core/src/test/java/net/consensys/pantheon/ethereum/blockcreation/MiningCoordinatorTest.java rename to ethereum/core/src/test/java/net/consensys/pantheon/ethereum/blockcreation/EthHashMiningCoordinatorTest.java index e4db31728e..6e617ae6ab 100644 --- a/ethereum/core/src/test/java/net/consensys/pantheon/ethereum/blockcreation/MiningCoordinatorTest.java +++ b/ethereum/core/src/test/java/net/consensys/pantheon/ethereum/blockcreation/EthHashMiningCoordinatorTest.java @@ -14,15 +14,15 @@ import java.util.Optional; import org.junit.Test; -public class MiningCoordinatorTest { +public class EthHashMiningCoordinatorTest { private final ExecutionContextTestFixture executionContext = new ExecutionContextTestFixture(); @Test public void miningCoordinatorIsCreatedDisabledWithNoReportableMiningStatistics() { final EthHashMinerExecutor executor = mock(EthHashMinerExecutor.class); - final MiningCoordinator miningCoordinator = - new MiningCoordinator(executionContext.getBlockchain(), executor); + final EthHashMiningCoordinator miningCoordinator = + new EthHashMiningCoordinator(executionContext.getBlockchain(), executor); final EthHashSolution solution = new EthHashSolution(1L, Hash.EMPTY, new byte[Bytes32.SIZE]); assertThat(miningCoordinator.isRunning()).isFalse(); @@ -46,8 +46,8 @@ public class MiningCoordinatorTest { final EthHashMinerExecutor executor = mock(EthHashMinerExecutor.class); when(executor.startAsyncMining(any(), any())).thenReturn(miner); - final MiningCoordinator miningCoordinator = - new MiningCoordinator(executionContext.getBlockchain(), executor); + final EthHashMiningCoordinator miningCoordinator = + new EthHashMiningCoordinator(executionContext.getBlockchain(), executor); miningCoordinator.enable(); // Must enable prior returning data assertThat(miningCoordinator.hashesPerSecond()).isEqualTo(hashRate1); diff --git a/ethereum/eth/src/main/java/net/consensys/pantheon/ethereum/eth/manager/EthProtocolManager.java b/ethereum/eth/src/main/java/net/consensys/pantheon/ethereum/eth/manager/EthProtocolManager.java index 2faa5ede12..5a7613e828 100644 --- a/ethereum/eth/src/main/java/net/consensys/pantheon/ethereum/eth/manager/EthProtocolManager.java +++ b/ethereum/eth/src/main/java/net/consensys/pantheon/ethereum/eth/manager/EthProtocolManager.java @@ -2,7 +2,7 @@ package net.consensys.pantheon.ethereum.eth.manager; import static com.google.common.base.Preconditions.checkArgument; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator.MinedBlockObserver; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator.MinedBlockObserver; import net.consensys.pantheon.ethereum.chain.Blockchain; import net.consensys.pantheon.ethereum.core.Block; import net.consensys.pantheon.ethereum.core.Hash; diff --git a/ethereum/jsonrpc/src/integration-test/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcTestMethodsFactory.java b/ethereum/jsonrpc/src/integration-test/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcTestMethodsFactory.java index c8aed9700b..10895ca0d6 100644 --- a/ethereum/jsonrpc/src/integration-test/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcTestMethodsFactory.java +++ b/ethereum/jsonrpc/src/integration-test/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcTestMethodsFactory.java @@ -3,7 +3,7 @@ package net.consensys.pantheon.ethereum.jsonrpc; import static org.mockito.Mockito.mock; import net.consensys.pantheon.ethereum.ProtocolContext; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import net.consensys.pantheon.ethereum.chain.MutableBlockchain; import net.consensys.pantheon.ethereum.core.Block; import net.consensys.pantheon.ethereum.core.BlockImporter; @@ -67,7 +67,7 @@ public class JsonRpcTestMethodsFactory { final TransactionPool transactionPool = mock(TransactionPool.class); final FilterManager filterManager = new FilterManager(blockchainQueries, transactionPool, new FilterIdGenerator()); - final MiningCoordinator miningCoordinator = mock(MiningCoordinator.class); + final EthHashMiningCoordinator miningCoordinator = mock(EthHashMiningCoordinator.class); return new JsonRpcMethodsFactory() .methods( diff --git a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java index 29b4befb00..3921fa1f55 100644 --- a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java +++ b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java @@ -1,6 +1,6 @@ package net.consensys.pantheon.ethereum.jsonrpc; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; import net.consensys.pantheon.ethereum.chain.Blockchain; import net.consensys.pantheon.ethereum.core.Synchronizer; import net.consensys.pantheon.ethereum.core.TransactionPool; @@ -83,7 +83,7 @@ public class JsonRpcMethodsFactory { final Synchronizer synchronizer, final TransactionPool transactionPool, final ProtocolSchedule protocolSchedule, - final MiningCoordinator miningCoordinator, + final AbstractMiningCoordinator miningCoordinator, final Set supportedCapabilities, final Collection rpcApis) { final BlockchainQueries blockchainQueries = @@ -113,7 +113,7 @@ public class JsonRpcMethodsFactory { final ProtocolSchedule protocolSchedule, final FilterManager filterManager, final TransactionPool transactionPool, - final MiningCoordinator miningCoordinator, + final AbstractMiningCoordinator miningCoordinator, final Set supportedCapabilities, final Collection rpcApis) { final Map enabledMethods = new HashMap<>(); @@ -164,10 +164,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)); } if (rpcApis.contains(RpcApis.DEBUG)) { final BlockReplay blockReplay = @@ -196,8 +196,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/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbase.java b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbase.java index 3981ac336f..09fee18dfe 100644 --- a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbase.java +++ b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbase.java @@ -1,6 +1,6 @@ package net.consensys.pantheon.ethereum.jsonrpc.internal.methods; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; import net.consensys.pantheon.ethereum.core.Address; import net.consensys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; @@ -12,9 +12,9 @@ import java.util.Optional; public class EthCoinbase implements JsonRpcMethod { - private final MiningCoordinator miningCoordinator; + private final AbstractMiningCoordinator miningCoordinator; - public EthCoinbase(final MiningCoordinator miningCoordinator) { + public EthCoinbase(final AbstractMiningCoordinator miningCoordinator) { this.miningCoordinator = miningCoordinator; } diff --git a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPrice.java b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPrice.java index be485ccac0..fa4b23a74a 100644 --- a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPrice.java +++ b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPrice.java @@ -1,17 +1,20 @@ package net.consensys.pantheon.ethereum.jsonrpc.internal.methods; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractBlockCreator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.BlockMiner; import net.consensys.pantheon.ethereum.core.Wei; import net.consensys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; import net.consensys.pantheon.ethereum.jsonrpc.internal.results.Quantity; -public class EthGasPrice implements JsonRpcMethod { +public class EthGasPrice>> + implements JsonRpcMethod { - private final MiningCoordinator miningCoordinator; + private final AbstractMiningCoordinator miningCoordinator; - public EthGasPrice(final MiningCoordinator miningCoordinator) { + public EthGasPrice(final AbstractMiningCoordinator miningCoordinator) { this.miningCoordinator = miningCoordinator; } diff --git a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthMining.java b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthMining.java index 6af6f34b69..9c562eb662 100644 --- a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthMining.java +++ b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthMining.java @@ -1,15 +1,18 @@ package net.consensys.pantheon.ethereum.jsonrpc.internal.methods; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractBlockCreator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.BlockMiner; import net.consensys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -public class EthMining implements JsonRpcMethod { +public class EthMining>> + implements JsonRpcMethod { - private final MiningCoordinator miningCoordinator; + private final AbstractMiningCoordinator miningCoordinator; - public EthMining(final MiningCoordinator miningCoordinator) { + public EthMining(final AbstractMiningCoordinator miningCoordinator) { this.miningCoordinator = miningCoordinator; } diff --git a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbase.java b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbase.java index e3796797ec..e6bb810513 100644 --- a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbase.java +++ b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbase.java @@ -1,6 +1,6 @@ package net.consensys.pantheon.ethereum.jsonrpc.internal.methods.miner; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; import net.consensys.pantheon.ethereum.core.Address; import net.consensys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import net.consensys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod; @@ -10,11 +10,11 @@ import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessR public class MinerSetCoinbase implements JsonRpcMethod { - private final MiningCoordinator miningCoordinator; + private final AbstractMiningCoordinator miningCoordinator; private final JsonRpcParameter parameters; public MinerSetCoinbase( - final MiningCoordinator miningCoordinator, final JsonRpcParameter parameters) { + final AbstractMiningCoordinator miningCoordinator, final JsonRpcParameter parameters) { this.miningCoordinator = miningCoordinator; this.parameters = parameters; } diff --git a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStart.java b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStart.java index 5f2d34904e..ff4ae34ea7 100644 --- a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStart.java +++ b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStart.java @@ -1,7 +1,9 @@ package net.consensys.pantheon.ethereum.jsonrpc.internal.methods.miner; +import net.consensys.pantheon.ethereum.blockcreation.AbstractBlockCreator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.BlockMiner; import net.consensys.pantheon.ethereum.blockcreation.CoinbaseNotSetException; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; import net.consensys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import net.consensys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; @@ -9,11 +11,12 @@ import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorRes import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -public class MinerStart implements JsonRpcMethod { +public class MinerStart>> + implements JsonRpcMethod { - private final MiningCoordinator miningCoordinator; + private final AbstractMiningCoordinator miningCoordinator; - public MinerStart(final MiningCoordinator miningCoordinator) { + public MinerStart(final AbstractMiningCoordinator miningCoordinator) { this.miningCoordinator = miningCoordinator; } diff --git a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStop.java b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStop.java index 1d5e678506..f16d5a62fd 100644 --- a/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStop.java +++ b/ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStop.java @@ -1,16 +1,19 @@ package net.consensys.pantheon.ethereum.jsonrpc.internal.methods.miner; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractBlockCreator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.BlockMiner; import net.consensys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import net.consensys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -public class MinerStop implements JsonRpcMethod { +public class MinerStop>> + implements JsonRpcMethod { - private final MiningCoordinator miningCoordinator; + private final AbstractMiningCoordinator miningCoordinator; - public MinerStop(final MiningCoordinator miningCoordinator) { + public MinerStop(final AbstractMiningCoordinator miningCoordinator) { this.miningCoordinator = miningCoordinator; } diff --git a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/AbstractEthJsonRpcHttpServiceTest.java b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/AbstractEthJsonRpcHttpServiceTest.java index ed989d7c08..898b8e8eb5 100644 --- a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/AbstractEthJsonRpcHttpServiceTest.java +++ b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/AbstractEthJsonRpcHttpServiceTest.java @@ -7,7 +7,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import net.consensys.pantheon.ethereum.ProtocolContext; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import net.consensys.pantheon.ethereum.chain.GenesisConfig; import net.consensys.pantheon.ethereum.chain.MutableBlockchain; import net.consensys.pantheon.ethereum.core.Block; @@ -130,7 +130,7 @@ public abstract class AbstractEthJsonRpcHttpServiceTest { final Synchronizer synchronizerMock = mock(Synchronizer.class); final P2PNetwork peerDiscoveryMock = mock(P2PNetwork.class); final TransactionPool transactionPoolMock = mock(TransactionPool.class); - final MiningCoordinator miningCoordinatorMock = mock(MiningCoordinator.class); + final EthHashMiningCoordinator miningCoordinatorMock = mock(EthHashMiningCoordinator.class); when(transactionPoolMock.addLocalTransaction(any(Transaction.class))) .thenReturn(ValidationResult.valid()); final PendingTransactions pendingTransactionsMock = mock(PendingTransactions.class); diff --git a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceRpcApisTest.java b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceRpcApisTest.java index d0d09dd530..a068109702 100644 --- a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceRpcApisTest.java +++ b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceRpcApisTest.java @@ -5,7 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import net.consensys.pantheon.ethereum.core.Synchronizer; import net.consensys.pantheon.ethereum.core.TransactionPool; import net.consensys.pantheon.ethereum.eth.EthProtocol; @@ -162,7 +162,7 @@ public class JsonRpcHttpServiceRpcApisTest { MainnetProtocolSchedule.create(), mock(FilterManager.class), mock(TransactionPool.class), - mock(MiningCoordinator.class), + mock(EthHashMiningCoordinator.class), supportedCapabilities, config.getRpcApis())); final JsonRpcHttpService jsonRpcHttpService = new JsonRpcHttpService(vertx, config, rpcMethods); diff --git a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java index c7f34d2f84..fc5bcc8e4c 100644 --- a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java +++ b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java @@ -7,7 +7,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import net.consensys.pantheon.ethereum.core.Address; import net.consensys.pantheon.ethereum.core.Block; import net.consensys.pantheon.ethereum.core.BlockHeader; @@ -102,7 +102,7 @@ public class JsonRpcHttpServiceTest { MainnetProtocolSchedule.create(), mock(FilterManager.class), mock(TransactionPool.class), - mock(MiningCoordinator.class), + mock(EthHashMiningCoordinator.class), supportedCapabilities, JSON_RPC_APIS)); service = createJsonRpcHttpService(); diff --git a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbaseTest.java b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbaseTest.java index 2a82a60a8d..e1a3d20795 100644 --- a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbaseTest.java +++ b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthCoinbaseTest.java @@ -5,7 +5,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import net.consensys.pantheon.ethereum.core.Address; import net.consensys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; @@ -24,7 +24,7 @@ import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class EthCoinbaseTest { - @Mock private MiningCoordinator miningCoordinator; + @Mock private EthHashMiningCoordinator 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/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPriceTest.java b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPriceTest.java index 121c914702..fea12e6cc8 100644 --- a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPriceTest.java +++ b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthGasPriceTest.java @@ -5,7 +5,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.EthHashBlockMiner; +import net.consensys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import net.consensys.pantheon.ethereum.core.Wei; import net.consensys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; @@ -20,14 +21,14 @@ import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class EthGasPriceTest { - @Mock private MiningCoordinator miningCoordinator; - private EthGasPrice method; + @Mock private EthHashMiningCoordinator miningCoordinator; + 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/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthMiningTest.java b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthMiningTest.java index 04de4a9b48..b827fce211 100644 --- a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthMiningTest.java +++ b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthMiningTest.java @@ -5,7 +5,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.EthHashBlockMiner; +import net.consensys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import net.consensys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; @@ -19,14 +20,14 @@ import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class EthMiningTest { - @Mock private MiningCoordinator miningCoordinator; - private EthMining method; + @Mock private EthHashMiningCoordinator miningCoordinator; + 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/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbaseTest.java b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbaseTest.java index e724c4b12f..5172c50eb3 100644 --- a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbaseTest.java +++ b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerSetCoinbaseTest.java @@ -5,7 +5,7 @@ import static org.assertj.core.api.Assertions.catchThrowable; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import net.consensys.pantheon.ethereum.core.Address; import net.consensys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import net.consensys.pantheon.ethereum.jsonrpc.internal.exception.InvalidJsonRpcParameters; @@ -24,7 +24,7 @@ public class MinerSetCoinbaseTest { private MinerSetCoinbase method; - @Mock private MiningCoordinator miningCoordinator; + @Mock private EthHashMiningCoordinator miningCoordinator; @Before public void before() { diff --git a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStartTest.java b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStartTest.java index f05d6706ca..66aaec6473 100644 --- a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStartTest.java +++ b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStartTest.java @@ -4,7 +4,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doThrow; import net.consensys.pantheon.ethereum.blockcreation.CoinbaseNotSetException; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.EthHashBlockMiner; +import net.consensys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import net.consensys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; @@ -20,13 +21,13 @@ import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class MinerStartTest { - private MinerStart method; + private MinerStart method; - @Mock private MiningCoordinator miningCoordinator; + @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/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStopTest.java b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStopTest.java index 9f1ff14fc0..49e2c04f27 100644 --- a/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStopTest.java +++ b/ethereum/jsonrpc/src/test/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/miner/MinerStopTest.java @@ -2,7 +2,8 @@ package net.consensys.pantheon.ethereum.jsonrpc.internal.methods.miner; import static org.assertj.core.api.Assertions.assertThat; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.EthHashBlockMiner; +import net.consensys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import net.consensys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import net.consensys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; @@ -16,13 +17,13 @@ import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class MinerStopTest { - private MinerStop method; + private MinerStop method; - @Mock private MiningCoordinator miningCoordinator; + @Mock private EthHashMiningCoordinator miningCoordinator; @Before public void before() { - method = new MinerStop(miningCoordinator); + method = new MinerStop<>(miningCoordinator); } @Test diff --git a/pantheon/src/main/java/net/consensys/pantheon/Runner.java b/pantheon/src/main/java/net/consensys/pantheon/Runner.java index b944018e78..bb114cc84f 100644 --- a/pantheon/src/main/java/net/consensys/pantheon/Runner.java +++ b/pantheon/src/main/java/net/consensys/pantheon/Runner.java @@ -33,7 +33,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( @@ -41,7 +41,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/net/consensys/pantheon/RunnerBuilder.java b/pantheon/src/main/java/net/consensys/pantheon/RunnerBuilder.java index df8e406f1f..3b7dd5f790 100644 --- a/pantheon/src/main/java/net/consensys/pantheon/RunnerBuilder.java +++ b/pantheon/src/main/java/net/consensys/pantheon/RunnerBuilder.java @@ -7,7 +7,7 @@ import net.consensys.pantheon.consensus.ibft.jsonrpc.IbftJsonRpcMethodsFactory; import net.consensys.pantheon.controller.PantheonController; import net.consensys.pantheon.crypto.SECP256K1.KeyPair; import net.consensys.pantheon.ethereum.ProtocolContext; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; import net.consensys.pantheon.ethereum.chain.Blockchain; import net.consensys.pantheon.ethereum.core.Synchronizer; import net.consensys.pantheon.ethereum.core.TransactionPool; @@ -55,7 +55,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, @@ -124,7 +124,8 @@ public class RunnerBuilder { final Synchronizer synchronizer = pantheonController.getSynchronizer(); final TransactionPool transactionPool = pantheonController.getTransactionPool(); - final MiningCoordinator miningCoordinator = pantheonController.getMiningCoordinator(); + final AbstractMiningCoordinator miningCoordinator = + pantheonController.getMiningCoordinator(); Optional jsonRpcHttpService = Optional.empty(); if (jsonRpcConfiguration.isEnabled()) { @@ -181,11 +182,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 MiningCoordinator miningCoordinator, + final AbstractMiningCoordinator miningCoordinator, final Set supportedCapabilities, final Collection jsonRpcApis) { final Map methods = diff --git a/pantheon/src/main/java/net/consensys/pantheon/cli/ExportPublicKeySubCommand.java b/pantheon/src/main/java/net/consensys/pantheon/cli/ExportPublicKeySubCommand.java index 29f6720d06..1bd7e87ef7 100644 --- a/pantheon/src/main/java/net/consensys/pantheon/cli/ExportPublicKeySubCommand.java +++ b/pantheon/src/main/java/net/consensys/pantheon/cli/ExportPublicKeySubCommand.java @@ -39,7 +39,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/net/consensys/pantheon/cli/PantheonCommand.java b/pantheon/src/main/java/net/consensys/pantheon/cli/PantheonCommand.java index 5386f7eac5..86ab9f54df 100644 --- a/pantheon/src/main/java/net/consensys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/net/consensys/pantheon/cli/PantheonCommand.java @@ -375,7 +375,7 @@ public class PantheonCommand implements Runnable { webSocketConfiguration()); } - PantheonController buildController() { + PantheonController buildController() { try { return controllerBuilder.build( buildSyncConfig(syncMode), @@ -418,7 +418,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/net/consensys/pantheon/cli/PantheonControllerBuilder.java b/pantheon/src/main/java/net/consensys/pantheon/cli/PantheonControllerBuilder.java index 0fd96394b1..9b99e972a3 100644 --- a/pantheon/src/main/java/net/consensys/pantheon/cli/PantheonControllerBuilder.java +++ b/pantheon/src/main/java/net/consensys/pantheon/cli/PantheonControllerBuilder.java @@ -17,7 +17,7 @@ import java.nio.file.Path; public class PantheonControllerBuilder { - public PantheonController build( + public PantheonController build( final SynchronizerConfiguration synchronizerConfiguration, final File genesisFile, final Path homePath, diff --git a/pantheon/src/main/java/net/consensys/pantheon/controller/CliquePantheonController.java b/pantheon/src/main/java/net/consensys/pantheon/controller/CliquePantheonController.java index 6a70ffb56d..d76c2844a7 100644 --- a/pantheon/src/main/java/net/consensys/pantheon/controller/CliquePantheonController.java +++ b/pantheon/src/main/java/net/consensys/pantheon/controller/CliquePantheonController.java @@ -5,11 +5,12 @@ import static org.apache.logging.log4j.LogManager.getLogger; import net.consensys.pantheon.consensus.clique.CliqueContext; import net.consensys.pantheon.consensus.clique.CliqueVoteTallyUpdater; import net.consensys.pantheon.consensus.clique.VoteTallyCache; +import net.consensys.pantheon.consensus.clique.blockcreation.CliqueBlockMiner; import net.consensys.pantheon.consensus.common.EpochManager; import net.consensys.pantheon.consensus.common.VoteProposer; import net.consensys.pantheon.crypto.SECP256K1.KeyPair; import net.consensys.pantheon.ethereum.ProtocolContext; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; import net.consensys.pantheon.ethereum.chain.GenesisConfig; import net.consensys.pantheon.ethereum.chain.MutableBlockchain; import net.consensys.pantheon.ethereum.core.BlockHashFunction; @@ -37,7 +38,8 @@ import java.nio.file.Path; import org.apache.logging.log4j.Logger; -public class CliquePantheonController implements PantheonController { +public class CliquePantheonController + implements PantheonController { private static final Logger LOG = getLogger(); private final GenesisConfig genesisConfig; @@ -66,7 +68,7 @@ public class CliquePantheonController implements PantheonController init( + public static PantheonController init( final Path home, final GenesisConfig genesisConfig, final SynchronizerConfiguration taintedSyncConfig, @@ -152,7 +154,7 @@ public class CliquePantheonController implements PantheonController getMiningCoordinator() { return null; } diff --git a/pantheon/src/main/java/net/consensys/pantheon/controller/IbftPantheonController.java b/pantheon/src/main/java/net/consensys/pantheon/controller/IbftPantheonController.java index d8d5d9a5d2..a2a5913449 100644 --- a/pantheon/src/main/java/net/consensys/pantheon/controller/IbftPantheonController.java +++ b/pantheon/src/main/java/net/consensys/pantheon/controller/IbftPantheonController.java @@ -11,13 +11,14 @@ import net.consensys.pantheon.consensus.ibft.IbftProcessor; import net.consensys.pantheon.consensus.ibft.IbftProtocolSchedule; import net.consensys.pantheon.consensus.ibft.IbftStateMachine; import net.consensys.pantheon.consensus.ibft.VoteTallyUpdater; +import net.consensys.pantheon.consensus.ibft.blockcreation.IbftBlockMiner; import net.consensys.pantheon.consensus.ibft.protocol.IbftProtocolManager; import net.consensys.pantheon.consensus.ibft.protocol.IbftSubProtocol; import net.consensys.pantheon.consensus.ibft.protocol.Istanbul64Protocol; import net.consensys.pantheon.consensus.ibft.protocol.Istanbul64ProtocolManager; import net.consensys.pantheon.crypto.SECP256K1.KeyPair; import net.consensys.pantheon.ethereum.ProtocolContext; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; import net.consensys.pantheon.ethereum.chain.GenesisConfig; import net.consensys.pantheon.ethereum.chain.MutableBlockchain; import net.consensys.pantheon.ethereum.core.BlockHashFunction; @@ -51,7 +52,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(); @@ -90,7 +91,7 @@ public class IbftPantheonController implements PantheonController { this.closer = closer; } - public static PantheonController init( + public static PantheonController init( final Path home, final GenesisConfig genesisConfig, final SynchronizerConfiguration taintedSyncConfig, @@ -215,7 +216,7 @@ public class IbftPantheonController implements PantheonController { } @Override - public MiningCoordinator getMiningCoordinator() { + public AbstractMiningCoordinator getMiningCoordinator() { return null; } diff --git a/pantheon/src/main/java/net/consensys/pantheon/controller/MainnetPantheonController.java b/pantheon/src/main/java/net/consensys/pantheon/controller/MainnetPantheonController.java index 02007a68cb..bd2b436942 100644 --- a/pantheon/src/main/java/net/consensys/pantheon/controller/MainnetPantheonController.java +++ b/pantheon/src/main/java/net/consensys/pantheon/controller/MainnetPantheonController.java @@ -6,8 +6,9 @@ import static org.apache.logging.log4j.LogManager.getLogger; import net.consensys.pantheon.crypto.SECP256K1.KeyPair; import net.consensys.pantheon.ethereum.ProtocolContext; import net.consensys.pantheon.ethereum.blockcreation.DefaultBlockScheduler; +import net.consensys.pantheon.ethereum.blockcreation.EthHashBlockMiner; import net.consensys.pantheon.ethereum.blockcreation.EthHashMinerExecutor; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.EthHashMiningCoordinator; import net.consensys.pantheon.ethereum.blockcreation.MiningParameters; import net.consensys.pantheon.ethereum.chain.GenesisConfig; import net.consensys.pantheon.ethereum.chain.MutableBlockchain; @@ -41,7 +42,7 @@ import java.util.concurrent.TimeUnit; import org.apache.logging.log4j.Logger; -public class MainnetPantheonController implements PantheonController { +public class MainnetPantheonController implements PantheonController { private static final Logger LOG = getLogger(); public static final int MAINNET_NETWORK_ID = 1; @@ -53,7 +54,7 @@ public class MainnetPantheonController implements PantheonController { private final Synchronizer synchronizer; private final TransactionPool transactionPool; - private final MiningCoordinator miningCoordinator; + private final EthHashMiningCoordinator miningCoordinator; private final Runnable close; public MainnetPantheonController( @@ -63,7 +64,7 @@ public class MainnetPantheonController implements PantheonController { final Synchronizer synchronizer, final KeyPair keyPair, final TransactionPool transactionPool, - final MiningCoordinator miningCoordinator, + final EthHashMiningCoordinator miningCoordinator, final Runnable close) { this.genesisConfig = genesisConfig; this.protocolContext = protocolContext; @@ -75,7 +76,8 @@ public class MainnetPantheonController implements PantheonController { this.close = close; } - public static 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( @@ -87,7 +89,7 @@ public class MainnetPantheonController implements PantheonController { nodeKeys); } - public static PantheonController init( + public static PantheonController init( final Path home, final GenesisConfig genesisConfig, final SynchronizerConfiguration taintedSyncConfig, @@ -138,8 +140,8 @@ public class MainnetPantheonController implements PantheonController { MainnetBlockHeaderValidator.TIMESTAMP_TOLERANCE_S, new SystemClock())); - final MiningCoordinator miningCoordinator = - new MiningCoordinator(protocolContext.getBlockchain(), executor); + final EthHashMiningCoordinator miningCoordinator = + new EthHashMiningCoordinator(protocolContext.getBlockchain(), executor); miningCoordinator.addMinedBlockObserver(ethProtocolManager); if (miningParams.isMiningEnabled()) { miningCoordinator.enable(); @@ -196,7 +198,7 @@ public class MainnetPantheonController implements PantheonController { } @Override - public MiningCoordinator getMiningCoordinator() { + public EthHashMiningCoordinator getMiningCoordinator() { return miningCoordinator; } diff --git a/pantheon/src/main/java/net/consensys/pantheon/controller/PantheonController.java b/pantheon/src/main/java/net/consensys/pantheon/controller/PantheonController.java index 691ac572ee..a4acd16ce7 100644 --- a/pantheon/src/main/java/net/consensys/pantheon/controller/PantheonController.java +++ b/pantheon/src/main/java/net/consensys/pantheon/controller/PantheonController.java @@ -4,7 +4,9 @@ import net.consensys.pantheon.consensus.clique.CliqueProtocolSchedule; import net.consensys.pantheon.consensus.ibft.IbftProtocolSchedule; import net.consensys.pantheon.crypto.SECP256K1.KeyPair; import net.consensys.pantheon.ethereum.ProtocolContext; -import net.consensys.pantheon.ethereum.blockcreation.MiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractBlockCreator; +import net.consensys.pantheon.ethereum.blockcreation.AbstractMiningCoordinator; +import net.consensys.pantheon.ethereum.blockcreation.BlockMiner; import net.consensys.pantheon.ethereum.blockcreation.MiningParameters; import net.consensys.pantheon.ethereum.chain.GenesisConfig; import net.consensys.pantheon.ethereum.core.Synchronizer; @@ -20,11 +22,12 @@ import java.nio.file.Path; import io.vertx.core.json.JsonObject; -public interface 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, @@ -82,5 +85,5 @@ public interface PantheonController extends Closeable { TransactionPool getTransactionPool(); - MiningCoordinator getMiningCoordinator(); + AbstractMiningCoordinator getMiningCoordinator(); } diff --git a/pantheon/src/main/java/net/consensys/pantheon/util/BlockImporter.java b/pantheon/src/main/java/net/consensys/pantheon/util/BlockImporter.java index 37ce9743ba..d7cd623506 100644 --- a/pantheon/src/main/java/net/consensys/pantheon/util/BlockImporter.java +++ b/pantheon/src/main/java/net/consensys/pantheon/util/BlockImporter.java @@ -4,6 +4,8 @@ import static org.apache.logging.log4j.LogManager.getLogger; import net.consensys.pantheon.controller.PantheonController; import net.consensys.pantheon.ethereum.ProtocolContext; +import net.consensys.pantheon.ethereum.blockcreation.AbstractBlockCreator; +import net.consensys.pantheon.ethereum.blockcreation.BlockMiner; import net.consensys.pantheon.ethereum.chain.GenesisConfig; import net.consensys.pantheon.ethereum.chain.MutableBlockchain; import net.consensys.pantheon.ethereum.core.Block; @@ -35,8 +37,9 @@ public class BlockImporter { * @return the import result * @throws IOException On Failure */ - public BlockImporter.ImportResult importBlockchain( - final Path blocks, final PantheonController pantheonController) throws IOException { + public >> + BlockImporter.ImportResult importBlockchain( + 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/net/consensys/pantheon/util/BlockchainImporter.java b/pantheon/src/main/java/net/consensys/pantheon/util/BlockchainImporter.java index 411a51fce0..6c174456b0 100644 --- a/pantheon/src/main/java/net/consensys/pantheon/util/BlockchainImporter.java +++ b/pantheon/src/main/java/net/consensys/pantheon/util/BlockchainImporter.java @@ -5,6 +5,8 @@ import static java.lang.String.format; import net.consensys.pantheon.controller.PantheonController; import net.consensys.pantheon.ethereum.ProtocolContext; +import net.consensys.pantheon.ethereum.blockcreation.AbstractBlockCreator; +import net.consensys.pantheon.ethereum.blockcreation.BlockMiner; import net.consensys.pantheon.ethereum.chain.GenesisConfig; import net.consensys.pantheon.ethereum.chain.MutableBlockchain; import net.consensys.pantheon.ethereum.core.Address; @@ -90,16 +92,17 @@ 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; @@ -152,12 +155,13 @@ 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(); @@ -311,8 +315,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) { @@ -470,8 +474,9 @@ 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/net/consensys/pantheon/RunnerTest.java b/pantheon/src/test/java/net/consensys/pantheon/RunnerTest.java index c56e8b5c7d..daa4d1d6dc 100644 --- a/pantheon/src/test/java/net/consensys/pantheon/RunnerTest.java +++ b/pantheon/src/test/java/net/consensys/pantheon/RunnerTest.java @@ -7,6 +7,7 @@ import net.consensys.pantheon.controller.MainnetPantheonController; import net.consensys.pantheon.controller.PantheonController; import net.consensys.pantheon.crypto.SECP256K1.KeyPair; import net.consensys.pantheon.ethereum.ProtocolContext; +import net.consensys.pantheon.ethereum.blockcreation.EthHashBlockMiner; import net.consensys.pantheon.ethereum.chain.GenesisConfig; import net.consensys.pantheon.ethereum.core.Block; import net.consensys.pantheon.ethereum.core.BlockImporter; @@ -78,7 +79,7 @@ public final class RunnerTest { .build(); // Setup state with block data - try (final PantheonController controller = + try (final PantheonController controller = MainnetPantheonController.init( dbAhead, GenesisConfig.mainnet(), @@ -90,7 +91,7 @@ public final class RunnerTest { } // Setup Runner with blocks - final PantheonController controllerAhead = + final PantheonController controllerAhead = MainnetPantheonController.init( dbAhead, GenesisConfig.mainnet(), @@ -124,7 +125,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/net/consensys/pantheon/cli/CommandTestAbstract.java b/pantheon/src/test/java/net/consensys/pantheon/cli/CommandTestAbstract.java index a054678510..a6661ca9f8 100644 --- a/pantheon/src/test/java/net/consensys/pantheon/cli/CommandTestAbstract.java +++ b/pantheon/src/test/java/net/consensys/pantheon/cli/CommandTestAbstract.java @@ -50,7 +50,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/net/consensys/pantheon/util/BlockImporterTest.java b/pantheon/src/test/java/net/consensys/pantheon/util/BlockImporterTest.java index 68f091a899..d72c6cc0e5 100644 --- a/pantheon/src/test/java/net/consensys/pantheon/util/BlockImporterTest.java +++ b/pantheon/src/test/java/net/consensys/pantheon/util/BlockImporterTest.java @@ -55,7 +55,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/net/consensys/pantheon/util/BlockchainImporterTest.java b/pantheon/src/test/java/net/consensys/pantheon/util/BlockchainImporterTest.java index c7b69e61dd..1ee05853db 100644 --- a/pantheon/src/test/java/net/consensys/pantheon/util/BlockchainImporterTest.java +++ b/pantheon/src/test/java/net/consensys/pantheon/util/BlockchainImporterTest.java @@ -6,6 +6,7 @@ import static org.assertj.core.api.Assertions.assertThat; import net.consensys.pantheon.controller.MainnetPantheonController; import net.consensys.pantheon.controller.PantheonController; import net.consensys.pantheon.crypto.SECP256K1.KeyPair; +import net.consensys.pantheon.ethereum.blockcreation.EthHashBlockMiner; import net.consensys.pantheon.ethereum.blockcreation.MiningParameters; import net.consensys.pantheon.ethereum.chain.GenesisConfig; import net.consensys.pantheon.ethereum.core.MiningParametersTestBuilder; @@ -53,7 +54,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,