-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ETCM-759] refactor mining #979
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, still unclear the use of MockedMiner, but I noticed you added a TODO to another ticket
919e9bf
to
69b683b
Compare
src/main/scala/io/iohk/ethereum/consensus/pow/miners/EthashDAGManager.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/PoWMiningCoordinator.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/PoWMiningCoordinator.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/PoWMiningCoordinator.scala
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/PoWMiningCoordinator.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/PoWMiningCoordinator.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/PoWMiningCoordinator.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/PoWMiningCoordinator.scala
Outdated
Show resolved
Hide resolved
coordinator ! StopMining | ||
} | ||
|
||
it should "[Recurrent Mining] ProcessMining starts EthashMiner if mineWithKeccak is false" in new TestSetup( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure these tags will scale. maybe we could use a spec that allows nesting (WordSpec
, FreeSpec
, FunSpec
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FreeSpec is a good fit
src/test/scala/io/iohk/ethereum/consensus/pow/PoWMinerCoordinatorSpec.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/PoWConsensus.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/PoWConsensus.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/PoWConsensus.scala
Outdated
Show resolved
Hide resolved
@@ -65,15 +83,30 @@ class PoWConsensus private ( | |||
* | |||
* TODO further refactors should focus on extracting two types - one with a miner, one without - based on the config | |||
*/ | |||
private[this] def startMiningProcess(node: Node): Unit = { | |||
if (minerRef.isEmpty) { | |||
private[this] def startMiningProcess(node: Node, blocKCreator: PoWBlockCreator): Unit = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: startMiningCoordinator
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the mockedMiner is supposed to be removed, yes. Otherwise no. What do you think? :)
src/main/scala/io/iohk/ethereum/consensus/pow/PoWConsensus.scala
Outdated
Show resolved
Hide resolved
src/test/scala/io/iohk/ethereum/consensus/pow/PoWConsensusSpec.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/miners/EthashMiner.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/PoWConsensus.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/consensus/pow/PoWMiningCoordinator.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks good. please review my comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please verify that the node can synch to sagano with these changes. Would it be possible to verify if ethash mining is still behaving as expected (compatible with sagano)?
b2d11d9
to
26e949b
Compare
A couple of day ago I deployed this branch in staging, and it is mining and synching. |
It's deployed in Sagano as well |
… of EthashMiner. PoWMinerCoordinator is a typed actor and MockedMiner is a classic actor, that's the reason for the extra code added.
…ccakMiner. (Mining on demand, managed by the PoWMiningManager)
…, keccak, ethash miners and the coordinator
… when getBestBlock() returns null. Add tests to cover the scenario
…e: MiningMode)) in PoWMiningCoordinator
26e949b
to
226c6a3
Compare
Description
In ETCM-746 a temporary modification in EthashMiner was introduced to support the new PoW mining algorithm with Keccak mining
In order to keep a separation of concerns, this PR introduces the following refactoring:
PoWMiningCoordinator protocol contains a placeholder to replace MockedMiner in the future
PoWMiningCoordinator is a typed actor. EthashMiner was modified to not be an actor anymore and just run a Monix task. The same to the KeccakMiner
Reorganized protocols (some is specific the MockedMiner for example)
Reorganized Spec setups for the miners
Testing
Tested in pottery private network using mantis-automation (making sure ethash mining still works as expected)
Currently deployed in Staging (making sure ethash mining still works as expected)