diff --git a/common/config/config.go b/common/config/config.go index ed9dacf5c..326f864bd 100644 --- a/common/config/config.go +++ b/common/config/config.go @@ -180,7 +180,6 @@ func GetDefaultParams() *Configuration { MaxInactiveRoundsOfRandomNode: 36 * 8, RevertToPOWNoBlockTime: 12 * 3600, StopConfirmBlockTime: 11 * 3600, - RevertToPOWV1Height: math.MaxUint32, // todo complete me RevertToPOWNoBlockTimeV1: 2 * 3600, // todo complete me StopConfirmBlockTimeV1: 6600, // todo complete me ChangeViewV1Height: math.MaxUint32, // todo complete me @@ -364,10 +363,9 @@ func (p *Configuration) TestNet() *Configuration { p.MaxReservedCustomIDLength = 255 p.DPoSConfiguration.RevertToPOWNoBlockTime = 12 * 3600 p.DPoSConfiguration.StopConfirmBlockTime = 11 * 3600 - p.DPoSConfiguration.RevertToPOWV1Height = math.MaxUint32 // todo complete me - p.DPoSConfiguration.RevertToPOWNoBlockTimeV1 = 2 * 3600 // todo complete me - p.DPoSConfiguration.StopConfirmBlockTimeV1 = 6600 // todo complete me - p.DPoSConfiguration.ChangeViewV1Height = math.MaxUint32 // todo complete me + p.DPoSConfiguration.RevertToPOWNoBlockTimeV1 = 2 * 3600 // todo complete me + p.DPoSConfiguration.StopConfirmBlockTimeV1 = 6600 // todo complete me + p.DPoSConfiguration.ChangeViewV1Height = math.MaxUint32 // todo complete me p.DPoSConfiguration.RevertToPOWStartHeight = 815060 p.HalvingRewardHeight = 877880 //767000 + 154 * 720 p.HalvingRewardInterval = 1051200 //4 * 365 * 720 @@ -492,10 +490,9 @@ func (p *Configuration) RegNet() *Configuration { p.MaxReservedCustomIDLength = 255 p.DPoSConfiguration.RevertToPOWNoBlockTime = 12 * 3600 p.DPoSConfiguration.StopConfirmBlockTime = 11 * 3600 - p.DPoSConfiguration.RevertToPOWV1Height = math.MaxUint32 // todo complete me - p.DPoSConfiguration.RevertToPOWNoBlockTimeV1 = 2 * 3600 // todo complete me - p.DPoSConfiguration.StopConfirmBlockTimeV1 = 6600 // todo complete me - p.DPoSConfiguration.ChangeViewV1Height = math.MaxUint32 // todo complete me + p.DPoSConfiguration.RevertToPOWNoBlockTimeV1 = 2 * 3600 // todo complete me + p.DPoSConfiguration.StopConfirmBlockTimeV1 = 6600 // todo complete me + p.DPoSConfiguration.ChangeViewV1Height = math.MaxUint32 // todo complete me p.DPoSConfiguration.RevertToPOWStartHeight = 706240 p.HalvingRewardHeight = 801240 //690360 + 154 * 720 p.HalvingRewardInterval = 1051200 //4 * 365 * 720 @@ -733,8 +730,6 @@ type DPoSConfiguration struct { RevertToPOWNoBlockTime int64 `screw:"--reverttopownoblocktime" usage:"defines how long time does it take to revert to POW mode"` // StopConfirmBlockTime defines how long time dose it take before stop confirm block. StopConfirmBlockTime int64 `screw:"--stopconfirmblocktime" usage:"defines how long time does it take to stop confirm block"` - // RevertToPOWV1Height defines how the height of POW mode of version 1.0 - RevertToPOWV1Height uint32 `screw:"--reverttopowv1height" usage:"defines how the height of POW mode of version 1.0"` // RevertToPOWInterval defines how long time does it take to revert to POW mode. RevertToPOWNoBlockTimeV1 int64 `screw:"--reverttopownoblocktimev1" usage:"defines how long time does it take to revert to POW mode"` // StopConfirmBlockTime defines how long time dose it take before stop confirm block. @@ -930,9 +925,8 @@ func (p *Configuration) newRewardPerBlock(targetTimePerBlock time.Duration, heig generatedBlocksPerYear := 365 * 24 * 60 * 60 / blockGenerateInterval factor := uint32(1) if height >= p.HalvingRewardHeight { - factor = 2 + (height-p.HalvingRewardHeight)/p.HalvingRewardInterval + factor = 2 + (height-p.HalvingRewardHeight)/p.HalvingRewardInterval // HalvingRewardHeight: 1051200 } - return common.Fixed64(float64(newInflationPerYear) / float64(generatedBlocksPerYear) / math.Pow(2, float64(factor-1))) } diff --git a/core/transaction/illegalproposaltransaction.go b/core/transaction/illegalproposaltransaction.go index 40717f5a0..cbc9403ed 100644 --- a/core/transaction/illegalproposaltransaction.go +++ b/core/transaction/illegalproposaltransaction.go @@ -26,8 +26,7 @@ func (t *IllegalProposalTransaction) HeightVersionCheck() error { if blockHeight < chainParams.DPoSConfiguration.ChangeViewV1Height { return errors.New(fmt.Sprintf("not support %s transaction "+ - "with payload version %d after IllegalV2Height", - t.TxType().Name(), t.PayloadVersion())) + "before ChangeViewV1Height", t.TxType().Name())) } return nil } diff --git a/core/transaction/reverttopowtransaction.go b/core/transaction/reverttopowtransaction.go index ba6f1ed23..3db25c6d8 100644 --- a/core/transaction/reverttopowtransaction.go +++ b/core/transaction/reverttopowtransaction.go @@ -82,7 +82,7 @@ func (t *RevertToPOWTransaction) SpecialContextCheck() (result elaerr.ELAError, lastBlockTime := int64(t.parameters.BlockChain.BestChain.Timestamp) var noBlockTime int64 - if t.parameters.BlockHeight < t.parameters.Config.DPoSConfiguration.RevertToPOWV1Height { + if t.parameters.BlockHeight < t.parameters.Config.DPoSConfiguration.ChangeViewV1Height { noBlockTime = t.parameters.Config.DPoSConfiguration.RevertToPOWNoBlockTime } else { noBlockTime = t.parameters.Config.DPoSConfiguration.RevertToPOWNoBlockTimeV1 diff --git a/dpos/arbitrator.go b/dpos/arbitrator.go index edae3230a..92a3851a6 100644 --- a/dpos/arbitrator.go +++ b/dpos/arbitrator.go @@ -206,10 +206,10 @@ func (a *Arbitrator) OnBlockReceived(b *types.Block, confirmed bool) { localTimestamp := a.cfg.Chain.TimeSource.AdjustedTime().Unix() var stopConfirmTime int64 - if b.Height < a.cfg.ChainParams.DPoSConfiguration.RevertToPOWV1Height { + if b.Height < a.cfg.ChainParams.DPoSConfiguration.ChangeViewV1Height { stopConfirmTime = a.cfg.ChainParams.DPoSConfiguration.StopConfirmBlockTime } else { - stopConfirmTime = a.cfg.ChainParams.DPoSConfiguration.StopConfirmBlockTime + stopConfirmTime = a.cfg.ChainParams.DPoSConfiguration.StopConfirmBlockTimeV1 } if localTimestamp-lastBlockTimestamp >= stopConfirmTime { diff --git a/dpos/manager/consensus.go b/dpos/manager/consensus.go index 5733c75dc..b2e9143da 100644 --- a/dpos/manager/consensus.go +++ b/dpos/manager/consensus.go @@ -19,7 +19,7 @@ const ( consensusReady = iota consensusRunning - DefaultViewOffset = 10 + DefaultViewOffset = 0 ) type Consensus struct { diff --git a/pow/revertlistener.go b/pow/revertlistener.go index 87e8e4c9f..d0ca7b3d8 100644 --- a/pow/revertlistener.go +++ b/pow/revertlistener.go @@ -31,7 +31,7 @@ func (pow *Service) ListenForRevert() { lastBlockTimestamp := int64(pow.arbiters.GetLastBlockTimestamp()) localTimestamp := pow.chain.TimeSource.AdjustedTime().Unix() var noBlockTime int64 - if currentHeight < pow.chainParams.DPoSConfiguration.RevertToPOWV1Height { + if currentHeight < pow.chainParams.DPoSConfiguration.ChangeViewV1Height { noBlockTime = pow.chainParams.DPoSConfiguration.RevertToPOWNoBlockTime } else { noBlockTime = pow.chainParams.DPoSConfiguration.RevertToPOWNoBlockTimeV1