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

[release-v1.7] blockchain: Enforce testnet difficulty throttling. #2979

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Aug 2, 2022

This is a backport of the blockchain portions of #2978 to the 1.7 release branch.

@davecgh davecgh added this to the 1.7.4 milestone Aug 2, 2022
@davecgh davecgh force-pushed the rel17_blockchain_enforce_testnet_diff_throttling branch from 5d7ebd0 to 3387e4e Compare August 2, 2022 12:20
This updates to the following Github Actions:

- actions/setup-go@f6164bd #v3.0.0
- actions/checkout@a12a394 #v3.0.0

It also updates golangci-lint to 1.45.2 and also to use the latest
recommended installation method and corrects the issues the updated
version identified.
@davecgh davecgh force-pushed the rel17_blockchain_enforce_testnet_diff_throttling branch from 3387e4e to 5d2cba5 Compare August 2, 2022 12:29
@davecgh davecgh force-pushed the rel17_blockchain_enforce_testnet_diff_throttling branch from 5d2cba5 to c5a5e20 Compare August 2, 2022 19:34
This makes the calcNextRequiredDifficulty method a little more
consistent with the code in terms of the name of the parameter and using
a shorter local convenience var to avoid overly long lines.
@davecgh davecgh force-pushed the rel17_blockchain_enforce_testnet_diff_throttling branch from c5a5e20 to 661a630 Compare August 3, 2022 00:56
Currently, version 3 of the test network implements a minimum difficulty
reduction rule that was inherited from btcsuite which intends to act as
mechanism to deal with major difficulty spikes due to ASICs which are
typically not running testnet and since it's not reasonable to require
high-powered hardware to keep the test network running smoothly.

Unfortunately, this existing rule is not a particularly good solution in
general as it is not very deterministic and introduces additional
complications around difficulty selection.  It is an even worse solution
in the the case of Decred due to its hybrid model.

Rather than the aforementioned reactive approach, this introduces more
deterministic proactive testnet rules in order limit the type of games
that ASICs can play on testnet.

In particular, two new rules are introduced that are only imposed
started with block height 962928:

- A maximum allowed difficulty is now imposed on testnet such that
  CPU mining will still be feasible without resorting to any type of
  reactive and more complicated difficulty dropping
- Once the maximum allowed difficulty is reached on testnet, blocks must
  be at least 1 minute apart

The combination of these rules will prevent the difficulty on testnet
from ever rising to levels that are out of reach for CPUs to continue
mining blocks and throttle production in the case of higher-powered
hardware such as GPUs and ASICs.

It should be noted that this solution is only suitable on a test network
where no real monetary value is in play and thus the typical game theory
mechanics do not apply.

Finally, code to invalidate the existing extremely high work testnet
chain which has stalled testnet after that point is added to allow the
test network to be recovered without needing to fire up a bunch of
ASICs.
@davecgh davecgh force-pushed the rel17_blockchain_enforce_testnet_diff_throttling branch from 661a630 to 0b3e9a9 Compare August 3, 2022 01:30
@davecgh davecgh merged commit 0b3e9a9 into decred:blockchain_v4 Aug 3, 2022
@davecgh davecgh deleted the rel17_blockchain_enforce_testnet_diff_throttling branch August 3, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants