From e47f7480bfc3d2a8aa129d7029395a7d6cb611ab Mon Sep 17 00:00:00 2001 From: OneEvil Date: Fri, 6 Nov 2020 15:27:59 +0500 Subject: [PATCH 1/2] Bit boundary fix for the DAG generation routine --- consensus/ethash/algorithm.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/consensus/ethash/algorithm.go b/consensus/ethash/algorithm.go index 46ef1a2c07..d1ba790f0e 100644 --- a/consensus/ethash/algorithm.go +++ b/consensus/ethash/algorithm.go @@ -320,16 +320,16 @@ func generateDataset(dest []uint32, epoch uint64, epochLength uint64, cache []ui keccak512 := makeHasher(sha3.NewLegacyKeccak512()) // Calculate the data segment this thread should generate - batch := uint32((size + hashBytes*uint64(threads) - 1) / (hashBytes * uint64(threads))) - first := uint32(id) * batch + batch := uint64((size + hashBytes*uint64(threads) - 1) / (hashBytes * uint64(threads))) + first := uint64(id) * batch limit := first + batch - if limit > uint32(size/hashBytes) { - limit = uint32(size / hashBytes) + if limit > uint64(size/hashBytes) { + limit = uint64(size / hashBytes) } // Calculate the dataset segment percent := uint32(size / hashBytes / 100) for index := first; index < limit; index++ { - item := generateDatasetItem(cache, index, keccak512) + item := generateDatasetItem(cache, uint32(index), keccak512) if swapped { swap(item) } From 03674af77969206efbb7cd009e84e02cb2c9dabc Mon Sep 17 00:00:00 2001 From: OneEvil Date: Fri, 6 Nov 2020 16:01:26 +0500 Subject: [PATCH 2/2] Fix unnecessary conversion warnings --- consensus/ethash/algorithm.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/consensus/ethash/algorithm.go b/consensus/ethash/algorithm.go index d1ba790f0e..2593e29e4c 100644 --- a/consensus/ethash/algorithm.go +++ b/consensus/ethash/algorithm.go @@ -320,11 +320,11 @@ func generateDataset(dest []uint32, epoch uint64, epochLength uint64, cache []ui keccak512 := makeHasher(sha3.NewLegacyKeccak512()) // Calculate the data segment this thread should generate - batch := uint64((size + hashBytes*uint64(threads) - 1) / (hashBytes * uint64(threads))) + batch := (size + hashBytes*uint64(threads) - 1) / (hashBytes * uint64(threads)) first := uint64(id) * batch limit := first + batch - if limit > uint64(size/hashBytes) { - limit = uint64(size / hashBytes) + if limit > size/hashBytes { + limit = size / hashBytes } // Calculate the dataset segment percent := uint32(size / hashBytes / 100)