diff --git a/consensus/ubqhash/consensus.go b/consensus/ubqhash/consensus.go index 73e68f9c22..4beefb7952 100644 --- a/consensus/ubqhash/consensus.go +++ b/consensus/ubqhash/consensus.go @@ -51,13 +51,11 @@ var ( nPowMaxAdjustDown = big.NewInt(16) // 16% adjustment down nPowMaxAdjustUp = big.NewInt(8) // 8% adjustment up - diffChangeBlock = big.NewInt(4088) nPowAveragingWindow88 = big.NewInt(88) nPowMaxAdjustDown2 = big.NewInt(3) // 3% adjustment down nPowMaxAdjustUp2 = big.NewInt(2) // 2% adjustment up // Flux - fluxChangeBlock = big.NewInt(8000) nPowMaxAdjustDownFlux = big.NewInt(5) // 0.5% adjustment down nPowMaxAdjustUpFlux = big.NewInt(3) // 0.3% adjustment up nPowDampFlux = big.NewInt(1) // 0.1% @@ -394,10 +392,13 @@ func CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Head parentNumber := parent.Number parentDiff := parent.Difficulty - if parentNumber.Cmp(diffChangeBlock) < 0 { + config := chain.Config() + ubqhashConfig := config.Ubqhash + + if parentNumber.Cmp(ubqhashConfig.DigishieldModBlock) < 0 { return calcDifficultyOrig(chain, parentNumber, parentDiff, parent) } - if parentNumber.Cmp(fluxChangeBlock) < 0 { + if parentNumber.Cmp(ubqhashConfig.FluxBlock) < 0 { // (chain consensus.ChainReader, parentNumber, parentDiff *big.Int, parent *types.Header) return calcDifficulty2(chain, parentNumber, parentDiff, parent) } else { diff --git a/params/config.go b/params/config.go index db078a16b7..bad6c1aaa2 100644 --- a/params/config.go +++ b/params/config.go @@ -42,7 +42,10 @@ var ( ByzantiumBlock: big.NewInt(math.MaxInt64), ConstantinopleBlock: big.NewInt(math.MaxInt64), PetersburgBlock: big.NewInt(math.MaxInt64), - Ubqhash: new(UbqhashConfig), + Ubqhash: &UbqhashConfig{ + DigishieldModBlock: big.NewInt(4088), + FluxBlock: big.NewInt(8000), + }, } // MainnetTrustedCheckpoint contains the light client trusted checkpoint for the main network. @@ -65,7 +68,10 @@ var ( ByzantiumBlock: big.NewInt(math.MaxInt64), ConstantinopleBlock: big.NewInt(math.MaxInt64), PetersburgBlock: big.NewInt(math.MaxInt64), - Ubqhash: new(UbqhashConfig), + Ubqhash: &UbqhashConfig{ + DigishieldModBlock: big.NewInt(4088), + FluxBlock: big.NewInt(8000), + }, } // TestnetTrustedCheckpoint contains the light client trusted checkpoint for the Ropsten test network. @@ -82,7 +88,7 @@ var ( // // This configuration is intentionally not using keyed fields to force anyone // adding flags to the config to also have to set these fields. - AllUbqhashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(UbqhashConfig), nil} + AllUbqhashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, &UbqhashConfig{DigishieldModBlock: big.NewInt(0), FluxBlock: big.NewInt(0)}, nil} // AllCliqueProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ubiq core developers into the Clique consensus. @@ -135,7 +141,10 @@ type ChainConfig struct { } // UbqhashConfig is the consensus engine configs for proof-of-work based sealing. -type UbqhashConfig struct{} +type UbqhashConfig struct { + DigishieldModBlock *big.Int `json:"digishieldModBlock"` // Block to activate the DigiShield V3 mod + FluxBlock *big.Int `json:"fluxBlock"` // Block to activate the Flux difficulty algorithm (must be > DigiShieldModBlock) +} // String implements the stringer interface, returning the consensus engine details. func (c *UbqhashConfig) String() string {