mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
consensus/ubqhash: move diff algo changeover blocks to ChainConfig.Ubqhash
This commit is contained in:
parent
8b1cff54b9
commit
88b56df9eb
2 changed files with 18 additions and 8 deletions
|
|
@ -51,13 +51,11 @@ var (
|
||||||
nPowMaxAdjustDown = big.NewInt(16) // 16% adjustment down
|
nPowMaxAdjustDown = big.NewInt(16) // 16% adjustment down
|
||||||
nPowMaxAdjustUp = big.NewInt(8) // 8% adjustment up
|
nPowMaxAdjustUp = big.NewInt(8) // 8% adjustment up
|
||||||
|
|
||||||
diffChangeBlock = big.NewInt(4088)
|
|
||||||
nPowAveragingWindow88 = big.NewInt(88)
|
nPowAveragingWindow88 = big.NewInt(88)
|
||||||
nPowMaxAdjustDown2 = big.NewInt(3) // 3% adjustment down
|
nPowMaxAdjustDown2 = big.NewInt(3) // 3% adjustment down
|
||||||
nPowMaxAdjustUp2 = big.NewInt(2) // 2% adjustment up
|
nPowMaxAdjustUp2 = big.NewInt(2) // 2% adjustment up
|
||||||
|
|
||||||
// Flux
|
// Flux
|
||||||
fluxChangeBlock = big.NewInt(8000)
|
|
||||||
nPowMaxAdjustDownFlux = big.NewInt(5) // 0.5% adjustment down
|
nPowMaxAdjustDownFlux = big.NewInt(5) // 0.5% adjustment down
|
||||||
nPowMaxAdjustUpFlux = big.NewInt(3) // 0.3% adjustment up
|
nPowMaxAdjustUpFlux = big.NewInt(3) // 0.3% adjustment up
|
||||||
nPowDampFlux = big.NewInt(1) // 0.1%
|
nPowDampFlux = big.NewInt(1) // 0.1%
|
||||||
|
|
@ -394,10 +392,13 @@ func CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Head
|
||||||
parentNumber := parent.Number
|
parentNumber := parent.Number
|
||||||
parentDiff := parent.Difficulty
|
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)
|
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)
|
// (chain consensus.ChainReader, parentNumber, parentDiff *big.Int, parent *types.Header)
|
||||||
return calcDifficulty2(chain, parentNumber, parentDiff, parent)
|
return calcDifficulty2(chain, parentNumber, parentDiff, parent)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,10 @@ var (
|
||||||
ByzantiumBlock: big.NewInt(math.MaxInt64),
|
ByzantiumBlock: big.NewInt(math.MaxInt64),
|
||||||
ConstantinopleBlock: big.NewInt(math.MaxInt64),
|
ConstantinopleBlock: big.NewInt(math.MaxInt64),
|
||||||
PetersburgBlock: 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.
|
// MainnetTrustedCheckpoint contains the light client trusted checkpoint for the main network.
|
||||||
|
|
@ -65,7 +68,10 @@ var (
|
||||||
ByzantiumBlock: big.NewInt(math.MaxInt64),
|
ByzantiumBlock: big.NewInt(math.MaxInt64),
|
||||||
ConstantinopleBlock: big.NewInt(math.MaxInt64),
|
ConstantinopleBlock: big.NewInt(math.MaxInt64),
|
||||||
PetersburgBlock: 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.
|
// 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
|
// This configuration is intentionally not using keyed fields to force anyone
|
||||||
// adding flags to the config to also have to set these fields.
|
// 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
|
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
|
||||||
// and accepted by the Ubiq core developers into the Clique consensus.
|
// 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.
|
// 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.
|
// String implements the stringer interface, returning the consensus engine details.
|
||||||
func (c *UbqhashConfig) String() string {
|
func (c *UbqhashConfig) String() string {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue