From 0956557f03c6ef57c663cf7e2bae4b9c7e50d228 Mon Sep 17 00:00:00 2001 From: Hussam Date: Mon, 18 Nov 2024 13:21:54 -0600 Subject: [PATCH] Change dataset cache sizes --- consensus/progpow/algorithm.go | 39 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/consensus/progpow/algorithm.go b/consensus/progpow/algorithm.go index d98f8d391b..26cada778f 100644 --- a/consensus/progpow/algorithm.go +++ b/consensus/progpow/algorithm.go @@ -19,7 +19,6 @@ package progpow import ( "encoding/binary" "hash" - "math" "math/big" "reflect" "runtime" @@ -35,29 +34,33 @@ import ( "github.com/dominant-strategies/go-quai/common/bitutil" "github.com/dominant-strategies/go-quai/crypto" "github.com/dominant-strategies/go-quai/log" + "github.com/dominant-strategies/go-quai/params" ) const ( - datasetInitBytes = 1 << 30 // Bytes in dataset at genesis - datasetGrowthBytes = 1 << 23 // Dataset growth per epoch - cacheInitBytes = 1 << 24 // Bytes in cache at genesis - cacheGrowthBytes = 1 << 17 // Cache growth per epoch - C_epochLength = math.MaxUint64 // Blocks per epoch - mixBytes = 128 // Width of mix - hashBytes = 64 // Hash length in bytes - hashWords = 16 // Number of 32 bit ints in a hash - datasetParents = 512 // Number of parents of each dataset element - cacheRounds = 3 // Number of rounds in cache production - loopAccesses = 64 // Number of accesses in hashimoto loop + datasetInitBytes = 1 << 32 // Bytes in dataset at genesis + datasetGrowthBytes = 1 << 25 // Dataset growth per epoch + cacheInitBytes = 1 << 24 // Bytes in cache at genesis + cacheGrowthBytes = 1 << 20 // Cache growth per epoch + mixBytes = 128 // Width of mix + hashBytes = 64 // Hash length in bytes + hashWords = 16 // Number of 32 bit ints in a hash + datasetParents = 512 // Number of parents of each dataset element + cacheRounds = 3 // Number of rounds in cache production + loopAccesses = 64 // Number of accesses in hashimoto loop +) + +var ( + C_epochLength = params.BlocksPerDay * 30 / 4 // 30 days worth of prime blocks ) // cacheSize returns the size of the ethash verification cache that belongs to a certain // block number. func cacheSize(block uint64) uint64 { epoch := int(block / C_epochLength) - if epoch < maxEpoch { - return cacheSizes[epoch] - } + // if epoch < maxEpoch { + // return cacheSizes[epoch] + // } return calcCacheSize(epoch) } @@ -76,9 +79,9 @@ func calcCacheSize(epoch int) uint64 { // block number. func datasetSize(block uint64) uint64 { epoch := int(block / C_epochLength) - if epoch < maxEpoch { - return datasetSizes[epoch] - } + // if epoch < maxEpoch { + // return datasetSizes[epoch] + // } return calcDatasetSize(epoch) }