Skip to content

Commit

Permalink
Change dataset cache sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
Djadih committed Nov 19, 2024
1 parent 75d0aba commit 0956557
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions consensus/progpow/algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package progpow
import (
"encoding/binary"
"hash"
"math"
"math/big"
"reflect"
"runtime"
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand Down

0 comments on commit 0956557

Please sign in to comment.