[NOD-1257] Disable difficulty adjustment on simnet (#862)

* [NOD-1257] Disable difficulty adjustment on simnet

* [NOD-1257] Explictly set DisableDifficultyAdjustment everywhere
This commit is contained in:
Ori Newman 2020-08-12 12:24:37 +03:00 committed by GitHub
parent 91f0fe5740
commit aa9556aa59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -15,7 +15,7 @@ import (
// block given its bluest parent.
func (dag *BlockDAG) requiredDifficulty(bluestParent *blockNode, newBlockTime mstime.Time) uint32 {
// Genesis block.
if bluestParent == nil || bluestParent.blueScore < dag.difficultyAdjustmentWindowSize+1 {
if dag.Params.DisableDifficultyAdjustment || bluestParent == nil || bluestParent.blueScore < dag.difficultyAdjustmentWindowSize+1 {
return dag.powMaxBits
}

View File

@ -80,7 +80,7 @@ func TestCalcWork(t *testing.T) {
}
func TestDifficulty(t *testing.T) {
params := dagconfig.SimnetParams
params := dagconfig.MainnetParams
params.K = 1
params.DifficultyAdjustmentWindowSize = 264
dag, teardownFunc, err := DAGSetup("TestDifficulty", true, Config{

View File

@ -178,6 +178,9 @@ type Params struct {
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
EnableNonNativeSubnetworks bool
// DisableDifficultyAdjustment determine whether to use difficulty
DisableDifficultyAdjustment bool
}
// NormalizeRPCServerAddress returns addr with the current network default
@ -235,6 +238,8 @@ var MainnetParams = Params{
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
EnableNonNativeSubnetworks: false,
DisableDifficultyAdjustment: false,
}
// RegressionNetParams defines the network parameters for the regression test
@ -288,6 +293,8 @@ var RegressionNetParams = Params{
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
EnableNonNativeSubnetworks: false,
DisableDifficultyAdjustment: false,
}
// TestnetParams defines the network parameters for the test Kaspa network.
@ -339,6 +346,8 @@ var TestnetParams = Params{
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
EnableNonNativeSubnetworks: false,
DisableDifficultyAdjustment: false,
}
// SimnetParams defines the network parameters for the simulation test Kaspa
@ -394,6 +403,8 @@ var SimnetParams = Params{
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
EnableNonNativeSubnetworks: false,
DisableDifficultyAdjustment: true,
}
// DevnetParams defines the network parameters for the development Kaspa network.
@ -445,6 +456,8 @@ var DevnetParams = Params{
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
EnableNonNativeSubnetworks: false,
DisableDifficultyAdjustment: false,
}
var (