Skip to content
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

ECIP 1099: Calibrate Epoch Duration #367

Merged
merged 9 commits into from
Sep 11, 2020
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions _specs/ecip-1099.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
lang: en
ecip: 1099
title: Calibrate Epoch Duration
status: Draft
type: Standards Track
category: Core
discussions-to: https://github.com/ethereumclassic/ECIPs/issues/368
author: Luke Williams (@iquidus)
created: 2020-09-10
replaces: 1043
---

### Abstract

The purpose of this ECIP is to calibrate the epoch length used in DAG calculations.

### Motivation ###
The original intent of the DAG was to provide ASIC resistance to the mining protocol in order to prevent centralization of mining distributions and thereby provide for an objectively fair distribution of tokens. As evident by ASICs being developed that are capable of matching current GPU miners while being more energy efficient, the DAG has succeeded in leveling the playing field between GPU incumbents and ASIC challengers, avoiding ASIC takeover and domination, and leading to a competitive and large mining ecosystem. However the original parameters are proving too aggressive, resulting in obsoleting support for GPUs still in wide use today by miners.

Calibrating these parameters to better reflect todays hardware markets and mining ecosystem will bring the DAG growth back in sync with commonly used GPUs. Allowing the DAG system to continue to serve it's purpose far into the future.

### Specification ###

```
const oldEpochLength = 30000
const newEpochLength = 60000
const activationBlock = n

// calcEpochLength returns the epoch length for a given block number.
func calcEpochLength(blockNum uint64) uint64 {
if(blockNum < activationBlock) {
return oldEpochLength
}
return newEpochLength
}

// calcEpoch returns the epoch for a given block number
func calcEpoch(block uint64) int {
epochLength := uint64(calcEpochLength(block))
epoch := int(block / epochLength)
return epoch
}

// seedHash is the seed to use for generating a verification cache and the
// mining dataset.
func seedHash(block uint64) []byte {
seed := make([]byte, 32)
if block < epochLength {
return seed
}
// keep using oldEpochLength here so seeds don't overlap
keccak256 := makeHasher(sha3.NewLegacyKeccak256())
for i := 0; i < int(block/oldEpochLength); i++ {
keccak256(seed, seed)
}
return seed
}
```
The oldEpochLength (30000) changes to newEpochLength (60000) at a given activationBlock (hardfork required).

This will result in the epoch (blockNumber/[old/new]EpochLength) halving upon activation. As the DAG cache and dataset sizes are calculated from epoch, the growth in which they have experienced too will half upon activation. DAG caches and dataset will then continue to grow as intended, however at half of the pre-activation rate. To avoid re-use of seeds oldEpochLength will continue to be used within the seedHash function.

### Rationale ###
At current epoch (372) the DAG size is 3.91 GB. 4GB GPUs are getting obsoleted while they still make up a significant amount of ethash hashrate. Activating this change at epoch 376 (for example), would reduce the DAG size from 3.94GB to 2.47GB. With the reduced growth rate, 4GB GPUs will remain supported for an additional 3+ years.

### Implementation ###
Hard fork required for activation.
Mining software and pool implementations required.

For the smoothest possible transition activation should occur on a block in which an epoch transition to an even epoch number is occurring.

* Epoch 374/2 = 187 (good) = block 11220000
* Epoch 375/2 = 187.5 (bad) -
* Epoch 376/2 = 188 (good) = block 11280000

#### Clients ####
* [] core-geth
* [] besu
#### Pools ####
* [] open-ethereum-pool
#### Mining Software ####
* [] ethminer

### References
- [ECIP-1099 Research/Test data](https://github.com/iquidus/ecip-1099-data)
- [ECIP 1043 - Fixed DAG limit restriction](https://ecips.ethereumclassic.org/ECIPs/ecip-1043)
- [ECIP-? Limit DAG growth #6](https://github.com/ethereumproject/ECIPs/issues/6)
- [Ethash Sources](https://github.com/ethereum/ethash)
- [DAG Size Calculator](https://investoon.com/tools/dag_size)