-
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-109] ECIP-1099 implementation #764
Changes from 1 commit
60f214c
e773a4f
bea8963
866bf08
2525670
4feac9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,12 +56,12 @@ class EthashMiner( | |
|
||
def processMining(): Unit = { | ||
val parentBlock = blockchain.getBestBlock() | ||
val epoch = EthashUtils.epoch(parentBlock.header.number.toLong + 1) | ||
|
||
val blockNumber = parentBlock.header.number.toLong + 1 | ||
val epoch = EthashUtils.epoch(blockNumber, blockCreator.blockchainConfig.ecip1099BlockNumber.toLong) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not accepting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we are using only |
||
val (dag, dagSize) = (currentEpoch, currentEpochDag, currentEpochDagSize) match { | ||
case (Some(`epoch`), Some(dag), Some(dagSize)) => (dag, dagSize) | ||
case _ => | ||
val seed = EthashUtils.seed(epoch) | ||
val seed = EthashUtils.seed(blockNumber) | ||
val dagSize = EthashUtils.dagSize(epoch) | ||
val dagNumHashes = (dagSize / EthashUtils.HASH_BYTES).toInt | ||
val dag = | ||
|
@@ -122,7 +122,7 @@ class EthashMiner( | |
val outputStream = new FileOutputStream(dagFile(seed).getAbsolutePath) | ||
outputStream.write(DagFilePrefix.toArray[Byte]) | ||
|
||
val cache = EthashUtils.makeCache(epoch) | ||
val cache = EthashUtils.makeCache(epoch, seed) | ||
val res = new Array[Array[Int]](dagNumHashes) | ||
|
||
(0 until dagNumHashes).foreach { i => | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package io.iohk.ethereum.consensus.ethash | ||
package validators | ||
|
||
import akka.util.ByteString | ||
import io.iohk.ethereum.consensus.difficulty.DifficultyCalculator | ||
import io.iohk.ethereum.consensus.ethash.difficulty.EthashDifficultyCalculator | ||
import io.iohk.ethereum.consensus.validators.BlockHeaderError.HeaderPoWError | ||
|
@@ -41,11 +42,11 @@ class EthashBlockHeaderValidator(blockchainConfig: BlockchainConfig) | |
|
||
import scala.collection.JavaConverters._ | ||
|
||
def getPowCacheData(epoch: Long): PowCacheData = { | ||
def getPowCacheData(epoch: Long, seed: ByteString): PowCacheData = { | ||
Option(powCaches.get(epoch)) match { | ||
case Some(pcd) => pcd | ||
case None => | ||
val data = new PowCacheData(cache = EthashUtils.makeCache(epoch), dagSize = EthashUtils.dagSize(epoch)) | ||
val data = new PowCacheData(cache = EthashUtils.makeCache(epoch, seed), dagSize = EthashUtils.dagSize(epoch)) | ||
|
||
val keys = powCaches.keySet().asScala | ||
val keysToRemove = keys.toSeq.sorted.take(keys.size - MaxPowCaches + 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it won't make problems during transition. i.e
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. I fixed that |
||
|
@@ -57,7 +58,9 @@ class EthashBlockHeaderValidator(blockchainConfig: BlockchainConfig) | |
} | ||
} | ||
|
||
val powCacheData = getPowCacheData(epoch(blockHeader.number.toLong)) | ||
val epoch = EthashUtils.epoch(blockHeader.number.toLong, blockchainConfig.ecip1099BlockNumber.toLong) | ||
val seed = EthashUtils.seed(blockHeader.number.toLong) | ||
val powCacheData = getPowCacheData(epoch, seed) | ||
|
||
val proofOfWork = hashimotoLight( | ||
crypto.kec256(BlockHeader.getEncodedWithoutNonce(blockHeader)), | ||
|
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.
this has already been reached on Mordor, right? Have we synced and try it there already?
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.
Good point. I will sync with the Mordor before the merge