From a607a3178b55e5ee083fc4fee55b1e4d2f640361 Mon Sep 17 00:00:00 2001 From: Jason Coombs Date: Sat, 6 Aug 2016 23:55:22 -1000 Subject: [PATCH 1/2] Wrong Mathematica code for tabulating DAG sizes The code for DAG sizes was actually the code for cache sizes, but the inverse was not true. Now searching for the correct Mathematica code for DAG sizes... I will email Matthew Wampler-Doty for guidance. The code can be verified using https://lab.wolframcloud.com/app/ --- src/libethash/data_sizes.h | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/libethash/data_sizes.h b/src/libethash/data_sizes.h index 83cc30bc..a6c42949 100644 --- a/src/libethash/data_sizes.h +++ b/src/libethash/data_sizes.h @@ -33,19 +33,7 @@ extern "C" { // 2048 Epochs (~20 years) worth of tabulated DAG sizes -// Generated with the following Mathematica Code: - -// GetCacheSizes[n_] := Module[{ -// CacheSizeBytesInit = 2^24, -// CacheGrowth = 2^17, -// HashBytes = 64, -// j = 0}, -// Reap[ -// While[j < n, -// Module[{i = -// Floor[(CacheSizeBytesInit + CacheGrowth * j) / HashBytes]}, -// While[! PrimeQ[i], i--]; -// Sow[i*HashBytes]; j++]]]][[2]][[1]] +// TODO: find the Mathematica code used to generate this dataset static const uint64_t dag_sizes[2048] = { @@ -461,21 +449,22 @@ static const uint64_t dag_sizes[2048] = { 18228444544U, 18236833408U, 18245220736U }; +// 2048 Epochs (~20 years) worth of tabulated cache sizes // Generated with the following Mathematica Code: // GetCacheSizes[n_] := Module[{ -// DataSetSizeBytesInit = 2^30, -// MixBytes = 128, -// DataSetGrowth = 2^23, -// HashBytes = 64, -// CacheMultiplier = 1024, -// j = 0}, -// Reap[ -// While[j < n, -// Module[{i = Floor[(DataSetSizeBytesInit + DataSetGrowth * j) / (CacheMultiplier * HashBytes)]}, -// While[! PrimeQ[i], i--]; -// Sow[i*HashBytes]; j++]]]][[2]][[1]] +// CacheSizeBytesInit = 2^24, +// CacheGrowth = 2^17, +// HashBytes = 64, +// j = 0}, +// Reap[ +// While[j < n, +// Module[{i = +// Floor[(CacheSizeBytesInit + CacheGrowth * j) / HashBytes]}, +// While[! PrimeQ[i], i--]; +// Sow[i*HashBytes]; j++]]]][[2]][[1]] +// GetCacheSizes[2048] const uint64_t cache_sizes[2048] = { 16776896U, 16907456U, 17039296U, 17170112U, 17301056U, 17432512U, 17563072U, From cb9c80d94f35ef7787ab52fdce0629dd32398375 Mon Sep 17 00:00:00 2001 From: Jason Coombs Date: Sun, 7 Aug 2016 10:43:36 -1000 Subject: [PATCH 2/2] Retrieved GetDataSizes from Ethereum history From here: https://github.com/ethereum/wiki/wiki/Ethash/ae38504014dc17950cfe680923f7a7fbba8f9b58 Thanks, Matthew. --- src/libethash/data_sizes.h | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/libethash/data_sizes.h b/src/libethash/data_sizes.h index a6c42949..55fde0de 100644 --- a/src/libethash/data_sizes.h +++ b/src/libethash/data_sizes.h @@ -33,8 +33,21 @@ extern "C" { // 2048 Epochs (~20 years) worth of tabulated DAG sizes -// TODO: find the Mathematica code used to generate this dataset +// Generated with the following Mathematica Code: +// GetDataSizes[n_] := Module[{ +// DataSetSizeBytesInit = 2^30, +// MixBytes = 128, +// DataSetGrowth = 2^23, +// j = 0}, +// Reap[ +// While[j < n, +// Module[{i = +// Floor[(DataSetSizeBytesInit + DataSetGrowth * j) / MixBytes]}, +// While[! PrimeQ[i], i--]; +// Sow[i*MixBytes]; j++]]]][[2]][[1]] +// +// GetDataSizes[2048] static const uint64_t dag_sizes[2048] = { 1073739904U, 1082130304U, 1090514816U, 1098906752U, 1107293056U, @@ -454,16 +467,17 @@ static const uint64_t dag_sizes[2048] = { // Generated with the following Mathematica Code: // GetCacheSizes[n_] := Module[{ -// CacheSizeBytesInit = 2^24, -// CacheGrowth = 2^17, -// HashBytes = 64, -// j = 0}, -// Reap[ -// While[j < n, -// Module[{i = -// Floor[(CacheSizeBytesInit + CacheGrowth * j) / HashBytes]}, -// While[! PrimeQ[i], i--]; -// Sow[i*HashBytes]; j++]]]][[2]][[1]] +// CacheSizeBytesInit = 2^24, +// CacheGrowth = 2^17, +// HashBytes = 64, +// j = 0}, +// Reap[ +// While[j < n, +// Module[{i = +// Floor[(CacheSizeBytesInit + CacheGrowth * j) / HashBytes]}, +// While[! PrimeQ[i], i--]; +// Sow[i*HashBytes]; j++]]]][[2]][[1]] +// // GetCacheSizes[2048] const uint64_t cache_sizes[2048] = {