Skip to content

Commit b81d183

Browse files
author
Leonor Boga
authored
[ETCM-759] Refactor mining by adding a PowMiningCoordinator that handles both Ethash and Keccak mining coordination
* [ETCM-759] Rename EthashBlockCreator to PoWBlockCreator * [ETCM-759] Rename MinerResponse to MockedMinerResponse * [ETCM-759] Add PoWMiningCoordinator * [ETCM-759] Update PowConsensus to use new PoWMiningCoordinator instead of EthashMiner. PoWMiningCoordinator is a typed actor and MockedMiner is a classic actor, that's the reason for the extra code added. * [ETCM-759] Modify EthashMiner to only mine on demand, managed by the PoWMiningManager * [ETCM-759] Extract code to mining with Keccak into an actor called KeccakMiner. (Mining on demand, managed by the PoWMiningManager) * [ETCM-759] Adjust MinerSpecSetup to contain shared setup between mock, keccak, ethash miners and the coordinator * [ETCM-759] Rename PoWMinerCooordinatorSpec to PoWMiningCoordinatorSpec * [ETCM-759] Add assertion in Ethash and Keccak miners spec M-759] Fix PoWMiningCoordinatorSpec * [ETCM-759] Renamed DoMining to MineNext in PoWMiningCoordinator * [ETCM-759] Rename StartMining(mode: MiningMode) to SetMiningMode((mode: MiningMode)) in PoWMiningCoordinator
1 parent 0146d23 commit b81d183

29 files changed

+1209
-541
lines changed

project/Dependencies.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ object Dependencies {
1313
val akka: Seq[ModuleID] = {
1414
Seq(
1515
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
16+
"com.typesafe.akka" %% "akka-actor-typed" % akkaVersion,
1617
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion,
1718
"com.typesafe.akka" %% "akka-actor-typed" % akkaVersion,
1819
"com.typesafe.akka" %% "akka-testkit" % akkaVersion,

src/main/resources/conf/pottery.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ mantis {
1515

1616
consensus {
1717
coinbase = "0011223344556677889900112233445566778899" # has to be changed for each node
18-
mining-enabled = false
19-
protocol = "restricted-ethash"
18+
mining-enabled = true
19+
protocol = "restricted-pow"
2020
}
2121

2222
metrics {

src/main/scala/io/iohk/ethereum/consensus/Consensus.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package io.iohk.ethereum.consensus
22

33
import io.iohk.ethereum.consensus.blocks.{BlockGenerator, TestBlockGenerator}
44
import io.iohk.ethereum.consensus.difficulty.DifficultyCalculator
5-
import io.iohk.ethereum.consensus.pow.{MinerProtocol, MinerResponse}
5+
import io.iohk.ethereum.consensus.pow.miners.MinerProtocol
6+
import io.iohk.ethereum.consensus.pow.miners.MockedMiner.{MockedMinerProtocol, MockedMinerResponse}
67
import io.iohk.ethereum.consensus.validators.Validators
78
import io.iohk.ethereum.ledger.BlockPreparator
89
import io.iohk.ethereum.ledger.Ledger.VMImpl
@@ -63,7 +64,7 @@ trait Consensus {
6364
/**
6465
* Sends msg to the internal miner and waits for the response
6566
*/
66-
def askMiner(msg: MinerProtocol): Task[MinerResponse]
67+
def askMiner(msg: MockedMinerProtocol): Task[MockedMinerResponse]
6768

6869
/**
6970
* Sends msg to the internal miner

src/main/scala/io/iohk/ethereum/consensus/pow/EthashMiner.scala

Lines changed: 0 additions & 205 deletions
This file was deleted.

src/main/scala/io/iohk/ethereum/consensus/pow/MinerProtocol.scala

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/main/scala/io/iohk/ethereum/consensus/pow/MinerUtils.scala

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/main/scala/io/iohk/ethereum/consensus/pow/EthashBlockCreator.scala renamed to src/main/scala/io/iohk/ethereum/consensus/pow/PoWBlockCreator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import io.iohk.ethereum.transactions.TransactionPicker
1313
import monix.eval.Task
1414
import scala.concurrent.duration.FiniteDuration
1515

16-
class EthashBlockCreator(
16+
class PoWBlockCreator(
1717
val pendingTransactionsManager: ActorRef,
1818
val getTransactionFromPoolTimeout: FiniteDuration,
1919
consensus: PoWConsensus,

0 commit comments

Comments
 (0)